Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like FillBlanks often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use FillBlanks, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 11 | class FillBlanks extends Question |
||
| 12 | { |
||
| 13 | static $typePicture = 'fill_in_blanks.png'; |
||
| 14 | static $explanationLangVar = 'FillBlanks'; |
||
| 15 | |||
| 16 | const FILL_THE_BLANK_STANDARD = 0; |
||
| 17 | const FILL_THE_BLANK_MENU = 1; |
||
| 18 | const FILL_THE_BLANK_SEVERAL_ANSWER = 2; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Constructor |
||
| 22 | */ |
||
| 23 | public function __construct() |
||
| 29 | |||
| 30 | /** |
||
| 31 | * function which redefines Question::createAnswersForm |
||
| 32 | * @param FormValidator $form |
||
| 33 | */ |
||
| 34 | public function createAnswersForm($form) |
||
| 35 | { |
||
| 36 | $fillBlanksAllowedSeparator = self::getAllowedSeparator(); |
||
| 37 | $defaults = array(); |
||
| 38 | |||
| 39 | if (!empty($this->id)) { |
||
| 40 | $objectAnswer = new Answer($this->id); |
||
| 41 | $answer = $objectAnswer->selectAnswer(1); |
||
| 42 | $listAnswersInfo = FillBlanks::getAnswerInfo($answer); |
||
| 43 | |||
| 44 | if ($listAnswersInfo["switchable"]) { |
||
| 45 | $defaults['multiple_answer'] = 1; |
||
| 46 | } else { |
||
| 47 | $defaults['multiple_answer'] = 0; |
||
| 48 | } |
||
| 49 | //take the complete string except after the last '::' |
||
| 50 | $defaults['answer'] = $listAnswersInfo["text"]; |
||
| 51 | $defaults['select_separator'] = $listAnswersInfo["blankseparatornumber"]; |
||
| 52 | $blanksepartornumber = $listAnswersInfo["blankseparatornumber"]; |
||
| 53 | } else { |
||
| 54 | $defaults['answer'] = get_lang('DefaultTextInBlanks'); |
||
| 55 | $defaults['select_separator'] = 0; |
||
| 56 | $blanksepartornumber = 0; |
||
| 57 | } |
||
| 58 | |||
| 59 | $blankSeparatorStart = self::getStartSeparator($blanksepartornumber); |
||
| 60 | $blankSeparatorEnd = self::getEndSeparator($blanksepartornumber); |
||
| 61 | |||
| 62 | $setValues = null; |
||
| 63 | |||
| 64 | if (isset($a_weightings) && count($a_weightings) > 0) { |
||
|
|
|||
| 65 | foreach ($a_weightings as $i => $weighting) { |
||
| 66 | $setValues .= 'document.getElementById("weighting['.$i.']").value = "'.$weighting.'";'; |
||
| 67 | } |
||
| 68 | } |
||
| 69 | // javascript |
||
| 70 | echo '<script> |
||
| 71 | |||
| 72 | var blankSeparatortStart = "'.$blankSeparatorStart.'"; |
||
| 73 | var blankSeparatortEnd = "'.$blankSeparatorEnd.'"; |
||
| 74 | var blankSeparatortStartRegexp = getBlankSeparatorRegexp(blankSeparatortStart); |
||
| 75 | var blankSeparatortEndRegexp = getBlankSeparatorRegexp(blankSeparatortEnd); |
||
| 76 | |||
| 77 | CKEDITOR.on("instanceCreated", function(e) { |
||
| 78 | if (e.editor.name === "answer") { |
||
| 79 | e.editor.on("change", updateBlanks); |
||
| 80 | } |
||
| 81 | }); |
||
| 82 | |||
| 83 | var firstTime = true; |
||
| 84 | |||
| 85 | function updateBlanks() |
||
| 86 | { |
||
| 87 | if (firstTime) { |
||
| 88 | var field = document.getElementById("answer"); |
||
| 89 | var answer = field.value; |
||
| 90 | } else { |
||
| 91 | var answer = CKEDITOR.instances["answer"].getData(); |
||
| 92 | } |
||
| 93 | |||
| 94 | // disable the save button, if not blanks have been created |
||
| 95 | $("button").attr("disabled", "disabled"); |
||
| 96 | $("#defineoneblank").show(); |
||
| 97 | |||
| 98 | var blanksRegexp = "/"+blankSeparatortStartRegexp+"[^"+blankSeparatortStartRegexp+"]*"+blankSeparatortEndRegexp+"/g"; |
||
| 99 | |||
| 100 | var blanks = answer.match(eval(blanksRegexp)); |
||
| 101 | var fields = "<div class=\"form-group \">"; |
||
| 102 | fields += "<label class=\"col-sm-2 control-label\">'.get_lang('Weighting').'</label>"; |
||
| 103 | fields += "<div class=\"col-sm-8\">"; |
||
| 104 | fields += "<table>"; |
||
| 105 | fields += "<tr><th style=\"padding:0 20px\">'.get_lang("WordTofind").'</th><th style=\"padding:0 20px\">'.get_lang("QuestionWeighting").'</th><th style=\"padding:0 20px\">'.get_lang("BlankInputSize").'</th></tr>"; |
||
| 106 | |||
| 107 | if (blanks != null) { |
||
| 108 | for (var i=0 ; i < blanks.length ; i++){ |
||
| 109 | // remove forbidden characters that causes bugs |
||
| 110 | blanks[i] = removeForbiddenChars(blanks[i]); |
||
| 111 | // trim blanks between brackets |
||
| 112 | blanks[i] = trimBlanksBetweenSeparator(blanks[i], blankSeparatortStart, blankSeparatortEnd); |
||
| 113 | |||
| 114 | // if the word is empty [] |
||
| 115 | if (blanks[i] == blankSeparatortStartRegexp+blankSeparatortEndRegexp) { |
||
| 116 | break; |
||
| 117 | } |
||
| 118 | // get input size |
||
| 119 | var lainputsize = 200; |
||
| 120 | if ($("#samplesize\\\["+i+"\\\]").width()) { |
||
| 121 | // this is a weird patch to avoid to reduce the size of input blank when you are writing in the ckeditor. |
||
| 122 | lainputsize = $("#samplesize\\\["+i+"\\\]").width() + 9; |
||
| 123 | } |
||
| 124 | |||
| 125 | if (document.getElementById("weighting["+i+"]")) { |
||
| 126 | var value = document.getElementById("weighting["+i+"]").value; |
||
| 127 | } else { |
||
| 128 | var value = "10"; |
||
| 129 | } |
||
| 130 | fields += "<tr>"; |
||
| 131 | fields += "<td>"+blanks[i]+"</td>"; |
||
| 132 | fields += "<td><input style=\"width:35px\" value=\""+value+"\" type=\"text\" id=\"weighting["+i+"]\" name=\"weighting["+i+"]\" /></td>"; |
||
| 133 | fields += "<td>"; |
||
| 134 | fields += "<input type=\"button\" value=\"-\" onclick=\"changeInputSize(-1, "+i+")\">"; |
||
| 135 | fields += "<input type=\"button\" value=\"+\" onclick=\"changeInputSize(1, "+i+")\">"; |
||
| 136 | fields += "<input value=\""+blanks[i].substr(1, blanks[i].length - 2)+"\" style=\"width:"+lainputsize+"px\" disabled=disabled id=\"samplesize["+i+"]\"/>"; |
||
| 137 | fields += "<input type=\"hidden\" id=\"sizeofinput["+i+"]\" name=\"sizeofinput["+i+"]\" value=\""+lainputsize+"\" \"/>"; |
||
| 138 | fields += "</td>"; |
||
| 139 | fields += "</tr>"; |
||
| 140 | // enable the save button |
||
| 141 | $("button").removeAttr("disabled"); |
||
| 142 | $("#defineoneblank").hide(); |
||
| 143 | } |
||
| 144 | } |
||
| 145 | document.getElementById("blanks_weighting").innerHTML = fields + "</table></div></div>"; |
||
| 146 | if (firstTime) { |
||
| 147 | firstTime = false; |
||
| 148 | '; |
||
| 149 | |||
| 150 | if (isset($listAnswersInfo) && count($listAnswersInfo["tabweighting"]) > 0) { |
||
| 151 | |||
| 152 | foreach ($listAnswersInfo["tabweighting"] as $i => $weighting) { |
||
| 153 | echo 'document.getElementById("weighting['.$i.']").value = "'.$weighting.'";'; |
||
| 154 | } |
||
| 155 | foreach ($listAnswersInfo["tabinputsize"] as $i => $sizeOfInput) { |
||
| 156 | echo 'document.getElementById("sizeofinput['.$i.']").value = "'.$sizeOfInput.'";'; |
||
| 157 | echo '$("#samplesize\\\['.$i.'\\\]").width('.$sizeOfInput.');'; |
||
| 158 | } |
||
| 159 | } |
||
| 160 | |||
| 161 | echo '} |
||
| 162 | } |
||
| 163 | window.onload = updateBlanks; |
||
| 164 | |||
| 165 | function getInputSize() { |
||
| 166 | var outTabSize = new Array(); |
||
| 167 | $("input").each(function() { |
||
| 168 | if ($(this).attr("id") && $(this).attr("id").match(/samplesize/)) { |
||
| 169 | var tabidnum = $(this).attr("id").match(/\d+/); |
||
| 170 | var idnum = tabidnum[0]; |
||
| 171 | var thewidth = $(this).next().attr("value"); |
||
| 172 | tabInputSize[idnum] = thewidth; |
||
| 173 | } |
||
| 174 | }); |
||
| 175 | } |
||
| 176 | |||
| 177 | function changeInputSize(inCoef, inIdNum) |
||
| 178 | { |
||
| 179 | var currentWidth = $("#samplesize\\\["+inIdNum+"\\\]").width(); |
||
| 180 | var newWidth = currentWidth + inCoef * 20; |
||
| 181 | newWidth = Math.max(20, newWidth); |
||
| 182 | newWidth = Math.min(newWidth, 600); |
||
| 183 | $("#samplesize\\\["+inIdNum+"\\\]").width(newWidth); |
||
| 184 | $("#sizeofinput\\\["+inIdNum+"\\\]").attr("value", newWidth); |
||
| 185 | } |
||
| 186 | |||
| 187 | function removeForbiddenChars(inTxt) { |
||
| 188 | outTxt = inTxt; |
||
| 189 | |||
| 190 | outTxt = outTxt.replace(/"/g, ""); // remove the char |
||
| 191 | outTxt = outTxt.replace(/\x22/g, ""); // remove the char |
||
| 192 | outTxt = outTxt.replace(/"/g, ""); // remove the char |
||
| 193 | outTxt = outTxt.replace(/\\\\/g, ""); // remove the \ char |
||
| 194 | outTxt = outTxt.replace(/ /g, " "); |
||
| 195 | outTxt = outTxt.replace(/^ +/, ""); |
||
| 196 | outTxt = outTxt.replace(/ +$/, ""); |
||
| 197 | return outTxt; |
||
| 198 | } |
||
| 199 | |||
| 200 | function changeBlankSeparator() |
||
| 201 | { |
||
| 202 | var separatorNumber = $("#select_separator").val(); |
||
| 203 | var tabSeparator = getSeparatorFromNumber(separatorNumber); |
||
| 204 | blankSeparatortStart = tabSeparator[0]; |
||
| 205 | blankSeparatortEnd = tabSeparator[1]; |
||
| 206 | blankSeparatortStartRegexp = getBlankSeparatorRegexp(blankSeparatortStart); |
||
| 207 | blankSeparatortEndRegexp = getBlankSeparatorRegexp(blankSeparatortEnd); |
||
| 208 | updateBlanks(); |
||
| 209 | } |
||
| 210 | |||
| 211 | // this function is the same than the PHP one |
||
| 212 | // if modify it modify the php one escapeForRegexp |
||
| 213 | function getBlankSeparatorRegexp(inTxt) |
||
| 214 | { |
||
| 215 | var tabSpecialChar = new Array(".", "+", "*", "?", "[", "^", "]", "$", "(", ")", |
||
| 216 | "{", "}", "=", "!", "<", ">", "|", ":", "-", ")"); |
||
| 217 | for (var i=0; i < tabSpecialChar.length; i++) { |
||
| 218 | if (inTxt == tabSpecialChar[i]) { |
||
| 219 | return "\\\"+inTxt; |
||
| 220 | } |
||
| 221 | } |
||
| 222 | return inTxt; |
||
| 223 | } |
||
| 224 | |||
| 225 | // this function is the same than the PHP one |
||
| 226 | // if modify it modify the php one getAllowedSeparator |
||
| 227 | function getSeparatorFromNumber(innumber) |
||
| 228 | { |
||
| 229 | tabSeparator = new Array(); |
||
| 230 | tabSeparator[0] = new Array("[", "]"); |
||
| 231 | tabSeparator[1] = new Array("{", "}"); |
||
| 232 | tabSeparator[2] = new Array("(", ")"); |
||
| 233 | tabSeparator[3] = new Array("*", "*"); |
||
| 234 | tabSeparator[4] = new Array("#", "#"); |
||
| 235 | tabSeparator[5] = new Array("%", "%"); |
||
| 236 | tabSeparator[6] = new Array("$", "$"); |
||
| 237 | return tabSeparator[innumber]; |
||
| 238 | } |
||
| 239 | |||
| 240 | function trimBlanksBetweenSeparator(inTxt, inSeparatorStart, inSeparatorEnd) |
||
| 241 | { |
||
| 242 | // blankSeparatortStartRegexp |
||
| 243 | // blankSeparatortEndRegexp |
||
| 244 | var result = inTxt |
||
| 245 | result = result.replace(inSeparatorStart, ""); |
||
| 246 | result = result.replace(inSeparatorEnd, ""); |
||
| 247 | result = result.trim(); |
||
| 248 | return inSeparatorStart+result+inSeparatorEnd; |
||
| 249 | } |
||
| 250 | </script>'; |
||
| 251 | |||
| 252 | // answer |
||
| 253 | $form->addElement('label', null, '<br /><br />'.get_lang('TypeTextBelow').', '.get_lang('And').' '.get_lang('UseTagForBlank')); |
||
| 254 | $form->addElement( |
||
| 255 | 'html_editor', |
||
| 256 | 'answer', |
||
| 257 | Display::return_icon('fill_field.png'), |
||
| 258 | ['id' => 'answer', 'onkeyup' => "javascript: updateBlanks(this);"], |
||
| 259 | array('ToolbarSet' => 'TestQuestionDescription') |
||
| 260 | ); |
||
| 261 | $form->addRule('answer',get_lang('GiveText'),'required'); |
||
| 262 | |||
| 263 | //added multiple answers |
||
| 264 | $form->addElement('checkbox','multiple_answer','', get_lang('FillInBlankSwitchable')); |
||
| 265 | $form->addElement( |
||
| 266 | 'select', |
||
| 267 | 'select_separator', |
||
| 268 | get_lang("SelectFillTheBlankSeparator"), |
||
| 269 | self::getAllowedSeparatorForSelect(), |
||
| 270 | ' id="select_separator" style="width:150px" onchange="changeBlankSeparator()" ' |
||
| 271 | ); |
||
| 272 | $form->addElement( |
||
| 273 | 'label', |
||
| 274 | null, |
||
| 275 | '<input type="button" onclick="updateBlanks()" value="'.get_lang('RefreshBlanks').'" class="btn btn-default" />' |
||
| 276 | ); |
||
| 277 | $form->addElement('html','<div id="blanks_weighting"></div>'); |
||
| 278 | |||
| 279 | global $text; |
||
| 280 | // setting the save button here and not in the question class.php |
||
| 281 | $form->addElement('html','<div id="defineoneblank" style="color:#D04A66; margin-left:160px">'.get_lang('DefineBlanks').'</div>'); |
||
| 282 | $form->addButtonSave($text, 'submitQuestion'); |
||
| 283 | |||
| 284 | if (!empty($this->id)) { |
||
| 285 | $form->setDefaults($defaults); |
||
| 286 | } else { |
||
| 287 | if ($this->isContent == 1) { |
||
| 288 | $form->setDefaults($defaults); |
||
| 289 | } |
||
| 290 | } |
||
| 291 | } |
||
| 292 | |||
| 293 | /** |
||
| 294 | * Function which creates the form to create/edit the answers of the question |
||
| 295 | * @param FormValidator $form |
||
| 296 | */ |
||
| 297 | public function processAnswersCreation($form) |
||
| 411 | |||
| 412 | /** |
||
| 413 | * @param null $feedback_type |
||
| 414 | * @param null $counter |
||
| 415 | * @param null $score |
||
| 416 | * @return null|string |
||
| 417 | */ |
||
| 418 | View Code Duplication | public function return_header($feedback_type = null, $counter = null, $score = null) |
|
| 428 | |||
| 429 | /** |
||
| 430 | * @param $separatorStartRegexp |
||
| 431 | * @param $separatorEndRegexp |
||
| 432 | * @param $correctItemRegexp |
||
| 433 | * @param $questionId |
||
| 434 | * @param $correctItem |
||
| 435 | * @param $attributes |
||
| 436 | * @param $answer |
||
| 437 | * @param $listAnswersInfo |
||
| 438 | * @param $displayForStudent |
||
| 439 | * @return string |
||
| 440 | */ |
||
| 441 | public static function getFillTheBlankHtml( |
||
| 494 | |||
| 495 | /** |
||
| 496 | * Return an array with the different choices available |
||
| 497 | * when the answers between bracket show as a menu |
||
| 498 | * @param string $correctAnswer |
||
| 499 | * @param bool $displayForStudent true if we want to shuffle the choices of the menu for students |
||
| 500 | * |
||
| 501 | * @return array |
||
| 502 | */ |
||
| 503 | public static function getFillTheBlankMenuAnswers($correctAnswer, $displayForStudent) |
||
| 513 | |||
| 514 | /** |
||
| 515 | * Return the array index of the student answer |
||
| 516 | * @param string $correctAnswer the menu Choice1|Choice2|Choice3 |
||
| 517 | * @param string $studentAnswer the student answer must be Choice1 or Choice2 or Choice3 |
||
| 518 | * |
||
| 519 | * @return int in the example 0 1 or 2 depending of the choice of the student |
||
| 520 | */ |
||
| 521 | public static function getFillTheBlankMenuAnswerNum($correctAnswer, $studentAnswer) |
||
| 533 | |||
| 534 | |||
| 535 | /** |
||
| 536 | * Return the possible answer if the answer between brackets is a multiple choice menu |
||
| 537 | * @param string $correctAnswer |
||
| 538 | * |
||
| 539 | * @return array |
||
| 540 | */ |
||
| 541 | public static function getFillTheBlankSeveralAnswers($correctAnswer) |
||
| 548 | |||
| 549 | /** |
||
| 550 | * Return true if student answer is right according to the correctAnswer |
||
| 551 | * it is not as simple as equality, because of the type of Fill The Blank question |
||
| 552 | * eg : studentAnswer = 'Un' and correctAnswer = 'Un||1||un' |
||
| 553 | * @param string $studentAnswer [studentanswer] of the info array of the answer field |
||
| 554 | * @param string $correctAnswer [tabwords] of the info array of the answer field |
||
| 555 | * |
||
| 556 | * @return bool |
||
| 557 | */ |
||
| 558 | public static function isGoodStudentAnswer($studentAnswer, $correctAnswer) |
||
| 578 | |||
| 579 | /** |
||
| 580 | * @param string $correctAnswer |
||
| 581 | * |
||
| 582 | * @return int |
||
| 583 | */ |
||
| 584 | public static function getFillTheBlankAnswerType($correctAnswer) |
||
| 594 | |||
| 595 | /** |
||
| 596 | * Return information about the answer |
||
| 597 | * @param string $userAnswer the text of the answer of the question |
||
| 598 | * @param bool $isStudentAnswer true if it's a student answer false the empty question model |
||
| 599 | * |
||
| 600 | * @return array of information about the answer |
||
| 601 | */ |
||
| 602 | public static function getAnswerInfo($userAnswer = "", $isStudentAnswer = false) |
||
| 728 | |||
| 729 | /** |
||
| 730 | * Return an array of student state answers for fill the blank questions |
||
| 731 | * for each students that answered the question |
||
| 732 | * -2 : didn't answer |
||
| 733 | * -1 : student answer is wrong |
||
| 734 | * 0 : student answer is correct |
||
| 735 | * >0 : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0) |
||
| 736 | * |
||
| 737 | * @param $testId |
||
| 738 | * @param $questionId |
||
| 739 | * @param $studentsIdList |
||
| 740 | * @param $startDate |
||
| 741 | * @param $endDate |
||
| 742 | * @param bool $useLastAnswerredAttempt |
||
| 743 | * @return array |
||
| 744 | * ( |
||
| 745 | * [student_id] => Array |
||
| 746 | * ( |
||
| 747 | * [first fill the blank for question] => -1 |
||
| 748 | * [second fill the blank for question] => 2 |
||
| 749 | * [third fill the blank for question] => -1 |
||
| 750 | * ) |
||
| 751 | * ) |
||
| 752 | */ |
||
| 753 | public static function getFillTheBlankTabResult($testId, $questionId, $studentsIdList, $startDate, $endDate, $useLastAnswerredAttempt = true) { |
||
| 826 | |||
| 827 | |||
| 828 | |||
| 829 | /** |
||
| 830 | * Return the number of student that give at leat an answer in the fill the blank test |
||
| 831 | * @param $resultList |
||
| 832 | * @return int |
||
| 833 | */ |
||
| 834 | public static function getNbResultFillBlankAll($resultList) |
||
| 850 | |||
| 851 | /** |
||
| 852 | * Replace the occurrence of blank word with [correct answer][student answer][answer is correct] |
||
| 853 | * @param array $listWithStudentAnswer |
||
| 854 | * |
||
| 855 | * @return string |
||
| 856 | */ |
||
| 857 | public static function getAnswerInStudentAttempt($listWithStudentAnswer) |
||
| 876 | |||
| 877 | /** |
||
| 878 | * This function is the same than the js one above getBlankSeparatorRegexp |
||
| 879 | * @param string $inChar |
||
| 880 | * |
||
| 881 | * @return string |
||
| 882 | */ |
||
| 883 | public static function escapeForRegexp($inChar) |
||
| 913 | |||
| 914 | /** |
||
| 915 | * return $text protected for use in regexp |
||
| 916 | * @param string $text |
||
| 917 | * |
||
| 918 | * @return mixed |
||
| 919 | */ |
||
| 920 | public static function getRegexpProtected($text) |
||
| 951 | |||
| 952 | |||
| 953 | /** |
||
| 954 | * This function must be the same than the js one getSeparatorFromNumber above |
||
| 955 | * @return array |
||
| 956 | */ |
||
| 957 | public static function getAllowedSeparator() |
||
| 971 | |||
| 972 | /** |
||
| 973 | * return the start separator for answer |
||
| 974 | * @param string $number |
||
| 975 | * |
||
| 976 | * @return mixed |
||
| 977 | */ |
||
| 978 | public static function getStartSeparator($number) |
||
| 984 | |||
| 985 | /** |
||
| 986 | * return the end separator for answer |
||
| 987 | * @param string $number |
||
| 988 | * |
||
| 989 | * @return mixed |
||
| 990 | */ |
||
| 991 | public static function getEndSeparator($number) |
||
| 997 | |||
| 998 | /** |
||
| 999 | * Return as a description text, array of allowed separators for question |
||
| 1000 | * eg: array("[...]", "(...)") |
||
| 1001 | * @return array |
||
| 1002 | */ |
||
| 1003 | public static function getAllowedSeparatorForSelect() |
||
| 1013 | |||
| 1014 | /** |
||
| 1015 | * return the code number of the separator for the question |
||
| 1016 | * @param string $startSeparator |
||
| 1017 | * @param string $endSeparator |
||
| 1018 | * |
||
| 1019 | * @return int |
||
| 1020 | */ |
||
| 1021 | public function getDefaultSeparatorNumber($startSeparator, $endSeparator) |
||
| 1035 | |||
| 1036 | /** |
||
| 1037 | * return the HTML display of the answer |
||
| 1038 | * @param string $answer |
||
| 1039 | * @param bool $resultsDisabled |
||
| 1040 | * @param bool $showTotalScoreAndUserChoices |
||
| 1041 | * |
||
| 1042 | * @return string |
||
| 1043 | */ |
||
| 1044 | public static function getHtmlDisplayForAnswer($answer, $resultsDisabled = false, $showTotalScoreAndUserChoices = false) |
||
| 1087 | |||
| 1088 | /** |
||
| 1089 | * return the HTML code of answer for correct and wrong answer |
||
| 1090 | * @param string $answer |
||
| 1091 | * @param string $correct |
||
| 1092 | * @param string $right |
||
| 1093 | * @param bool $resultsDisabled |
||
| 1094 | * |
||
| 1095 | * @return string |
||
| 1096 | */ |
||
| 1097 | public static function getHtmlAnswer($answer, $correct, $right, $resultsDisabled = false) |
||
| 1143 | |||
| 1144 | /** |
||
| 1145 | * return HTML code for correct answer |
||
| 1146 | * @param string $answer |
||
| 1147 | * @param string $correct |
||
| 1148 | * @param bool $resultsDisabled |
||
| 1149 | * |
||
| 1150 | * @return string |
||
| 1151 | */ |
||
| 1152 | public static function getHtmlRightAnswer($answer, $correct, $resultsDisabled = false) |
||
| 1156 | |||
| 1157 | /** |
||
| 1158 | * return HTML code for wrong answer |
||
| 1159 | * @param string $answer |
||
| 1160 | * @param string $correct |
||
| 1161 | * @param bool $resultsDisabled |
||
| 1162 | * |
||
| 1163 | * @return string |
||
| 1164 | */ |
||
| 1165 | public static function getHtmlWrongAnswer($answer, $correct, $resultsDisabled = false) |
||
| 1169 | } |
||
| 1170 |
This check looks for calls to
isset(...)orempty()on variables that are yet undefined. These calls will always produce the same result and can be removed.This is most likely caused by the renaming of a variable or the removal of a function/method parameter.