Browse Source

Minor - format code, update docs

jmontoyaa 8 years ago
parent
commit
672635f566

+ 16 - 20
main/exercise/exercise.class.php

@@ -7039,7 +7039,6 @@ class Exercise
                 }
 
                 $i = 1;
-
                 $select_items[0]['id'] = 0;
                 $select_items[0]['letter'] = '--';
                 $select_items[0]['answer'] = '';
@@ -7056,7 +7055,13 @@ class Exercise
                 if ($modelType == EXERCISE_MODEL_TYPE_COMMITTEE) {
                     $toolBar = 'TestFreeAnswerStrict';
                 }
-                $form->addElement('html_editor', "choice[".$questionId."]", null, array('id' => "choice[".$questionId."]"), array('ToolbarSet' => $toolBar));
+                $form->addElement(
+                    'html_editor',
+                    "choice[".$questionId."]",
+                    null,
+                    array('id' => "choice[".$questionId."]"),
+                    array('ToolbarSet' => $toolBar)
+                );
                 $form->setDefaults(array("choice[".$questionId."]" => $content));
                 $s .= $form->returnForm();
             } elseif ($answerType == ORAL_EXPRESSION) {
@@ -7091,13 +7096,12 @@ class Exercise
                     array('ToolbarSet' => 'TestFreeAnswer')
                 );
                 //$form->setDefaults(array("choice[".$questionId."]" => $content));
-                $s .= $form->return_form();
+                $s .= $form->returnForm();
             }
 
             // Now navigate through the possible answers, using the max number of
             // answers for the question as a limiter
             $lines_count = 1; // a counter for matching-type answers
-
             if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
                 $header = Display::tag('th', get_lang('Options'));
                 foreach ($objQuestionTmp->options as $item) {
@@ -7133,8 +7137,6 @@ class Exercise
                 $answer = $objAnswerTmp->selectAnswer($answerId);
                 $answerCorrect = $objAnswerTmp->isCorrect($answerId);
                 $comment = $objAnswerTmp->selectComment($answerId);
-
-                //$numAnswer       = $objAnswerTmp->selectAutoId($answerId);
                 $numAnswer = $answerId;
 
                 $attributes = array();
@@ -7183,7 +7185,6 @@ class Exercise
                     } else {
                         $s .= $answer_input;
                     }
-
                 } elseif (in_array($answerType, array(MULTIPLE_ANSWER, MULTIPLE_ANSWER_TRUE_FALSE, GLOBAL_MULTIPLE_ANSWER))) {
                     $input_id = 'choice-'.$questionId.'-'.$answerId;
                     $answer = Security::remove_XSS($answer);
@@ -7203,7 +7204,6 @@ class Exercise
 
                     if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) {
                         $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
-
                         $answer_input = '<label class="checkbox">';
                         $answer_input .= Display::input('checkbox', 'choice['.$questionId.']['.$numAnswer.']', $numAnswer, $attributes);
                         $answer_input .= $answer;
@@ -7221,7 +7221,6 @@ class Exercise
                             $s .= $answer_input;
                         }
                     } elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
-
                         $my_choice = array();
                         if (!empty($user_choice_array)) {
                             foreach ($user_choice_array as $item) {
@@ -7333,17 +7332,16 @@ class Exercise
                     $s.='</tr>';
                 } elseif ($answerType == FILL_IN_BLANKS) {
                     list($answer) = explode('::', $answer);
-
-                    //Correct answer
+                    // Correct answer
                     api_preg_match_all('/\[[^]]+\]/', $answer, $correct_answer_list);
 
-                    //Student's answezr
+                    // Student's answer
                     if (isset($user_choice[0]['answer'])) {
                         api_preg_match_all('/\[[^]]+\]/', $user_choice[0]['answer'], $student_answer_list);
                         $student_answer_list = $student_answer_list[0];
                     }
 
-                    //If debug
+                    // If debug
                     if ($debug_mark_answer) {
                         $student_answer_list = $correct_answer_list[0];
                     }
@@ -7386,12 +7384,12 @@ class Exercise
                         $s .= '<tr><td width="45%">';
                         $parsed_answer = $answer;
                         $windowId = $questionId.'_'.$lines_count;
-                        //left part questions
+                        // Left part questions
                         $s .= ' <div id="window_'.$windowId.'" class="window window_left_question window'.$questionId.'_question">
                                     <b>'.$lines_count.'</b>.&nbsp'.$parsed_answer.'
                                 </div>
                                 </td>';
-                        // middle part (matches selects)
+                        // Middle part (matches selects)
                         $s .= '<td width="10%" align="center">&nbsp;&nbsp;';
                         $s .= '<div style="display:block">';
                         $s .= '<select id="window_'.$windowId.'_select" name="choice['.$questionId.']['.$numAnswer.']">';
@@ -7408,7 +7406,9 @@ class Exercise
                                     $selectedValue = $val['id'];
                                 }
                             }
-                            if (isset($user_choice[$matching_correct_answer]) && $val['id'] == $user_choice[$matching_correct_answer]['answer']) {
+                            if (isset($user_choice[$matching_correct_answer]) &&
+                                $val['id'] == $user_choice[$matching_correct_answer]['answer']
+                            ) {
                                 $selected = 'selected="selected"';
                                 $selectedValue = $val['id'];
                             }
@@ -7431,7 +7431,6 @@ class Exercise
                                 </script>';
                         }
                         $s .= '</select></div></td>';
-
                         $s.='<td width="45%" valign="top" >';
                         if (isset($select_items[$lines_count])) {
                             $s.= '<div id="window_'.$windowId.'_answer" class="window window_right_question">
@@ -7546,7 +7545,6 @@ class Exercise
 
             if ($answerType == DRAGGABLE) {
                 $s .= '</ul><div class="clear"></div>';
-
                 $counterAnswer = 1;
                 foreach ($objAnswerTmp->answer as $answerId => $answer_item) {
                     $answerCorrect = $objAnswerTmp->isCorrect($answerId);
@@ -7566,10 +7564,8 @@ class Exercise
 
             // destruction of the Answer object
             unset($objAnswerTmp);
-
             // destruction of the Question object
             unset($objQuestionTmp);
-
             $html .= $s;
             return $html;
         } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) {

+ 3 - 2
main/exercise/matching.class.php

@@ -141,7 +141,6 @@ class Matching extends Question
             );
 
             $form->addHtml('<tr>');
-
             $form->addHtml("<td>$i</td>");
             $form->addText("answer[$i]", null);
 
@@ -151,6 +150,7 @@ class Matching extends Question
                 $matches,
                 ['id' => 'matches_'.$i]
             );
+
             $form->addText(
                 "weighting[$i]",
                 null,
@@ -163,7 +163,6 @@ class Matching extends Question
 
         $form->addHtml('</tbody></table>');
         $group = array();
-
         $form->addGroup($group);
 
         // DISPLAY OPTIONS
@@ -286,6 +285,8 @@ class Matching extends Question
      * Check if a answer is correct
      * @param int $position
      * @param int $answer
+     * @param int $questionId
+     *
      * @return bool
      */
     public static function isCorrect($position, $answer, $questionId)

+ 16 - 15
main/inc/lib/exercise_show_functions.lib.php

@@ -266,19 +266,22 @@ class ExerciseShowFunctions
 		<?php
 	}
 
-	/**
-	 * Display the answers to a multiple choice question
-	 * @param int $feedback_type Feedback type
-	 * @param integer Answer type
-	 * @param integer Student choice
-	 * @param string  Textual answer
-	 * @param string  Comment on answer
-	 * @param string  Correct answer comment
-	 * @param integer Exercise ID
-	 * @param integer Question ID
-	 * @param boolean Whether to show the answer comment or not
-	 * @return void
-	 */
+    /**
+     * Display the answers to a multiple choice question
+     * @param int $feedback_type Feedback type
+     * @param int $answerType Answer type
+     * @param int $studentChoice Student choice
+     * @param string $answer Textual answer
+     * @param string $answerComment Comment on answer
+     * @param string $answerCorrect Correct answer comment
+     * @param int $id Exercise ID
+     * @param int $questionId Question ID
+     * @param boolean $ans Whether to show the answer comment or not
+     * @param bool $resultsDisabled
+     * @param bool $showTotalScoreAndUserChoices
+     *
+     * @return void
+     */
 	public static function display_unique_or_multiple_answer(
         $feedback_type,
         $answerType,
@@ -292,7 +295,6 @@ class ExerciseShowFunctions
         $resultsDisabled,
         $showTotalScoreAndUserChoices
     ) {
-
         $hide_expected_answer = false;
         if ($feedback_type == 0 && ($resultsDisabled == RESULT_DISABLE_SHOW_SCORE_ONLY)) {
             $hide_expected_answer = true;
@@ -309,7 +311,6 @@ class ExerciseShowFunctions
         $icon = in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION)) ? 'radio':'checkbox';
 		$icon .= $studentChoice?'_on':'_off';
 		$icon .= '.gif';
-
 		$iconAnswer = in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION)) ? 'radio':'checkbox';
 		$iconAnswer .= $answerCorrect?'_on':'_off';
 		$iconAnswer .= '.gif';