| Conditions | 7 |
| Paths | 16 |
| Total Lines | 51 |
| Code Lines | 25 |
| 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 |
||
| 107 | public static function processQuestions(&$objQuizz, &$manifest, CcAssesmentSection &$section, $rootpath, $contextid, $outdir) |
||
| 108 | { |
||
| 109 | PkgResourceDependencies::instance()->reset(); |
||
| 110 | $questioncount = 0; |
||
| 111 | foreach ($objQuizz['questions'] as $question) { |
||
| 112 | $qtype = $question->quiz_type; |
||
| 113 | /* Question type comes from the c_quiz_question.type column. |
||
| 114 | * You can find the different types defined in api.lib.php. |
||
| 115 | * Look for UNIQUE_ANSWER as the first constant defined |
||
| 116 | * 1 : Unique Answer (Multiple choice, single response) |
||
| 117 | * 2 : Multiple Answers (Multiple choice, multiple response) |
||
| 118 | * |
||
| 119 | */ |
||
| 120 | $questionProcessor = null; |
||
| 121 | switch ($qtype) { |
||
| 122 | case UNIQUE_ANSWER: |
||
| 123 | try { |
||
| 124 | $questionProcessor = new CcAssesmentQuestionMultichoice($objQuizz, $objQuizz['questions'], $manifest, $section, $question, $rootpath, $contextid, $outdir); |
||
| 125 | $questionProcessor->generate(); |
||
| 126 | $questioncount++; |
||
| 127 | } catch (RuntimeException $e) { |
||
| 128 | error_log($e->getMessage().' in question of test '.$objQuizz['title']); |
||
| 129 | continue 2; |
||
| 130 | } |
||
| 131 | break; |
||
| 132 | case MULTIPLE_ANSWER: |
||
| 133 | try { |
||
| 134 | $questionProcessor = new CcAssesmentQuestionMultichoiceMultiresponse($objQuizz, $objQuizz['questions'], $manifest, $section, $question, $rootpath, $contextid, $outdir); |
||
| 135 | $questionProcessor->generate(); |
||
| 136 | $questioncount++; |
||
| 137 | } catch (RuntimeException $e) { |
||
| 138 | error_log($e->getMessage().' in question of test '.$objQuizz['title']); |
||
| 139 | continue 2; |
||
| 140 | } |
||
| 141 | break; |
||
| 142 | /* |
||
| 143 | case FILL_IN_BLANKS: |
||
| 144 | try { |
||
| 145 | $questionProcessor = new CcAssesmentRenderFibtype($objQuizz, $objQuizz['questions'], $manifest, $section, $question, $rootpath, $contextid, $outdir); |
||
| 146 | $questionProcessor->generate(); |
||
| 147 | $questioncount++; |
||
| 148 | } catch (RuntimeException $e) { |
||
| 149 | error_log($e->getMessage().' in question of test '.$objQuizz['title']); |
||
| 150 | continue; |
||
| 151 | } |
||
| 152 | break; |
||
| 153 | */ |
||
| 154 | } |
||
| 155 | } |
||
| 156 | //return dependencies |
||
| 157 | return ($questioncount == 0) ? false : PkgResourceDependencies::instance()->getDeps(); |
||
| 158 | } |
||
| 160 |