| Conditions | 9 |
| Paths | 48 |
| Total Lines | 135 |
| Code Lines | 92 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 53 | public function build() |
||
| 54 | { |
||
| 55 | $plugin = ImsLtiPlugin::create(); |
||
| 56 | |||
| 57 | $this->addHeader($plugin->get_lang('ToolSettings')); |
||
| 58 | $this->addText('name', get_lang('Name')); |
||
| 59 | $this->addTextarea('description', get_lang('Description')); |
||
| 60 | |||
| 61 | if (null === $this->baseTool) { |
||
| 62 | $this->addUrl('launch_url', $plugin->get_lang('LaunchUrl'), true); |
||
| 63 | $this->addRadio( |
||
| 64 | 'version', |
||
| 65 | $plugin->get_lang('LtiVersion'), |
||
| 66 | [ |
||
| 67 | ImsLti::V_1P1 => 'LTI 1.0 / 1.1', |
||
| 68 | ImsLti::V_1P3 => 'LTI 1.3.0', |
||
| 69 | ] |
||
| 70 | ); |
||
| 71 | $this->addHtml('<div class="'.ImsLti::V_1P1.'" style="display: none;">'); |
||
| 72 | $this->addText('consumer_key', $plugin->get_lang('ConsumerKey'), false); |
||
| 73 | $this->addText('shared_secret', $plugin->get_lang('SharedSecret'), false); |
||
| 74 | $this->addHtml('</div>'); |
||
| 75 | $this->addHtml('<div class="'.ImsLti::V_1P3.'" style="display: block;">'); |
||
| 76 | $this->addRadio( |
||
| 77 | 'public_key_type', |
||
| 78 | $plugin->get_lang('PublicKeyType'), |
||
| 79 | [ |
||
| 80 | ImsLti::LTI_JWK_KEYSET => $plugin->get_lang('KeySetUrl'), |
||
| 81 | ImsLti::LTI_RSA_KEY => $plugin->get_lang('RsaKey'), |
||
| 82 | ] |
||
| 83 | ); |
||
| 84 | $this->addHtml('<div class="'.ImsLti::LTI_JWK_KEYSET.'" style="display: block;">'); |
||
| 85 | $this->addUrl('jwks_url', $plugin->get_lang('PublicKeyset'), false); |
||
| 86 | $this->addHtml('</div>'); |
||
| 87 | $this->addHtml('<div class="'.ImsLti::LTI_RSA_KEY.'" style="display: none;">'); |
||
| 88 | $this->addTextarea( |
||
| 89 | 'public_key', |
||
| 90 | $plugin->get_lang('PublicKey'), |
||
| 91 | ['style' => 'font-family: monospace;', 'rows' => 5] |
||
| 92 | ); |
||
| 93 | $this->addHtml('</div>'); |
||
| 94 | $this->addUrl('login_url', $plugin->get_lang('LoginUrl'), false); |
||
| 95 | $this->addUrl('redirect_url', $plugin->get_lang('RedirectUrl'), false); |
||
| 96 | $this->addHtml('</div>'); |
||
| 97 | } |
||
| 98 | |||
| 99 | $this->addButtonAdvancedSettings('lti_adv'); |
||
| 100 | $this->addHtml('<div id="lti_adv_options" style="display:none;">'); |
||
| 101 | $this->addTextarea( |
||
| 102 | 'custom_params', |
||
| 103 | [$plugin->get_lang('CustomParams'), $plugin->get_lang('CustomParamsHelp')] |
||
| 104 | ); |
||
| 105 | $this->addSelect( |
||
| 106 | 'document_target', |
||
| 107 | get_lang('LinkTarget'), |
||
| 108 | ['iframe' => 'iframe', 'window' => 'window'] |
||
| 109 | ); |
||
| 110 | |||
| 111 | if (null === $this->baseTool |
||
| 112 | || ($this->baseTool && !$this->baseTool->isActiveDeepLinking()) |
||
| 113 | ) { |
||
| 114 | $this->addCheckBox( |
||
| 115 | 'deep_linking', |
||
| 116 | [null, $plugin->get_lang('SupportDeppLinkingHelp'), null], |
||
| 117 | $plugin->get_lang('SupportDeepLinking') |
||
| 118 | ); |
||
| 119 | } |
||
| 120 | |||
| 121 | $showAGS = false; |
||
| 122 | |||
| 123 | if (api_get_course_int_id()) { |
||
| 124 | $caterories = Category::load(null, null, api_get_course_id()); |
||
| 125 | |||
| 126 | if (!empty($caterories)) { |
||
| 127 | $showAGS = true; |
||
| 128 | } |
||
| 129 | } else { |
||
| 130 | $showAGS = true; |
||
| 131 | } |
||
| 132 | |||
| 133 | $this->addHtml('<div class="'.ImsLti::V_1P3.'" style="display: none;">'); |
||
| 134 | |||
| 135 | if ($showAGS) { |
||
| 136 | $this->addRadio( |
||
| 137 | '1p3_ags', |
||
| 138 | $plugin->get_lang('AssigmentAndGradesService'), |
||
| 139 | [ |
||
| 140 | LtiAssignmentGradesService::AGS_NONE => $plugin->get_lang('DontUseService'), |
||
| 141 | LtiAssignmentGradesService::AGS_SIMPLE => $plugin->get_lang('AGServiceSimple'), |
||
| 142 | LtiAssignmentGradesService::AGS_FULL => $plugin->get_lang('AGServiceFull'), |
||
| 143 | ] |
||
| 144 | ); |
||
| 145 | } else { |
||
| 146 | $gradebookUrl = api_get_path(WEB_CODE_PATH).'gradebook/index.php?'.api_get_cidreq(); |
||
| 147 | |||
| 148 | $this->addLabel( |
||
| 149 | $plugin->get_lang('AssigmentAndGradesService'), |
||
| 150 | sprintf( |
||
| 151 | $plugin->get_lang('YouNeedCreateTheGradebokInCourseFirst'), |
||
| 152 | Display::url($gradebookUrl, $gradebookUrl) |
||
| 153 | ) |
||
| 154 | ); |
||
| 155 | } |
||
| 156 | |||
| 157 | $this->addRadio( |
||
| 158 | '1p3_nrps', |
||
| 159 | $plugin->get_lang('NamesAndRoleProvisioningService'), |
||
| 160 | [ |
||
| 161 | LtiNamesRoleProvisioningService::NRPS_NONE => $plugin->get_lang('DontUseService'), |
||
| 162 | LtiNamesRoleProvisioningService::NRPS_CONTEXT_MEMBERSHIP => $plugin->get_lang('UseService'), |
||
| 163 | ] |
||
| 164 | ); |
||
| 165 | $this->addHtml('</div>'); |
||
| 166 | |||
| 167 | if (!$this->baseTool) { |
||
| 168 | $this->addText( |
||
| 169 | 'replacement_user_id', |
||
| 170 | [ |
||
| 171 | $plugin->get_lang('ReplacementUserId'), |
||
| 172 | $plugin->get_lang('ReplacementUserIdHelp'), |
||
| 173 | ], |
||
| 174 | false |
||
| 175 | ); |
||
| 176 | $this->applyFilter('replacement_user_id', 'trim'); |
||
| 177 | } |
||
| 178 | |||
| 179 | $this->addHtml('</div>'); |
||
| 180 | $this->addButtonAdvancedSettings('lti_privacy', get_lang('Privacy')); |
||
| 181 | $this->addHtml('<div id="lti_privacy_options" style="display:none;">'); |
||
| 182 | $this->addCheckBox('share_name', null, $plugin->get_lang('ShareLauncherName')); |
||
| 183 | $this->addCheckBox('share_email', null, $plugin->get_lang('ShareLauncherEmail')); |
||
| 184 | $this->addCheckBox('share_picture', null, $plugin->get_lang('ShareLauncherPicture')); |
||
| 185 | $this->addHtml('</div>'); |
||
| 186 | $this->addButtonCreate($plugin->get_lang('AddExternalTool')); |
||
| 187 | $this->applyFilter('__ALL__', 'trim'); |
||
| 188 | } |
||
| 240 |