@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
286 | - * @return int |
|
286 | + * @return string |
|
287 | 287 | */ |
288 | 288 | public function selectPassPercentage() |
289 | 289 | { |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * tells if questions are selected randomly, and if so returns the draws |
379 | 379 | * |
380 | 380 | * @author Olivier Brouckaert |
381 | - * @return integer - 0 if not random, otherwise the draws |
|
381 | + * @return boolean - 0 if not random, otherwise the draws |
|
382 | 382 | */ |
383 | 383 | public function isRandom() |
384 | 384 | { |
@@ -1856,7 +1856,7 @@ discard block |
||
1856 | 1856 | * @param int int lp id |
1857 | 1857 | * @param int int lp item id |
1858 | 1858 | * @param int int lp item_view id |
1859 | - * @param float $weight |
|
1859 | + * @param integer $weight |
|
1860 | 1860 | * @param array question list |
1861 | 1861 | */ |
1862 | 1862 | public function save_stat_track_exercise_info( |
@@ -4121,6 +4121,7 @@ discard block |
||
4121 | 4121 | /** |
4122 | 4122 | * Sends a notification when a user ends an examn |
4123 | 4123 | * |
4124 | + * @param integer $exe_id |
|
4124 | 4125 | */ |
4125 | 4126 | public function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id) |
4126 | 4127 | { |
@@ -4201,6 +4202,7 @@ discard block |
||
4201 | 4202 | /** |
4202 | 4203 | * Sends a notification when a user ends an examn |
4203 | 4204 | * |
4205 | + * @param integer $exe_id |
|
4204 | 4206 | */ |
4205 | 4207 | function send_notification_for_open_questions($question_list_answers, $origin, $exe_id) |
4206 | 4208 | { |
@@ -4298,6 +4300,9 @@ discard block |
||
4298 | 4300 | } |
4299 | 4301 | } |
4300 | 4302 | |
4303 | + /** |
|
4304 | + * @param integer $exe_id |
|
4305 | + */ |
|
4301 | 4306 | function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id) |
4302 | 4307 | { |
4303 | 4308 | if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { |
@@ -4391,7 +4396,7 @@ discard block |
||
4391 | 4396 | |
4392 | 4397 | /** |
4393 | 4398 | * @param array $user_data result of api_get_user_info() |
4394 | - * @param null $start_date |
|
4399 | + * @param string $start_date |
|
4395 | 4400 | * @param null $duration |
4396 | 4401 | * @param string $ip Optional. The user IP |
4397 | 4402 | * @return string |
@@ -4449,7 +4454,7 @@ discard block |
||
4449 | 4454 | * @param int Maximum number of attempts (0 if no limit) |
4450 | 4455 | * @param int Feedback type |
4451 | 4456 | * @todo this was function was added due the import exercise via CSV |
4452 | - * @return int New exercise ID |
|
4457 | + * @return string New exercise ID |
|
4453 | 4458 | */ |
4454 | 4459 | public function createExercise( |
4455 | 4460 | $title, |
@@ -1966,7 +1966,7 @@ discard block |
||
1966 | 1966 | $label = get_lang('NextQuestion'); |
1967 | 1967 | $class = 'btn btn-primary'; |
1968 | 1968 | } |
1969 | - $class .= ' question-validate-btn'; // used to select it with jquery |
|
1969 | + $class .= ' question-validate-btn'; // used to select it with jquery |
|
1970 | 1970 | if ($this->type == ONE_PER_PAGE) { |
1971 | 1971 | if ($questionNum != 1) { |
1972 | 1972 | $prev_question = $questionNum - 2; |
@@ -1991,7 +1991,7 @@ discard block |
||
1991 | 1991 | $all_label = get_lang('EndTest'); |
1992 | 1992 | $class = 'btn btn-warning'; |
1993 | 1993 | } |
1994 | - $class .= ' question-validate-btn'; // used to select it with jquery |
|
1994 | + $class .= ' question-validate-btn'; // used to select it with jquery |
|
1995 | 1995 | $all_button = ' <a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>'; |
1996 | 1996 | $all_button .= ' ' . Display::span(null, ['id' => 'save_all_reponse']); |
1997 | 1997 | $html .= $all_button; |
@@ -3774,7 +3774,7 @@ discard block |
||
3774 | 3774 | |
3775 | 3775 | //Fixes multiple answer question in order to be exact |
3776 | 3776 | //if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) { |
3777 | - /* if ($answerType == GLOBAL_MULTIPLE_ANSWER) { |
|
3777 | + /* if ($answerType == GLOBAL_MULTIPLE_ANSWER) { |
|
3778 | 3778 | $diff = @array_diff($answer_correct_array, $real_answers); |
3779 | 3779 | |
3780 | 3780 | // All good answers or nothing works like exact |
@@ -5073,8 +5073,8 @@ discard block |
||
5073 | 5073 | } |
5074 | 5074 | |
5075 | 5075 | /** |
5076 | - * @return string |
|
5077 | - */ |
|
5076 | + * @return string |
|
5077 | + */ |
|
5078 | 5078 | public function get_formated_title() |
5079 | 5079 | { |
5080 | 5080 | return api_html_entity_decode($this->selectTitle()); |
@@ -538,10 +538,11 @@ discard block |
||
538 | 538 | */ |
539 | 539 | public function isInList($questionId) |
540 | 540 | { |
541 | - if (is_array($this->questionList)) |
|
542 | - return in_array($questionId,$this->questionList); |
|
543 | - else |
|
544 | - return false; |
|
541 | + if (is_array($this->questionList)) { |
|
542 | + return in_array($questionId,$this->questionList); |
|
543 | + } else { |
|
544 | + return false; |
|
545 | + } |
|
545 | 546 | } |
546 | 547 | |
547 | 548 | /** |
@@ -1227,10 +1228,11 @@ discard block |
||
1227 | 1228 | |
1228 | 1229 | $var = Exercise::selectTimeLimit(); |
1229 | 1230 | |
1230 | - if (($this->start_time != '0000-00-00 00:00:00')) |
|
1231 | - $form->addElement('html','<div id="start_date_div" style="display:block;">'); |
|
1232 | - else |
|
1233 | - $form->addElement('html','<div id="start_date_div" style="display:none;">'); |
|
1231 | + if (($this->start_time != '0000-00-00 00:00:00')) { |
|
1232 | + $form->addElement('html','<div id="start_date_div" style="display:block;">'); |
|
1233 | + } else { |
|
1234 | + $form->addElement('html','<div id="start_date_div" style="display:none;">'); |
|
1235 | + } |
|
1234 | 1236 | |
1235 | 1237 | $form->addElement('date_time_picker', 'start_time'); |
1236 | 1238 | |
@@ -1238,10 +1240,11 @@ discard block |
||
1238 | 1240 | |
1239 | 1241 | $form->addElement('checkbox', 'activate_end_date_check', null , get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()')); |
1240 | 1242 | |
1241 | - if (($this->end_time != '0000-00-00 00:00:00')) |
|
1242 | - $form->addElement('html','<div id="end_date_div" style="display:block;">'); |
|
1243 | - else |
|
1244 | - $form->addElement('html','<div id="end_date_div" style="display:none;">'); |
|
1243 | + if (($this->end_time != '0000-00-00 00:00:00')) { |
|
1244 | + $form->addElement('html','<div id="end_date_div" style="display:block;">'); |
|
1245 | + } else { |
|
1246 | + $form->addElement('html','<div id="end_date_div" style="display:none;">'); |
|
1247 | + } |
|
1245 | 1248 | |
1246 | 1249 | $form->addElement('date_time_picker', 'end_time'); |
1247 | 1250 | $form->addElement('html','</div>'); |
@@ -2268,7 +2271,9 @@ discard block |
||
2268 | 2271 | $organs_at_risk_hit = 0; |
2269 | 2272 | $questionScore = 0; |
2270 | 2273 | |
2271 | - if ($debug) error_log('Start answer loop '); |
|
2274 | + if ($debug) { |
|
2275 | + error_log('Start answer loop '); |
|
2276 | + } |
|
2272 | 2277 | |
2273 | 2278 | $answer_correct_array = array(); |
2274 | 2279 | |
@@ -2383,7 +2388,9 @@ discard block |
||
2383 | 2388 | } |
2384 | 2389 | $totalScore += $answerWeighting; |
2385 | 2390 | |
2386 | - if ($debug) error_log("studentChoice: $studentChoice"); |
|
2391 | + if ($debug) { |
|
2392 | + error_log("studentChoice: $studentChoice"); |
|
2393 | + } |
|
2387 | 2394 | break; |
2388 | 2395 | case GLOBAL_MULTIPLE_ANSWER: |
2389 | 2396 | if ($from_database) { |
@@ -2408,7 +2415,9 @@ discard block |
||
2408 | 2415 | $real_answers[$answerId] = (bool)$studentChoice; |
2409 | 2416 | } |
2410 | 2417 | $totalScore += $answerWeighting; |
2411 | - if ($debug) error_log("studentChoice: $studentChoice"); |
|
2418 | + if ($debug) { |
|
2419 | + error_log("studentChoice: $studentChoice"); |
|
2420 | + } |
|
2412 | 2421 | break; |
2413 | 2422 | case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE: |
2414 | 2423 | if ($from_database) { |
@@ -3125,9 +3134,13 @@ discard block |
||
3125 | 3134 | } // end switch Answertype |
3126 | 3135 | |
3127 | 3136 | if ($show_result) { |
3128 | - if ($debug) error_log('show result '.$show_result); |
|
3137 | + if ($debug) { |
|
3138 | + error_log('show result '.$show_result); |
|
3139 | + } |
|
3129 | 3140 | if ($from == 'exercise_result') { |
3130 | - if ($debug) error_log('Showing questions $from '.$from); |
|
3141 | + if ($debug) { |
|
3142 | + error_log('Showing questions $from '.$from); |
|
3143 | + } |
|
3131 | 3144 | //display answers (if not matching type, or if the answer is correct) |
3132 | 3145 | if ( |
3133 | 3146 | !in_array( |
@@ -3415,7 +3428,9 @@ discard block |
||
3415 | 3428 | } |
3416 | 3429 | } |
3417 | 3430 | } else { |
3418 | - if ($debug) error_log('Showing questions $from '.$from); |
|
3431 | + if ($debug) { |
|
3432 | + error_log('Showing questions $from '.$from); |
|
3433 | + } |
|
3419 | 3434 | |
3420 | 3435 | switch ($answerType) { |
3421 | 3436 | case UNIQUE_ANSWER: |
@@ -3747,10 +3762,14 @@ discard block |
||
3747 | 3762 | } |
3748 | 3763 | } |
3749 | 3764 | } |
3750 | - if ($debug) error_log(' ------ '); |
|
3765 | + if ($debug) { |
|
3766 | + error_log(' ------ '); |
|
3767 | + } |
|
3751 | 3768 | } // end for that loops over all answers of the current question |
3752 | 3769 | |
3753 | - if ($debug) error_log('-- end answer loop --'); |
|
3770 | + if ($debug) { |
|
3771 | + error_log('-- end answer loop --'); |
|
3772 | + } |
|
3754 | 3773 | |
3755 | 3774 | $final_answer = true; |
3756 | 3775 | |
@@ -3823,7 +3842,9 @@ discard block |
||
3823 | 3842 | // some results that haven't been stored in the database yet |
3824 | 3843 | if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION ) { |
3825 | 3844 | |
3826 | - if ($debug) error_log('$from AND this is a hotspot kind of question '); |
|
3845 | + if ($debug) { |
|
3846 | + error_log('$from AND this is a hotspot kind of question '); |
|
3847 | + } |
|
3827 | 3848 | |
3828 | 3849 | $my_exe_id = 0; |
3829 | 3850 | $from_database = 0; |
@@ -3999,8 +4020,12 @@ discard block |
||
3999 | 4020 | // stored by exercise_results.php (using the session) |
4000 | 4021 | |
4001 | 4022 | if ($saved_results) { |
4002 | - if ($debug) error_log("Save question results $saved_results"); |
|
4003 | - if ($debug) error_log(print_r($choice ,1 )); |
|
4023 | + if ($debug) { |
|
4024 | + error_log("Save question results $saved_results"); |
|
4025 | + } |
|
4026 | + if ($debug) { |
|
4027 | + error_log(print_r($choice ,1 )); |
|
4028 | + } |
|
4004 | 4029 | |
4005 | 4030 | if (empty($choice)) { |
4006 | 4031 | $choice = 0; |
@@ -4102,7 +4127,9 @@ discard block |
||
4102 | 4127 | $sql = 'UPDATE ' . $stat_table . ' SET |
4103 | 4128 | exe_result = exe_result + ' . floatval($questionScore) . ' |
4104 | 4129 | WHERE exe_id = ' . $exeId; |
4105 | - if ($debug) error_log($sql); |
|
4130 | + if ($debug) { |
|
4131 | + error_log($sql); |
|
4132 | + } |
|
4106 | 4133 | Database::query($sql); |
4107 | 4134 | } |
4108 | 4135 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public $feedback_type; |
30 | 30 | public $end_time; |
31 | 31 | public $start_time; |
32 | - public $questionList; // array with the list of this exercise's questions |
|
32 | + public $questionList; // array with the list of this exercise's questions |
|
33 | 33 | public $results_disabled; |
34 | 34 | public $expired_time; |
35 | 35 | public $course; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); |
100 | 100 | $table_lp_item = Database::get_course_table(TABLE_LP_ITEM); |
101 | 101 | |
102 | - $id = intval($id); |
|
102 | + $id = intval($id); |
|
103 | 103 | if (empty($this->course_id)) { |
104 | 104 | return false; |
105 | 105 | } |
@@ -156,17 +156,17 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | if ($object->end_time != '0000-00-00 00:00:00') { |
159 | - $this->end_time = $object->end_time; |
|
159 | + $this->end_time = $object->end_time; |
|
160 | 160 | } |
161 | 161 | if ($object->start_time != '0000-00-00 00:00:00') { |
162 | - $this->start_time = $object->start_time; |
|
162 | + $this->start_time = $object->start_time; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | //control time |
166 | - $this->expired_time = $object->expired_time; |
|
166 | + $this->expired_time = $object->expired_time; |
|
167 | 167 | |
168 | 168 | //Checking if question_order is correctly set |
169 | - $this->questionList = $this->selectQuestionList(true); |
|
169 | + $this->questionList = $this->selectQuestionList(true); |
|
170 | 170 | |
171 | 171 | //overload questions list with recorded questions list |
172 | 172 | //load questions only for exercises of type 'one question per page' |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | */ |
385 | 385 | public function isRandom() |
386 | 386 | { |
387 | - if($this->random > 0 || $this->random == -1) { |
|
387 | + if ($this->random > 0 || $this->random == -1) { |
|
388 | 388 | return true; |
389 | 389 | } else { |
390 | 390 | return false; |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | public function selectQuestionList($from_db = false) |
430 | 430 | { |
431 | 431 | if ($from_db && !empty($this->id)) { |
432 | - $TBL_EXERCISE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
432 | + $TBL_EXERCISE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
433 | 433 | $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); |
434 | 434 | |
435 | 435 | $sql = "SELECT DISTINCT e.question_order |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | $question_list = array(); |
457 | 457 | |
458 | 458 | while ($new_object = Database::fetch_object($result)) { |
459 | - $question_list[$new_object->question_order]= $new_object->question_id; |
|
459 | + $question_list[$new_object->question_order] = $new_object->question_id; |
|
460 | 460 | $temp_question_list[$counter] = $new_object->question_id; |
461 | 461 | $counter++; |
462 | 462 | } |
@@ -502,16 +502,16 @@ discard block |
||
502 | 502 | */ |
503 | 503 | public function selectRandomList() |
504 | 504 | { |
505 | - $nbQuestions = $this->selectNbrQuestions(); |
|
506 | - $temp_list = $this->questionList; |
|
505 | + $nbQuestions = $this->selectNbrQuestions(); |
|
506 | + $temp_list = $this->questionList; |
|
507 | 507 | |
508 | 508 | //Not a random exercise, or if there are not at least 2 questions |
509 | - if($this->random == 0 || $nbQuestions < 2) { |
|
509 | + if ($this->random == 0 || $nbQuestions < 2) { |
|
510 | 510 | return $this->questionList; |
511 | 511 | } |
512 | 512 | if ($nbQuestions != 0) { |
513 | 513 | shuffle($temp_list); |
514 | - $my_random_list = array_combine(range(1,$nbQuestions),$temp_list); |
|
514 | + $my_random_list = array_combine(range(1, $nbQuestions), $temp_list); |
|
515 | 515 | $my_question_list = array(); |
516 | 516 | // $this->random == -1 if random with all questions |
517 | 517 | if ($this->random > 0) { |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | public function isInList($questionId) |
542 | 542 | { |
543 | 543 | if (is_array($this->questionList)) |
544 | - return in_array($questionId,$this->questionList); |
|
544 | + return in_array($questionId, $this->questionList); |
|
545 | 545 | else |
546 | 546 | return false; |
547 | 547 | } |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | */ |
555 | 555 | public function updateTitle($title) |
556 | 556 | { |
557 | - $this->exercise=$title; |
|
557 | + $this->exercise = $title; |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | /** |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | */ |
565 | 565 | public function updateAttempts($attempts) |
566 | 566 | { |
567 | - $this->attempts=$attempts; |
|
567 | + $this->attempts = $attempts; |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | /** |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | */ |
575 | 575 | public function updateFeedbackType($feedback_type) |
576 | 576 | { |
577 | - $this->feedback_type=$feedback_type; |
|
577 | + $this->feedback_type = $feedback_type; |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | /** |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | */ |
586 | 586 | public function updateDescription($description) |
587 | 587 | { |
588 | - $this->description=$description; |
|
588 | + $this->description = $description; |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | /** |
@@ -630,23 +630,23 @@ discard block |
||
630 | 630 | * @param string $sound - exercise sound file |
631 | 631 | * @param string $delete - ask to delete the file |
632 | 632 | */ |
633 | - public function updateSound($sound,$delete) |
|
633 | + public function updateSound($sound, $delete) |
|
634 | 634 | { |
635 | 635 | global $audioPath, $documentPath; |
636 | 636 | $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); |
637 | 637 | |
638 | - if ($sound['size'] && (strstr($sound['type'],'audio') || strstr($sound['type'],'video'))) { |
|
639 | - $this->sound=$sound['name']; |
|
638 | + if ($sound['size'] && (strstr($sound['type'], 'audio') || strstr($sound['type'], 'video'))) { |
|
639 | + $this->sound = $sound['name']; |
|
640 | 640 | |
641 | - if (@move_uploaded_file($sound['tmp_name'],$audioPath.'/'.$this->sound)) { |
|
641 | + if (@move_uploaded_file($sound['tmp_name'], $audioPath.'/'.$this->sound)) { |
|
642 | 642 | $query = "SELECT 1 FROM $TBL_DOCUMENT |
643 | - WHERE c_id = ".$this->course_id." AND path='".str_replace($documentPath,'',$audioPath).'/'.$this->sound."'"; |
|
644 | - $result=Database::query($query); |
|
643 | + WHERE c_id = ".$this->course_id." AND path='".str_replace($documentPath, '', $audioPath).'/'.$this->sound."'"; |
|
644 | + $result = Database::query($query); |
|
645 | 645 | |
646 | 646 | if (!Database::num_rows($result)) { |
647 | 647 | $id = add_document( |
648 | 648 | $this->course, |
649 | - str_replace($documentPath,'',$audioPath).'/'.$this->sound, |
|
649 | + str_replace($documentPath, '', $audioPath).'/'.$this->sound, |
|
650 | 650 | 'file', |
651 | 651 | $sound['size'], |
652 | 652 | $sound['name'] |
@@ -665,8 +665,8 @@ discard block |
||
665 | 665 | ); |
666 | 666 | } |
667 | 667 | } |
668 | - } elseif($delete && is_file($audioPath.'/'.$this->sound)) { |
|
669 | - $this->sound=''; |
|
668 | + } elseif ($delete && is_file($audioPath.'/'.$this->sound)) { |
|
669 | + $this->sound = ''; |
|
670 | 670 | } |
671 | 671 | } |
672 | 672 | |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | */ |
679 | 679 | public function updateType($type) |
680 | 680 | { |
681 | - $this->type=$type; |
|
681 | + $this->type = $type; |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | /** |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | */ |
715 | 715 | public function enable() |
716 | 716 | { |
717 | - $this->active=1; |
|
717 | + $this->active = 1; |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | /** |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | */ |
725 | 725 | public function disable() |
726 | 726 | { |
727 | - $this->active=0; |
|
727 | + $this->active = 0; |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | /** |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | public function removeFromList($questionId) |
991 | 991 | { |
992 | 992 | // searches the position of the question ID in the list |
993 | - $pos = array_search($questionId,$this->questionList); |
|
993 | + $pos = array_search($questionId, $this->questionList); |
|
994 | 994 | |
995 | 995 | // question not found |
996 | 996 | if ($pos === false) { |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | * Creates the form to create / edit an exercise |
1038 | 1038 | * @param FormValidator $form |
1039 | 1039 | */ |
1040 | - public function createForm($form, $type='full') |
|
1040 | + public function createForm($form, $type = 'full') |
|
1041 | 1041 | { |
1042 | 1042 | if (empty($type)) { |
1043 | 1043 | $type = 'full'; |
@@ -1068,7 +1068,7 @@ discard block |
||
1068 | 1068 | 'Width' => '100%', |
1069 | 1069 | 'Height' => '150', |
1070 | 1070 | ); |
1071 | - if (is_array($type)){ |
|
1071 | + if (is_array($type)) { |
|
1072 | 1072 | $editor_config = array_merge($editor_config, $type); |
1073 | 1073 | } |
1074 | 1074 | |
@@ -1122,13 +1122,13 @@ discard block |
||
1122 | 1122 | '2', |
1123 | 1123 | array('id' => 'exerciseType_2') |
1124 | 1124 | ); |
1125 | - $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'),get_lang('FeedbackDisplayOptions')), ''); |
|
1125 | + $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')), ''); |
|
1126 | 1126 | |
1127 | 1127 | // Type of results display on the final page |
1128 | 1128 | $radios_results_disabled = array(); |
1129 | 1129 | $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0')); |
1130 | - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()')); |
|
1131 | - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2')); |
|
1130 | + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()')); |
|
1131 | + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2')); |
|
1132 | 1132 | //$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ExamModeWithFinalScoreShowOnlyFinalScoreWithCategoriesIfAvailable'), '3', array('id'=>'result_disabled_3','onclick' => 'check_results_disabled()')); |
1133 | 1133 | |
1134 | 1134 | $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), ''); |
@@ -1136,8 +1136,8 @@ discard block |
||
1136 | 1136 | // Type of questions disposition on page |
1137 | 1137 | $radios = array(); |
1138 | 1138 | |
1139 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all')); |
|
1140 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one')); |
|
1139 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all')); |
|
1140 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one')); |
|
1141 | 1141 | |
1142 | 1142 | $form->addGroup($radios, null, get_lang('QuestionsPerPage'), ''); |
1143 | 1143 | |
@@ -1147,33 +1147,33 @@ discard block |
||
1147 | 1147 | |
1148 | 1148 | // feedback type |
1149 | 1149 | $radios_feedback = array(); |
1150 | - $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'),'0',array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()')); |
|
1150 | + $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()')); |
|
1151 | 1151 | |
1152 | 1152 | if (api_get_setting('exercise.enable_quiz_scenario') == 'true') { |
1153 | - $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1' , 'onclick' => 'check_direct_feedback()')); |
|
1153 | + $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1', 'onclick' => 'check_direct_feedback()')); |
|
1154 | 1154 | } |
1155 | - $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'),'2',array('id' =>'exerciseType_2')); |
|
1156 | - $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'),get_lang('FeedbackDisplayOptions'))); |
|
1155 | + $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' =>'exerciseType_2')); |
|
1156 | + $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions'))); |
|
1157 | 1157 | |
1158 | 1158 | //$form->addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"'); |
1159 | 1159 | $radios_results_disabled = array(); |
1160 | 1160 | $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0')); |
1161 | - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()')); |
|
1162 | - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()')); |
|
1163 | - $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'),''); |
|
1161 | + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()')); |
|
1162 | + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()')); |
|
1163 | + $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), ''); |
|
1164 | 1164 | |
1165 | 1165 | // Type of questions disposition on page |
1166 | 1166 | $radios = array(); |
1167 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1'); |
|
1168 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2'); |
|
1167 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1'); |
|
1168 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2'); |
|
1169 | 1169 | $form->addGroup($radios, null, get_lang('ExerciseType')); |
1170 | 1170 | |
1171 | 1171 | } else { |
1172 | 1172 | //Show options freeze |
1173 | 1173 | $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0')); |
1174 | - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()')); |
|
1175 | - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()')); |
|
1176 | - $result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'),''); |
|
1174 | + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()')); |
|
1175 | + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()')); |
|
1176 | + $result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), ''); |
|
1177 | 1177 | $result_disable_group->freeze(); |
1178 | 1178 | |
1179 | 1179 | //we force the options to the DirectFeedback exercisetype |
@@ -1181,8 +1181,8 @@ discard block |
||
1181 | 1181 | $form->addElement('hidden', 'exerciseType', ONE_PER_PAGE); |
1182 | 1182 | |
1183 | 1183 | // Type of questions disposition on page |
1184 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all')); |
|
1185 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one')); |
|
1184 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all')); |
|
1185 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one')); |
|
1186 | 1186 | |
1187 | 1187 | $type_group = $form->addGroup($radios, null, get_lang('QuestionsPerPage'), ''); |
1188 | 1188 | $type_group->freeze(); |
@@ -1191,26 +1191,26 @@ discard block |
||
1191 | 1191 | |
1192 | 1192 | // number of random question |
1193 | 1193 | |
1194 | - $max = ($this->id > 0) ? $this->selectNbrQuestions() : 10 ; |
|
1195 | - $option = range(0,$max); |
|
1194 | + $max = ($this->id > 0) ? $this->selectNbrQuestions() : 10; |
|
1195 | + $option = range(0, $max); |
|
1196 | 1196 | $option[0] = get_lang('No'); |
1197 | 1197 | $option[-1] = get_lang('AllQuestionsShort'); |
1198 | - $form->addElement('select', 'randomQuestions',array(get_lang('RandomQuestions'), get_lang('RandomQuestionsHelp')), $option, array('id'=>'randomQuestions')); |
|
1198 | + $form->addElement('select', 'randomQuestions', array(get_lang('RandomQuestions'), get_lang('RandomQuestionsHelp')), $option, array('id'=>'randomQuestions')); |
|
1199 | 1199 | |
1200 | 1200 | // Random answers |
1201 | 1201 | $radios_random_answers = array(); |
1202 | - $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('Yes'),'1'); |
|
1203 | - $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('No'),'0'); |
|
1202 | + $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('Yes'), '1'); |
|
1203 | + $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('No'), '0'); |
|
1204 | 1204 | $form->addGroup($radios_random_answers, null, get_lang('RandomAnswers'), ''); |
1205 | 1205 | |
1206 | 1206 | // Random by category |
1207 | - $form->addElement('html','<div class="clear"> </div>'); |
|
1207 | + $form->addElement('html', '<div class="clear"> </div>'); |
|
1208 | 1208 | $radiocat = array(); |
1209 | - $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesShuffled'),'1'); |
|
1210 | - $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesSorted'),'2'); |
|
1211 | - $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('No'),'0'); |
|
1209 | + $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesShuffled'), '1'); |
|
1210 | + $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesSorted'), '2'); |
|
1211 | + $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('No'), '0'); |
|
1212 | 1212 | $radioCatGroup = $form->addGroup($radiocat, null, get_lang('RandomQuestionByCategory'), ''); |
1213 | - $form->addElement('html','<div class="clear"> </div>'); |
|
1213 | + $form->addElement('html', '<div class="clear"> </div>'); |
|
1214 | 1214 | |
1215 | 1215 | // add the radio display the category name for student |
1216 | 1216 | $radio_display_cat_name = array(); |
@@ -1231,36 +1231,36 @@ discard block |
||
1231 | 1231 | ); |
1232 | 1232 | |
1233 | 1233 | // Exercise time limit |
1234 | - $form->addElement('checkbox', 'activate_start_date_check',null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()')); |
|
1234 | + $form->addElement('checkbox', 'activate_start_date_check', null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()')); |
|
1235 | 1235 | |
1236 | 1236 | $var = Exercise::selectTimeLimit(); |
1237 | 1237 | |
1238 | 1238 | if (($this->start_time != '0000-00-00 00:00:00')) |
1239 | - $form->addElement('html','<div id="start_date_div" style="display:block;">'); |
|
1239 | + $form->addElement('html', '<div id="start_date_div" style="display:block;">'); |
|
1240 | 1240 | else |
1241 | - $form->addElement('html','<div id="start_date_div" style="display:none;">'); |
|
1241 | + $form->addElement('html', '<div id="start_date_div" style="display:none;">'); |
|
1242 | 1242 | |
1243 | 1243 | $form->addElement('date_time_picker', 'start_time'); |
1244 | 1244 | |
1245 | - $form->addElement('html','</div>'); |
|
1245 | + $form->addElement('html', '</div>'); |
|
1246 | 1246 | |
1247 | - $form->addElement('checkbox', 'activate_end_date_check', null , get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()')); |
|
1247 | + $form->addElement('checkbox', 'activate_end_date_check', null, get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()')); |
|
1248 | 1248 | |
1249 | 1249 | if (($this->end_time != '0000-00-00 00:00:00')) |
1250 | - $form->addElement('html','<div id="end_date_div" style="display:block;">'); |
|
1250 | + $form->addElement('html', '<div id="end_date_div" style="display:block;">'); |
|
1251 | 1251 | else |
1252 | - $form->addElement('html','<div id="end_date_div" style="display:none;">'); |
|
1252 | + $form->addElement('html', '<div id="end_date_div" style="display:none;">'); |
|
1253 | 1253 | |
1254 | 1254 | $form->addElement('date_time_picker', 'end_time'); |
1255 | - $form->addElement('html','</div>'); |
|
1255 | + $form->addElement('html', '</div>'); |
|
1256 | 1256 | |
1257 | 1257 | //$check_option=$this->selectType(); |
1258 | 1258 | $diplay = 'block'; |
1259 | 1259 | $form->addElement('checkbox', 'propagate_neg', null, get_lang('PropagateNegativeResults')); |
1260 | - $form->addElement('html','<div class="clear"> </div>'); |
|
1260 | + $form->addElement('html', '<div class="clear"> </div>'); |
|
1261 | 1261 | $form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers')); |
1262 | 1262 | |
1263 | - $form->addElement('html','<div id="divtimecontrol" style="display:'.$diplay.';">'); |
|
1263 | + $form->addElement('html', '<div id="divtimecontrol" style="display:'.$diplay.';">'); |
|
1264 | 1264 | |
1265 | 1265 | //Timer control |
1266 | 1266 | //$time_hours_option = range(0,12); |
@@ -1276,12 +1276,12 @@ discard block |
||
1276 | 1276 | 'onload' => 'check_load_time()', |
1277 | 1277 | ) |
1278 | 1278 | ); |
1279 | - $expired_date = (int)$this->selectExpiredTime(); |
|
1279 | + $expired_date = (int) $this->selectExpiredTime(); |
|
1280 | 1280 | |
1281 | - if (($expired_date!='0')) { |
|
1282 | - $form->addElement('html','<div id="timercontrol" style="display:block;">'); |
|
1281 | + if (($expired_date != '0')) { |
|
1282 | + $form->addElement('html', '<div id="timercontrol" style="display:block;">'); |
|
1283 | 1283 | } else { |
1284 | - $form->addElement('html','<div id="timercontrol" style="display:none;">'); |
|
1284 | + $form->addElement('html', '<div id="timercontrol" style="display:none;">'); |
|
1285 | 1285 | } |
1286 | 1286 | $form->addText( |
1287 | 1287 | 'enabletimercontroltotalminutes', |
@@ -1292,7 +1292,7 @@ discard block |
||
1292 | 1292 | 'cols-size' => [2, 2, 8] |
1293 | 1293 | ] |
1294 | 1294 | ); |
1295 | - $form->addElement('html','</div>'); |
|
1295 | + $form->addElement('html', '</div>'); |
|
1296 | 1296 | |
1297 | 1297 | $form->addElement( |
1298 | 1298 | 'text', |
@@ -1314,18 +1314,18 @@ discard block |
||
1314 | 1314 | $defaults = array(); |
1315 | 1315 | |
1316 | 1316 | if (api_get_setting('search.search_enabled') === 'true') { |
1317 | - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
1317 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
1318 | 1318 | |
1319 | - $form->addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument')); |
|
1320 | - $form->addElement ('select_language', 'language', get_lang('SearchFeatureDocumentLanguage')); |
|
1319 | + $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument')); |
|
1320 | + $form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage')); |
|
1321 | 1321 | |
1322 | 1322 | $specific_fields = get_specific_field_list(); |
1323 | 1323 | |
1324 | 1324 | foreach ($specific_fields as $specific_field) { |
1325 | - $form->addElement ('text', $specific_field['code'], $specific_field['name']); |
|
1326 | - $filter = array('c_id'=> "'". api_get_course_int_id() ."'", 'field_id' => $specific_field['id'], 'ref_id' => $this->id, 'tool_id' => '\''. TOOL_QUIZ .'\''); |
|
1325 | + $form->addElement('text', $specific_field['code'], $specific_field['name']); |
|
1326 | + $filter = array('c_id'=> "'".api_get_course_int_id()."'", 'field_id' => $specific_field['id'], 'ref_id' => $this->id, 'tool_id' => '\''.TOOL_QUIZ.'\''); |
|
1327 | 1327 | $values = get_specific_field_values_list($filter, array('value')); |
1328 | - if ( !empty($values) ) { |
|
1328 | + if (!empty($values)) { |
|
1329 | 1329 | $arr_str_values = array(); |
1330 | 1330 | foreach ($values as $value) { |
1331 | 1331 | $arr_str_values[] = $value['value']; |
@@ -1336,8 +1336,8 @@ discard block |
||
1336 | 1336 | //$form->addElement ('html','</div>'); |
1337 | 1337 | } |
1338 | 1338 | |
1339 | - $form->addElement('html','</div>'); //End advanced setting |
|
1340 | - $form->addElement('html','</div>'); |
|
1339 | + $form->addElement('html', '</div>'); //End advanced setting |
|
1340 | + $form->addElement('html', '</div>'); |
|
1341 | 1341 | } |
1342 | 1342 | |
1343 | 1343 | // submit |
@@ -1357,10 +1357,10 @@ discard block |
||
1357 | 1357 | } |
1358 | 1358 | |
1359 | 1359 | // defaults |
1360 | - if ($type=='full') { |
|
1360 | + if ($type == 'full') { |
|
1361 | 1361 | if ($this->id > 0) { |
1362 | 1362 | if ($this->random > $this->selectNbrQuestions()) { |
1363 | - $defaults['randomQuestions'] = $this->selectNbrQuestions(); |
|
1363 | + $defaults['randomQuestions'] = $this->selectNbrQuestions(); |
|
1364 | 1364 | } else { |
1365 | 1365 | $defaults['randomQuestions'] = $this->random; |
1366 | 1366 | } |
@@ -1386,8 +1386,8 @@ discard block |
||
1386 | 1386 | $defaults['activate_end_date_check'] = 1; |
1387 | 1387 | } |
1388 | 1388 | |
1389 | - $defaults['start_time'] = ($this->start_time!='0000-00-00 00:00:00') ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00'); |
|
1390 | - $defaults['end_time'] = ($this->end_time!='0000-00-00 00:00:00') ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time()+84600); |
|
1389 | + $defaults['start_time'] = ($this->start_time != '0000-00-00 00:00:00') ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00'); |
|
1390 | + $defaults['end_time'] = ($this->end_time != '0000-00-00 00:00:00') ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time() + 84600); |
|
1391 | 1391 | |
1392 | 1392 | // Get expired time |
1393 | 1393 | if ($this->expired_time != '0') { |
@@ -1408,7 +1408,7 @@ discard block |
||
1408 | 1408 | $defaults['text_when_finished'] = ""; |
1409 | 1409 | $defaults['start_time'] = date('Y-m-d 12:00:00'); |
1410 | 1410 | $defaults['display_category_name'] = 1; |
1411 | - $defaults['end_time'] = date('Y-m-d 12:00:00', time()+84600); |
|
1411 | + $defaults['end_time'] = date('Y-m-d 12:00:00', time() + 84600); |
|
1412 | 1412 | $defaults['pass_percentage'] = ''; |
1413 | 1413 | } |
1414 | 1414 | } else { |
@@ -1475,7 +1475,7 @@ discard block |
||
1475 | 1475 | $end_time = $form->getSubmitValue('end_time'); |
1476 | 1476 | $this->end_time = api_get_utc_datetime($end_time); |
1477 | 1477 | } else { |
1478 | - $this->end_time = '0000-00-00 00:00:00'; |
|
1478 | + $this->end_time = '0000-00-00 00:00:00'; |
|
1479 | 1479 | } |
1480 | 1480 | |
1481 | 1481 | if ($form->getSubmitValue('enabletimercontrol') == 1) { |
@@ -1488,9 +1488,9 @@ discard block |
||
1488 | 1488 | } |
1489 | 1489 | |
1490 | 1490 | if ($form->getSubmitValue('randomAnswers') == 1) { |
1491 | - $this->random_answers=1; |
|
1491 | + $this->random_answers = 1; |
|
1492 | 1492 | } else { |
1493 | - $this->random_answers=0; |
|
1493 | + $this->random_answers = 0; |
|
1494 | 1494 | } |
1495 | 1495 | $this->save($type); |
1496 | 1496 | } |
@@ -1505,9 +1505,9 @@ discard block |
||
1505 | 1505 | |
1506 | 1506 | $course = $em->find('ChamiloCoreBundle:Course', api_get_course_int_id()); |
1507 | 1507 | |
1508 | - require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'; |
|
1509 | - require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php'; |
|
1510 | - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
1508 | + require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'; |
|
1509 | + require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php'; |
|
1510 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
1511 | 1511 | |
1512 | 1512 | $specific_fields = get_specific_field_list(); |
1513 | 1513 | $ic_slide = new IndexableChunk(); |
@@ -1517,7 +1517,7 @@ discard block |
||
1517 | 1517 | if (isset($_REQUEST[$specific_field['code']])) { |
1518 | 1518 | $sterms = trim($_REQUEST[$specific_field['code']]); |
1519 | 1519 | if (!empty($sterms)) { |
1520 | - $all_specific_terms .= ' '. $sterms; |
|
1520 | + $all_specific_terms .= ' '.$sterms; |
|
1521 | 1521 | $sterms = explode(',', $sterms); |
1522 | 1522 | foreach ($sterms as $sterm) { |
1523 | 1523 | $ic_slide->addTerm(trim($sterm), $specific_field['code']); |
@@ -1534,15 +1534,15 @@ discard block |
||
1534 | 1534 | $xapian_data = array( |
1535 | 1535 | SE_COURSE_ID => $course->getCode(), |
1536 | 1536 | SE_TOOL_ID => TOOL_QUIZ, |
1537 | - SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id), |
|
1538 | - SE_USER => (int)api_get_user_id(), |
|
1537 | + SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id), |
|
1538 | + SE_USER => (int) api_get_user_id(), |
|
1539 | 1539 | ); |
1540 | 1540 | $ic_slide->xapian_data = serialize($xapian_data); |
1541 | - $exercise_description = $all_specific_terms .' '. $this->description; |
|
1541 | + $exercise_description = $all_specific_terms.' '.$this->description; |
|
1542 | 1542 | $ic_slide->addValue("content", $exercise_description); |
1543 | 1543 | |
1544 | 1544 | $di = new ChamiloIndexer(); |
1545 | - isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english'; |
|
1545 | + isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english'; |
|
1546 | 1546 | $di->connectDb(NULL, NULL, $lang); |
1547 | 1547 | $di->addChunk($ic_slide); |
1548 | 1548 | |
@@ -1584,9 +1584,9 @@ discard block |
||
1584 | 1584 | ]); |
1585 | 1585 | |
1586 | 1586 | if ($se_ref) { |
1587 | - require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'); |
|
1588 | - require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php'); |
|
1589 | - require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'); |
|
1587 | + require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'); |
|
1588 | + require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php'); |
|
1589 | + require_once(api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'); |
|
1590 | 1590 | |
1591 | 1591 | $specific_fields = get_specific_field_list(); |
1592 | 1592 | $ic_slide = new IndexableChunk(); |
@@ -1601,7 +1601,7 @@ discard block |
||
1601 | 1601 | ); |
1602 | 1602 | if (isset($_REQUEST[$specific_field['code']])) { |
1603 | 1603 | $sterms = trim($_REQUEST[$specific_field['code']]); |
1604 | - $all_specific_terms .= ' '. $sterms; |
|
1604 | + $all_specific_terms .= ' '.$sterms; |
|
1605 | 1605 | $sterms = explode(',', $sterms); |
1606 | 1606 | foreach ($sterms as $sterm) { |
1607 | 1607 | $ic_slide->addTerm(trim($sterm), $specific_field['code']); |
@@ -1623,15 +1623,15 @@ discard block |
||
1623 | 1623 | $xapian_data = array( |
1624 | 1624 | SE_COURSE_ID => $course->getCode(), |
1625 | 1625 | SE_TOOL_ID => TOOL_QUIZ, |
1626 | - SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id), |
|
1627 | - SE_USER => (int)api_get_user_id(), |
|
1626 | + SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id), |
|
1627 | + SE_USER => (int) api_get_user_id(), |
|
1628 | 1628 | ); |
1629 | 1629 | $ic_slide->xapian_data = serialize($xapian_data); |
1630 | - $exercise_description = $all_specific_terms .' '. $this->description; |
|
1630 | + $exercise_description = $all_specific_terms.' '.$this->description; |
|
1631 | 1631 | $ic_slide->addValue("content", $exercise_description); |
1632 | 1632 | |
1633 | 1633 | $di = new ChamiloIndexer(); |
1634 | - isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english'; |
|
1634 | + isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english'; |
|
1635 | 1635 | $di->connectDb(NULL, NULL, $lang); |
1636 | 1636 | $di->remove_document($se_ref->getSearchDid()); |
1637 | 1637 | $di->addChunk($ic_slide); |
@@ -1682,19 +1682,19 @@ discard block |
||
1682 | 1682 | |
1683 | 1683 | if (count($res) > 0) { |
1684 | 1684 | $row = current($res); |
1685 | - require_once(api_get_path(LIBRARY_PATH) .'search/ChamiloIndexer.class.php'); |
|
1685 | + require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'); |
|
1686 | 1686 | $di = new ChamiloIndexer(); |
1687 | 1687 | $di->remove_document($row->getSearchDid()); |
1688 | 1688 | unset($di); |
1689 | 1689 | $tbl_quiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION); |
1690 | - foreach ( $this->questionList as $question_i) { |
|
1690 | + foreach ($this->questionList as $question_i) { |
|
1691 | 1691 | $sql = 'SELECT type FROM %s WHERE id=%s'; |
1692 | 1692 | $sql = sprintf($sql, $tbl_quiz_question, $question_i); |
1693 | 1693 | $qres = Database::query($sql); |
1694 | 1694 | if (Database::num_rows($qres) > 0) { |
1695 | 1695 | $qrow = Database::fetch_array($qres); |
1696 | 1696 | $objQuestion = Question::getInstance($qrow['type']); |
1697 | - $objQuestion = Question::read((int)$question_i); |
|
1697 | + $objQuestion = Question::read((int) $question_i); |
|
1698 | 1698 | $objQuestion->search_engine_edit($this->id, FALSE, TRUE); |
1699 | 1699 | unset($objQuestion); |
1700 | 1700 | } |
@@ -1711,7 +1711,7 @@ discard block |
||
1711 | 1711 | ->execute([1 => $course, 2 => TOOL_QUIZ, 3 => $this->id]); |
1712 | 1712 | |
1713 | 1713 | // remove terms from db |
1714 | - require_once api_get_path(LIBRARY_PATH) .'specific_fields_manager.lib.php'; |
|
1714 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
1715 | 1715 | delete_all_values_for_item($course->getCode(), TOOL_QUIZ, $this->id); |
1716 | 1716 | } |
1717 | 1717 | } |
@@ -1812,7 +1812,7 @@ discard block |
||
1812 | 1812 | */ |
1813 | 1813 | public function copy_exercise() |
1814 | 1814 | { |
1815 | - $exercise_obj= new Exercise(); |
|
1815 | + $exercise_obj = new Exercise(); |
|
1816 | 1816 | $exercise_obj = $this; |
1817 | 1817 | |
1818 | 1818 | // force the creation of a new exercise |
@@ -1884,25 +1884,25 @@ discard block |
||
1884 | 1884 | $lp_id = 0; |
1885 | 1885 | } |
1886 | 1886 | if (empty($lp_item_id)) { |
1887 | - $lp_item_id = 0; |
|
1887 | + $lp_item_id = 0; |
|
1888 | 1888 | } |
1889 | 1889 | if (empty($lp_item_view_id)) { |
1890 | 1890 | $lp_item_view_id = 0; |
1891 | 1891 | } |
1892 | - $condition = ' WHERE exe_exo_id = ' . "'" . $this->id . "'" .' AND |
|
1893 | - exe_user_id = ' . "'" . api_get_user_id() . "'" . ' AND |
|
1894 | - c_id = ' . api_get_course_int_id() . ' AND |
|
1895 | - status = ' . "'" . Database::escape_string($status). "'" . ' AND |
|
1896 | - orig_lp_id = ' . "'" . $lp_id . "'" . ' AND |
|
1897 | - orig_lp_item_id = ' . "'" . $lp_item_id . "'" . ' AND |
|
1898 | - orig_lp_item_view_id = ' . "'" . $lp_item_view_id . "'" . ' AND |
|
1899 | - session_id = ' . "'" . api_get_session_id() . "' LIMIT 1"; //Adding limit 1 just in case |
|
1892 | + $condition = ' WHERE exe_exo_id = '."'".$this->id."'".' AND |
|
1893 | + exe_user_id = ' . "'".api_get_user_id()."'".' AND |
|
1894 | + c_id = ' . api_get_course_int_id().' AND |
|
1895 | + status = ' . "'".Database::escape_string($status)."'".' AND |
|
1896 | + orig_lp_id = ' . "'".$lp_id."'".' AND |
|
1897 | + orig_lp_item_id = ' . "'".$lp_item_id."'".' AND |
|
1898 | + orig_lp_item_view_id = ' . "'".$lp_item_view_id."'".' AND |
|
1899 | + session_id = ' . "'".api_get_session_id()."' LIMIT 1"; //Adding limit 1 just in case |
|
1900 | 1900 | |
1901 | 1901 | $sql_track = 'SELECT * FROM '.$track_exercises.$condition; |
1902 | 1902 | |
1903 | 1903 | $result = Database::query($sql_track); |
1904 | 1904 | $new_array = array(); |
1905 | - if (Database::num_rows($result) > 0 ) { |
|
1905 | + if (Database::num_rows($result) > 0) { |
|
1906 | 1906 | $new_array = Database::fetch_array($result, 'ASSOC'); |
1907 | 1907 | $new_array['num_exe'] = Database::num_rows($result); |
1908 | 1908 | } |
@@ -1945,12 +1945,12 @@ discard block |
||
1945 | 1945 | $questionList = array_map('intval', $questionList); |
1946 | 1946 | |
1947 | 1947 | $params = array( |
1948 | - 'exe_exo_id' => $this->id , |
|
1948 | + 'exe_exo_id' => $this->id, |
|
1949 | 1949 | 'exe_user_id' => api_get_user_id(), |
1950 | 1950 | 'c_id' => api_get_course_int_id(), |
1951 | 1951 | 'status' => 'incomplete', |
1952 | 1952 | 'session_id' => api_get_session_id(), |
1953 | - 'data_tracking' => implode(',', $questionList) , |
|
1953 | + 'data_tracking' => implode(',', $questionList), |
|
1954 | 1954 | 'start_date' => api_get_utc_datetime(), |
1955 | 1955 | 'orig_lp_id' => $safe_lp_id, |
1956 | 1956 | 'orig_lp_item_id' => $safe_lp_item_id, |
@@ -1982,7 +1982,7 @@ discard block |
||
1982 | 1982 | $nbrQuestions = $this->get_count_question_list(); |
1983 | 1983 | |
1984 | 1984 | $all_button = $html = $label = ''; |
1985 | - $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']):null; |
|
1985 | + $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']) : null; |
|
1986 | 1986 | |
1987 | 1987 | if ($this->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT && $this->type == ONE_PER_PAGE) { |
1988 | 1988 | $urlTitle = get_lang('ContinueTest'); |
@@ -1993,7 +1993,7 @@ discard block |
||
1993 | 1993 | |
1994 | 1994 | $html .= Display::url( |
1995 | 1995 | $urlTitle, |
1996 | - 'exercise_submit_modal.php?' . http_build_query([ |
|
1996 | + 'exercise_submit_modal.php?'.http_build_query([ |
|
1997 | 1997 | 'learnpath_id' => $safe_lp_id, |
1998 | 1998 | 'learnpath_item_id' => $safe_lp_item_id, |
1999 | 1999 | 'learnpath_item_view_id' => $safe_lp_item_view_id, |
@@ -2010,7 +2010,7 @@ discard block |
||
2010 | 2010 | 'data-size' => 'md' |
2011 | 2011 | ] |
2012 | 2012 | ); |
2013 | - $html .='<br />'; |
|
2013 | + $html .= '<br />'; |
|
2014 | 2014 | } else { |
2015 | 2015 | // User |
2016 | 2016 | if (api_is_allowed_to_session_edit()) { |
@@ -2035,7 +2035,7 @@ discard block |
||
2035 | 2035 | |
2036 | 2036 | //Next question |
2037 | 2037 | if (!empty($questions_in_media)) { |
2038 | - $questions_in_media = "['".implode("','",$questions_in_media)."']"; |
|
2038 | + $questions_in_media = "['".implode("','", $questions_in_media)."']"; |
|
2039 | 2039 | $all_button .= ' <a href="javascript://" class="'.$class.'" onclick="save_question_list('.$questions_in_media.'); ">'.$label.'</a>'; |
2040 | 2040 | } else { |
2041 | 2041 | $all_button .= ' <a href="javascript://" class="'.$class.'" onclick="save_now('.$question_id.', \'\', \''.$currentAnswer.'\'); ">'.$label.'</a>'; |
@@ -2053,7 +2053,7 @@ discard block |
||
2053 | 2053 | } |
2054 | 2054 | $class .= ' question-validate-btn'; // used to select it with jquery |
2055 | 2055 | $all_button = ' <a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>'; |
2056 | - $all_button .= ' ' . Display::span(null, ['id' => 'save_all_reponse']); |
|
2056 | + $all_button .= ' '.Display::span(null, ['id' => 'save_all_reponse']); |
|
2057 | 2057 | $html .= $all_button; |
2058 | 2058 | } |
2059 | 2059 | } |
@@ -2295,8 +2295,8 @@ discard block |
||
2295 | 2295 | $params = array(); |
2296 | 2296 | $params['course_id'] = $course_id; |
2297 | 2297 | $params['session_id'] = api_get_session_id(); |
2298 | - $params['user_id'] = isset($exe_info['exe_user_id'])? $exe_info['exe_user_id'] : api_get_user_id(); |
|
2299 | - $params['exercise_id'] = isset($exe_info['exe_exo_id'])? $exe_info['exe_exo_id'] : $this->id; |
|
2298 | + $params['user_id'] = isset($exe_info['exe_user_id']) ? $exe_info['exe_user_id'] : api_get_user_id(); |
|
2299 | + $params['exercise_id'] = isset($exe_info['exe_exo_id']) ? $exe_info['exe_exo_id'] : $this->id; |
|
2300 | 2300 | $params['question_id'] = $questionId; |
2301 | 2301 | $params['exe_id'] = isset($exe_info['exe_id']) ? $exe_info['exe_id'] : $exeId; |
2302 | 2302 | |
@@ -2338,10 +2338,10 @@ discard block |
||
2338 | 2338 | $answer = $objAnswerTmp->selectAnswer($answerId); |
2339 | 2339 | $answerComment = $objAnswerTmp->selectComment($answerId); |
2340 | 2340 | $answerCorrect = $objAnswerTmp->isCorrect($answerId); |
2341 | - $answerWeighting = (float)$objAnswerTmp->selectWeighting($answerId); |
|
2341 | + $answerWeighting = (float) $objAnswerTmp->selectWeighting($answerId); |
|
2342 | 2342 | $answerAutoId = $objAnswerTmp->selectAutoId($answerId); |
2343 | 2343 | |
2344 | - $answer_correct_array[$answerId] = (bool)$answerCorrect; |
|
2344 | + $answer_correct_array[$answerId] = (bool) $answerCorrect; |
|
2345 | 2345 | |
2346 | 2346 | if ($debug) { |
2347 | 2347 | error_log("answer auto id: $answerAutoId "); |
@@ -2350,7 +2350,7 @@ discard block |
||
2350 | 2350 | |
2351 | 2351 | // Delineation |
2352 | 2352 | $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1); |
2353 | - $answer_delineation_destination=$objAnswerTmp->selectDestination(1); |
|
2353 | + $answer_delineation_destination = $objAnswerTmp->selectDestination(1); |
|
2354 | 2354 | |
2355 | 2355 | switch ($answerType) { |
2356 | 2356 | // for unique answer |
@@ -2363,7 +2363,7 @@ discard block |
||
2363 | 2363 | exe_id = '".$exeId."' AND |
2364 | 2364 | question_id= '".$questionId."'"; |
2365 | 2365 | $result = Database::query($sql); |
2366 | - $choice = Database::result($result,0,"answer"); |
|
2366 | + $choice = Database::result($result, 0, "answer"); |
|
2367 | 2367 | |
2368 | 2368 | $studentChoice = $choice == $answerAutoId ? 1 : 0; |
2369 | 2369 | if ($studentChoice) { |
@@ -2414,7 +2414,7 @@ discard block |
||
2414 | 2414 | } else { |
2415 | 2415 | // If no result then the user just hit don't know |
2416 | 2416 | $studentChoice = 3; |
2417 | - $questionScore += $doubt_score; |
|
2417 | + $questionScore += $doubt_score; |
|
2418 | 2418 | } |
2419 | 2419 | $totalScore = $questionScore; |
2420 | 2420 | break; |
@@ -2430,17 +2430,17 @@ discard block |
||
2430 | 2430 | } |
2431 | 2431 | |
2432 | 2432 | $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; |
2433 | - $real_answers[$answerId] = (bool)$studentChoice; |
|
2433 | + $real_answers[$answerId] = (bool) $studentChoice; |
|
2434 | 2434 | |
2435 | 2435 | if ($studentChoice) { |
2436 | - $questionScore +=$answerWeighting; |
|
2436 | + $questionScore += $answerWeighting; |
|
2437 | 2437 | } |
2438 | 2438 | } else { |
2439 | 2439 | $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; |
2440 | - $real_answers[$answerId] = (bool)$studentChoice; |
|
2440 | + $real_answers[$answerId] = (bool) $studentChoice; |
|
2441 | 2441 | |
2442 | 2442 | if (isset($studentChoice)) { |
2443 | - $questionScore += $answerWeighting; |
|
2443 | + $questionScore += $answerWeighting; |
|
2444 | 2444 | } |
2445 | 2445 | } |
2446 | 2446 | $totalScore += $answerWeighting; |
@@ -2458,16 +2458,16 @@ discard block |
||
2458 | 2458 | $choice[$ind] = 1; |
2459 | 2459 | } |
2460 | 2460 | $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; |
2461 | - $real_answers[$answerId] = (bool)$studentChoice; |
|
2461 | + $real_answers[$answerId] = (bool) $studentChoice; |
|
2462 | 2462 | if ($studentChoice) { |
2463 | - $questionScore +=$answerWeighting; |
|
2463 | + $questionScore += $answerWeighting; |
|
2464 | 2464 | } |
2465 | 2465 | } else { |
2466 | 2466 | $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; |
2467 | 2467 | if (isset($studentChoice)) { |
2468 | 2468 | $questionScore += $answerWeighting; |
2469 | 2469 | } |
2470 | - $real_answers[$answerId] = (bool)$studentChoice; |
|
2470 | + $real_answers[$answerId] = (bool) $studentChoice; |
|
2471 | 2471 | } |
2472 | 2472 | $totalScore += $answerWeighting; |
2473 | 2473 | if ($debug) error_log("studentChoice: $studentChoice"); |
@@ -2479,7 +2479,7 @@ discard block |
||
2479 | 2479 | $resultans = Database::query($sql); |
2480 | 2480 | while ($row = Database::fetch_array($resultans)) { |
2481 | 2481 | $ind = $row['answer']; |
2482 | - $result = explode(':',$ind); |
|
2482 | + $result = explode(':', $ind); |
|
2483 | 2483 | if (isset($result[0])) { |
2484 | 2484 | $my_answer_id = isset($result[0]) ? $result[0] : ''; |
2485 | 2485 | $option = isset($result[1]) ? $result[1] : ''; |
@@ -2600,10 +2600,10 @@ discard block |
||
2600 | 2600 | } |
2601 | 2601 | // adds the piece of text that is before the blank |
2602 | 2602 | //and ends with '[' into a general storage array |
2603 | - $real_text[] = api_substr($temp, 0, $pos +1); |
|
2604 | - $answer .= api_substr($temp, 0, $pos +1); |
|
2603 | + $real_text[] = api_substr($temp, 0, $pos + 1); |
|
2604 | + $answer .= api_substr($temp, 0, $pos + 1); |
|
2605 | 2605 | //take the string remaining (after the last "[" we found) |
2606 | - $temp = api_substr($temp, $pos +1); |
|
2606 | + $temp = api_substr($temp, $pos + 1); |
|
2607 | 2607 | // quit the loop if there are no more blanks, and update $pos to the position of next ']' |
2608 | 2608 | if (($pos = api_strpos($temp, ']')) === false) { |
2609 | 2609 | // adds the end of the text |
@@ -2639,7 +2639,7 @@ discard block |
||
2639 | 2639 | //put the contents of the [] answer tag into correct_tags[] |
2640 | 2640 | $correct_tags[] = api_substr($temp, 0, $pos); |
2641 | 2641 | $j++; |
2642 | - $temp = api_substr($temp, $pos +1); |
|
2642 | + $temp = api_substr($temp, $pos + 1); |
|
2643 | 2643 | } |
2644 | 2644 | $answer = ''; |
2645 | 2645 | $real_correct_tags = $correct_tags; |
@@ -2662,7 +2662,7 @@ discard block |
||
2662 | 2662 | } elseif (!empty($user_tags[$i])) { |
2663 | 2663 | // else if the word entered by the student IS NOT the same as the one defined by the professor |
2664 | 2664 | // adds the word in red at the end of the string, and strikes it |
2665 | - $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>'; |
|
2665 | + $answer .= '<font color="red"><s>'.$user_tags[$i].'</s></font>'; |
|
2666 | 2666 | } else { |
2667 | 2667 | // adds a tabulation if no word has been typed by the student |
2668 | 2668 | $answer .= ''; // remove that causes issue |
@@ -2681,17 +2681,17 @@ discard block |
||
2681 | 2681 | } elseif (!empty ($user_tags[$i])) { |
2682 | 2682 | // else if the word entered by the student IS NOT the same as the one defined by the professor |
2683 | 2683 | // adds the word in red at the end of the string, and strikes it |
2684 | - $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>'; |
|
2684 | + $answer .= '<font color="red"><s>'.$user_tags[$i].'</s></font>'; |
|
2685 | 2685 | } else { |
2686 | 2686 | // adds a tabulation if no word has been typed by the student |
2687 | - $answer .= ''; // remove that causes issue |
|
2687 | + $answer .= ''; // remove that causes issue |
|
2688 | 2688 | } |
2689 | 2689 | } |
2690 | 2690 | |
2691 | 2691 | // adds the correct word, followed by ] to close the blank |
2692 | - $answer .= ' / <font color="green"><b>' . $real_correct_tags[$i] . '</b></font>]'; |
|
2693 | - if (isset($real_text[$i +1])) { |
|
2694 | - $answer .= $real_text[$i +1]; |
|
2692 | + $answer .= ' / <font color="green"><b>'.$real_correct_tags[$i].'</b></font>]'; |
|
2693 | + if (isset($real_text[$i + 1])) { |
|
2694 | + $answer .= $real_text[$i + 1]; |
|
2695 | 2695 | } |
2696 | 2696 | } |
2697 | 2697 | } else { |
@@ -2828,10 +2828,10 @@ discard block |
||
2828 | 2828 | } |
2829 | 2829 | // adds the piece of text that is before the blank |
2830 | 2830 | //and ends with '[' into a general storage array |
2831 | - $realText[] = api_substr($temp, 0, $pos +1); |
|
2832 | - $answer .= api_substr($temp, 0, $pos +1); |
|
2831 | + $realText[] = api_substr($temp, 0, $pos + 1); |
|
2832 | + $answer .= api_substr($temp, 0, $pos + 1); |
|
2833 | 2833 | //take the string remaining (after the last "[" we found) |
2834 | - $temp = api_substr($temp, $pos +1); |
|
2834 | + $temp = api_substr($temp, $pos + 1); |
|
2835 | 2835 | // quit the loop if there are no more blanks, and update $pos to the position of next ']' |
2836 | 2836 | if (($pos = api_strpos($temp, ']')) === false) { |
2837 | 2837 | // adds the end of the text |
@@ -2865,7 +2865,7 @@ discard block |
||
2865 | 2865 | //put the contents of the [] answer tag into correct_tags[] |
2866 | 2866 | $correctTags[] = api_substr($temp, 0, $pos); |
2867 | 2867 | $j++; |
2868 | - $temp = api_substr($temp, $pos +1); |
|
2868 | + $temp = api_substr($temp, $pos + 1); |
|
2869 | 2869 | } |
2870 | 2870 | $answer = ''; |
2871 | 2871 | $realCorrectTags = $correctTags; |
@@ -2885,22 +2885,22 @@ discard block |
||
2885 | 2885 | } elseif (!empty($userTags[$i])) { |
2886 | 2886 | // else if the word entered by the student IS NOT the same as the one defined by the professor |
2887 | 2887 | // adds the word in red at the end of the string, and strikes it |
2888 | - $answer .= '<font color="red"><s>' . $userTags[$i] . '</s></font>'; |
|
2888 | + $answer .= '<font color="red"><s>'.$userTags[$i].'</s></font>'; |
|
2889 | 2889 | } else { |
2890 | 2890 | // adds a tabulation if no word has been typed by the student |
2891 | 2891 | $answer .= ''; // remove that causes issue |
2892 | 2892 | } |
2893 | 2893 | // adds the correct word, followed by ] to close the blank |
2894 | - $answer .= ' / <font color="green"><b>' . $realCorrectTags[$i] . '</b></font>]'; |
|
2895 | - if (isset($realText[$i +1])) { |
|
2896 | - $answer .= $realText[$i +1]; |
|
2894 | + $answer .= ' / <font color="green"><b>'.$realCorrectTags[$i].'</b></font>]'; |
|
2895 | + if (isset($realText[$i + 1])) { |
|
2896 | + $answer .= $realText[$i + 1]; |
|
2897 | 2897 | } |
2898 | 2898 | } |
2899 | 2899 | break; |
2900 | 2900 | // for free answer |
2901 | 2901 | case FREE_ANSWER: |
2902 | 2902 | if ($from_database) { |
2903 | - $query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT." |
|
2903 | + $query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT." |
|
2904 | 2904 | WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'"; |
2905 | 2905 | $resq = Database::query($query); |
2906 | 2906 | $data = Database::fetch_array($resq); |
@@ -2911,9 +2911,9 @@ discard block |
||
2911 | 2911 | $questionScore = $data['marks']; |
2912 | 2912 | |
2913 | 2913 | if ($questionScore == -1) { |
2914 | - $totalScore+= 0; |
|
2914 | + $totalScore += 0; |
|
2915 | 2915 | } else { |
2916 | - $totalScore+= $questionScore; |
|
2916 | + $totalScore += $questionScore; |
|
2917 | 2917 | } |
2918 | 2918 | if ($questionScore == '') { |
2919 | 2919 | $questionScore = 0; |
@@ -2934,14 +2934,14 @@ discard block |
||
2934 | 2934 | $query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT." |
2935 | 2935 | WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'"; |
2936 | 2936 | $resq = Database::query($query); |
2937 | - $choice = Database::result($resq,0,'answer'); |
|
2937 | + $choice = Database::result($resq, 0, 'answer'); |
|
2938 | 2938 | $choice = str_replace('\r\n', '', $choice); |
2939 | 2939 | $choice = stripslashes($choice); |
2940 | - $questionScore = Database::result($resq,0,"marks"); |
|
2941 | - if ($questionScore==-1) { |
|
2942 | - $totalScore+=0; |
|
2940 | + $questionScore = Database::result($resq, 0, "marks"); |
|
2941 | + if ($questionScore == -1) { |
|
2942 | + $totalScore += 0; |
|
2943 | 2943 | } else { |
2944 | - $totalScore+=$questionScore; |
|
2944 | + $totalScore += $questionScore; |
|
2945 | 2945 | } |
2946 | 2946 | $arrques = $questionName; |
2947 | 2947 | $arrans = $choice; |
@@ -2986,7 +2986,7 @@ discard block |
||
2986 | 2986 | |
2987 | 2987 | while ($a_answers = Database::fetch_array($res_answers)) { |
2988 | 2988 | $i_answer_id = $a_answers['id']; //3 |
2989 | - $s_answer_label = $a_answers['answer']; // your daddy - your mother |
|
2989 | + $s_answer_label = $a_answers['answer']; // your daddy - your mother |
|
2990 | 2990 | $i_answer_correct_answer = $a_answers['correct']; //1 - 2 |
2991 | 2991 | $i_answer_id_auto = $a_answers['id_auto']; // 3 - 4 |
2992 | 2992 | |
@@ -3038,8 +3038,8 @@ discard block |
||
3038 | 3038 | |
3039 | 3039 | if ($show_result) { |
3040 | 3040 | echo '<tr>'; |
3041 | - echo '<td>' . $s_answer_label . '</td>'; |
|
3042 | - echo '<td>' . $user_answer; |
|
3041 | + echo '<td>'.$s_answer_label.'</td>'; |
|
3042 | + echo '<td>'.$user_answer; |
|
3043 | 3043 | |
3044 | 3044 | if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) { |
3045 | 3045 | if (isset($real_list[$i_answer_correct_answer])) { |
@@ -3159,13 +3159,13 @@ discard block |
||
3159 | 3159 | |
3160 | 3160 | // THIS is very important otherwise the poly_compile will throw an error!! |
3161 | 3161 | // round-up the coordinates |
3162 | - $coords = explode('/',$user_answer); |
|
3162 | + $coords = explode('/', $user_answer); |
|
3163 | 3163 | $user_array = ''; |
3164 | 3164 | foreach ($coords as $coord) { |
3165 | - list($x,$y) = explode(';',$coord); |
|
3165 | + list($x, $y) = explode(';', $coord); |
|
3166 | 3166 | $user_array .= round($x).';'.round($y).'/'; |
3167 | 3167 | } |
3168 | - $user_array = substr($user_array,0,-1); |
|
3168 | + $user_array = substr($user_array, 0, -1); |
|
3169 | 3169 | } else { |
3170 | 3170 | if (!empty($studentChoice)) { |
3171 | 3171 | $newquestionList[] = $questionId; |
@@ -3175,13 +3175,13 @@ discard block |
||
3175 | 3175 | $studentChoice = $choice[$answerId]; |
3176 | 3176 | $questionScore += $answerWeighting; |
3177 | 3177 | |
3178 | - if ($hotspot_delineation_result[1]==1) { |
|
3178 | + if ($hotspot_delineation_result[1] == 1) { |
|
3179 | 3179 | $totalScore += $answerWeighting; //adding the total |
3180 | 3180 | } |
3181 | 3181 | } |
3182 | 3182 | } |
3183 | - $_SESSION['hotspot_coord'][1] = $delineation_cord; |
|
3184 | - $_SESSION['hotspot_dest'][1] = $answer_delineation_destination; |
|
3183 | + $_SESSION['hotspot_coord'][1] = $delineation_cord; |
|
3184 | + $_SESSION['hotspot_dest'][1] = $answer_delineation_destination; |
|
3185 | 3185 | break; |
3186 | 3186 | } // end switch Answertype |
3187 | 3187 | |
@@ -3239,7 +3239,7 @@ discard block |
||
3239 | 3239 | $results_disabled |
3240 | 3240 | ); |
3241 | 3241 | //} |
3242 | - } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) { |
|
3242 | + } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { |
|
3243 | 3243 | // if ($origin!='learnpath') { |
3244 | 3244 | ExerciseShowFunctions::display_multiple_answer_combination_true_false( |
3245 | 3245 | $feedback_type, |
@@ -3256,11 +3256,11 @@ discard block |
||
3256 | 3256 | //} |
3257 | 3257 | } elseif ($answerType == FILL_IN_BLANKS) { |
3258 | 3258 | //if ($origin!='learnpath') { |
3259 | - ExerciseShowFunctions::display_fill_in_blanks_answer($feedback_type, $answer,0,0, $results_disabled); |
|
3259 | + ExerciseShowFunctions::display_fill_in_blanks_answer($feedback_type, $answer, 0, 0, $results_disabled); |
|
3260 | 3260 | // } |
3261 | 3261 | } elseif ($answerType == CALCULATED_ANSWER) { |
3262 | 3262 | //if ($origin!='learnpath') { |
3263 | - ExerciseShowFunctions::display_calculated_answer($feedback_type, $answer,0,0); |
|
3263 | + ExerciseShowFunctions::display_calculated_answer($feedback_type, $answer, 0, 0); |
|
3264 | 3264 | // } |
3265 | 3265 | } elseif ($answerType == FREE_ANSWER) { |
3266 | 3266 | //if($origin != 'learnpath') { |
@@ -3307,13 +3307,13 @@ discard block |
||
3307 | 3307 | $user_answer = $_SESSION['exerciseResultCoordinates'][$questionId]; |
3308 | 3308 | |
3309 | 3309 | //round-up the coordinates |
3310 | - $coords = explode('/',$user_answer); |
|
3310 | + $coords = explode('/', $user_answer); |
|
3311 | 3311 | $user_array = ''; |
3312 | 3312 | foreach ($coords as $coord) { |
3313 | - list($x,$y) = explode(';',$coord); |
|
3313 | + list($x, $y) = explode(';', $coord); |
|
3314 | 3314 | $user_array .= round($x).';'.round($y).'/'; |
3315 | 3315 | } |
3316 | - $user_array = substr($user_array,0,-1); |
|
3316 | + $user_array = substr($user_array, 0, -1); |
|
3317 | 3317 | |
3318 | 3318 | if ($next) { |
3319 | 3319 | |
@@ -3340,7 +3340,7 @@ discard block |
||
3340 | 3340 | //$overlap = round(polygons_overlap($poly_answer,$poly_user)); |
3341 | 3341 | // //this is an area in pixels |
3342 | 3342 | if ($debug > 0) { |
3343 | - error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0); |
|
3343 | + error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0); |
|
3344 | 3344 | } |
3345 | 3345 | |
3346 | 3346 | if ($overlap < 1) { |
@@ -3353,43 +3353,43 @@ discard block |
||
3353 | 3353 | // that is overlapped by the user's polygon |
3354 | 3354 | $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100); |
3355 | 3355 | if ($debug > 1) { |
3356 | - error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0); |
|
3356 | + error_log(__LINE__.' - Final overlap is '.$final_overlap, 0); |
|
3357 | 3357 | } |
3358 | 3358 | // the final missing area is the percentage of the initial polygon |
3359 | 3359 | // that is not overlapped by the user's polygon |
3360 | 3360 | $final_missing = 100 - $final_overlap; |
3361 | 3361 | if ($debug > 1) { |
3362 | - error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0); |
|
3362 | + error_log(__LINE__.' - Final missing is '.$final_missing, 0); |
|
3363 | 3363 | } |
3364 | 3364 | // the final excess area is the percentage of the initial polygon's size |
3365 | 3365 | // that is covered by the user's polygon outside of the initial polygon |
3366 | 3366 | $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100); |
3367 | 3367 | if ($debug > 1) { |
3368 | - error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0); |
|
3368 | + error_log(__LINE__.' - Final excess is '.$final_excess, 0); |
|
3369 | 3369 | } |
3370 | 3370 | } |
3371 | 3371 | |
3372 | 3372 | //checking the destination parameters parsing the "@@" |
3373 | - $destination_items= explode('@@', $answerDestination); |
|
3373 | + $destination_items = explode('@@', $answerDestination); |
|
3374 | 3374 | $threadhold_total = $destination_items[0]; |
3375 | - $threadhold_items=explode(';',$threadhold_total); |
|
3375 | + $threadhold_items = explode(';', $threadhold_total); |
|
3376 | 3376 | $threadhold1 = $threadhold_items[0]; // overlap |
3377 | 3377 | $threadhold2 = $threadhold_items[1]; // excess |
3378 | - $threadhold3 = $threadhold_items[2]; //missing |
|
3378 | + $threadhold3 = $threadhold_items[2]; //missing |
|
3379 | 3379 | |
3380 | 3380 | // if is delineation |
3381 | - if ($answerId===1) { |
|
3381 | + if ($answerId === 1) { |
|
3382 | 3382 | //setting colors |
3383 | - if ($final_overlap>=$threadhold1) { |
|
3384 | - $overlap_color=true; //echo 'a'; |
|
3383 | + if ($final_overlap >= $threadhold1) { |
|
3384 | + $overlap_color = true; //echo 'a'; |
|
3385 | 3385 | } |
3386 | 3386 | //echo $excess.'-'.$threadhold2; |
3387 | - if ($final_excess<=$threadhold2) { |
|
3388 | - $excess_color=true; //echo 'b'; |
|
3387 | + if ($final_excess <= $threadhold2) { |
|
3388 | + $excess_color = true; //echo 'b'; |
|
3389 | 3389 | } |
3390 | 3390 | //echo '--------'.$missing.'-'.$threadhold3; |
3391 | - if ($final_missing<=$threadhold3) { |
|
3392 | - $missing_color=true; //echo 'c'; |
|
3391 | + if ($final_missing <= $threadhold3) { |
|
3392 | + $missing_color = true; //echo 'c'; |
|
3393 | 3393 | } |
3394 | 3394 | |
3395 | 3395 | // if pass |
@@ -3398,67 +3398,67 @@ discard block |
||
3398 | 3398 | $final_missing <= $threadhold3 && |
3399 | 3399 | $final_excess <= $threadhold2 |
3400 | 3400 | ) { |
3401 | - $next=1; //go to the oars |
|
3402 | - $result_comment=get_lang('Acceptable'); |
|
3403 | - $final_answer = 1; // do not update with update_exercise_attempt |
|
3401 | + $next = 1; //go to the oars |
|
3402 | + $result_comment = get_lang('Acceptable'); |
|
3403 | + $final_answer = 1; // do not update with update_exercise_attempt |
|
3404 | 3404 | } else { |
3405 | - $next=0; |
|
3406 | - $result_comment=get_lang('Unacceptable'); |
|
3407 | - $comment=$answerDestination=$objAnswerTmp->selectComment(1); |
|
3408 | - $answerDestination=$objAnswerTmp->selectDestination(1); |
|
3405 | + $next = 0; |
|
3406 | + $result_comment = get_lang('Unacceptable'); |
|
3407 | + $comment = $answerDestination = $objAnswerTmp->selectComment(1); |
|
3408 | + $answerDestination = $objAnswerTmp->selectDestination(1); |
|
3409 | 3409 | //checking the destination parameters parsing the "@@" |
3410 | - $destination_items= explode('@@', $answerDestination); |
|
3410 | + $destination_items = explode('@@', $answerDestination); |
|
3411 | 3411 | } |
3412 | - } elseif($answerId>1) { |
|
3412 | + } elseif ($answerId > 1) { |
|
3413 | 3413 | if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') { |
3414 | - if ($debug>0) { |
|
3415 | - error_log(__LINE__.' - answerId is of type noerror',0); |
|
3414 | + if ($debug > 0) { |
|
3415 | + error_log(__LINE__.' - answerId is of type noerror', 0); |
|
3416 | 3416 | } |
3417 | 3417 | //type no error shouldn't be treated |
3418 | 3418 | $next = 1; |
3419 | 3419 | continue; |
3420 | 3420 | } |
3421 | - if ($debug>0) { |
|
3422 | - error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0); |
|
3421 | + if ($debug > 0) { |
|
3422 | + error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0); |
|
3423 | 3423 | } |
3424 | 3424 | //check the intersection between the oar and the user |
3425 | 3425 | //echo 'user'; print_r($x_user_list); print_r($y_user_list); |
3426 | 3426 | //echo 'official';print_r($x_list);print_r($y_list); |
3427 | 3427 | //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list); |
3428 | - $inter= $result['success']; |
|
3428 | + $inter = $result['success']; |
|
3429 | 3429 | |
3430 | 3430 | //$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId); |
3431 | - $delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId); |
|
3431 | + $delineation_cord = $objAnswerTmp->selectHotspotCoordinates($answerId); |
|
3432 | 3432 | |
3433 | - $poly_answer = convert_coordinates($delineation_cord,'|'); |
|
3434 | - $max_coord = poly_get_max($poly_user,$poly_answer); |
|
3435 | - $poly_answer_compiled = poly_compile($poly_answer,$max_coord); |
|
3436 | - $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord); |
|
3433 | + $poly_answer = convert_coordinates($delineation_cord, '|'); |
|
3434 | + $max_coord = poly_get_max($poly_user, $poly_answer); |
|
3435 | + $poly_answer_compiled = poly_compile($poly_answer, $max_coord); |
|
3436 | + $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord); |
|
3437 | 3437 | |
3438 | 3438 | if ($overlap == false) { |
3439 | 3439 | //all good, no overlap |
3440 | 3440 | $next = 1; |
3441 | 3441 | continue; |
3442 | 3442 | } else { |
3443 | - if ($debug>0) { |
|
3444 | - error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0); |
|
3443 | + if ($debug > 0) { |
|
3444 | + error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0); |
|
3445 | 3445 | } |
3446 | 3446 | $organs_at_risk_hit++; |
3447 | 3447 | //show the feedback |
3448 | - $next=0; |
|
3449 | - $comment=$answerDestination=$objAnswerTmp->selectComment($answerId); |
|
3450 | - $answerDestination=$objAnswerTmp->selectDestination($answerId); |
|
3451 | - |
|
3452 | - $destination_items= explode('@@', $answerDestination); |
|
3453 | - $try_hotspot=$destination_items[1]; |
|
3454 | - $lp_hotspot=$destination_items[2]; |
|
3455 | - $select_question_hotspot=$destination_items[3]; |
|
3456 | - $url_hotspot=$destination_items[4]; |
|
3448 | + $next = 0; |
|
3449 | + $comment = $answerDestination = $objAnswerTmp->selectComment($answerId); |
|
3450 | + $answerDestination = $objAnswerTmp->selectDestination($answerId); |
|
3451 | + |
|
3452 | + $destination_items = explode('@@', $answerDestination); |
|
3453 | + $try_hotspot = $destination_items[1]; |
|
3454 | + $lp_hotspot = $destination_items[2]; |
|
3455 | + $select_question_hotspot = $destination_items[3]; |
|
3456 | + $url_hotspot = $destination_items[4]; |
|
3457 | 3457 | } |
3458 | 3458 | } |
3459 | 3459 | } else { // the first delineation feedback |
3460 | - if ($debug>0) { |
|
3461 | - error_log(__LINE__.' first',0); |
|
3460 | + if ($debug > 0) { |
|
3461 | + error_log(__LINE__.' first', 0); |
|
3462 | 3462 | } |
3463 | 3463 | } |
3464 | 3464 | } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) { |
@@ -3466,7 +3466,7 @@ discard block |
||
3466 | 3466 | echo Display::tag('td', $answerMatching[$answerId]); |
3467 | 3467 | echo Display::tag( |
3468 | 3468 | 'td', |
3469 | - "$user_answer / " . Display::tag( |
|
3469 | + "$user_answer / ".Display::tag( |
|
3470 | 3470 | 'strong', |
3471 | 3471 | $answerMatching[$answerCorrect], |
3472 | 3472 | ['style' => 'color: #008000; font-weight: bold;'] |
@@ -3606,7 +3606,7 @@ discard block |
||
3606 | 3606 | $exeId, |
3607 | 3607 | $questionId, |
3608 | 3608 | $nano |
3609 | - ) . '</td> |
|
3609 | + ).'</td> |
|
3610 | 3610 | </tr> |
3611 | 3611 | </table>'; |
3612 | 3612 | break; |
@@ -3665,7 +3665,7 @@ discard block |
||
3665 | 3665 | |
3666 | 3666 | //$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels |
3667 | 3667 | if ($debug > 0) { |
3668 | - error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0); |
|
3668 | + error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0); |
|
3669 | 3669 | } |
3670 | 3670 | if ($overlap < 1) { |
3671 | 3671 | //shortcut to avoid complicated calculations |
@@ -3676,17 +3676,17 @@ discard block |
||
3676 | 3676 | // the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon |
3677 | 3677 | $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100); |
3678 | 3678 | if ($debug > 1) { |
3679 | - error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0); |
|
3679 | + error_log(__LINE__.' - Final overlap is '.$final_overlap, 0); |
|
3680 | 3680 | } |
3681 | 3681 | // the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon |
3682 | 3682 | $final_missing = 100 - $final_overlap; |
3683 | 3683 | if ($debug > 1) { |
3684 | - error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0); |
|
3684 | + error_log(__LINE__.' - Final missing is '.$final_missing, 0); |
|
3685 | 3685 | } |
3686 | 3686 | // the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon |
3687 | 3687 | $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100); |
3688 | 3688 | if ($debug > 1) { |
3689 | - error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0); |
|
3689 | + error_log(__LINE__.' - Final excess is '.$final_excess, 0); |
|
3690 | 3690 | } |
3691 | 3691 | } |
3692 | 3692 | |
@@ -3696,7 +3696,7 @@ discard block |
||
3696 | 3696 | $threadhold_items = explode(';', $threadhold_total); |
3697 | 3697 | $threadhold1 = $threadhold_items[0]; // overlap |
3698 | 3698 | $threadhold2 = $threadhold_items[1]; // excess |
3699 | - $threadhold3 = $threadhold_items[2]; //missing |
|
3699 | + $threadhold3 = $threadhold_items[2]; //missing |
|
3700 | 3700 | // if is delineation |
3701 | 3701 | if ($answerId === 1) { |
3702 | 3702 | //setting colors |
@@ -3728,14 +3728,14 @@ discard block |
||
3728 | 3728 | } elseif ($answerId > 1) { |
3729 | 3729 | if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') { |
3730 | 3730 | if ($debug > 0) { |
3731 | - error_log(__LINE__ . ' - answerId is of type noerror', 0); |
|
3731 | + error_log(__LINE__.' - answerId is of type noerror', 0); |
|
3732 | 3732 | } |
3733 | 3733 | //type no error shouldn't be treated |
3734 | 3734 | $next = 1; |
3735 | 3735 | continue; |
3736 | 3736 | } |
3737 | 3737 | if ($debug > 0) { |
3738 | - error_log(__LINE__ . ' - answerId is >1 so we\'re probably in OAR', 0); |
|
3738 | + error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0); |
|
3739 | 3739 | } |
3740 | 3740 | //check the intersection between the oar and the user |
3741 | 3741 | //echo 'user'; print_r($x_user_list); print_r($y_user_list); |
@@ -3749,7 +3749,7 @@ discard block |
||
3749 | 3749 | $poly_answer = convert_coordinates($delineation_cord, '|'); |
3750 | 3750 | $max_coord = poly_get_max($poly_user, $poly_answer); |
3751 | 3751 | $poly_answer_compiled = poly_compile($poly_answer, $max_coord); |
3752 | - $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord); |
|
3752 | + $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord); |
|
3753 | 3753 | |
3754 | 3754 | if ($overlap == false) { |
3755 | 3755 | //all good, no overlap |
@@ -3757,7 +3757,7 @@ discard block |
||
3757 | 3757 | continue; |
3758 | 3758 | } else { |
3759 | 3759 | if ($debug > 0) { |
3760 | - error_log(__LINE__ . ' - Overlap is ' . $overlap . ': OAR hit', 0); |
|
3760 | + error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0); |
|
3761 | 3761 | } |
3762 | 3762 | $organs_at_risk_hit++; |
3763 | 3763 | //show the feedback |
@@ -3769,12 +3769,12 @@ discard block |
||
3769 | 3769 | $try_hotspot = $destination_items[1]; |
3770 | 3770 | $lp_hotspot = $destination_items[2]; |
3771 | 3771 | $select_question_hotspot = $destination_items[3]; |
3772 | - $url_hotspot=$destination_items[4]; |
|
3772 | + $url_hotspot = $destination_items[4]; |
|
3773 | 3773 | } |
3774 | 3774 | } |
3775 | 3775 | } else { // the first delineation feedback |
3776 | 3776 | if ($debug > 0) { |
3777 | - error_log(__LINE__ . ' first', 0); |
|
3777 | + error_log(__LINE__.' first', 0); |
|
3778 | 3778 | } |
3779 | 3779 | } |
3780 | 3780 | break; |
@@ -3796,7 +3796,7 @@ discard block |
||
3796 | 3796 | echo Display::tag('td', $answerMatching[$answerId]); |
3797 | 3797 | echo Display::tag( |
3798 | 3798 | 'td', |
3799 | - "$user_answer / " . Display::tag( |
|
3799 | + "$user_answer / ".Display::tag( |
|
3800 | 3800 | 'strong', |
3801 | 3801 | $answerMatching[$answerCorrect], |
3802 | 3802 | ['style' => 'color: #008000; font-weight: bold;'] |
@@ -3882,7 +3882,7 @@ discard block |
||
3882 | 3882 | // we use the results from the session (from_db=0) |
3883 | 3883 | // TODO Change this, because it is wrong to show the user |
3884 | 3884 | // some results that haven't been stored in the database yet |
3885 | - if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION ) { |
|
3885 | + if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION) { |
|
3886 | 3886 | |
3887 | 3887 | if ($debug) error_log('$from AND this is a hotspot kind of question '); |
3888 | 3888 | |
@@ -3891,19 +3891,19 @@ discard block |
||
3891 | 3891 | if ($answerType == HOT_SPOT_DELINEATION) { |
3892 | 3892 | if (0) { |
3893 | 3893 | if ($overlap_color) { |
3894 | - $overlap_color='green'; |
|
3894 | + $overlap_color = 'green'; |
|
3895 | 3895 | } else { |
3896 | - $overlap_color='red'; |
|
3896 | + $overlap_color = 'red'; |
|
3897 | 3897 | } |
3898 | 3898 | if ($missing_color) { |
3899 | - $missing_color='green'; |
|
3899 | + $missing_color = 'green'; |
|
3900 | 3900 | } else { |
3901 | - $missing_color='red'; |
|
3901 | + $missing_color = 'red'; |
|
3902 | 3902 | } |
3903 | 3903 | if ($excess_color) { |
3904 | - $excess_color='green'; |
|
3904 | + $excess_color = 'green'; |
|
3905 | 3905 | } else { |
3906 | - $excess_color='red'; |
|
3906 | + $excess_color = 'red'; |
|
3907 | 3907 | } |
3908 | 3908 | if (!is_numeric($final_overlap)) { |
3909 | 3909 | $final_overlap = 0; |
@@ -3915,33 +3915,33 @@ discard block |
||
3915 | 3915 | $final_excess = 0; |
3916 | 3916 | } |
3917 | 3917 | |
3918 | - if ($final_overlap>100) { |
|
3918 | + if ($final_overlap > 100) { |
|
3919 | 3919 | $final_overlap = 100; |
3920 | 3920 | } |
3921 | 3921 | |
3922 | - $table_resume='<table class="data_table"> |
|
3922 | + $table_resume = '<table class="data_table"> |
|
3923 | 3923 | <tr class="row_odd" > |
3924 | 3924 | <td></td> |
3925 | - <td ><b>' . get_lang('Requirements') . '</b></td> |
|
3926 | - <td><b>' . get_lang('YourAnswer') . '</b></td> |
|
3925 | + <td ><b>' . get_lang('Requirements').'</b></td> |
|
3926 | + <td><b>' . get_lang('YourAnswer').'</b></td> |
|
3927 | 3927 | </tr> |
3928 | 3928 | <tr class="row_even"> |
3929 | - <td><b>' . get_lang('Overlap') . '</b></td> |
|
3930 | - <td>' . get_lang('Min') . ' ' . $threadhold1 . '</td> |
|
3931 | - <td><div style="color:' . $overlap_color . '">' |
|
3932 | - . (($final_overlap < 0) ? 0 : intval($final_overlap)) . '</div></td> |
|
3929 | + <td><b>' . get_lang('Overlap').'</b></td> |
|
3930 | + <td>' . get_lang('Min').' '.$threadhold1.'</td> |
|
3931 | + <td><div style="color:' . $overlap_color.'">' |
|
3932 | + . (($final_overlap < 0) ? 0 : intval($final_overlap)).'</div></td> |
|
3933 | 3933 | </tr> |
3934 | 3934 | <tr> |
3935 | - <td><b>' . get_lang('Excess') . '</b></td> |
|
3936 | - <td>' . get_lang('Max') . ' ' . $threadhold2 . '</td> |
|
3937 | - <td><div style="color:' . $excess_color . '">' |
|
3938 | - . (($final_excess < 0) ? 0 : intval($final_excess)) . '</div></td> |
|
3935 | + <td><b>' . get_lang('Excess').'</b></td> |
|
3936 | + <td>' . get_lang('Max').' '.$threadhold2.'</td> |
|
3937 | + <td><div style="color:' . $excess_color.'">' |
|
3938 | + . (($final_excess < 0) ? 0 : intval($final_excess)).'</div></td> |
|
3939 | 3939 | </tr> |
3940 | 3940 | <tr class="row_even"> |
3941 | - <td><b>' . get_lang('Missing') . '</b></td> |
|
3942 | - <td>' . get_lang('Max') . ' ' . $threadhold3 . '</td> |
|
3943 | - <td><div style="color:' . $missing_color . '">' |
|
3944 | - . (($final_missing < 0) ? 0 : intval($final_missing)) . '</div></td> |
|
3941 | + <td><b>' . get_lang('Missing').'</b></td> |
|
3942 | + <td>' . get_lang('Max').' '.$threadhold3.'</td> |
|
3943 | + <td><div style="color:' . $missing_color.'">' |
|
3944 | + . (($final_missing < 0) ? 0 : intval($final_missing)).'</div></td> |
|
3945 | 3945 | </tr> |
3946 | 3946 | </table>'; |
3947 | 3947 | if ($next == 0) { |
@@ -3956,20 +3956,20 @@ discard block |
||
3956 | 3956 | $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers); |
3957 | 3957 | } |
3958 | 3958 | |
3959 | - echo '<h1><div style="color:#333;">' . get_lang('Feedback') . '</div></h1> |
|
3959 | + echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1> |
|
3960 | 3960 | <p style="text-align:center">'; |
3961 | 3961 | |
3962 | - $message = '<p>' . get_lang('YourDelineation') . '</p>'; |
|
3962 | + $message = '<p>'.get_lang('YourDelineation').'</p>'; |
|
3963 | 3963 | $message .= $table_resume; |
3964 | - $message .= '<br />' . get_lang('ResultIs') . ' ' . $result_comment . '<br />'; |
|
3964 | + $message .= '<br />'.get_lang('ResultIs').' '.$result_comment.'<br />'; |
|
3965 | 3965 | if ($organs_at_risk_hit > 0) { |
3966 | - $message .= '<p><b>' . get_lang('OARHit') . '</b></p>'; |
|
3966 | + $message .= '<p><b>'.get_lang('OARHit').'</b></p>'; |
|
3967 | 3967 | } |
3968 | - $message .='<p>' . $comment . '</p>'; |
|
3968 | + $message .= '<p>'.$comment.'</p>'; |
|
3969 | 3969 | echo $message; |
3970 | 3970 | } else { |
3971 | 3971 | echo $hotspot_delineation_result[0]; //prints message |
3972 | - $from_database = 1; // the hotspot_solution.swf needs this variable |
|
3972 | + $from_database = 1; // the hotspot_solution.swf needs this variable |
|
3973 | 3973 | } |
3974 | 3974 | |
3975 | 3975 | //save the score attempts |
@@ -3991,20 +3991,20 @@ discard block |
||
3991 | 3991 | $exerciseResultCoordinates[$quesId] |
3992 | 3992 | ); |
3993 | 3993 | } else { |
3994 | - if ($final_answer==0) { |
|
3994 | + if ($final_answer == 0) { |
|
3995 | 3995 | $questionScore = 0; |
3996 | - $answer=0; |
|
3996 | + $answer = 0; |
|
3997 | 3997 | Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0); |
3998 | 3998 | if (is_array($exerciseResultCoordinates[$quesId])) { |
3999 | - foreach($exerciseResultCoordinates[$quesId] as $idx => $val) { |
|
4000 | - Event::saveExerciseAttemptHotspot($exeId,$quesId,$idx,0,$val); |
|
3999 | + foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) { |
|
4000 | + Event::saveExerciseAttemptHotspot($exeId, $quesId, $idx, 0, $val); |
|
4001 | 4001 | } |
4002 | 4002 | } |
4003 | 4003 | } else { |
4004 | 4004 | Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0); |
4005 | 4005 | if (is_array($exerciseResultCoordinates[$quesId])) { |
4006 | - foreach($exerciseResultCoordinates[$quesId] as $idx => $val) { |
|
4007 | - Event::saveExerciseAttemptHotspot($exeId,$quesId,$idx,$choice[$idx],$val); |
|
4006 | + foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) { |
|
4007 | + Event::saveExerciseAttemptHotspot($exeId, $quesId, $idx, $choice[$idx], $val); |
|
4008 | 4008 | } |
4009 | 4009 | } |
4010 | 4010 | } |
@@ -4023,7 +4023,7 @@ discard block |
||
4023 | 4023 | echo " |
4024 | 4024 | <tr> |
4025 | 4025 | <td colspan=\"2\"> |
4026 | - <p><em>" . get_lang('HotSpot') . "</em></p> |
|
4026 | + <p><em>" . get_lang('HotSpot')."</em></p> |
|
4027 | 4027 | |
4028 | 4028 | <div id=\"hotspot-solution-$questionId\"></div> |
4029 | 4029 | |
@@ -4061,7 +4061,7 @@ discard block |
||
4061 | 4061 | |
4062 | 4062 | if ($saved_results) { |
4063 | 4063 | if ($debug) error_log("Save question results $saved_results"); |
4064 | - if ($debug) error_log(print_r($choice ,1 )); |
|
4064 | + if ($debug) error_log(print_r($choice, 1)); |
|
4065 | 4065 | |
4066 | 4066 | if (empty($choice)) { |
4067 | 4067 | $choice = 0; |
@@ -4073,14 +4073,14 @@ discard block |
||
4073 | 4073 | $ans = $reply[$i]; |
4074 | 4074 | Event::saveQuestionAttempt( |
4075 | 4075 | $questionScore, |
4076 | - $ans . ':' . $choice[$ans], |
|
4076 | + $ans.':'.$choice[$ans], |
|
4077 | 4077 | $quesId, |
4078 | 4078 | $exeId, |
4079 | 4079 | $i, |
4080 | 4080 | $this->id |
4081 | 4081 | ); |
4082 | 4082 | if ($debug) { |
4083 | - error_log('result =>' . $questionScore . ' ' . $ans . ':' . $choice[$ans]); |
|
4083 | + error_log('result =>'.$questionScore.' '.$ans.':'.$choice[$ans]); |
|
4084 | 4084 | } |
4085 | 4085 | } |
4086 | 4086 | } else { |
@@ -4091,7 +4091,7 @@ discard block |
||
4091 | 4091 | $reply = array_keys($choice); |
4092 | 4092 | |
4093 | 4093 | if ($debug) { |
4094 | - error_log("reply " . print_r($reply, 1) . ""); |
|
4094 | + error_log("reply ".print_r($reply, 1).""); |
|
4095 | 4095 | } |
4096 | 4096 | for ($i = 0; $i < sizeof($reply); $i++) { |
4097 | 4097 | $ans = $reply[$i]; |
@@ -4150,7 +4150,7 @@ discard block |
||
4150 | 4150 | |
4151 | 4151 | Event::saveQuestionAttempt($questionScore, implode('|', $answer), $quesId, $exeId, 0, $this->id); |
4152 | 4152 | } else { |
4153 | - Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0,$this->id); |
|
4153 | + Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id); |
|
4154 | 4154 | } |
4155 | 4155 | } |
4156 | 4156 | |
@@ -4160,8 +4160,8 @@ discard block |
||
4160 | 4160 | |
4161 | 4161 | if ($saved_results) { |
4162 | 4162 | $stat_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
4163 | - $sql = 'UPDATE ' . $stat_table . ' SET |
|
4164 | - exe_result = exe_result + ' . floatval($questionScore) . ' |
|
4163 | + $sql = 'UPDATE '.$stat_table.' SET |
|
4164 | + exe_result = exe_result + ' . floatval($questionScore).' |
|
4165 | 4165 | WHERE exe_id = ' . $exeId; |
4166 | 4166 | if ($debug) error_log($sql); |
4167 | 4167 | Database::query($sql); |
@@ -4185,7 +4185,7 @@ discard block |
||
4185 | 4185 | */ |
4186 | 4186 | public function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id) |
4187 | 4187 | { |
4188 | - if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { |
|
4188 | + if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) { |
|
4189 | 4189 | return null; |
4190 | 4190 | } |
4191 | 4191 | // Email configuration settings |
@@ -4236,7 +4236,7 @@ discard block |
||
4236 | 4236 | $msg = str_replace("#course#", $courseInfo['name'], $msg1); |
4237 | 4237 | |
4238 | 4238 | if ($origin != 'learnpath') { |
4239 | - $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
|
4239 | + $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
|
4240 | 4240 | } |
4241 | 4241 | $msg1 = str_replace("#url#", $url_email, $msg); |
4242 | 4242 | $mail_content = $msg1; |
@@ -4265,7 +4265,7 @@ discard block |
||
4265 | 4265 | */ |
4266 | 4266 | function send_notification_for_open_questions($question_list_answers, $origin, $exe_id) |
4267 | 4267 | { |
4268 | - if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { |
|
4268 | + if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) { |
|
4269 | 4269 | return null; |
4270 | 4270 | } |
4271 | 4271 | // Email configuration settings |
@@ -4328,11 +4328,11 @@ discard block |
||
4328 | 4328 | $msg .= '</table><br />'; |
4329 | 4329 | |
4330 | 4330 | |
4331 | - $msg1 = str_replace("#exercise#", $this->exercise, $msg); |
|
4332 | - $msg = str_replace("#firstName#", $user_info['firstname'],$msg1); |
|
4333 | - $msg1 = str_replace("#lastName#", $user_info['lastname'],$msg); |
|
4334 | - $msg = str_replace("#mail#", $user_info['email'],$msg1); |
|
4335 | - $msg = str_replace("#course#", $course_info['name'],$msg1); |
|
4331 | + $msg1 = str_replace("#exercise#", $this->exercise, $msg); |
|
4332 | + $msg = str_replace("#firstName#", $user_info['firstname'], $msg1); |
|
4333 | + $msg1 = str_replace("#lastName#", $user_info['lastname'], $msg); |
|
4334 | + $msg = str_replace("#mail#", $user_info['email'], $msg1); |
|
4335 | + $msg = str_replace("#course#", $course_info['name'], $msg1); |
|
4336 | 4336 | |
4337 | 4337 | if ($origin != 'learnpath') { |
4338 | 4338 | $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
@@ -4363,7 +4363,7 @@ discard block |
||
4363 | 4363 | |
4364 | 4364 | function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id) |
4365 | 4365 | { |
4366 | - if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { |
|
4366 | + if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) { |
|
4367 | 4367 | return null; |
4368 | 4368 | } |
4369 | 4369 | // Email configuration settings |
@@ -4387,7 +4387,7 @@ discard block |
||
4387 | 4387 | $answer_type = $item['answer_type']; |
4388 | 4388 | |
4389 | 4389 | if (!empty($question) && !empty($answer) && $answer_type == ORAL_EXPRESSION) { |
4390 | - $oral_question_list.='<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">' |
|
4390 | + $oral_question_list .= '<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">' |
|
4391 | 4391 | .'<tr>' |
4392 | 4392 | .'<td width="220" valign="top" bgcolor="#E5EDF8"> '.get_lang('Question').'</td>' |
4393 | 4393 | .'<td width="473" valign="top" bgcolor="#F3F3F3">'.$question.'</td>' |
@@ -4420,7 +4420,7 @@ discard block |
||
4420 | 4420 | .'<td> #mail#</td>' |
4421 | 4421 | .'</tr>' |
4422 | 4422 | .'</table>'; |
4423 | - $msg .= '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'),$oral_question_list).'<br />'; |
|
4423 | + $msg .= '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'), $oral_question_list).'<br />'; |
|
4424 | 4424 | $msg1 = str_replace("#exercise#", $this->exercise, $msg); |
4425 | 4425 | $msg = str_replace("#firstName#", $user_info['firstname'], $msg1); |
4426 | 4426 | $msg1 = str_replace("#lastName#", $user_info['lastname'], $msg); |
@@ -4428,7 +4428,7 @@ discard block |
||
4428 | 4428 | $msg = str_replace("#course#", $course_info['name'], $msg1); |
4429 | 4429 | |
4430 | 4430 | if ($origin != 'learnpath') { |
4431 | - $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
|
4431 | + $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
|
4432 | 4432 | } |
4433 | 4433 | $msg1 = str_replace("#url#", $url_email, $msg); |
4434 | 4434 | $mail_content = $msg1; |
@@ -4496,10 +4496,10 @@ discard block |
||
4496 | 4496 | } |
4497 | 4497 | $html = '<div class="question-result">'; |
4498 | 4498 | $html .= Display::page_header( |
4499 | - Display::return_icon('test-quiz.png', get_lang('Result'),null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result') |
|
4499 | + Display::return_icon('test-quiz.png', get_lang('Result'), null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result') |
|
4500 | 4500 | ); |
4501 | 4501 | $html .= Display::description($array); |
4502 | - $html .="</div>"; |
|
4502 | + $html .= "</div>"; |
|
4503 | 4503 | return $html; |
4504 | 4504 | } |
4505 | 4505 | |
@@ -4616,7 +4616,7 @@ discard block |
||
4616 | 4616 | false, |
4617 | 4617 | $objExercise->selectPropagateNeg() |
4618 | 4618 | ); |
4619 | - $totalScore += $question_result['score']; |
|
4619 | + $totalScore += $question_result['score']; |
|
4620 | 4620 | } |
4621 | 4621 | |
4622 | 4622 | if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) { |
@@ -4760,7 +4760,7 @@ discard block |
||
4760 | 4760 | } |
4761 | 4761 | } |
4762 | 4762 | |
4763 | - if (!empty($message)){ |
|
4763 | + if (!empty($message)) { |
|
4764 | 4764 | $message = Display::return_message($message, 'warning', false); |
4765 | 4765 | } |
4766 | 4766 | |
@@ -4774,7 +4774,7 @@ discard block |
||
4774 | 4774 | { |
4775 | 4775 | $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM); |
4776 | 4776 | $sql = "SELECT max_score FROM $TBL_LP_ITEM |
4777 | - WHERE c_id = {$this->course_id} AND item_type = '" . TOOL_QUIZ . "' AND path = '{$this->id}'"; |
|
4777 | + WHERE c_id = {$this->course_id} AND item_type = '".TOOL_QUIZ."' AND path = '{$this->id}'"; |
|
4778 | 4778 | $result = Database::query($sql); |
4779 | 4779 | if (Database::num_rows($result) > 0) { |
4780 | 4780 | return true; |
@@ -4940,7 +4940,7 @@ discard block |
||
4940 | 4940 | $sql_track = "SELECT * FROM $track_exercises WHERE exe_id = $exe_id "; |
4941 | 4941 | $result = Database::query($sql_track); |
4942 | 4942 | $new_array = array(); |
4943 | - if (Database::num_rows($result) > 0 ) { |
|
4943 | + if (Database::num_rows($result) > 0) { |
|
4944 | 4944 | $new_array = Database::fetch_array($result, 'ASSOC'); |
4945 | 4945 | |
4946 | 4946 | $new_array['duration'] = null; |
@@ -4952,11 +4952,11 @@ discard block |
||
4952 | 4952 | $start_date = api_strtotime($start_date, 'UTC'); |
4953 | 4953 | $end_date = api_strtotime($end_date, 'UTC'); |
4954 | 4954 | if ($start_date && $end_date) { |
4955 | - $mytime = $end_date- $start_date; |
|
4955 | + $mytime = $end_date - $start_date; |
|
4956 | 4956 | $new_learnpath_item = new learnpathItem(null); |
4957 | 4957 | $time_attemp = $new_learnpath_item->get_scorm_time('js', $mytime); |
4958 | 4958 | $h = get_lang('h'); |
4959 | - $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp); |
|
4959 | + $time_attemp = str_replace('NaN', '00'.$h.'00\'00"', $time_attemp); |
|
4960 | 4960 | $new_array['duration'] = $time_attemp; |
4961 | 4961 | } |
4962 | 4962 | } |
@@ -4978,7 +4978,7 @@ discard block |
||
4978 | 4978 | $result = Database::query($sql); |
4979 | 4979 | } |
4980 | 4980 | } else { |
4981 | - $remind_list = explode(',',$exercise_info['questions_to_check']); |
|
4981 | + $remind_list = explode(',', $exercise_info['questions_to_check']); |
|
4982 | 4982 | |
4983 | 4983 | $remind_list_string = ''; |
4984 | 4984 | if ($action == 'add') { |
@@ -4990,7 +4990,7 @@ discard block |
||
4990 | 4990 | } |
4991 | 4991 | $remind_list_string = implode(',', $remind_list); |
4992 | 4992 | } |
4993 | - } elseif ($action == 'delete') { |
|
4993 | + } elseif ($action == 'delete') { |
|
4994 | 4994 | if (!empty($remind_list)) { |
4995 | 4995 | if (in_array($question_id, $remind_list)) { |
4996 | 4996 | $remind_list = array_flip($remind_list); |
@@ -5091,7 +5091,7 @@ discard block |
||
5091 | 5091 | public function get_max_score() |
5092 | 5092 | { |
5093 | 5093 | $out_max_score = 0; |
5094 | - $tab_question_list = $this->selectQuestionList(true); // list of question's id !!! the array key start at 1 !!! |
|
5094 | + $tab_question_list = $this->selectQuestionList(true); // list of question's id !!! the array key start at 1 !!! |
|
5095 | 5095 | // test is randomQuestions - see field random of test |
5096 | 5096 | if ($this->random > 0 && $this->randomByCat == 0) { |
5097 | 5097 | $nb_random_questions = $this->random; |
@@ -10,6 +10,10 @@ |
||
10 | 10 | if ( count( get_included_files() ) == 1 ) die( '---' ); |
11 | 11 | |
12 | 12 | if (!function_exists('mime_content_type')) { |
13 | + |
|
14 | + /** |
|
15 | + * @param string $filename |
|
16 | + */ |
|
13 | 17 | function mime_content_type($filename) { |
14 | 18 | return DocumentManager::file_get_mime_type((string)$filename); |
15 | 19 | } |
@@ -1,18 +1,18 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* For licensing terms, see /license.txt */ |
3 | 3 | /** |
4 | - * @author Claro Team <[email protected]> |
|
5 | - * @author Yannick Warnier <[email protected]> - updated ImsAnswerHotspot to match QTI norms |
|
6 | - * @author César Perales <[email protected]> Updated function names and import files for Aiken format support |
|
7 | - * @package chamilo.exercise |
|
8 | - */ |
|
4 | + * @author Claro Team <[email protected]> |
|
5 | + * @author Yannick Warnier <[email protected]> - updated ImsAnswerHotspot to match QTI norms |
|
6 | + * @author César Perales <[email protected]> Updated function names and import files for Aiken format support |
|
7 | + * @package chamilo.exercise |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | if ( count( get_included_files() ) == 1 ) die( '---' ); |
11 | 11 | |
12 | 12 | if (!function_exists('mime_content_type')) { |
13 | - function mime_content_type($filename) { |
|
14 | - return DocumentManager::file_get_mime_type((string)$filename); |
|
15 | - } |
|
13 | + function mime_content_type($filename) { |
|
14 | + return DocumentManager::file_get_mime_type((string)$filename); |
|
15 | + } |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | case MCUA : |
31 | 31 | $answer = new AikenAnswerMultipleChoice($this->id); |
32 | - return $answer; |
|
32 | + return $answer; |
|
33 | 33 | default : |
34 | 34 | $answer = null; |
35 | 35 | break; |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | } |
39 | 39 | function createAnswersForm($form) |
40 | 40 | { |
41 | - return true; |
|
41 | + return true; |
|
42 | 42 | } |
43 | 43 | function processAnswersCreation($form) |
44 | 44 | { |
45 | - return true; |
|
45 | + return true; |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 |
@@ -7,11 +7,11 @@ discard block |
||
7 | 7 | * @package chamilo.exercise |
8 | 8 | */ |
9 | 9 | |
10 | -if ( count( get_included_files() ) == 1 ) die( '---' ); |
|
10 | +if (count(get_included_files()) == 1) die('---'); |
|
11 | 11 | |
12 | 12 | if (!function_exists('mime_content_type')) { |
13 | 13 | function mime_content_type($filename) { |
14 | - return DocumentManager::file_get_mime_type((string)$filename); |
|
14 | + return DocumentManager::file_get_mime_type((string) $filename); |
|
15 | 15 | } |
16 | 16 | } |
17 | 17 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function setAnswer() |
27 | 27 | { |
28 | - switch($this->type) |
|
28 | + switch ($this->type) |
|
29 | 29 | { |
30 | 30 | case MCUA : |
31 | 31 | $answer = new AikenAnswerMultipleChoice($this->id); |
@@ -7,7 +7,9 @@ |
||
7 | 7 | * @package chamilo.exercise |
8 | 8 | */ |
9 | 9 | |
10 | -if ( count( get_included_files() ) == 1 ) die( '---' ); |
|
10 | +if ( count( get_included_files() ) == 1 ) { |
|
11 | + die( '---' ); |
|
12 | +} |
|
11 | 13 | |
12 | 14 | if (!function_exists('mime_content_type')) { |
13 | 15 | function mime_content_type($filename) { |
@@ -55,6 +55,8 @@ discard block |
||
55 | 55 | * Gets the uploaded file (from $_FILES) and unzip it to the given directory |
56 | 56 | * @param string The directory where to do the work |
57 | 57 | * @param string The path of the temporary directory where the exercise was uploaded and unzipped |
58 | + * @param string $baseWorkDir |
|
59 | + * @param string $uploadPath |
|
58 | 60 | * @return bool True on success, false on failure |
59 | 61 | */ |
60 | 62 | function get_and_unzip_uploaded_exercise($baseWorkDir, $uploadPath) { |
@@ -229,7 +231,10 @@ discard block |
||
229 | 231 | * @param string Path to the directory with the file to be parsed (without final /) |
230 | 232 | * @param string Name of the last directory part for the file (without /) |
231 | 233 | * @param string Name of the file to be parsed (including extension) |
232 | - * @return mixed True on success, error message on error |
|
234 | + * @param string $exercisePath |
|
235 | + * @param string $file |
|
236 | + * @param string $questionFile |
|
237 | + * @return string|boolean True on success, error message on error |
|
233 | 238 | * @assert ('','','') === false |
234 | 239 | */ |
235 | 240 | function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile) { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $dir .= '/'; |
26 | 26 | |
27 | 27 | do { |
28 | - $path = $dir . $prefix . mt_rand(0, 9999999); |
|
28 | + $path = $dir.$prefix.mt_rand(0, 9999999); |
|
29 | 29 | } while (!mkdir($path, $mode)); |
30 | 30 | |
31 | 31 | return $path; |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | function aiken_display_form($msg = '') { |
39 | 39 | $name_tools = get_lang('ImportAikenQuiz'); |
40 | 40 | $form = '<div class="actions">'; |
41 | - $form .= '<a href="exercise.php?show=test">' . Display :: return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
41 | + $form .= '<a href="exercise.php?show=test">'.Display :: return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
42 | 42 | $form .= '</div>'; |
43 | 43 | $form .= $msg; |
44 | - $form_validator = new FormValidator('aiken_upload', 'post',api_get_self()."?".api_get_cidreq(), null, array('enctype' => 'multipart/form-data') ); |
|
44 | + $form_validator = new FormValidator('aiken_upload', 'post', api_get_self()."?".api_get_cidreq(), null, array('enctype' => 'multipart/form-data')); |
|
45 | 45 | $form_validator->addElement('header', $name_tools); |
46 | 46 | $form_validator->addElement('text', 'total_weight', get_lang('TotalWeight')); |
47 | 47 | $form_validator->addElement('file', 'userFile', get_lang('DownloadFile')); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | global $record_item_body; |
90 | 90 | // used to specify the question directory where files could be found in relation in any question |
91 | 91 | global $questionTempDir; |
92 | - $archive_path = api_get_path(SYS_ARCHIVE_PATH) . 'aiken'; |
|
92 | + $archive_path = api_get_path(SYS_ARCHIVE_PATH).'aiken'; |
|
93 | 93 | $baseWorkDir = $archive_path; |
94 | 94 | |
95 | 95 | if (!is_dir($baseWorkDir)) { |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | |
131 | 131 | // Parse every subdirectory to search txt question files |
132 | 132 | while (false !== ($file = readdir($exerciseHandle))) { |
133 | - if (is_dir($baseWorkDir . '/' . $file) && $file != "." && $file != "..") { |
|
133 | + if (is_dir($baseWorkDir.'/'.$file) && $file != "." && $file != "..") { |
|
134 | 134 | //find each manifest for each question repository found |
135 | - $questionHandle = opendir($baseWorkDir . '/' . $file); |
|
135 | + $questionHandle = opendir($baseWorkDir.'/'.$file); |
|
136 | 136 | while (false !== ($questionFile = readdir($questionHandle))) { |
137 | 137 | if (preg_match('/.txt$/i', $questionFile)) { |
138 | 138 | $result = aiken_parse_file( |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $result = 'NoTxtFileFoundInTheZip'; |
155 | 155 | } |
156 | 156 | |
157 | - if ($result !== true ) { |
|
157 | + if ($result !== true) { |
|
158 | 158 | return $result; |
159 | 159 | } |
160 | 160 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | // Delete the temp dir where the exercise was unzipped |
218 | - my_delete($baseWorkDir . $uploadPath); |
|
218 | + my_delete($baseWorkDir.$uploadPath); |
|
219 | 219 | $operation = $last_exercise_id; |
220 | 220 | } |
221 | 221 | |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile) { |
236 | 236 | global $questionTempDir; |
237 | 237 | |
238 | - $questionTempDir = $exercisePath . '/' . $file . '/'; |
|
239 | - $questionFilePath = $questionTempDir . $questionFile; |
|
238 | + $questionTempDir = $exercisePath.'/'.$file.'/'; |
|
239 | + $questionFilePath = $questionTempDir.$questionFile; |
|
240 | 240 | |
241 | 241 | if (!is_file($questionFilePath)) { |
242 | 242 | return 'FileNotFound'; |
@@ -248,13 +248,13 @@ discard block |
||
248 | 248 | $answers_array = array(); |
249 | 249 | $new_question = true; |
250 | 250 | foreach ($data as $line => $info) { |
251 | - if ($question_index > 0 && $new_question == true && preg_match('/^(\r)?\n/',$info)) { |
|
251 | + if ($question_index > 0 && $new_question == true && preg_match('/^(\r)?\n/', $info)) { |
|
252 | 252 | // double empty line |
253 | 253 | continue; |
254 | 254 | } |
255 | 255 | $new_question = false; |
256 | 256 | //make sure it is transformed from iso-8859-1 to utf-8 if in that form |
257 | - if (!mb_check_encoding($info,'utf-8') && mb_check_encoding($info,'iso-8859-1')) { |
|
257 | + if (!mb_check_encoding($info, 'utf-8') && mb_check_encoding($info, 'iso-8859-1')) { |
|
258 | 258 | $info = utf8_encode($info); |
259 | 259 | } |
260 | 260 | $exercise_info['question'][$question_index]['type'] = 'MCUA'; |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | } elseif (preg_match('/^ETIQUETAS:\s?([A-Z])\s?/', $info, $matches)) { |
287 | 287 | //TAGS for chamilo >= 1.10 (Spanish e-ducativa format) |
288 | 288 | $exercise_info['question'][$question_index]['answer_tags'] = explode(',', $matches[1]); |
289 | - } elseif (preg_match('/^(\r)?\n/',$info)) { |
|
289 | + } elseif (preg_match('/^(\r)?\n/', $info)) { |
|
290 | 290 | //moving to next question (tolerate \r\n or just \n) |
291 | 291 | if (empty($exercise_info['question'][$question_index]['correct_answers'])) { |
292 | 292 | error_log('Aiken: Error in question index '.$question_index.': no correct answer defined'); |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | $exercise_info['question'][$question_index]['title'] = $info; |
307 | 307 | } else { |
308 | 308 | //Question itself (use a 100-chars long title and a larger description) |
309 | - $exercise_info['question'][$question_index]['title'] = trim(substr($info, 0, 100)) . '...'; |
|
309 | + $exercise_info['question'][$question_index]['title'] = trim(substr($info, 0, 100)).'...'; |
|
310 | 310 | $exercise_info['question'][$question_index]['description'] = $info; |
311 | 311 | } |
312 | 312 | } else { |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | } |
317 | 317 | $total_questions = count($exercise_info['question']); |
318 | 318 | $total_weight = (!empty($_POST['total_weight'])) ? intval($_POST['total_weight']) : 20; |
319 | - foreach ($exercise_info['question'] as $key => $question) { |
|
319 | + foreach ($exercise_info['question'] as $key => $question) { |
|
320 | 320 | $exercise_info['question'][$key]['weighting'][current(array_keys($exercise_info['question'][$key]['weighting']))] = $total_weight / $total_questions; |
321 | 321 | } |
322 | 322 | return true; |
@@ -10,8 +10,9 @@ discard block |
||
10 | 10 | /** |
11 | 11 | * Security check |
12 | 12 | */ |
13 | -if (count(get_included_files()) == 1) |
|
13 | +if (count(get_included_files()) == 1) { |
|
14 | 14 | die('---'); |
15 | +} |
|
15 | 16 | |
16 | 17 | /** |
17 | 18 | * Creates a temporary directory |
@@ -21,8 +22,9 @@ discard block |
||
21 | 22 | * @return string |
22 | 23 | */ |
23 | 24 | function tempdir($dir, $prefix = 'tmp', $mode = 0777) { |
24 | - if (substr($dir, -1) != '/') |
|
25 | - $dir .= '/'; |
|
25 | + if (substr($dir, -1) != '/') { |
|
26 | + $dir .= '/'; |
|
27 | + } |
|
26 | 28 | |
27 | 29 | do { |
28 | 30 | $path = $dir . $prefix . mt_rand(0, 9999999); |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | } |
79 | 79 | } |
80 | 80 | /** |
81 | - * Main function to import the Aiken exercise |
|
82 | - * @return mixed True on success, error message on failure |
|
83 | - */ |
|
81 | + * Main function to import the Aiken exercise |
|
82 | + * @return mixed True on success, error message on failure |
|
83 | + */ |
|
84 | 84 | function aiken_import_exercise($file) |
85 | 85 | { |
86 | 86 | global $exercise_info; |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $correct_answer_index = array_search($matches[1], $answers_array); |
282 | 282 | $exercise_info['question'][$question_index]['title'] = $matches[1]; |
283 | 283 | } elseif (preg_match('/^TAGS:\s?([A-Z])\s?/', $info, $matches)) { |
284 | - //TAGS for chamilo >= 1.10 |
|
284 | + //TAGS for chamilo >= 1.10 |
|
285 | 285 | $exercise_info['question'][$question_index]['answer_tags'] = explode(',', $matches[1]); |
286 | 286 | } elseif (preg_match('/^ETIQUETAS:\s?([A-Z])\s?/', $info, $matches)) { |
287 | 287 | //TAGS for chamilo >= 1.10 (Spanish e-ducativa format) |
@@ -30,6 +30,8 @@ discard block |
||
30 | 30 | * Unzip the exercise in the temp folder |
31 | 31 | * @param string The path of the temporary directory where the exercise was uploaded and unzipped |
32 | 32 | * @param string |
33 | + * @param string $baseWorkDir |
|
34 | + * @param string $uploadPath |
|
33 | 35 | * @return bool |
34 | 36 | */ |
35 | 37 | function get_and_unzip_uploaded_exercise($baseWorkDir, $uploadPath) |
@@ -217,9 +219,9 @@ discard block |
||
217 | 219 | |
218 | 220 | /** |
219 | 221 | * Parses a given XML file and fills global arrays with the elements |
220 | - * @param $exercisePath |
|
221 | - * @param $file |
|
222 | - * @param $questionFile |
|
222 | + * @param string $exercisePath |
|
223 | + * @param string $file |
|
224 | + * @param string $questionFile |
|
223 | 225 | * @return bool |
224 | 226 | */ |
225 | 227 | function parse_file($exercisePath, $file, $questionFile) |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | do { |
23 | - $path = $dir . $prefix . mt_rand(0, 9999999); |
|
23 | + $path = $dir.$prefix.mt_rand(0, 9999999); |
|
24 | 24 | } while (!mkdir($path, $mode)); |
25 | 25 | |
26 | 26 | return $path; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | // used to specify the question directory where files could be found in relation in any question |
75 | 75 | global $questionTempDir; |
76 | 76 | |
77 | - $archive_path = api_get_path(SYS_ARCHIVE_PATH) . 'qti2'; |
|
77 | + $archive_path = api_get_path(SYS_ARCHIVE_PATH).'qti2'; |
|
78 | 78 | $baseWorkDir = $archive_path; |
79 | 79 | |
80 | 80 | if (!is_dir($baseWorkDir)) { |
@@ -118,14 +118,14 @@ discard block |
||
118 | 118 | // parse every subdirectory to search xml question files |
119 | 119 | while (false !== ($file = readdir($exerciseHandle))) { |
120 | 120 | |
121 | - if (is_dir($baseWorkDir . '/' . $file) && $file != "." && $file != "..") { |
|
121 | + if (is_dir($baseWorkDir.'/'.$file) && $file != "." && $file != "..") { |
|
122 | 122 | |
123 | 123 | // Find each manifest for each question repository found |
124 | - $questionHandle = opendir($baseWorkDir . '/' . $file); |
|
124 | + $questionHandle = opendir($baseWorkDir.'/'.$file); |
|
125 | 125 | while (false !== ($questionFile = readdir($questionHandle))) { |
126 | 126 | if (preg_match('/.xml$/i', $questionFile)) { |
127 | 127 | $result = parse_file($baseWorkDir, $file, $questionFile); |
128 | - $filePath = $baseWorkDir . $file; |
|
128 | + $filePath = $baseWorkDir.$file; |
|
129 | 129 | $file_found = true; |
130 | 130 | } |
131 | 131 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | // Else ignore file |
135 | 135 | $result = parse_file($baseWorkDir, '', $file); |
136 | - $filePath = $baseWorkDir . '/' . $file; |
|
136 | + $filePath = $baseWorkDir.'/'.$file; |
|
137 | 137 | $file_found = true; |
138 | 138 | } |
139 | 139 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | // delete the temp dir where the exercise was unzipped |
203 | - my_delete($baseWorkDir . $uploadPath); |
|
203 | + my_delete($baseWorkDir.$uploadPath); |
|
204 | 204 | return $last_exercise_id; |
205 | 205 | } |
206 | 206 | |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | global $record_item_body; |
229 | 229 | global $questionTempDir; |
230 | 230 | |
231 | - $questionTempDir = $exercisePath . '/' . $file . '/'; |
|
232 | - $questionFilePath = $questionTempDir . $questionFile; |
|
231 | + $questionTempDir = $exercisePath.'/'.$file.'/'; |
|
232 | + $questionFilePath = $questionTempDir.$questionFile; |
|
233 | 233 | |
234 | 234 | if (!($fp = fopen($questionFilePath, 'r'))) { |
235 | 235 | Display:: display_error_message(get_lang('Error opening question\'s XML file')); |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | if ($record_item_body) { |
327 | 327 | |
328 | 328 | if ((!in_array($current_element, $non_HTML_tag_to_avoid))) { |
329 | - $current_question_item_body .= "<" . $name; |
|
329 | + $current_question_item_body .= "<".$name; |
|
330 | 330 | |
331 | 331 | foreach ($attributes as $attribute_name => $attribute_value) { |
332 | - $current_question_item_body .= " " . $attribute_name . "=\"" . $attribute_value . "\""; |
|
332 | + $current_question_item_body .= " ".$attribute_name."=\"".$attribute_value."\""; |
|
333 | 333 | } |
334 | 334 | $current_question_item_body .= ">"; |
335 | 335 | } else { |
@@ -338,11 +338,11 @@ discard block |
||
338 | 338 | |
339 | 339 | if ($current_element == 'INLINECHOICEINTERACTION') { |
340 | 340 | |
341 | - $current_question_item_body .= "**claroline_start**" . $attributes['RESPONSEIDENTIFIER'] . "**claroline_end**"; |
|
341 | + $current_question_item_body .= "**claroline_start**".$attributes['RESPONSEIDENTIFIER']."**claroline_end**"; |
|
342 | 342 | } |
343 | 343 | if ($current_element == 'TEXTENTRYINTERACTION') { |
344 | 344 | $correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id]; |
345 | - $current_question_item_body .= "[" . $correct_answer_value . "]"; |
|
345 | + $current_question_item_body .= "[".$correct_answer_value."]"; |
|
346 | 346 | |
347 | 347 | } |
348 | 348 | if ($current_element == 'BR') { |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | //treat the record of the full content of itembody tag : |
458 | 458 | |
459 | 459 | if ($record_item_body && (!in_array($current_element, $non_HTML_tag_to_avoid))) { |
460 | - $current_question_item_body .= "</" . $name . ">"; |
|
460 | + $current_question_item_body .= "</".$name.">"; |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | switch ($name) { |
@@ -515,14 +515,14 @@ discard block |
||
515 | 515 | if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'])) { |
516 | 516 | $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] = trim($data); |
517 | 517 | } else { |
518 | - $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= '' . trim($data); |
|
518 | + $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= ''.trim($data); |
|
519 | 519 | } |
520 | 520 | break; |
521 | 521 | case 'FEEDBACKINLINE': |
522 | 522 | if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'])) { |
523 | 523 | $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] = trim($data); |
524 | 524 | } else { |
525 | - $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' ' . trim($data); |
|
525 | + $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' '.trim($data); |
|
526 | 526 | } |
527 | 527 | break; |
528 | 528 | case 'SIMPLEASSOCIABLECHOICE': |
@@ -546,8 +546,8 @@ discard block |
||
546 | 546 | $answer_identifier = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id]; |
547 | 547 | if ($current_inlinechoice_id == $answer_identifier) { |
548 | 548 | $current_question_item_body = str_replace( |
549 | - "**claroline_start**" . $current_answer_id . "**claroline_end**", |
|
550 | - "[" . $data . "]", |
|
549 | + "**claroline_start**".$current_answer_id."**claroline_end**", |
|
550 | + "[".$data."]", |
|
551 | 551 | $current_question_item_body |
552 | 552 | ); |
553 | 553 | } else { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Constructor. |
34 | 34 | * |
35 | - * @param $question Ims2Question object we want to export. |
|
35 | + * @param Ims2Question $question Ims2Question object we want to export. |
|
36 | 36 | */ |
37 | 37 | function ImsAssessmentItem($question) |
38 | 38 | { |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * This is a default behaviour, some classes may want to override this. |
102 | 102 | * |
103 | 103 | * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
104 | - * @return A string, the XML flow for an Item. |
|
104 | + * @return string string, the XML flow for an Item. |
|
105 | 105 | */ |
106 | 106 | function export($standalone = false) |
107 | 107 | { |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | /** |
156 | 156 | * Constructor. |
157 | - * @param $exe The Exercise instance to export |
|
157 | + * @param Exercise $exe The Exercise instance to export |
|
158 | 158 | * @author Amand Tihon <[email protected]> |
159 | 159 | */ |
160 | 160 | function ImsSection($exe) |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * Export the exercise in IMS/QTI. |
240 | 240 | * |
241 | 241 | * @param bool $standalone Wether it should include XML tag and DTD line. |
242 | - * @return a string containing the XML flow |
|
242 | + * @return string string containing the XML flow |
|
243 | 243 | * @author Amand Tihon <[email protected]> |
244 | 244 | */ |
245 | 245 | function export($standalone) |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * This is a default behaviour, some classes may want to override this. |
384 | 384 | * |
385 | 385 | * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
386 | - * @return A string, the XML flow for an Item. |
|
386 | + * @return string string, the XML flow for an Item. |
|
387 | 387 | * @author Amand Tihon <[email protected]> |
388 | 388 | */ |
389 | 389 | function export($standalone = False) |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * |
418 | 418 | * @param int $exerciseId The exercise to export |
419 | 419 | * @param boolean $standalone Wether it should include XML tag and DTD line. |
420 | - * @return The XML as a string, or an empty string if there's no exercise with given ID. |
|
420 | + * @return string XML as a string, or an empty string if there's no exercise with given ID. |
|
421 | 421 | */ |
422 | 422 | function export_exercise_to_qti($exerciseId, $standalone = true) |
423 | 423 | { |
@@ -474,6 +474,9 @@ discard block |
||
474 | 474 | return htmlspecialchars($text); |
475 | 475 | } |
476 | 476 | |
477 | +/** |
|
478 | + * @param string $text |
|
479 | + */ |
|
477 | 480 | function cleanAttribute($text) |
478 | 481 | { |
479 | 482 | return $text; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | /** |
9 | 9 | * Code |
10 | 10 | */ |
11 | -require dirname(__FILE__) . '/qti2_classes.php'; |
|
11 | +require dirname(__FILE__).'/qti2_classes.php'; |
|
12 | 12 | /** |
13 | 13 | * Classes |
14 | 14 | */ |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | { |
39 | 39 | $this->question = $question; |
40 | 40 | $this->answer = $this->question->setAnswer(); |
41 | - $this->questionIdent = "QST_" . $question->id ; |
|
41 | + $this->questionIdent = "QST_".$question->id; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | function start_item_body() |
75 | 75 | { |
76 | - return ' <itemBody>' . "\n"; |
|
76 | + return ' <itemBody>'."\n"; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | function add_response_processing() |
94 | 94 | { |
95 | - return ' <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>' . "\n"; |
|
95 | + return ' <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>'."\n"; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $head = $foot = ""; |
109 | 109 | |
110 | 110 | if ($standalone) { |
111 | - $head = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . "\n"; |
|
111 | + $head = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'."\n"; |
|
112 | 112 | } |
113 | 113 | //TODO understand why answer might be a non-object sometimes |
114 | 114 | if (!is_object($this->answer)) { |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | function start_section() |
166 | 166 | { |
167 | - $out = '<section ident="EXO_' . $this->exercise->selectId() . '" title="' .cleanAttribute(formatExerciseQtiDescription($this->exercise->selectTitle())) . '">' . "\n"; |
|
167 | + $out = '<section ident="EXO_'.$this->exercise->selectId().'" title="'.cleanAttribute(formatExerciseQtiDescription($this->exercise->selectTitle())).'">'."\n"; |
|
168 | 168 | return $out; |
169 | 169 | } |
170 | 170 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | // return exercise duration in ISO8601 format. |
181 | 181 | $minutes = floor($max_time / 60); |
182 | 182 | $seconds = $max_time % 60; |
183 | - return '<duration>PT' . $minutes . 'M' . $seconds . "S</duration>\n"; |
|
183 | + return '<duration>PT'.$minutes.'M'.$seconds."S</duration>\n"; |
|
184 | 184 | } else { |
185 | 185 | return ''; |
186 | 186 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | function export_presentation() |
194 | 194 | { |
195 | 195 | $out = "<presentation_material><flow_mat><material>\n" |
196 | - . " <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n" |
|
196 | + . " <mattext><![CDATA[".formatExerciseQtiDescription($this->exercise->selectDescription())."]]></mattext>\n" |
|
197 | 197 | . "</material></flow_mat></presentation_material>\n"; |
198 | 198 | return $out; |
199 | 199 | } |
@@ -207,14 +207,14 @@ discard block |
||
207 | 207 | { |
208 | 208 | $out = ''; |
209 | 209 | if ($n = $this->exercise->getShuffle()) { |
210 | - $out.= "<selection_ordering>" |
|
210 | + $out .= "<selection_ordering>" |
|
211 | 211 | . " <selection>\n" |
212 | - . " <selection_number>" . $n . "</selection_number>\n" |
|
212 | + . " <selection_number>".$n."</selection_number>\n" |
|
213 | 213 | . " </selection>\n" |
214 | 214 | . ' <order order_type="Random" />' |
215 | 215 | . "\n</selection_ordering>\n"; |
216 | 216 | } else { |
217 | - $out.= '<selection_ordering sequence_type="Normal">' . "\n" |
|
217 | + $out .= '<selection_ordering sequence_type="Normal">'."\n" |
|
218 | 218 | . " <selection />\n" |
219 | 219 | . "</selection_ordering>\n"; |
220 | 220 | } |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | { |
247 | 247 | $head = $foot = ""; |
248 | 248 | if ($standalone) { |
249 | - $head = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>' . "\n" |
|
250 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
249 | + $head = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>'."\n" |
|
250 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">'."\n" |
|
251 | 251 | . "<questestinterop>\n"; |
252 | 252 | $foot = "</questestinterop>\n"; |
253 | 253 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | { |
309 | 309 | $this->question = $question; |
310 | 310 | $this->answer = $question->answer; |
311 | - $this->questionIdent = "QST_" . $question->selectId() ; |
|
311 | + $this->questionIdent = "QST_".$question->selectId(); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | */ |
321 | 321 | function start_item() |
322 | 322 | { |
323 | - return '<item title="' . cleanAttribute(formatExerciseQtiDescription($this->question->selectTitle())) . '" ident="' . $this->questionIdent . '">' . "\n"; |
|
323 | + return '<item title="'.cleanAttribute(formatExerciseQtiDescription($this->question->selectTitle())).'" ident="'.$this->questionIdent.'">'."\n"; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | */ |
344 | 344 | function start_presentation() |
345 | 345 | { |
346 | - return '<presentation label="' . $this->questionIdent . '"><flow>' . "\n" |
|
347 | - . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n"; |
|
346 | + return '<presentation label="'.$this->questionIdent.'"><flow>'."\n" |
|
347 | + . '<material><mattext>'.formatExerciseQtiDescription($this->question->selectDescription())."</mattext></material>\n"; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | */ |
365 | 365 | function start_processing() |
366 | 366 | { |
367 | - return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>' . "\n"; |
|
367 | + return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>'."\n"; |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | $head = $foot = ""; |
393 | 393 | |
394 | 394 | if ($standalone) { |
395 | - $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>' . "\n" |
|
396 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
395 | + $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>'."\n" |
|
396 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">'."\n" |
|
397 | 397 | . "<questestinterop>\n"; |
398 | 398 | $foot = "</questestinterop>\n"; |
399 | 399 | } |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | $question->type = $qst->type; |
448 | 448 | $question->question = $qst->question; |
449 | 449 | $question->description = $qst->description; |
450 | - $question->weighting=$qst->weighting; |
|
451 | - $question->position=$qst->position; |
|
452 | - $question->picture=$qst->picture; |
|
450 | + $question->weighting = $qst->weighting; |
|
451 | + $question->position = $qst->position; |
|
452 | + $question->picture = $qst->picture; |
|
453 | 453 | $ims = new ImsAssessmentItem($question); |
454 | 454 | |
455 | 455 | return $ims->export($standalone); |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* For licensing terms, see /license.txt */ |
3 | 3 | /** |
4 | - * @author Claro Team <[email protected]> |
|
5 | - * @author Yannick Warnier <[email protected]> |
|
6 | - * @package chamilo.exercise |
|
7 | - */ |
|
4 | + * @author Claro Team <[email protected]> |
|
5 | + * @author Yannick Warnier <[email protected]> |
|
6 | + * @package chamilo.exercise |
|
7 | + */ |
|
8 | 8 | /** |
9 | - * Code |
|
10 | - */ |
|
9 | + * Code |
|
10 | + */ |
|
11 | 11 | require dirname(__FILE__) . '/qti2_classes.php'; |
12 | 12 | /** |
13 | - * Classes |
|
13 | + * Classes |
|
14 | 14 | */ |
15 | 15 | |
16 | 16 | /** |
@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @param $question Ims2Question object we want to export. |
36 | 36 | */ |
37 | - function ImsAssessmentItem($question) |
|
38 | - { |
|
37 | + function ImsAssessmentItem($question) |
|
38 | + { |
|
39 | 39 | $this->question = $question; |
40 | 40 | $this->answer = $this->question->setAnswer(); |
41 | 41 | $this->questionIdent = "QST_" . $question->id ; |
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Start the XML flow. |
|
46 | - * |
|
47 | - * This opens the <item> block, with correct attributes. |
|
48 | - * |
|
49 | - */ |
|
50 | - function start_item() |
|
51 | - { |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Start the XML flow. |
|
46 | + * |
|
47 | + * This opens the <item> block, with correct attributes. |
|
48 | + * |
|
49 | + */ |
|
50 | + function start_item() |
|
51 | + { |
|
52 | 52 | $string = '<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1" |
53 | 53 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
54 | 54 | xsi:schemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p1 imsqti_v2p1.xsd" |
@@ -56,55 +56,55 @@ discard block |
||
56 | 56 | title="'.htmlspecialchars(formatExerciseQtiTitle($this->question->selectTitle())).'">'."\n"; |
57 | 57 | |
58 | 58 | return $string; |
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * End the XML flow, closing the </item> tag. |
|
63 | - * |
|
64 | - */ |
|
65 | - function end_item() |
|
66 | - { |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * End the XML flow, closing the </item> tag. |
|
63 | + * |
|
64 | + */ |
|
65 | + function end_item() |
|
66 | + { |
|
67 | 67 | return "</assessmentItem>\n"; |
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Start the itemBody |
|
72 | - * |
|
73 | - */ |
|
74 | - function start_item_body() |
|
75 | - { |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Start the itemBody |
|
72 | + * |
|
73 | + */ |
|
74 | + function start_item_body() |
|
75 | + { |
|
76 | 76 | return ' <itemBody>' . "\n"; |
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * End the itemBody part. |
|
81 | - * |
|
82 | - */ |
|
83 | - function end_item_body() |
|
84 | - { |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * End the itemBody part. |
|
81 | + * |
|
82 | + */ |
|
83 | + function end_item_body() |
|
84 | + { |
|
85 | 85 | return " </itemBody>\n"; |
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * add the response processing template used. |
|
90 | - * |
|
91 | - */ |
|
92 | - |
|
93 | - function add_response_processing() |
|
94 | - { |
|
95 | - return ' <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>' . "\n"; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Export the question as an IMS/QTI Item. |
|
100 | - * |
|
101 | - * This is a default behaviour, some classes may want to override this. |
|
102 | - * |
|
103 | - * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
104 | - * @return A string, the XML flow for an Item. |
|
105 | - */ |
|
106 | - function export($standalone = false) |
|
107 | - { |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * add the response processing template used. |
|
90 | + * |
|
91 | + */ |
|
92 | + |
|
93 | + function add_response_processing() |
|
94 | + { |
|
95 | + return ' <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>' . "\n"; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * Export the question as an IMS/QTI Item. |
|
100 | + * |
|
101 | + * This is a default behaviour, some classes may want to override this. |
|
102 | + * |
|
103 | + * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
104 | + * @return A string, the XML flow for an Item. |
|
105 | + */ |
|
106 | + function export($standalone = false) |
|
107 | + { |
|
108 | 108 | $head = $foot = ""; |
109 | 109 | |
110 | 110 | if ($standalone) { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | .$foot; |
132 | 132 | |
133 | 133 | return $res; |
134 | - } |
|
134 | + } |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | function export_presentation() |
194 | 194 | { |
195 | 195 | $out = "<presentation_material><flow_mat><material>\n" |
196 | - . " <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n" |
|
197 | - . "</material></flow_mat></presentation_material>\n"; |
|
196 | + . " <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n" |
|
197 | + . "</material></flow_mat></presentation_material>\n"; |
|
198 | 198 | return $out; |
199 | 199 | } |
200 | 200 | |
@@ -208,15 +208,15 @@ discard block |
||
208 | 208 | $out = ''; |
209 | 209 | if ($n = $this->exercise->getShuffle()) { |
210 | 210 | $out.= "<selection_ordering>" |
211 | - . " <selection>\n" |
|
212 | - . " <selection_number>" . $n . "</selection_number>\n" |
|
213 | - . " </selection>\n" |
|
214 | - . ' <order order_type="Random" />' |
|
215 | - . "\n</selection_ordering>\n"; |
|
211 | + . " <selection>\n" |
|
212 | + . " <selection_number>" . $n . "</selection_number>\n" |
|
213 | + . " </selection>\n" |
|
214 | + . ' <order order_type="Random" />' |
|
215 | + . "\n</selection_ordering>\n"; |
|
216 | 216 | } else { |
217 | 217 | $out.= '<selection_ordering sequence_type="Normal">' . "\n" |
218 | - . " <selection />\n" |
|
219 | - . "</selection_ordering>\n"; |
|
218 | + . " <selection />\n" |
|
219 | + . "</selection_ordering>\n"; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | return $out; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | { |
231 | 231 | $out = ""; |
232 | 232 | foreach ($this->exercise->selectQuestionList() as $q) { |
233 | - $out .= export_question_qti($q, false); |
|
233 | + $out .= export_question_qti($q, false); |
|
234 | 234 | } |
235 | 235 | return $out; |
236 | 236 | } |
@@ -247,18 +247,18 @@ discard block |
||
247 | 247 | $head = $foot = ""; |
248 | 248 | if ($standalone) { |
249 | 249 | $head = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>' . "\n" |
250 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
251 | - . "<questestinterop>\n"; |
|
250 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
251 | + . "<questestinterop>\n"; |
|
252 | 252 | $foot = "</questestinterop>\n"; |
253 | 253 | } |
254 | 254 | $out = $head |
255 | - . $this->start_section() |
|
256 | - . $this->export_duration() |
|
257 | - . $this->export_presentation() |
|
258 | - . $this->export_ordering() |
|
259 | - . $this->export_questions() |
|
260 | - . $this->end_section() |
|
261 | - . $foot; |
|
255 | + . $this->start_section() |
|
256 | + . $this->export_duration() |
|
257 | + . $this->export_presentation() |
|
258 | + . $this->export_ordering() |
|
259 | + . $this->export_questions() |
|
260 | + . $this->end_section() |
|
261 | + . $foot; |
|
262 | 262 | |
263 | 263 | return $out; |
264 | 264 | } |
@@ -304,97 +304,97 @@ discard block |
||
304 | 304 | * @param $question The Question object we want to export. |
305 | 305 | * @author Anamd Tihon |
306 | 306 | */ |
307 | - function ImsItem($question) |
|
308 | - { |
|
307 | + function ImsItem($question) |
|
308 | + { |
|
309 | 309 | $this->question = $question; |
310 | 310 | $this->answer = $question->answer; |
311 | 311 | $this->questionIdent = "QST_" . $question->selectId() ; |
312 | - } |
|
313 | - |
|
314 | - /** |
|
315 | - * Start the XML flow. |
|
316 | - * |
|
317 | - * This opens the <item> block, with correct attributes. |
|
318 | - * |
|
319 | - * @author Amand Tihon <[email protected]> |
|
320 | - */ |
|
321 | - function start_item() |
|
322 | - { |
|
312 | + } |
|
313 | + |
|
314 | + /** |
|
315 | + * Start the XML flow. |
|
316 | + * |
|
317 | + * This opens the <item> block, with correct attributes. |
|
318 | + * |
|
319 | + * @author Amand Tihon <[email protected]> |
|
320 | + */ |
|
321 | + function start_item() |
|
322 | + { |
|
323 | 323 | return '<item title="' . cleanAttribute(formatExerciseQtiDescription($this->question->selectTitle())) . '" ident="' . $this->questionIdent . '">' . "\n"; |
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * End the XML flow, closing the </item> tag. |
|
328 | - * |
|
329 | - * @author Amand Tihon <[email protected]> |
|
330 | - */ |
|
331 | - function end_item() |
|
332 | - { |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * End the XML flow, closing the </item> tag. |
|
328 | + * |
|
329 | + * @author Amand Tihon <[email protected]> |
|
330 | + */ |
|
331 | + function end_item() |
|
332 | + { |
|
333 | 333 | return "</item>\n"; |
334 | - } |
|
335 | - |
|
336 | - /** |
|
337 | - * Create the opening, with the question itself. |
|
338 | - * |
|
339 | - * This means it opens the <presentation> but doesn't close it, as this is the role of end_presentation(). |
|
340 | - * In between, the export_responses from the subclass should have been called. |
|
341 | - * |
|
342 | - * @author Amand Tihon <[email protected]> |
|
343 | - */ |
|
344 | - function start_presentation() |
|
345 | - { |
|
334 | + } |
|
335 | + |
|
336 | + /** |
|
337 | + * Create the opening, with the question itself. |
|
338 | + * |
|
339 | + * This means it opens the <presentation> but doesn't close it, as this is the role of end_presentation(). |
|
340 | + * In between, the export_responses from the subclass should have been called. |
|
341 | + * |
|
342 | + * @author Amand Tihon <[email protected]> |
|
343 | + */ |
|
344 | + function start_presentation() |
|
345 | + { |
|
346 | 346 | return '<presentation label="' . $this->questionIdent . '"><flow>' . "\n" |
347 | - . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n"; |
|
348 | - } |
|
349 | - |
|
350 | - /** |
|
351 | - * End the </presentation> part, opened by export_header. |
|
352 | - * |
|
353 | - * @author Amand Tihon <[email protected]> |
|
354 | - */ |
|
355 | - function end_presentation() |
|
356 | - { |
|
347 | + . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n"; |
|
348 | + } |
|
349 | + |
|
350 | + /** |
|
351 | + * End the </presentation> part, opened by export_header. |
|
352 | + * |
|
353 | + * @author Amand Tihon <[email protected]> |
|
354 | + */ |
|
355 | + function end_presentation() |
|
356 | + { |
|
357 | 357 | return "</flow></presentation>\n"; |
358 | - } |
|
359 | - |
|
360 | - /** |
|
361 | - * Start the response processing, and declare the default variable, SCORE, at 0 in the outcomes. |
|
362 | - * |
|
363 | - * @author Amand Tihon <[email protected]> |
|
364 | - */ |
|
365 | - function start_processing() |
|
366 | - { |
|
358 | + } |
|
359 | + |
|
360 | + /** |
|
361 | + * Start the response processing, and declare the default variable, SCORE, at 0 in the outcomes. |
|
362 | + * |
|
363 | + * @author Amand Tihon <[email protected]> |
|
364 | + */ |
|
365 | + function start_processing() |
|
366 | + { |
|
367 | 367 | return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>' . "\n"; |
368 | - } |
|
369 | - |
|
370 | - /** |
|
371 | - * End the response processing part. |
|
372 | - * |
|
373 | - * @author Amand Tihon <[email protected]> |
|
374 | - */ |
|
375 | - function end_processing() |
|
376 | - { |
|
368 | + } |
|
369 | + |
|
370 | + /** |
|
371 | + * End the response processing part. |
|
372 | + * |
|
373 | + * @author Amand Tihon <[email protected]> |
|
374 | + */ |
|
375 | + function end_processing() |
|
376 | + { |
|
377 | 377 | return "</resprocessing>\n"; |
378 | - } |
|
379 | - |
|
380 | - /** |
|
381 | - * Export the question as an IMS/QTI Item. |
|
382 | - * |
|
383 | - * This is a default behaviour, some classes may want to override this. |
|
384 | - * |
|
385 | - * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
386 | - * @return A string, the XML flow for an Item. |
|
387 | - * @author Amand Tihon <[email protected]> |
|
388 | - */ |
|
389 | - function export($standalone = False) |
|
390 | - { |
|
378 | + } |
|
379 | + |
|
380 | + /** |
|
381 | + * Export the question as an IMS/QTI Item. |
|
382 | + * |
|
383 | + * This is a default behaviour, some classes may want to override this. |
|
384 | + * |
|
385 | + * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
386 | + * @return A string, the XML flow for an Item. |
|
387 | + * @author Amand Tihon <[email protected]> |
|
388 | + */ |
|
389 | + function export($standalone = False) |
|
390 | + { |
|
391 | 391 | global $charset; |
392 | 392 | $head = $foot = ""; |
393 | 393 | |
394 | 394 | if ($standalone) { |
395 | 395 | $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>' . "\n" |
396 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
397 | - . "<questestinterop>\n"; |
|
396 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
397 | + . "<questestinterop>\n"; |
|
398 | 398 | $foot = "</questestinterop>\n"; |
399 | 399 | } |
400 | 400 | |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | . $this->answer->imsExportFeedback($this->questionIdent) |
410 | 410 | . $this->end_item() |
411 | 411 | . $foot; |
412 | - } |
|
412 | + } |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | $question->type = $qst->type; |
448 | 448 | $question->question = $qst->question; |
449 | 449 | $question->description = $qst->description; |
450 | - $question->weighting=$qst->weighting; |
|
451 | - $question->position=$qst->position; |
|
452 | - $question->picture=$qst->picture; |
|
450 | + $question->weighting=$qst->weighting; |
|
451 | + $question->position=$qst->position; |
|
452 | + $question->picture=$qst->picture; |
|
453 | 453 | $ims = new ImsAssessmentItem($question); |
454 | 454 | |
455 | 455 | return $ims->export($standalone); |
@@ -27,6 +27,7 @@ discard block |
||
27 | 27 | * @param int The JavaScript ID for this question. |
28 | 28 | * Due to the nature of interactions, we must have a natural sequence for |
29 | 29 | * questions in the generated JavaScript. |
30 | + * @param integer $js_id |
|
30 | 31 | */ |
31 | 32 | public static function export_question($questionId, $standalone = true, $js_id) |
32 | 33 | { |
@@ -687,7 +688,7 @@ discard block |
||
687 | 688 | /** |
688 | 689 | * Constructor. |
689 | 690 | * |
690 | - * @param $question The Question object we want to export. |
|
691 | + * @param ScormQuestion $question The Question object we want to export. |
|
691 | 692 | */ |
692 | 693 | public function ScormAssessmentItem($question, $standalone = false) |
693 | 694 | { |
@@ -915,7 +916,7 @@ discard block |
||
915 | 916 | * |
916 | 917 | * @param int $exerciseId The exercise to exporte |
917 | 918 | * @param boolean $standalone Wether it should include XML tag and DTD line. |
918 | - * @return The XML as a string, or an empty string if there's no exercise with given ID. |
|
919 | + * @return string XML as a string, or an empty string if there's no exercise with given ID. |
|
919 | 920 | */ |
920 | 921 | public static function export_exercise_to_scorm($exerciseId, $standalone=true) { |
921 | 922 | $exercise = new Exercise(); |
@@ -930,7 +931,7 @@ discard block |
||
930 | 931 | |
931 | 932 | /** |
932 | 933 | * Constructor. |
933 | - * @param $exe The Exercise instance to export |
|
934 | + * @param Exercise $exe The Exercise instance to export |
|
934 | 935 | * @author Amand Tihon <[email protected]> |
935 | 936 | */ |
936 | 937 | function ScormSection($exe) { |
@@ -1091,7 +1092,7 @@ discard block |
||
1091 | 1092 | * This is a default behaviour, some classes may want to override this. |
1092 | 1093 | * |
1093 | 1094 | * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
1094 | - * @return A string, the XML flow for an Item. |
|
1095 | + * @return string string, the XML flow for an Item. |
|
1095 | 1096 | */ |
1096 | 1097 | function export() |
1097 | 1098 | { |
@@ -49,86 +49,86 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | - * Include the correct answer class and create answer |
|
53 | - */ |
|
54 | - public function setAnswer() |
|
55 | - { |
|
56 | - switch ($this->type) { |
|
57 | - case MCUA: |
|
58 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
52 | + * Include the correct answer class and create answer |
|
53 | + */ |
|
54 | + public function setAnswer() |
|
55 | + { |
|
56 | + switch ($this->type) { |
|
57 | + case MCUA: |
|
58 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
59 | 59 | $this->answer->questionJSId = $this->js_id; |
60 | - break; |
|
61 | - case MCMA: |
|
60 | + break; |
|
61 | + case MCMA: |
|
62 | 62 | case GLOBAL_MULTIPLE_ANSWER: |
63 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
63 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
64 | 64 | $this->answer->questionJSId = $this->js_id; |
65 | - break; |
|
66 | - case TF: |
|
67 | - $this->answer = new ScormAnswerTrueFalse($this->id); |
|
65 | + break; |
|
66 | + case TF: |
|
67 | + $this->answer = new ScormAnswerTrueFalse($this->id); |
|
68 | 68 | $this->answer->questionJSId = $this->js_id; |
69 | - break; |
|
70 | - case FIB: |
|
71 | - $this->answer = new ScormAnswerFillInBlanks($this->id); |
|
69 | + break; |
|
70 | + case FIB: |
|
71 | + $this->answer = new ScormAnswerFillInBlanks($this->id); |
|
72 | 72 | $this->answer->questionJSId = $this->js_id; |
73 | - break; |
|
74 | - case MATCHING: |
|
73 | + break; |
|
74 | + case MATCHING: |
|
75 | 75 | case MATCHING_DRAGGABLE: |
76 | - $this->answer = new ScormAnswerMatching($this->id); |
|
76 | + $this->answer = new ScormAnswerMatching($this->id); |
|
77 | 77 | $this->answer->questionJSId = $this->js_id; |
78 | - break; |
|
78 | + break; |
|
79 | 79 | case ORAL_EXPRESSION: |
80 | - case FREE_ANSWER: |
|
81 | - $this->answer = new ScormAnswerFree($this->id); |
|
80 | + case FREE_ANSWER: |
|
81 | + $this->answer = new ScormAnswerFree($this->id); |
|
82 | 82 | $this->answer->questionJSId = $this->js_id; |
83 | - break; |
|
84 | - case HOT_SPOT: |
|
85 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
83 | + break; |
|
84 | + case HOT_SPOT: |
|
85 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
86 | 86 | $this->answer->questionJSId = $this->js_id; |
87 | - break; |
|
88 | - case MULTIPLE_ANSWER_COMBINATION: |
|
89 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
87 | + break; |
|
88 | + case MULTIPLE_ANSWER_COMBINATION: |
|
89 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
90 | 90 | $this->answer->questionJSId = $this->js_id; |
91 | - break; |
|
91 | + break; |
|
92 | 92 | case HOT_SPOT_ORDER: |
93 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
93 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
94 | 94 | $this->answer->questionJSId = $this->js_id; |
95 | - break; |
|
96 | - case HOT_SPOT_DELINEATION: |
|
97 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
95 | + break; |
|
96 | + case HOT_SPOT_DELINEATION: |
|
97 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
98 | 98 | $this->answer->questionJSId = $this->js_id; |
99 | - break; |
|
100 | - default : |
|
101 | - $this->answer = null; |
|
99 | + break; |
|
100 | + default : |
|
101 | + $this->answer = null; |
|
102 | 102 | $this->answer->questionJSId = $this->js_id; |
103 | - break; |
|
104 | - } |
|
103 | + break; |
|
104 | + } |
|
105 | 105 | |
106 | - return true; |
|
107 | - } |
|
106 | + return true; |
|
107 | + } |
|
108 | 108 | |
109 | - function export() |
|
110 | - { |
|
111 | - $html = $this->getQuestionHTML(); |
|
112 | - $js = $this->getQuestionJS(); |
|
109 | + function export() |
|
110 | + { |
|
111 | + $html = $this->getQuestionHTML(); |
|
112 | + $js = $this->getQuestionJS(); |
|
113 | 113 | |
114 | - if( is_object($this->answer) ) |
|
115 | - { |
|
116 | - list($js2,$html2) = $this->answer->export(); |
|
117 | - $js .= $js2; |
|
118 | - $html .= $html2; |
|
119 | - } |
|
114 | + if( is_object($this->answer) ) |
|
115 | + { |
|
116 | + list($js2,$html2) = $this->answer->export(); |
|
117 | + $js .= $js2; |
|
118 | + $html .= $html2; |
|
119 | + } |
|
120 | 120 | |
121 | - return array($js,$html); |
|
122 | - } |
|
121 | + return array($js,$html); |
|
122 | + } |
|
123 | 123 | |
124 | 124 | function createAnswersForm($form) |
125 | 125 | { |
126 | - return true; |
|
126 | + return true; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | function processAnswersCreation($form) |
130 | 130 | { |
131 | - return true; |
|
131 | + return true; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -136,20 +136,20 @@ discard block |
||
136 | 136 | */ |
137 | 137 | function getQuestionHTML() |
138 | 138 | { |
139 | - $title = $this->selectTitle(); |
|
140 | - $description = $this->selectDescription(); |
|
141 | - $cols = 2; |
|
142 | - $s='<tr>' . |
|
143 | - '<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">' . "\n" . |
|
144 | - $title. |
|
145 | - '</td>' . "\n" . |
|
146 | - '</tr>' . "\n" . |
|
147 | - '<tr>' . "\n" . |
|
148 | - '<td valign="top" colspan="'.$cols.'">' . "\n" . |
|
149 | - '<i>'.$description.'</i>' . "\n" . |
|
150 | - '</td>' . "\n" . |
|
151 | - '</tr>' . "\n"; |
|
152 | - return $s; |
|
139 | + $title = $this->selectTitle(); |
|
140 | + $description = $this->selectDescription(); |
|
141 | + $cols = 2; |
|
142 | + $s='<tr>' . |
|
143 | + '<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">' . "\n" . |
|
144 | + $title. |
|
145 | + '</td>' . "\n" . |
|
146 | + '</tr>' . "\n" . |
|
147 | + '<tr>' . "\n" . |
|
148 | + '<td valign="top" colspan="'.$cols.'">' . "\n" . |
|
149 | + '<i>'.$description.'</i>' . "\n" . |
|
150 | + '</td>' . "\n" . |
|
151 | + '</tr>' . "\n"; |
|
152 | + return $s; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -157,16 +157,16 @@ discard block |
||
157 | 157 | */ |
158 | 158 | function getQuestionJS() |
159 | 159 | { |
160 | - //$id = $this->id; |
|
161 | - $w = $this->selectWeighting(); |
|
162 | - $s = 'questions.push('.$this->js_id.');'."\n"; |
|
163 | - if($this->type == FREE_ANSWER or $this->type == HOT_SPOT) |
|
164 | - { //put the max score to 0 to avoid discounting the points of |
|
165 | - //non-exported quiz types in the SCORM |
|
166 | - $w=0; |
|
167 | - } |
|
168 | - $s .= 'questions_score_max['.$this->js_id.'] = '.$w.";\n"; |
|
169 | - return $s; |
|
160 | + //$id = $this->id; |
|
161 | + $w = $this->selectWeighting(); |
|
162 | + $s = 'questions.push('.$this->js_id.');'."\n"; |
|
163 | + if($this->type == FREE_ANSWER or $this->type == HOT_SPOT) |
|
164 | + { //put the max score to 0 to avoid discounting the points of |
|
165 | + //non-exported quiz types in the SCORM |
|
166 | + $w=0; |
|
167 | + } |
|
168 | + $s .= 'questions_score_max['.$this->js_id.'] = '.$w.";\n"; |
|
169 | + return $s; |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
@@ -177,107 +177,107 @@ discard block |
||
177 | 177 | */ |
178 | 178 | class ScormAnswerMultipleChoice extends Answer |
179 | 179 | { |
180 | - /** |
|
181 | - * Return HTML code for possible answers |
|
180 | + /** |
|
181 | + * Return HTML code for possible answers |
|
182 | 182 | */ |
183 | - function export() |
|
184 | - { |
|
185 | - $html = ''; |
|
186 | - $js = ''; |
|
187 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
188 | - $type = $this->getQuestionType(); |
|
189 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
190 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
191 | - |
|
192 | - //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM |
|
183 | + function export() |
|
184 | + { |
|
185 | + $html = ''; |
|
186 | + $js = ''; |
|
187 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
188 | + $type = $this->getQuestionType(); |
|
189 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
190 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
191 | + |
|
192 | + //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM |
|
193 | 193 | //if ($type == MCMA || $type == MULTIPLE_ANSWER_COMBINATION ) { |
194 | - if ($type == MCMA ) { |
|
195 | - //$questionTypeLang = get_lang('MultipleChoiceMultipleAnswers'); |
|
196 | - $id = 1; |
|
197 | - $jstmp = ''; |
|
198 | - $jstmpc = ''; |
|
199 | - foreach( $this->answer as $i => $answer ) |
|
200 | - { |
|
201 | - $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i; |
|
202 | - $html .= |
|
203 | - '<tr>' . "\n" |
|
204 | - . '<td align="center" width="5%">' . "\n" |
|
205 | - . '<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />' . "\n" |
|
206 | - . '</td>' . "\n" |
|
207 | - . '<td width="95%">' . "\n" |
|
208 | - . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
209 | - . '</td>' . "\n" |
|
210 | - . '</tr>' . "\n\n"; |
|
211 | - $jstmp .= $i.','; |
|
212 | - if($this->correct[$i]) |
|
213 | - { |
|
214 | - $jstmpc .= $i.','; |
|
215 | - } |
|
216 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
|
217 | - $id++; |
|
218 | - } |
|
219 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
220 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
221 | - if ($type == MCMA) { |
|
222 | - $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n"; |
|
223 | - } else { |
|
224 | - $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n"; |
|
225 | - } |
|
226 | - $js .= $jstmpw; |
|
194 | + if ($type == MCMA ) { |
|
195 | + //$questionTypeLang = get_lang('MultipleChoiceMultipleAnswers'); |
|
196 | + $id = 1; |
|
197 | + $jstmp = ''; |
|
198 | + $jstmpc = ''; |
|
199 | + foreach( $this->answer as $i => $answer ) |
|
200 | + { |
|
201 | + $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i; |
|
202 | + $html .= |
|
203 | + '<tr>' . "\n" |
|
204 | + . '<td align="center" width="5%">' . "\n" |
|
205 | + . '<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />' . "\n" |
|
206 | + . '</td>' . "\n" |
|
207 | + . '<td width="95%">' . "\n" |
|
208 | + . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
209 | + . '</td>' . "\n" |
|
210 | + . '</tr>' . "\n\n"; |
|
211 | + $jstmp .= $i.','; |
|
212 | + if($this->correct[$i]) |
|
213 | + { |
|
214 | + $jstmpc .= $i.','; |
|
215 | + } |
|
216 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
|
217 | + $id++; |
|
218 | + } |
|
219 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
220 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
221 | + if ($type == MCMA) { |
|
222 | + $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n"; |
|
223 | + } else { |
|
224 | + $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n"; |
|
225 | + } |
|
226 | + $js .= $jstmpw; |
|
227 | 227 | } elseif ($type == MULTIPLE_ANSWER_COMBINATION) { |
228 | - //To this items we show the ThisItemIsNotExportable |
|
229 | - $qId = $this->questionJSId; |
|
230 | - $js = ''; |
|
231 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
232 | - // some javascript must be added for that kind of questions |
|
233 | - $html .= '<tr>' . "\n" |
|
234 | - . '<td>' . "\n" |
|
235 | - . '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>' . "\n" |
|
236 | - . '</td>' . "\n" |
|
237 | - . '</tr>' . "\n"; |
|
238 | - $html .= '</table></td></tr>' . "\n"; |
|
239 | - // currently the exact answers cannot be displayed, so ignore the textarea |
|
240 | - $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
241 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
242 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
243 | - $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n"; |
|
244 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
245 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
246 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
247 | - $js .= $jstmpw; |
|
248 | - return array($js,$html); |
|
228 | + //To this items we show the ThisItemIsNotExportable |
|
229 | + $qId = $this->questionJSId; |
|
230 | + $js = ''; |
|
231 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
232 | + // some javascript must be added for that kind of questions |
|
233 | + $html .= '<tr>' . "\n" |
|
234 | + . '<td>' . "\n" |
|
235 | + . '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>' . "\n" |
|
236 | + . '</td>' . "\n" |
|
237 | + . '</tr>' . "\n"; |
|
238 | + $html .= '</table></td></tr>' . "\n"; |
|
239 | + // currently the exact answers cannot be displayed, so ignore the textarea |
|
240 | + $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
241 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
242 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
243 | + $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n"; |
|
244 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
245 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
246 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
247 | + $js .= $jstmpw; |
|
248 | + return array($js,$html); |
|
249 | 249 | } else { |
250 | - //$questionTypeLang = get_lang('MultipleChoiceUniqueAnswer'); |
|
251 | - $id = 1; |
|
252 | - $jstmp = ''; |
|
253 | - $jstmpc = ''; |
|
254 | - foreach( $this->answer as $i => $answer ) |
|
255 | - { |
|
256 | - $identifier = 'question_'.$this->questionJSId.'_unique_'.$i; |
|
257 | - $identifier_name = 'question_'.$this->questionJSId.'_unique_answer'; |
|
258 | - $html .= |
|
259 | - '<tr>' . "\n" |
|
260 | - . '<td align="center" width="5%">' . "\n" |
|
261 | - . '<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>' . "\n" |
|
262 | - . '</td>' . "\n" |
|
263 | - . '<td width="95%">' . "\n" |
|
264 | - . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
265 | - . '</td>' . "\n" |
|
266 | - . '</tr>' . "\n\n"; |
|
267 | - $jstmp .= $i.','; |
|
268 | - if($this->correct[$i]) |
|
269 | - { |
|
270 | - $jstmpc .= $i; |
|
271 | - } |
|
272 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
|
273 | - $id++; |
|
274 | - } |
|
275 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
276 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = '.$jstmpc.';'."\n"; |
|
277 | - $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'."\n"; |
|
278 | - $js .= $jstmpw; |
|
250 | + //$questionTypeLang = get_lang('MultipleChoiceUniqueAnswer'); |
|
251 | + $id = 1; |
|
252 | + $jstmp = ''; |
|
253 | + $jstmpc = ''; |
|
254 | + foreach( $this->answer as $i => $answer ) |
|
255 | + { |
|
256 | + $identifier = 'question_'.$this->questionJSId.'_unique_'.$i; |
|
257 | + $identifier_name = 'question_'.$this->questionJSId.'_unique_answer'; |
|
258 | + $html .= |
|
259 | + '<tr>' . "\n" |
|
260 | + . '<td align="center" width="5%">' . "\n" |
|
261 | + . '<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>' . "\n" |
|
262 | + . '</td>' . "\n" |
|
263 | + . '<td width="95%">' . "\n" |
|
264 | + . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
265 | + . '</td>' . "\n" |
|
266 | + . '</tr>' . "\n\n"; |
|
267 | + $jstmp .= $i.','; |
|
268 | + if($this->correct[$i]) |
|
269 | + { |
|
270 | + $jstmpc .= $i; |
|
271 | + } |
|
272 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
|
273 | + $id++; |
|
274 | + } |
|
275 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
276 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = '.$jstmpc.';'."\n"; |
|
277 | + $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'."\n"; |
|
278 | + $js .= $jstmpw; |
|
279 | 279 | } |
280 | - $html .= '</table></td></tr>' . "\n"; |
|
280 | + $html .= '</table></td></tr>' . "\n"; |
|
281 | 281 | return array($js,$html); |
282 | 282 | } |
283 | 283 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | */ |
289 | 289 | class ScormAnswerTrueFalse extends Answer |
290 | 290 | { |
291 | - /** |
|
291 | + /** |
|
292 | 292 | * Return the XML flow for the possible answers. |
293 | 293 | * That's one <response_lid>, containing several <flow_label> |
294 | 294 | * |
@@ -296,46 +296,46 @@ discard block |
||
296 | 296 | */ |
297 | 297 | function export() |
298 | 298 | { |
299 | - $js = ''; |
|
300 | - $html = '<tr><td colspan="2"><table width="100%">'; |
|
301 | - $identifier = 'question_'.$this->questionJSId.'_tf'; |
|
302 | - $identifier_true = $identifier.'_true'; |
|
303 | - $identifier_false = $identifier.'_false'; |
|
304 | - $html .= |
|
305 | - '<tr>' . "\n" |
|
306 | - . '<td align="center" width="5%">' . "\n" |
|
307 | - . '<input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" ' |
|
308 | - . '/>' . "\n" |
|
309 | - . '</td>' . "\n" |
|
310 | - . '<td width="95%">' . "\n" |
|
311 | - . '<label for="'.$identifier_true.'">' . get_lang('True') . '</label>' . "\n" |
|
312 | - . '</td>' . "\n" |
|
313 | - . '</tr>' . "\n\n"; |
|
314 | - $html .= |
|
315 | - '<tr>' . "\n" |
|
316 | - . '<td align="center" width="5%">' . "\n" |
|
317 | - . '<input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" ' |
|
318 | - . '/>' . "\n" |
|
319 | - . '</td>' . "\n" |
|
320 | - . '<td width="95%">' . "\n" |
|
321 | - . '<label for="'.$identifier_false.'">' . get_lang('False') . '</label>' . "\n" |
|
322 | - . '</td>' . "\n" |
|
323 | - . '</tr>' . "\n\n"; |
|
324 | - $html .= '</table></td></tr>' . "\n"; |
|
325 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n"; |
|
326 | - $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n"; |
|
327 | - if($this->response == 'TRUE') |
|
328 | - { |
|
329 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
|
330 | - } |
|
331 | - else |
|
332 | - { |
|
333 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n"; |
|
334 | - } |
|
335 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
336 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
337 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n"; |
|
338 | - $js .= $jstmpw; |
|
299 | + $js = ''; |
|
300 | + $html = '<tr><td colspan="2"><table width="100%">'; |
|
301 | + $identifier = 'question_'.$this->questionJSId.'_tf'; |
|
302 | + $identifier_true = $identifier.'_true'; |
|
303 | + $identifier_false = $identifier.'_false'; |
|
304 | + $html .= |
|
305 | + '<tr>' . "\n" |
|
306 | + . '<td align="center" width="5%">' . "\n" |
|
307 | + . '<input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" ' |
|
308 | + . '/>' . "\n" |
|
309 | + . '</td>' . "\n" |
|
310 | + . '<td width="95%">' . "\n" |
|
311 | + . '<label for="'.$identifier_true.'">' . get_lang('True') . '</label>' . "\n" |
|
312 | + . '</td>' . "\n" |
|
313 | + . '</tr>' . "\n\n"; |
|
314 | + $html .= |
|
315 | + '<tr>' . "\n" |
|
316 | + . '<td align="center" width="5%">' . "\n" |
|
317 | + . '<input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" ' |
|
318 | + . '/>' . "\n" |
|
319 | + . '</td>' . "\n" |
|
320 | + . '<td width="95%">' . "\n" |
|
321 | + . '<label for="'.$identifier_false.'">' . get_lang('False') . '</label>' . "\n" |
|
322 | + . '</td>' . "\n" |
|
323 | + . '</tr>' . "\n\n"; |
|
324 | + $html .= '</table></td></tr>' . "\n"; |
|
325 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n"; |
|
326 | + $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n"; |
|
327 | + if($this->response == 'TRUE') |
|
328 | + { |
|
329 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
|
330 | + } |
|
331 | + else |
|
332 | + { |
|
333 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n"; |
|
334 | + } |
|
335 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
336 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
337 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n"; |
|
338 | + $js .= $jstmpw; |
|
339 | 339 | |
340 | 340 | return array($js,$html); |
341 | 341 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | */ |
348 | 348 | class ScormAnswerFillInBlanks extends Answer |
349 | 349 | { |
350 | - /** |
|
350 | + /** |
|
351 | 351 | * Export the text with missing words. |
352 | 352 | * |
353 | 353 | * As a side effect, it stores two lists in the class : |
@@ -355,57 +355,57 @@ discard block |
||
355 | 355 | */ |
356 | 356 | function export() |
357 | 357 | { |
358 | - global $charset; |
|
359 | - $js = ''; |
|
360 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
361 | - // get all enclosed answers |
|
362 | - $blankList = array(); |
|
363 | - // build replacement |
|
364 | - $replacementList = array(); |
|
365 | - foreach( $this->answer as $i => $answer) { |
|
366 | - $blankList[] = '['.$answer.']'; |
|
367 | - } |
|
368 | - $answerCount = count($blankList); |
|
369 | - |
|
370 | - // splits text and weightings that are joined with the character '::' |
|
371 | - list($answer,$weight)=explode('::',$answer); |
|
372 | - $weights = explode(',',$weight); |
|
373 | - // because [] is parsed here we follow this procedure: |
|
374 | - // 1. find everything between the [ and ] tags |
|
375 | - $i=1; |
|
376 | - $jstmp = ''; |
|
377 | - $jstmpc = ''; |
|
378 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
379 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
380 | - $startlocations=api_strpos($answer,'['); |
|
381 | - $endlocations=api_strpos($answer,']'); |
|
382 | - while($startlocations !== false && $endlocations !== false) { |
|
383 | - $texstring=api_substr($answer,$startlocations,($endlocations-$startlocations)+1); |
|
384 | - $answer = api_substr_replace($answer,'<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',$startlocations,($endlocations-$startlocations)+1); |
|
385 | - $jstmp .= $i.','; |
|
386 | - $jstmpc .= "'".api_htmlentities(api_substr($texstring,1,-1),ENT_QUOTES,$charset)."',"; |
|
387 | - $my_weight=explode('@',$weights[$i-1]); |
|
388 | - if (count($my_weight)==2) { |
|
389 | - $weight_db=$my_weight[0]; |
|
390 | - } else { |
|
391 | - $weight_db=$my_weight[0]; |
|
392 | - } |
|
393 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n"; |
|
394 | - $i++; |
|
395 | - $startlocations=api_strpos($answer,'['); |
|
396 | - $endlocations=api_strpos($answer,']'); |
|
397 | - } |
|
358 | + global $charset; |
|
359 | + $js = ''; |
|
360 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
361 | + // get all enclosed answers |
|
362 | + $blankList = array(); |
|
363 | + // build replacement |
|
364 | + $replacementList = array(); |
|
365 | + foreach( $this->answer as $i => $answer) { |
|
366 | + $blankList[] = '['.$answer.']'; |
|
367 | + } |
|
368 | + $answerCount = count($blankList); |
|
369 | + |
|
370 | + // splits text and weightings that are joined with the character '::' |
|
371 | + list($answer,$weight)=explode('::',$answer); |
|
372 | + $weights = explode(',',$weight); |
|
373 | + // because [] is parsed here we follow this procedure: |
|
374 | + // 1. find everything between the [ and ] tags |
|
375 | + $i=1; |
|
376 | + $jstmp = ''; |
|
377 | + $jstmpc = ''; |
|
378 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
379 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
380 | + $startlocations=api_strpos($answer,'['); |
|
381 | + $endlocations=api_strpos($answer,']'); |
|
382 | + while($startlocations !== false && $endlocations !== false) { |
|
383 | + $texstring=api_substr($answer,$startlocations,($endlocations-$startlocations)+1); |
|
384 | + $answer = api_substr_replace($answer,'<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',$startlocations,($endlocations-$startlocations)+1); |
|
385 | + $jstmp .= $i.','; |
|
386 | + $jstmpc .= "'".api_htmlentities(api_substr($texstring,1,-1),ENT_QUOTES,$charset)."',"; |
|
387 | + $my_weight=explode('@',$weights[$i-1]); |
|
388 | + if (count($my_weight)==2) { |
|
389 | + $weight_db=$my_weight[0]; |
|
390 | + } else { |
|
391 | + $weight_db=$my_weight[0]; |
|
392 | + } |
|
393 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n"; |
|
394 | + $i++; |
|
395 | + $startlocations=api_strpos($answer,'['); |
|
396 | + $endlocations=api_strpos($answer,']'); |
|
397 | + } |
|
398 | 398 | |
399 | - $html .= '<tr>' . "\n" |
|
400 | - . '<td>' . "\n" |
|
401 | - . $answer . "\n" |
|
402 | - . '</td>' . "\n" |
|
403 | - . '</tr>' . "\n"; |
|
404 | - $html .= '</table></td></tr>' . "\n"; |
|
405 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n"; |
|
406 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n"; |
|
407 | - $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n"; |
|
408 | - $js .= $jstmpw; |
|
399 | + $html .= '<tr>' . "\n" |
|
400 | + . '<td>' . "\n" |
|
401 | + . $answer . "\n" |
|
402 | + . '</td>' . "\n" |
|
403 | + . '</tr>' . "\n"; |
|
404 | + $html .= '</table></td></tr>' . "\n"; |
|
405 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n"; |
|
406 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n"; |
|
407 | + $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n"; |
|
408 | + $js .= $jstmpw; |
|
409 | 409 | return array($js,$html); |
410 | 410 | } |
411 | 411 | } |
@@ -416,101 +416,101 @@ discard block |
||
416 | 416 | */ |
417 | 417 | class ScormAnswerMatching extends Answer |
418 | 418 | { |
419 | - /** |
|
419 | + /** |
|
420 | 420 | * Export the question part as a matrix-choice, with only one possible answer per line. |
421 | 421 | * @author Amand Tihon <[email protected]> |
422 | 422 | */ |
423 | 423 | function export() |
424 | 424 | { |
425 | - $js = ''; |
|
426 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
427 | - // prepare list of right proposition to allow |
|
428 | - // - easiest display |
|
429 | - // - easiest randomisation if needed one day |
|
430 | - // (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...) |
|
431 | - if (is_array($this->rightList)) { |
|
432 | - $displayedRightList = array_values($this->rightList); |
|
433 | - } |
|
434 | - // get max length of displayed array |
|
435 | - $arrayLength = max( count($this->leftList), count($this->rightList) ); |
|
436 | - |
|
437 | - $nbrAnswers=$this->selectNbrAnswers(); |
|
438 | - $cpt1='A'; |
|
439 | - $cpt2=1; |
|
440 | - $Select=array(); |
|
441 | - $qId = $this->questionJSId; |
|
442 | - $s = ''; |
|
443 | - $jstmp = ''; |
|
444 | - $jstmpc = ''; |
|
425 | + $js = ''; |
|
426 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
427 | + // prepare list of right proposition to allow |
|
428 | + // - easiest display |
|
429 | + // - easiest randomisation if needed one day |
|
430 | + // (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...) |
|
431 | + if (is_array($this->rightList)) { |
|
432 | + $displayedRightList = array_values($this->rightList); |
|
433 | + } |
|
434 | + // get max length of displayed array |
|
435 | + $arrayLength = max( count($this->leftList), count($this->rightList) ); |
|
436 | + |
|
437 | + $nbrAnswers=$this->selectNbrAnswers(); |
|
438 | + $cpt1='A'; |
|
439 | + $cpt2=1; |
|
440 | + $Select=array(); |
|
441 | + $qId = $this->questionJSId; |
|
442 | + $s = ''; |
|
443 | + $jstmp = ''; |
|
444 | + $jstmpc = ''; |
|
445 | 445 | $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
446 | 446 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
447 | 447 | |
448 | - for($answerId=1;$answerId <= $nbrAnswers;$answerId++) { |
|
449 | - $identifier = 'question_'.$qId.'_matching_'; |
|
450 | - $answer=$this->selectAnswer($answerId); |
|
451 | - $answerCorrect=$this->isCorrect($answerId); |
|
452 | - $weight=$this->selectWeighting($answerId); |
|
453 | - $jstmp .= $answerId.','; |
|
454 | - |
|
455 | - if (!$answerCorrect) { |
|
456 | - // options (A, B, C, ...) that will be put into the list-box |
|
457 | - $Select[$answerId]['Lettre']=$cpt1; |
|
458 | - // answers that will be shown at the right side |
|
459 | - $Select[$answerId]['Reponse'] = $answer; |
|
460 | - $cpt1++; |
|
461 | - } else { |
|
462 | - $s.='<tr>'."\n"; |
|
463 | - $s.='<td width="40%" valign="top">'."\n".'<b>'.$cpt2.'</b>. '.$answer."\n</td>\n"; |
|
464 | - $s.='<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
465 | - $s.=' <option value="0">--</option>'; |
|
466 | - // fills the list-box |
|
467 | - foreach($Select as $key=>$val) |
|
468 | - { |
|
469 | - $s.='<option value="'.$key.'">'.$val['Lettre'].'</option>'; |
|
470 | - } // end foreach() |
|
471 | - |
|
472 | - $s.='</select> </td>'."\n"; |
|
473 | - $s.='<td width="40%" valign="top">'; |
|
474 | - if(isset($Select[$cpt2])) $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
475 | - else $s.=' '; |
|
476 | - $s.="</td>\n</tr>\n"; |
|
477 | - |
|
478 | - $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
|
479 | - |
|
480 | - $my_weight=explode('@',$weight); |
|
481 | - if (count($my_weight)==2) { |
|
482 | - $weight=$my_weight[0]; |
|
483 | - } else { |
|
484 | - $weight=$my_weight[0]; |
|
485 | - } |
|
486 | - $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n"; |
|
487 | - $cpt2++; |
|
488 | - |
|
489 | - // if the left side of the "matching" has been completely shown |
|
490 | - if($answerId == $nbrAnswers) |
|
491 | - { |
|
492 | - // if there remain answers to be shown on the right side |
|
493 | - while(isset($Select[$cpt2])) |
|
494 | - { |
|
495 | - //$s.='<tr>'."\n"; |
|
496 | - //$s.='<td colspan="2">'."\n"; |
|
497 | - //$s.='<table border="0" cellpadding="0" cellspacing="0" width="100%">'."\n"; |
|
498 | - $s.='<tr>'."\n"; |
|
499 | - $s.='<td width="60%" colspan="2"> </td>'."\n"; |
|
500 | - $s.='<td width="40%" valign="top">'; |
|
501 | - $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
502 | - $s.="</td>\n</tr>\n"; |
|
503 | - $cpt2++; |
|
504 | - } // end while() |
|
505 | - } // end if() |
|
506 | - } |
|
507 | - } |
|
508 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
509 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
510 | - $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n"; |
|
511 | - $js .= $jstmpw; |
|
512 | - $html .= $s; |
|
513 | - $html .= '</table></td></tr>' . "\n"; |
|
448 | + for($answerId=1;$answerId <= $nbrAnswers;$answerId++) { |
|
449 | + $identifier = 'question_'.$qId.'_matching_'; |
|
450 | + $answer=$this->selectAnswer($answerId); |
|
451 | + $answerCorrect=$this->isCorrect($answerId); |
|
452 | + $weight=$this->selectWeighting($answerId); |
|
453 | + $jstmp .= $answerId.','; |
|
454 | + |
|
455 | + if (!$answerCorrect) { |
|
456 | + // options (A, B, C, ...) that will be put into the list-box |
|
457 | + $Select[$answerId]['Lettre']=$cpt1; |
|
458 | + // answers that will be shown at the right side |
|
459 | + $Select[$answerId]['Reponse'] = $answer; |
|
460 | + $cpt1++; |
|
461 | + } else { |
|
462 | + $s.='<tr>'."\n"; |
|
463 | + $s.='<td width="40%" valign="top">'."\n".'<b>'.$cpt2.'</b>. '.$answer."\n</td>\n"; |
|
464 | + $s.='<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
465 | + $s.=' <option value="0">--</option>'; |
|
466 | + // fills the list-box |
|
467 | + foreach($Select as $key=>$val) |
|
468 | + { |
|
469 | + $s.='<option value="'.$key.'">'.$val['Lettre'].'</option>'; |
|
470 | + } // end foreach() |
|
471 | + |
|
472 | + $s.='</select> </td>'."\n"; |
|
473 | + $s.='<td width="40%" valign="top">'; |
|
474 | + if(isset($Select[$cpt2])) $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
475 | + else $s.=' '; |
|
476 | + $s.="</td>\n</tr>\n"; |
|
477 | + |
|
478 | + $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
|
479 | + |
|
480 | + $my_weight=explode('@',$weight); |
|
481 | + if (count($my_weight)==2) { |
|
482 | + $weight=$my_weight[0]; |
|
483 | + } else { |
|
484 | + $weight=$my_weight[0]; |
|
485 | + } |
|
486 | + $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n"; |
|
487 | + $cpt2++; |
|
488 | + |
|
489 | + // if the left side of the "matching" has been completely shown |
|
490 | + if($answerId == $nbrAnswers) |
|
491 | + { |
|
492 | + // if there remain answers to be shown on the right side |
|
493 | + while(isset($Select[$cpt2])) |
|
494 | + { |
|
495 | + //$s.='<tr>'."\n"; |
|
496 | + //$s.='<td colspan="2">'."\n"; |
|
497 | + //$s.='<table border="0" cellpadding="0" cellspacing="0" width="100%">'."\n"; |
|
498 | + $s.='<tr>'."\n"; |
|
499 | + $s.='<td width="60%" colspan="2"> </td>'."\n"; |
|
500 | + $s.='<td width="40%" valign="top">'; |
|
501 | + $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
502 | + $s.="</td>\n</tr>\n"; |
|
503 | + $cpt2++; |
|
504 | + } // end while() |
|
505 | + } // end if() |
|
506 | + } |
|
507 | + } |
|
508 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
509 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
510 | + $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n"; |
|
511 | + $js .= $jstmpw; |
|
512 | + $html .= $s; |
|
513 | + $html .= '</table></td></tr>' . "\n"; |
|
514 | 514 | |
515 | 515 | return array($js,$html); |
516 | 516 | } |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | */ |
523 | 523 | class ScormAnswerFree extends Answer |
524 | 524 | { |
525 | - /** |
|
525 | + /** |
|
526 | 526 | * Export the text with missing words. |
527 | 527 | * |
528 | 528 | * As a side effect, it stores two lists in the class : |
@@ -531,67 +531,67 @@ discard block |
||
531 | 531 | */ |
532 | 532 | function export() |
533 | 533 | { |
534 | - //$qId = $this->questionJSId; |
|
535 | - $js = ''; |
|
536 | - /*$html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
534 | + //$qId = $this->questionJSId; |
|
535 | + $js = ''; |
|
536 | + /*$html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
537 | 537 | // some javascript must be added for that kind of questions |
538 | 538 | $html .= '<tr><td> |
539 | 539 | <textarea name="question_'.$qId.'_free" id="question_'.$qId.'_free" rows="20" cols="100"></textarea> |
540 | 540 | </td> |
541 | 541 | </tr>'; |
542 | 542 | $html .= '</table></td></tr>';*/ |
543 | - // currently the free answers cannot be displayed, so ignore the textarea |
|
544 | - $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
545 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
546 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
547 | - $js .= 'questions_types['.$this->questionJSId.'] = \'free\';'."\n"; |
|
548 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
549 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
550 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
551 | - $js .= $jstmpw; |
|
543 | + // currently the free answers cannot be displayed, so ignore the textarea |
|
544 | + $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
545 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
546 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
547 | + $js .= 'questions_types['.$this->questionJSId.'] = \'free\';'."\n"; |
|
548 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
549 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
550 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
551 | + $js .= $jstmpw; |
|
552 | 552 | return array($js,$html); |
553 | 553 | } |
554 | 554 | } |
555 | 555 | /** |
556 | - * This class handles the SCORM export of hotpot questions |
|
557 | - * @package chamilo.exercise.scorm |
|
558 | - */ |
|
556 | + * This class handles the SCORM export of hotpot questions |
|
557 | + * @package chamilo.exercise.scorm |
|
558 | + */ |
|
559 | 559 | class ScormAnswerHotspot extends Answer |
560 | 560 | { |
561 | - /** |
|
562 | - * Returns the javascript code that goes with HotSpot exercises |
|
563 | - * @return string The JavaScript code |
|
564 | - */ |
|
565 | - function get_js_header() |
|
566 | - { |
|
567 | - if ($this->standalone) { |
|
568 | - $header = '<script type="text/javascript" language="javascript">'; |
|
569 | - $header .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js'); |
|
570 | - $header .= '</script>'; |
|
571 | - //because this header closes so many times the <script> tag, we have to reopen our own |
|
572 | - $header .= '<script type="text/javascript" language="javascript">'."\n"; |
|
573 | - $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
574 | - $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
575 | - $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
576 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
577 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
578 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
579 | - $header .= $jstmpw; |
|
580 | - } |
|
581 | - else |
|
582 | - { |
|
583 | - $header = ''; |
|
584 | - $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
585 | - $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
586 | - $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
587 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
588 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
589 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n"; |
|
590 | - $header .= $jstmpw; |
|
591 | - } |
|
592 | - return $header; |
|
593 | - } |
|
594 | - /** |
|
561 | + /** |
|
562 | + * Returns the javascript code that goes with HotSpot exercises |
|
563 | + * @return string The JavaScript code |
|
564 | + */ |
|
565 | + function get_js_header() |
|
566 | + { |
|
567 | + if ($this->standalone) { |
|
568 | + $header = '<script type="text/javascript" language="javascript">'; |
|
569 | + $header .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js'); |
|
570 | + $header .= '</script>'; |
|
571 | + //because this header closes so many times the <script> tag, we have to reopen our own |
|
572 | + $header .= '<script type="text/javascript" language="javascript">'."\n"; |
|
573 | + $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
574 | + $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
575 | + $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
576 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
577 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
578 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
579 | + $header .= $jstmpw; |
|
580 | + } |
|
581 | + else |
|
582 | + { |
|
583 | + $header = ''; |
|
584 | + $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
585 | + $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
586 | + $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
587 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
588 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
589 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n"; |
|
590 | + $header .= $jstmpw; |
|
591 | + } |
|
592 | + return $header; |
|
593 | + } |
|
594 | + /** |
|
595 | 595 | * Export the text with missing words. |
596 | 596 | * |
597 | 597 | * As a side effect, it stores two lists in the class : |
@@ -600,22 +600,22 @@ discard block |
||
600 | 600 | */ |
601 | 601 | function export() |
602 | 602 | { |
603 | - $js = $this->get_js_header(); |
|
604 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
605 | - // some javascript must be added for that kind of questions |
|
606 | - $html .= ''; |
|
603 | + $js = $this->get_js_header(); |
|
604 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
605 | + // some javascript must be added for that kind of questions |
|
606 | + $html .= ''; |
|
607 | 607 | |
608 | - // Get the answers, make a list |
|
609 | - $nbrAnswers=$this->selectNbrAnswers(); |
|
608 | + // Get the answers, make a list |
|
609 | + $nbrAnswers=$this->selectNbrAnswers(); |
|
610 | 610 | |
611 | - $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>'; |
|
612 | - for($answerId=1;$answerId <= $nbrAnswers;$answerId++) |
|
613 | - { |
|
614 | - $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>'; |
|
615 | - } |
|
616 | - $answer_list .= '</ol></div>'; |
|
611 | + $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>'; |
|
612 | + for($answerId=1;$answerId <= $nbrAnswers;$answerId++) |
|
613 | + { |
|
614 | + $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>'; |
|
615 | + } |
|
616 | + $answer_list .= '</ol></div>'; |
|
617 | 617 | |
618 | - /* |
|
618 | + /* |
|
619 | 619 | if(!$onlyAnswers) |
620 | 620 | { |
621 | 621 | $s="<tr> |
@@ -633,11 +633,11 @@ discard block |
||
633 | 633 | } |
634 | 634 | */ |
635 | 635 | |
636 | - //$canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1'); |
|
637 | - $canClick = true; |
|
638 | - //$tes = isset($_GET['modifyAnswers']) ? '0' : '1'; |
|
639 | - //echo $tes; |
|
640 | - $relPath = api_get_path(REL_PATH); |
|
636 | + //$canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1'); |
|
637 | + $canClick = true; |
|
638 | + //$tes = isset($_GET['modifyAnswers']) ? '0' : '1'; |
|
639 | + //echo $tes; |
|
640 | + $relPath = api_get_path(REL_PATH); |
|
641 | 641 | $html .= <<<HTML |
642 | 642 | <tr> |
643 | 643 | <td> |
@@ -658,10 +658,10 @@ discard block |
||
658 | 658 | </td> |
659 | 659 | <tr> |
660 | 660 | HTML; |
661 | - $html .= '</table></td></tr>' . "\n"; |
|
661 | + $html .= '</table></td></tr>' . "\n"; |
|
662 | 662 | |
663 | - // currently the free answers cannot be displayed, so ignore the textarea |
|
664 | - $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
663 | + // currently the free answers cannot be displayed, so ignore the textarea |
|
664 | + $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
665 | 665 | return array($js,$html); |
666 | 666 | } |
667 | 667 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | { |
33 | 33 | $question = new ScormQuestion(); |
34 | 34 | $qst = $question->read($questionId); |
35 | - if( !$qst ) { |
|
35 | + if (!$qst) { |
|
36 | 36 | return ''; |
37 | 37 | } |
38 | 38 | $question->id = $qst->id; |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | $question->type = $qst->type; |
41 | 41 | $question->question = $qst->question; |
42 | 42 | $question->description = $qst->description; |
43 | - $question->weighting=$qst->weighting; |
|
44 | - $question->position=$qst->position; |
|
45 | - $question->picture=$qst->picture; |
|
43 | + $question->weighting = $qst->weighting; |
|
44 | + $question->position = $qst->position; |
|
45 | + $question->picture = $qst->picture; |
|
46 | 46 | $assessmentItem = new ScormAssessmentItem($question, $standalone); |
47 | 47 | //echo "<pre>".print_r($scorm,1)."</pre>";exit; |
48 | 48 | return $assessmentItem->export(); |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | $html = $this->getQuestionHTML(); |
112 | 112 | $js = $this->getQuestionJS(); |
113 | 113 | |
114 | - if( is_object($this->answer) ) |
|
114 | + if (is_object($this->answer)) |
|
115 | 115 | { |
116 | - list($js2,$html2) = $this->answer->export(); |
|
116 | + list($js2, $html2) = $this->answer->export(); |
|
117 | 117 | $js .= $js2; |
118 | 118 | $html .= $html2; |
119 | 119 | } |
120 | 120 | |
121 | - return array($js,$html); |
|
121 | + return array($js, $html); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | function createAnswersForm($form) |
@@ -136,19 +136,19 @@ discard block |
||
136 | 136 | */ |
137 | 137 | function getQuestionHTML() |
138 | 138 | { |
139 | - $title = $this->selectTitle(); |
|
140 | - $description = $this->selectDescription(); |
|
139 | + $title = $this->selectTitle(); |
|
140 | + $description = $this->selectDescription(); |
|
141 | 141 | $cols = 2; |
142 | - $s='<tr>' . |
|
143 | - '<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">' . "\n" . |
|
142 | + $s = '<tr>'. |
|
143 | + '<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">'."\n". |
|
144 | 144 | $title. |
145 | - '</td>' . "\n" . |
|
146 | - '</tr>' . "\n" . |
|
147 | - '<tr>' . "\n" . |
|
148 | - '<td valign="top" colspan="'.$cols.'">' . "\n" . |
|
149 | - '<i>'.$description.'</i>' . "\n" . |
|
150 | - '</td>' . "\n" . |
|
151 | - '</tr>' . "\n"; |
|
145 | + '</td>'."\n". |
|
146 | + '</tr>'."\n". |
|
147 | + '<tr>'."\n". |
|
148 | + '<td valign="top" colspan="'.$cols.'">'."\n". |
|
149 | + '<i>'.$description.'</i>'."\n". |
|
150 | + '</td>'."\n". |
|
151 | + '</tr>'."\n"; |
|
152 | 152 | return $s; |
153 | 153 | } |
154 | 154 | |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | //$id = $this->id; |
161 | 161 | $w = $this->selectWeighting(); |
162 | 162 | $s = 'questions.push('.$this->js_id.');'."\n"; |
163 | - if($this->type == FREE_ANSWER or $this->type == HOT_SPOT) |
|
163 | + if ($this->type == FREE_ANSWER or $this->type == HOT_SPOT) |
|
164 | 164 | { //put the max score to 0 to avoid discounting the points of |
165 | 165 | //non-exported quiz types in the SCORM |
166 | - $w=0; |
|
166 | + $w = 0; |
|
167 | 167 | } |
168 | 168 | $s .= 'questions_score_max['.$this->js_id.'] = '.$w.";\n"; |
169 | 169 | return $s; |
@@ -184,40 +184,40 @@ discard block |
||
184 | 184 | { |
185 | 185 | $html = ''; |
186 | 186 | $js = ''; |
187 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
187 | + $html = '<tr><td colspan="2"><table width="100%">'."\n"; |
|
188 | 188 | $type = $this->getQuestionType(); |
189 | 189 | $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
190 | 190 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
191 | 191 | |
192 | 192 | //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM |
193 | 193 | //if ($type == MCMA || $type == MULTIPLE_ANSWER_COMBINATION ) { |
194 | - if ($type == MCMA ) { |
|
194 | + if ($type == MCMA) { |
|
195 | 195 | //$questionTypeLang = get_lang('MultipleChoiceMultipleAnswers'); |
196 | 196 | $id = 1; |
197 | 197 | $jstmp = ''; |
198 | 198 | $jstmpc = ''; |
199 | - foreach( $this->answer as $i => $answer ) |
|
199 | + foreach ($this->answer as $i => $answer) |
|
200 | 200 | { |
201 | 201 | $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i; |
202 | 202 | $html .= |
203 | - '<tr>' . "\n" |
|
204 | - . '<td align="center" width="5%">' . "\n" |
|
205 | - . '<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />' . "\n" |
|
206 | - . '</td>' . "\n" |
|
207 | - . '<td width="95%">' . "\n" |
|
208 | - . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
209 | - . '</td>' . "\n" |
|
210 | - . '</tr>' . "\n\n"; |
|
203 | + '<tr>'."\n" |
|
204 | + . '<td align="center" width="5%">'."\n" |
|
205 | + . '<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />'."\n" |
|
206 | + . '</td>'."\n" |
|
207 | + . '<td width="95%">'."\n" |
|
208 | + . '<label for="'.$identifier.'">'.$this->answer[$i].'</label>'."\n" |
|
209 | + . '</td>'."\n" |
|
210 | + . '</tr>'."\n\n"; |
|
211 | 211 | $jstmp .= $i.','; |
212 | - if($this->correct[$i]) |
|
212 | + if ($this->correct[$i]) |
|
213 | 213 | { |
214 | 214 | $jstmpc .= $i.','; |
215 | 215 | } |
216 | 216 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
217 | 217 | $id++; |
218 | 218 | } |
219 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
220 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
219 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp, 0, -1).');'."\n"; |
|
220 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc, 0, -1).');'."\n"; |
|
221 | 221 | if ($type == MCMA) { |
222 | 222 | $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n"; |
223 | 223 | } else { |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | //To this items we show the ThisItemIsNotExportable |
229 | 229 | $qId = $this->questionJSId; |
230 | 230 | $js = ''; |
231 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
231 | + $html = '<tr><td colspan="2"><table width="100%">'."\n"; |
|
232 | 232 | // some javascript must be added for that kind of questions |
233 | - $html .= '<tr>' . "\n" |
|
234 | - . '<td>' . "\n" |
|
235 | - . '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>' . "\n" |
|
236 | - . '</td>' . "\n" |
|
237 | - . '</tr>' . "\n"; |
|
238 | - $html .= '</table></td></tr>' . "\n"; |
|
233 | + $html .= '<tr>'."\n" |
|
234 | + . '<td>'."\n" |
|
235 | + . '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>'."\n" |
|
236 | + . '</td>'."\n" |
|
237 | + . '</tr>'."\n"; |
|
238 | + $html .= '</table></td></tr>'."\n"; |
|
239 | 239 | // currently the exact answers cannot be displayed, so ignore the textarea |
240 | 240 | $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
241 | 241 | $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
@@ -245,40 +245,40 @@ discard block |
||
245 | 245 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
246 | 246 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
247 | 247 | $js .= $jstmpw; |
248 | - return array($js,$html); |
|
248 | + return array($js, $html); |
|
249 | 249 | } else { |
250 | 250 | //$questionTypeLang = get_lang('MultipleChoiceUniqueAnswer'); |
251 | 251 | $id = 1; |
252 | 252 | $jstmp = ''; |
253 | 253 | $jstmpc = ''; |
254 | - foreach( $this->answer as $i => $answer ) |
|
254 | + foreach ($this->answer as $i => $answer) |
|
255 | 255 | { |
256 | 256 | $identifier = 'question_'.$this->questionJSId.'_unique_'.$i; |
257 | 257 | $identifier_name = 'question_'.$this->questionJSId.'_unique_answer'; |
258 | 258 | $html .= |
259 | - '<tr>' . "\n" |
|
260 | - . '<td align="center" width="5%">' . "\n" |
|
261 | - . '<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>' . "\n" |
|
262 | - . '</td>' . "\n" |
|
263 | - . '<td width="95%">' . "\n" |
|
264 | - . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
265 | - . '</td>' . "\n" |
|
266 | - . '</tr>' . "\n\n"; |
|
259 | + '<tr>'."\n" |
|
260 | + . '<td align="center" width="5%">'."\n" |
|
261 | + . '<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>'."\n" |
|
262 | + . '</td>'."\n" |
|
263 | + . '<td width="95%">'."\n" |
|
264 | + . '<label for="'.$identifier.'">'.$this->answer[$i].'</label>'."\n" |
|
265 | + . '</td>'."\n" |
|
266 | + . '</tr>'."\n\n"; |
|
267 | 267 | $jstmp .= $i.','; |
268 | - if($this->correct[$i]) |
|
268 | + if ($this->correct[$i]) |
|
269 | 269 | { |
270 | 270 | $jstmpc .= $i; |
271 | 271 | } |
272 | 272 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
273 | 273 | $id++; |
274 | 274 | } |
275 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
275 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp, 0, -1).');'."\n"; |
|
276 | 276 | $js .= 'questions_answers_correct['.$this->questionJSId.'] = '.$jstmpc.';'."\n"; |
277 | 277 | $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'."\n"; |
278 | 278 | $js .= $jstmpw; |
279 | 279 | } |
280 | - $html .= '</table></td></tr>' . "\n"; |
|
281 | - return array($js,$html); |
|
280 | + $html .= '</table></td></tr>'."\n"; |
|
281 | + return array($js, $html); |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | |
@@ -302,29 +302,29 @@ discard block |
||
302 | 302 | $identifier_true = $identifier.'_true'; |
303 | 303 | $identifier_false = $identifier.'_false'; |
304 | 304 | $html .= |
305 | - '<tr>' . "\n" |
|
306 | - . '<td align="center" width="5%">' . "\n" |
|
305 | + '<tr>'."\n" |
|
306 | + . '<td align="center" width="5%">'."\n" |
|
307 | 307 | . '<input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" ' |
308 | - . '/>' . "\n" |
|
309 | - . '</td>' . "\n" |
|
310 | - . '<td width="95%">' . "\n" |
|
311 | - . '<label for="'.$identifier_true.'">' . get_lang('True') . '</label>' . "\n" |
|
312 | - . '</td>' . "\n" |
|
313 | - . '</tr>' . "\n\n"; |
|
308 | + . '/>'."\n" |
|
309 | + . '</td>'."\n" |
|
310 | + . '<td width="95%">'."\n" |
|
311 | + . '<label for="'.$identifier_true.'">'.get_lang('True').'</label>'."\n" |
|
312 | + . '</td>'."\n" |
|
313 | + . '</tr>'."\n\n"; |
|
314 | 314 | $html .= |
315 | - '<tr>' . "\n" |
|
316 | - . '<td align="center" width="5%">' . "\n" |
|
315 | + '<tr>'."\n" |
|
316 | + . '<td align="center" width="5%">'."\n" |
|
317 | 317 | . '<input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" ' |
318 | - . '/>' . "\n" |
|
319 | - . '</td>' . "\n" |
|
320 | - . '<td width="95%">' . "\n" |
|
321 | - . '<label for="'.$identifier_false.'">' . get_lang('False') . '</label>' . "\n" |
|
322 | - . '</td>' . "\n" |
|
323 | - . '</tr>' . "\n\n"; |
|
324 | - $html .= '</table></td></tr>' . "\n"; |
|
318 | + . '/>'."\n" |
|
319 | + . '</td>'."\n" |
|
320 | + . '<td width="95%">'."\n" |
|
321 | + . '<label for="'.$identifier_false.'">'.get_lang('False').'</label>'."\n" |
|
322 | + . '</td>'."\n" |
|
323 | + . '</tr>'."\n\n"; |
|
324 | + $html .= '</table></td></tr>'."\n"; |
|
325 | 325 | $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n"; |
326 | 326 | $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n"; |
327 | - if($this->response == 'TRUE') |
|
327 | + if ($this->response == 'TRUE') |
|
328 | 328 | { |
329 | 329 | $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
330 | 330 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n"; |
338 | 338 | $js .= $jstmpw; |
339 | 339 | |
340 | - return array($js,$html); |
|
340 | + return array($js, $html); |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
@@ -357,56 +357,56 @@ discard block |
||
357 | 357 | { |
358 | 358 | global $charset; |
359 | 359 | $js = ''; |
360 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
360 | + $html = '<tr><td colspan="2"><table width="100%">'."\n"; |
|
361 | 361 | // get all enclosed answers |
362 | 362 | $blankList = array(); |
363 | 363 | // build replacement |
364 | 364 | $replacementList = array(); |
365 | - foreach( $this->answer as $i => $answer) { |
|
365 | + foreach ($this->answer as $i => $answer) { |
|
366 | 366 | $blankList[] = '['.$answer.']'; |
367 | 367 | } |
368 | 368 | $answerCount = count($blankList); |
369 | 369 | |
370 | 370 | // splits text and weightings that are joined with the character '::' |
371 | - list($answer,$weight)=explode('::',$answer); |
|
372 | - $weights = explode(',',$weight); |
|
371 | + list($answer, $weight) = explode('::', $answer); |
|
372 | + $weights = explode(',', $weight); |
|
373 | 373 | // because [] is parsed here we follow this procedure: |
374 | 374 | // 1. find everything between the [ and ] tags |
375 | - $i=1; |
|
375 | + $i = 1; |
|
376 | 376 | $jstmp = ''; |
377 | 377 | $jstmpc = ''; |
378 | 378 | $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
379 | 379 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
380 | - $startlocations=api_strpos($answer,'['); |
|
381 | - $endlocations=api_strpos($answer,']'); |
|
382 | - while($startlocations !== false && $endlocations !== false) { |
|
383 | - $texstring=api_substr($answer,$startlocations,($endlocations-$startlocations)+1); |
|
384 | - $answer = api_substr_replace($answer,'<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',$startlocations,($endlocations-$startlocations)+1); |
|
380 | + $startlocations = api_strpos($answer, '['); |
|
381 | + $endlocations = api_strpos($answer, ']'); |
|
382 | + while ($startlocations !== false && $endlocations !== false) { |
|
383 | + $texstring = api_substr($answer, $startlocations, ($endlocations - $startlocations) + 1); |
|
384 | + $answer = api_substr_replace($answer, '<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />', $startlocations, ($endlocations - $startlocations) + 1); |
|
385 | 385 | $jstmp .= $i.','; |
386 | - $jstmpc .= "'".api_htmlentities(api_substr($texstring,1,-1),ENT_QUOTES,$charset)."',"; |
|
387 | - $my_weight=explode('@',$weights[$i-1]); |
|
388 | - if (count($my_weight)==2) { |
|
389 | - $weight_db=$my_weight[0]; |
|
386 | + $jstmpc .= "'".api_htmlentities(api_substr($texstring, 1, -1), ENT_QUOTES, $charset)."',"; |
|
387 | + $my_weight = explode('@', $weights[$i - 1]); |
|
388 | + if (count($my_weight) == 2) { |
|
389 | + $weight_db = $my_weight[0]; |
|
390 | 390 | } else { |
391 | - $weight_db=$my_weight[0]; |
|
391 | + $weight_db = $my_weight[0]; |
|
392 | 392 | } |
393 | 393 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n"; |
394 | 394 | $i++; |
395 | - $startlocations=api_strpos($answer,'['); |
|
396 | - $endlocations=api_strpos($answer,']'); |
|
395 | + $startlocations = api_strpos($answer, '['); |
|
396 | + $endlocations = api_strpos($answer, ']'); |
|
397 | 397 | } |
398 | 398 | |
399 | - $html .= '<tr>' . "\n" |
|
400 | - . '<td>' . "\n" |
|
401 | - . $answer . "\n" |
|
402 | - . '</td>' . "\n" |
|
403 | - . '</tr>' . "\n"; |
|
404 | - $html .= '</table></td></tr>' . "\n"; |
|
405 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n"; |
|
406 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n"; |
|
399 | + $html .= '<tr>'."\n" |
|
400 | + . '<td>'."\n" |
|
401 | + . $answer."\n" |
|
402 | + . '</td>'."\n" |
|
403 | + . '</tr>'."\n"; |
|
404 | + $html .= '</table></td></tr>'."\n"; |
|
405 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp, 0, -1).');'."\n"; |
|
406 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc, 0, -1).');'."\n"; |
|
407 | 407 | $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n"; |
408 | 408 | $js .= $jstmpw; |
409 | - return array($js,$html); |
|
409 | + return array($js, $html); |
|
410 | 410 | } |
411 | 411 | } |
412 | 412 | |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | function export() |
424 | 424 | { |
425 | 425 | $js = ''; |
426 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
426 | + $html = '<tr><td colspan="2"><table width="100%">'."\n"; |
|
427 | 427 | // prepare list of right proposition to allow |
428 | 428 | // - easiest display |
429 | 429 | // - easiest randomisation if needed one day |
@@ -432,12 +432,12 @@ discard block |
||
432 | 432 | $displayedRightList = array_values($this->rightList); |
433 | 433 | } |
434 | 434 | // get max length of displayed array |
435 | - $arrayLength = max( count($this->leftList), count($this->rightList) ); |
|
435 | + $arrayLength = max(count($this->leftList), count($this->rightList)); |
|
436 | 436 | |
437 | - $nbrAnswers=$this->selectNbrAnswers(); |
|
438 | - $cpt1='A'; |
|
439 | - $cpt2=1; |
|
440 | - $Select=array(); |
|
437 | + $nbrAnswers = $this->selectNbrAnswers(); |
|
438 | + $cpt1 = 'A'; |
|
439 | + $cpt2 = 1; |
|
440 | + $Select = array(); |
|
441 | 441 | $qId = $this->questionJSId; |
442 | 442 | $s = ''; |
443 | 443 | $jstmp = ''; |
@@ -445,74 +445,74 @@ discard block |
||
445 | 445 | $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
446 | 446 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
447 | 447 | |
448 | - for($answerId=1;$answerId <= $nbrAnswers;$answerId++) { |
|
448 | + for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) { |
|
449 | 449 | $identifier = 'question_'.$qId.'_matching_'; |
450 | - $answer=$this->selectAnswer($answerId); |
|
451 | - $answerCorrect=$this->isCorrect($answerId); |
|
452 | - $weight=$this->selectWeighting($answerId); |
|
450 | + $answer = $this->selectAnswer($answerId); |
|
451 | + $answerCorrect = $this->isCorrect($answerId); |
|
452 | + $weight = $this->selectWeighting($answerId); |
|
453 | 453 | $jstmp .= $answerId.','; |
454 | 454 | |
455 | 455 | if (!$answerCorrect) { |
456 | 456 | // options (A, B, C, ...) that will be put into the list-box |
457 | - $Select[$answerId]['Lettre']=$cpt1; |
|
457 | + $Select[$answerId]['Lettre'] = $cpt1; |
|
458 | 458 | // answers that will be shown at the right side |
459 | 459 | $Select[$answerId]['Reponse'] = $answer; |
460 | 460 | $cpt1++; |
461 | 461 | } else { |
462 | - $s.='<tr>'."\n"; |
|
463 | - $s.='<td width="40%" valign="top">'."\n".'<b>'.$cpt2.'</b>. '.$answer."\n</td>\n"; |
|
464 | - $s.='<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
465 | - $s.=' <option value="0">--</option>'; |
|
462 | + $s .= '<tr>'."\n"; |
|
463 | + $s .= '<td width="40%" valign="top">'."\n".'<b>'.$cpt2.'</b>. '.$answer."\n</td>\n"; |
|
464 | + $s .= '<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
465 | + $s .= ' <option value="0">--</option>'; |
|
466 | 466 | // fills the list-box |
467 | - foreach($Select as $key=>$val) |
|
467 | + foreach ($Select as $key=>$val) |
|
468 | 468 | { |
469 | - $s.='<option value="'.$key.'">'.$val['Lettre'].'</option>'; |
|
469 | + $s .= '<option value="'.$key.'">'.$val['Lettre'].'</option>'; |
|
470 | 470 | } // end foreach() |
471 | 471 | |
472 | - $s.='</select> </td>'."\n"; |
|
473 | - $s.='<td width="40%" valign="top">'; |
|
474 | - if(isset($Select[$cpt2])) $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
475 | - else $s.=' '; |
|
476 | - $s.="</td>\n</tr>\n"; |
|
472 | + $s .= '</select> </td>'."\n"; |
|
473 | + $s .= '<td width="40%" valign="top">'; |
|
474 | + if (isset($Select[$cpt2])) $s .= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
475 | + else $s .= ' '; |
|
476 | + $s .= "</td>\n</tr>\n"; |
|
477 | 477 | |
478 | 478 | $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
479 | 479 | |
480 | - $my_weight=explode('@',$weight); |
|
481 | - if (count($my_weight)==2) { |
|
482 | - $weight=$my_weight[0]; |
|
480 | + $my_weight = explode('@', $weight); |
|
481 | + if (count($my_weight) == 2) { |
|
482 | + $weight = $my_weight[0]; |
|
483 | 483 | } else { |
484 | - $weight=$my_weight[0]; |
|
484 | + $weight = $my_weight[0]; |
|
485 | 485 | } |
486 | 486 | $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n"; |
487 | 487 | $cpt2++; |
488 | 488 | |
489 | 489 | // if the left side of the "matching" has been completely shown |
490 | - if($answerId == $nbrAnswers) |
|
490 | + if ($answerId == $nbrAnswers) |
|
491 | 491 | { |
492 | 492 | // if there remain answers to be shown on the right side |
493 | - while(isset($Select[$cpt2])) |
|
493 | + while (isset($Select[$cpt2])) |
|
494 | 494 | { |
495 | 495 | //$s.='<tr>'."\n"; |
496 | 496 | //$s.='<td colspan="2">'."\n"; |
497 | 497 | //$s.='<table border="0" cellpadding="0" cellspacing="0" width="100%">'."\n"; |
498 | - $s.='<tr>'."\n"; |
|
499 | - $s.='<td width="60%" colspan="2"> </td>'."\n"; |
|
500 | - $s.='<td width="40%" valign="top">'; |
|
501 | - $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
502 | - $s.="</td>\n</tr>\n"; |
|
498 | + $s .= '<tr>'."\n"; |
|
499 | + $s .= '<td width="60%" colspan="2"> </td>'."\n"; |
|
500 | + $s .= '<td width="40%" valign="top">'; |
|
501 | + $s .= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
502 | + $s .= "</td>\n</tr>\n"; |
|
503 | 503 | $cpt2++; |
504 | 504 | } // end while() |
505 | 505 | } // end if() |
506 | 506 | } |
507 | 507 | } |
508 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
509 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
508 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp, 0, -1).');'."\n"; |
|
509 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc, 0, -1).');'."\n"; |
|
510 | 510 | $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n"; |
511 | 511 | $js .= $jstmpw; |
512 | 512 | $html .= $s; |
513 | - $html .= '</table></td></tr>' . "\n"; |
|
513 | + $html .= '</table></td></tr>'."\n"; |
|
514 | 514 | |
515 | - return array($js,$html); |
|
515 | + return array($js, $html); |
|
516 | 516 | } |
517 | 517 | } |
518 | 518 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
550 | 550 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
551 | 551 | $js .= $jstmpw; |
552 | - return array($js,$html); |
|
552 | + return array($js, $html); |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | /** |
@@ -601,15 +601,15 @@ discard block |
||
601 | 601 | function export() |
602 | 602 | { |
603 | 603 | $js = $this->get_js_header(); |
604 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
604 | + $html = '<tr><td colspan="2"><table width="100%">'."\n"; |
|
605 | 605 | // some javascript must be added for that kind of questions |
606 | 606 | $html .= ''; |
607 | 607 | |
608 | 608 | // Get the answers, make a list |
609 | - $nbrAnswers=$this->selectNbrAnswers(); |
|
609 | + $nbrAnswers = $this->selectNbrAnswers(); |
|
610 | 610 | |
611 | 611 | $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>'; |
612 | - for($answerId=1;$answerId <= $nbrAnswers;$answerId++) |
|
612 | + for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) |
|
613 | 613 | { |
614 | 614 | $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>'; |
615 | 615 | } |
@@ -658,11 +658,11 @@ discard block |
||
658 | 658 | </td> |
659 | 659 | <tr> |
660 | 660 | HTML; |
661 | - $html .= '</table></td></tr>' . "\n"; |
|
661 | + $html .= '</table></td></tr>'."\n"; |
|
662 | 662 | |
663 | 663 | // currently the free answers cannot be displayed, so ignore the textarea |
664 | 664 | $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
665 | - return array($js,$html); |
|
665 | + return array($js, $html); |
|
666 | 666 | } |
667 | 667 | } |
668 | 668 | |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | { |
694 | 694 | $this->question = $question; |
695 | 695 | $this->question->setAnswer(); |
696 | - $this->questionIdent = "QST_" . $question->id ; |
|
696 | + $this->questionIdent = "QST_".$question->id; |
|
697 | 697 | $this->standalone = $standalone; |
698 | 698 | } |
699 | 699 | |
@@ -707,9 +707,9 @@ discard block |
||
707 | 707 | { |
708 | 708 | global $charset; |
709 | 709 | $head = ""; |
710 | - if( $this->standalone) |
|
710 | + if ($this->standalone) |
|
711 | 711 | { |
712 | - $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?>' . "\n"; |
|
712 | + $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?>'."\n"; |
|
713 | 713 | $head .= '<html>'."\n"; |
714 | 714 | } |
715 | 715 | return $head; |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | * |
721 | 721 | */ |
722 | 722 | function end_page() { |
723 | - if($this->standalone){return '</html>';} |
|
723 | + if ($this->standalone) {return '</html>'; } |
|
724 | 724 | return ''; |
725 | 725 | } |
726 | 726 | |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | * Start document header |
729 | 729 | */ |
730 | 730 | function start_header() { |
731 | - if($this->standalone){return '<head>'. "\n";} |
|
731 | + if ($this->standalone) {return '<head>'."\n"; } |
|
732 | 732 | return ''; |
733 | 733 | } |
734 | 734 | |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | */ |
756 | 756 | function end_header() |
757 | 757 | { |
758 | - if($this->standalone){return '</head>'. "\n";} |
|
758 | + if ($this->standalone) {return '</head>'."\n"; } |
|
759 | 759 | return ''; |
760 | 760 | } |
761 | 761 | /** |
@@ -775,11 +775,11 @@ discard block |
||
775 | 775 | function common_js() |
776 | 776 | { |
777 | 777 | $js = file_get_contents('../newscorm/js/api_wrapper.js'); |
778 | - $js .= 'var questions = new Array();' . "\n"; |
|
779 | - $js .= 'var questions_answers = new Array();' . "\n"; |
|
780 | - $js .= 'var questions_answers_correct = new Array();' . "\n"; |
|
781 | - $js .= 'var questions_types = new Array();' . "\n"; |
|
782 | - $js .= "\n" . |
|
778 | + $js .= 'var questions = new Array();'."\n"; |
|
779 | + $js .= 'var questions_answers = new Array();'."\n"; |
|
780 | + $js .= 'var questions_answers_correct = new Array();'."\n"; |
|
781 | + $js .= 'var questions_types = new Array();'."\n"; |
|
782 | + $js .= "\n". |
|
783 | 783 | '/** |
784 | 784 | * Assigns any event handler to any element |
785 | 785 | * @param object Element on which the event is added |
@@ -819,7 +819,7 @@ discard block |
||
819 | 819 | //$js .= 'addEvent(window,\'load\',loadPage,false);'."\n"; |
820 | 820 | //$js .= 'addEvent(window,\'unload\',unloadPage,false);'."\n"; |
821 | 821 | $js .= 'addEvent(window,\'load\',addListeners,false);'."\n"; |
822 | - if($this->standalone){return $js. "\n";} |
|
822 | + if ($this->standalone) {return $js."\n"; } |
|
823 | 823 | return ''; |
824 | 824 | } |
825 | 825 | |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | */ |
830 | 830 | function end_js() |
831 | 831 | { |
832 | - if($this->standalone){return '</script>'. "\n";} |
|
832 | + if ($this->standalone) {return '</script>'."\n"; } |
|
833 | 833 | return ''; |
834 | 834 | } |
835 | 835 | |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | */ |
840 | 840 | function start_body() |
841 | 841 | { |
842 | - if($this->standalone){return '<body>'. "\n".'<form id="dokeos_scorm_form" method="post" action="">'."\n";} |
|
842 | + if ($this->standalone) {return '<body>'."\n".'<form id="dokeos_scorm_form" method="post" action="">'."\n"; } |
|
843 | 843 | return ''; |
844 | 844 | } |
845 | 845 | |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | */ |
850 | 850 | function end_body() |
851 | 851 | { |
852 | - if($this->standalone){return '<br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form>'."\n".'</body>'. "\n";} |
|
852 | + if ($this->standalone) {return '<br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form>'."\n".'</body>'."\n"; } |
|
853 | 853 | return ''; |
854 | 854 | } |
855 | 855 | |
@@ -864,9 +864,9 @@ discard block |
||
864 | 864 | function export() |
865 | 865 | { |
866 | 866 | $js = $html = ''; |
867 | - list($js,$html) = $this->question->export(); |
|
867 | + list($js, $html) = $this->question->export(); |
|
868 | 868 | //list($js,$html) = $this->question->answer->export(); |
869 | - if($this->standalone) |
|
869 | + if ($this->standalone) |
|
870 | 870 | { |
871 | 871 | $res = $this->start_page() |
872 | 872 | . $this->start_header() |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | } |
889 | 889 | else |
890 | 890 | { |
891 | - return array($js,$html); |
|
891 | + return array($js, $html); |
|
892 | 892 | } |
893 | 893 | } |
894 | 894 | } |
@@ -917,9 +917,9 @@ discard block |
||
917 | 917 | * @param boolean $standalone Wether it should include XML tag and DTD line. |
918 | 918 | * @return The XML as a string, or an empty string if there's no exercise with given ID. |
919 | 919 | */ |
920 | - public static function export_exercise_to_scorm($exerciseId, $standalone=true) { |
|
920 | + public static function export_exercise_to_scorm($exerciseId, $standalone = true) { |
|
921 | 921 | $exercise = new Exercise(); |
922 | - if (! $exercise->read($exerciseId)) { |
|
922 | + if (!$exercise->read($exerciseId)) { |
|
923 | 923 | return ''; |
924 | 924 | } |
925 | 925 | $ims = new ScormSection($exercise); |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | function start_page() { |
947 | 947 | global $charset; |
948 | 948 | $head = $foot = ""; |
949 | - $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?>' . "\n".'<html>'."\n"; |
|
949 | + $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?>'."\n".'<html>'."\n"; |
|
950 | 950 | return $head; |
951 | 951 | } |
952 | 952 | |
@@ -962,7 +962,7 @@ discard block |
||
962 | 962 | * Start document header |
963 | 963 | */ |
964 | 964 | function start_header() { |
965 | - return '<head>'. "\n"; |
|
965 | + return '<head>'."\n"; |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | /** |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | * End document header |
985 | 985 | */ |
986 | 986 | function end_header() { |
987 | - return '</head>'. "\n"; |
|
987 | + return '</head>'."\n"; |
|
988 | 988 | } |
989 | 989 | |
990 | 990 | /** |
@@ -992,7 +992,7 @@ discard block |
||
992 | 992 | * |
993 | 993 | */ |
994 | 994 | function start_js() { |
995 | - return '<script type="text/javascript" language="javascript">'. "\n"; |
|
995 | + return '<script type="text/javascript" language="javascript">'."\n"; |
|
996 | 996 | } |
997 | 997 | |
998 | 998 | /** |
@@ -1002,11 +1002,11 @@ discard block |
||
1002 | 1002 | $js = "\n"; |
1003 | 1003 | $js .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js'); |
1004 | 1004 | $js .= file_get_contents('../newscorm/js/api_wrapper.js'); |
1005 | - $js .= 'var questions = new Array();' . "\n"; |
|
1006 | - $js .= 'var questions_answers = new Array();' . "\n"; |
|
1007 | - $js .= 'var questions_answers_correct = new Array();' . "\n"; |
|
1008 | - $js .= 'var questions_types = new Array();' . "\n"; |
|
1009 | - $js .= "\n" . |
|
1005 | + $js .= 'var questions = new Array();'."\n"; |
|
1006 | + $js .= 'var questions_answers = new Array();'."\n"; |
|
1007 | + $js .= 'var questions_answers_correct = new Array();'."\n"; |
|
1008 | + $js .= 'var questions_types = new Array();'."\n"; |
|
1009 | + $js .= "\n". |
|
1010 | 1010 | '/** |
1011 | 1011 | * Assigns any event handler to any element |
1012 | 1012 | * @param object Element on which the event is added |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | //$js .= 'addEvent(window,\'load\',loadPage,false);'."\n"; |
1054 | 1054 | //$js .= 'addEvent(window,\'unload\',unloadPage,false);'."\n"; |
1055 | 1055 | $js .= 'addEvent(window,\'load\',addListeners,false);'."\n"; |
1056 | - return $js. "\n"; |
|
1056 | + return $js."\n"; |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | /** |
@@ -1061,7 +1061,7 @@ discard block |
||
1061 | 1061 | * |
1062 | 1062 | */ |
1063 | 1063 | function end_js() { |
1064 | - return '</script>'. "\n"; |
|
1064 | + return '</script>'."\n"; |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | /** |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | */ |
1071 | 1071 | function start_body() |
1072 | 1072 | { |
1073 | - return '<body>'. "\n". |
|
1073 | + return '<body>'."\n". |
|
1074 | 1074 | '<h1>'.$this->exercise->selectTitle().'</h1><p>'.$this->exercise->selectDescription()."</p>\n". |
1075 | 1075 | '<form id="dokeos_scorm_form" method="post" action="">'."\n". |
1076 | 1076 | '<table width="100%">'."\n"; |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | */ |
1083 | 1083 | function end_body() |
1084 | 1084 | { |
1085 | - return '</table><br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form>'."\n".'</body>'. "\n"; |
|
1085 | + return '</table><br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form>'."\n".'</body>'."\n"; |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | /** |
@@ -1099,11 +1099,11 @@ discard block |
||
1099 | 1099 | |
1100 | 1100 | $head = ""; |
1101 | 1101 | if ($this->standalone) { |
1102 | - $head = '<?xml version = "1.0" encoding = "' . $charset . '" standalone = "no"?>' . "\n" |
|
1103 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"; |
|
1102 | + $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>'."\n" |
|
1103 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">'."\n"; |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | - list($js,$html) = $this->export_questions(); |
|
1106 | + list($js, $html) = $this->export_questions(); |
|
1107 | 1107 | //list($js,$html) = $this->question->answer->export(); |
1108 | 1108 | $res = $this->start_page() |
1109 | 1109 | . $this->start_header() |
@@ -1134,12 +1134,12 @@ discard block |
||
1134 | 1134 | $js = $html = ""; |
1135 | 1135 | $js_id = 0; |
1136 | 1136 | foreach ($this->exercise->selectQuestionList() as $q) { |
1137 | - list($jstmp,$htmltmp)= ScormQuestion::export_question($q, false, $js_id); |
|
1137 | + list($jstmp, $htmltmp) = ScormQuestion::export_question($q, false, $js_id); |
|
1138 | 1138 | $js .= $jstmp."\n"; |
1139 | 1139 | $html .= $htmltmp."\n"; |
1140 | 1140 | ++$js_id; |
1141 | 1141 | } |
1142 | - return array($js,$html); |
|
1142 | + return array($js, $html); |
|
1143 | 1143 | } |
1144 | 1144 | } |
1145 | 1145 |
@@ -327,8 +327,7 @@ discard block |
||
327 | 327 | if($this->response == 'TRUE') |
328 | 328 | { |
329 | 329 | $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
330 | - } |
|
331 | - else |
|
330 | + } else |
|
332 | 331 | { |
333 | 332 | $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n"; |
334 | 333 | } |
@@ -471,8 +470,11 @@ discard block |
||
471 | 470 | |
472 | 471 | $s.='</select> </td>'."\n"; |
473 | 472 | $s.='<td width="40%" valign="top">'; |
474 | - if(isset($Select[$cpt2])) $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
475 | - else $s.=' '; |
|
473 | + if(isset($Select[$cpt2])) { |
|
474 | + $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
475 | + } else { |
|
476 | + $s.=' '; |
|
477 | + } |
|
476 | 478 | $s.="</td>\n</tr>\n"; |
477 | 479 | |
478 | 480 | $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
@@ -577,8 +579,7 @@ discard block |
||
577 | 579 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
578 | 580 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
579 | 581 | $header .= $jstmpw; |
580 | - } |
|
581 | - else |
|
582 | + } else |
|
582 | 583 | { |
583 | 584 | $header = ''; |
584 | 585 | $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
@@ -885,8 +886,7 @@ discard block |
||
885 | 886 | . $this->end_body() |
886 | 887 | . $this->end_page(); |
887 | 888 | return $res; |
888 | - } |
|
889 | - else |
|
889 | + } else |
|
890 | 890 | { |
891 | 891 | return array($js,$html); |
892 | 892 | } |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | * @param null $feedback_type |
416 | 416 | * @param null $counter |
417 | 417 | * @param null $score |
418 | - * @return null|string |
|
418 | + * @return string |
|
419 | 419 | */ |
420 | 420 | public function return_header($feedback_type = null, $counter = null, $score = null) |
421 | 421 | { |
@@ -429,15 +429,16 @@ discard block |
||
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
432 | - * @param $separatorStartRegexp |
|
433 | - * @param $separatorEndRegexp |
|
434 | - * @param $correctItemRegexp |
|
435 | - * @param $questionId |
|
432 | + * @param string $separatorStartRegexp |
|
433 | + * @param string $separatorEndRegexp |
|
434 | + * @param string $correctItemRegexp |
|
435 | + * @param integer $questionId |
|
436 | 436 | * @param $correctItem |
437 | 437 | * @param $attributes |
438 | - * @param $answer |
|
438 | + * @param string $answer |
|
439 | 439 | * @param $listAnswersInfo |
440 | - * @param $displayForStudent |
|
440 | + * @param boolean $displayForStudent |
|
441 | + * @param integer $inBlankNumber |
|
441 | 442 | * @return string |
442 | 443 | */ |
443 | 444 | public static function getFillTheBlankHtml( |
@@ -736,11 +737,11 @@ discard block |
||
736 | 737 | * 0 : student answer is correct |
737 | 738 | * >0 : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0) |
738 | 739 | * |
739 | - * @param $testId |
|
740 | - * @param $questionId |
|
740 | + * @param integer $testId |
|
741 | + * @param integer $questionId |
|
741 | 742 | * @param $studentsIdList |
742 | - * @param $startDate |
|
743 | - * @param $endDate |
|
743 | + * @param string $startDate |
|
744 | + * @param string $endDate |
|
744 | 745 | * @param bool $useLastAnswerredAttempt |
745 | 746 | * @return array |
746 | 747 | * ( |
@@ -917,7 +918,7 @@ discard block |
||
917 | 918 | * return $text protected for use in regexp |
918 | 919 | * @param string $text |
919 | 920 | * |
920 | - * @return mixed |
|
921 | + * @return string |
|
921 | 922 | */ |
922 | 923 | public static function getRegexpProtected($text) |
923 | 924 | { |
@@ -975,7 +976,7 @@ discard block |
||
975 | 976 | * return the start separator for answer |
976 | 977 | * @param string $number |
977 | 978 | * |
978 | - * @return mixed |
|
979 | + * @return string |
|
979 | 980 | */ |
980 | 981 | public static function getStartSeparator($number) |
981 | 982 | { |
@@ -988,7 +989,7 @@ discard block |
||
988 | 989 | * return the end separator for answer |
989 | 990 | * @param string $number |
990 | 991 | * |
991 | - * @return mixed |
|
992 | + * @return string |
|
992 | 993 | */ |
993 | 994 | public static function getEndSeparator($number) |
994 | 995 | { |
@@ -729,43 +729,43 @@ discard block |
||
729 | 729 | } |
730 | 730 | |
731 | 731 | /** |
732 | - * Return an array of student state answers for fill the blank questions |
|
733 | - * for each students that answered the question |
|
734 | - * -2 : didn't answer |
|
735 | - * -1 : student answer is wrong |
|
736 | - * 0 : student answer is correct |
|
737 | - * >0 : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0) |
|
738 | - * |
|
739 | - * @param $testId |
|
740 | - * @param $questionId |
|
741 | - * @param $studentsIdList |
|
742 | - * @param $startDate |
|
743 | - * @param $endDate |
|
744 | - * @param bool $useLastAnswerredAttempt |
|
745 | - * @return array |
|
746 | - * ( |
|
747 | - * [student_id] => Array |
|
748 | - * ( |
|
749 | - * [first fill the blank for question] => -1 |
|
750 | - * [second fill the blank for question] => 2 |
|
751 | - * [third fill the blank for question] => -1 |
|
752 | - * ) |
|
753 | - * ) |
|
754 | - */ |
|
732 | + * Return an array of student state answers for fill the blank questions |
|
733 | + * for each students that answered the question |
|
734 | + * -2 : didn't answer |
|
735 | + * -1 : student answer is wrong |
|
736 | + * 0 : student answer is correct |
|
737 | + * >0 : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0) |
|
738 | + * |
|
739 | + * @param $testId |
|
740 | + * @param $questionId |
|
741 | + * @param $studentsIdList |
|
742 | + * @param $startDate |
|
743 | + * @param $endDate |
|
744 | + * @param bool $useLastAnswerredAttempt |
|
745 | + * @return array |
|
746 | + * ( |
|
747 | + * [student_id] => Array |
|
748 | + * ( |
|
749 | + * [first fill the blank for question] => -1 |
|
750 | + * [second fill the blank for question] => 2 |
|
751 | + * [third fill the blank for question] => -1 |
|
752 | + * ) |
|
753 | + * ) |
|
754 | + */ |
|
755 | 755 | public static function getFillTheBlankTabResult($testId, $questionId, $studentsIdList, $startDate, $endDate, $useLastAnswerredAttempt = true) { |
756 | 756 | |
757 | - $tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
758 | - $tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
|
759 | - $courseId = api_get_course_int_id(); |
|
757 | + $tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
758 | + $tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
|
759 | + $courseId = api_get_course_int_id(); |
|
760 | 760 | |
761 | - require_once api_get_path(SYS_PATH).'main/exercice/fill_blanks.class.php'; |
|
761 | + require_once api_get_path(SYS_PATH).'main/exercice/fill_blanks.class.php'; |
|
762 | 762 | |
763 | - // request to have all the answers of student for this question |
|
764 | - // student may have doing it several time |
|
765 | - // student may have not answered the bracket id, in this case, is result of the answer is empty |
|
763 | + // request to have all the answers of student for this question |
|
764 | + // student may have doing it several time |
|
765 | + // student may have not answered the bracket id, in this case, is result of the answer is empty |
|
766 | 766 | |
767 | - // we got the less recent attempt first |
|
768 | - $sql = ' |
|
767 | + // we got the less recent attempt first |
|
768 | + $sql = ' |
|
769 | 769 | SELECT * FROM '.$tblTrackEAttempt.' tea |
770 | 770 | |
771 | 771 | LEFT JOIN '.$tblTrackEExercise.' tee |
@@ -781,49 +781,49 @@ discard block |
||
781 | 781 | ORDER BY user_id, tea.exe_id; |
782 | 782 | '; |
783 | 783 | |
784 | - $res = Database::query($sql); |
|
785 | - $tabUserResult = array(); |
|
786 | - $bracketNumber = 0; |
|
787 | - // foreach attempts for all students starting with his older attempt |
|
788 | - while ($data = Database::fetch_array($res)) { |
|
789 | - $tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true); |
|
784 | + $res = Database::query($sql); |
|
785 | + $tabUserResult = array(); |
|
786 | + $bracketNumber = 0; |
|
787 | + // foreach attempts for all students starting with his older attempt |
|
788 | + while ($data = Database::fetch_array($res)) { |
|
789 | + $tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true); |
|
790 | 790 | |
791 | - // for each bracket to find in this question |
|
792 | - foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) { |
|
791 | + // for each bracket to find in this question |
|
792 | + foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) { |
|
793 | 793 | |
794 | - if ($tabAnswer['studentanswer'][$bracketNumber] != '') { |
|
795 | - // student has answered this bracket, cool |
|
796 | - switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) { |
|
797 | - case self::FILL_THE_BLANK_MENU : |
|
794 | + if ($tabAnswer['studentanswer'][$bracketNumber] != '') { |
|
795 | + // student has answered this bracket, cool |
|
796 | + switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) { |
|
797 | + case self::FILL_THE_BLANK_MENU : |
|
798 | 798 | // get the indice of the choosen answer in the menu |
799 | 799 | // we know that the right answer is the first entry of the menu, ie 0 |
800 | 800 | // (remember, menu entries are shuffled when taking the test) |
801 | 801 | $tabUserResult[$data['user_id']][$bracketNumber] = FillBlanks::getFillTheBlankMenuAnswerNum($tabAnswer['tabwords'][$bracketNumber], $tabAnswer['studentanswer'][$bracketNumber]); |
802 | - break; |
|
803 | - default : |
|
802 | + break; |
|
803 | + default : |
|
804 | 804 | if (FillBlanks::isGoodStudentAnswer($tabAnswer['studentanswer'][$bracketNumber], $tabAnswer['tabwords'][$bracketNumber])) { |
805 | - $tabUserResult[$data['user_id']][$bracketNumber] = 0; // right answer |
|
806 | - } else { |
|
807 | - $tabUserResult[$data['user_id']][$bracketNumber] = -1; // wrong answer |
|
808 | - } |
|
809 | - } |
|
810 | - } else { |
|
811 | - // student didn't answer this bracket |
|
812 | - if ($useLastAnswerredAttempt) { |
|
813 | - // if we take into account the last answered attempt |
|
814 | - if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) { |
|
815 | - $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
816 | - } |
|
817 | - } else { |
|
818 | - // we take the last attempt, even if the student answer the question before |
|
819 | - $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
820 | - } |
|
821 | - } |
|
822 | - } |
|
823 | - |
|
824 | - |
|
825 | - } |
|
826 | - return $tabUserResult; |
|
805 | + $tabUserResult[$data['user_id']][$bracketNumber] = 0; // right answer |
|
806 | + } else { |
|
807 | + $tabUserResult[$data['user_id']][$bracketNumber] = -1; // wrong answer |
|
808 | + } |
|
809 | + } |
|
810 | + } else { |
|
811 | + // student didn't answer this bracket |
|
812 | + if ($useLastAnswerredAttempt) { |
|
813 | + // if we take into account the last answered attempt |
|
814 | + if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) { |
|
815 | + $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
816 | + } |
|
817 | + } else { |
|
818 | + // we take the last attempt, even if the student answer the question before |
|
819 | + $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
820 | + } |
|
821 | + } |
|
822 | + } |
|
823 | + |
|
824 | + |
|
825 | + } |
|
826 | + return $tabUserResult; |
|
827 | 827 | } |
828 | 828 | |
829 | 829 |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | ['id' => 'answer', 'onkeyup' => "javascript: updateBlanks(this);"], |
261 | 261 | array('ToolbarSet' => 'TestQuestionDescription') |
262 | 262 | ); |
263 | - $form->addRule('answer',get_lang('GiveText'),'required'); |
|
263 | + $form->addRule('answer', get_lang('GiveText'), 'required'); |
|
264 | 264 | |
265 | 265 | //added multiple answers |
266 | - $form->addElement('checkbox','multiple_answer','', get_lang('FillInBlankSwitchable')); |
|
266 | + $form->addElement('checkbox', 'multiple_answer', '', get_lang('FillInBlankSwitchable')); |
|
267 | 267 | $form->addElement( |
268 | 268 | 'select', |
269 | 269 | 'select_separator', |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | null, |
277 | 277 | '<input type="button" onclick="updateBlanks()" value="'.get_lang('RefreshBlanks').'" class="btn btn-default" />' |
278 | 278 | ); |
279 | - $form->addElement('html','<div id="blanks_weighting"></div>'); |
|
279 | + $form->addElement('html', '<div id="blanks_weighting"></div>'); |
|
280 | 280 | |
281 | 281 | global $text; |
282 | 282 | // setting the save button here and not in the question class.php |
283 | - $form->addElement('html','<div id="defineoneblank" style="color:#D04A66; margin-left:160px">'.get_lang('DefineBlanks').'</div>'); |
|
283 | + $form->addElement('html', '<div id="defineoneblank" style="color:#D04A66; margin-left:160px">'.get_lang('DefineBlanks').'</div>'); |
|
284 | 284 | $form->addButtonSave($text, 'submitQuestion'); |
285 | 285 | |
286 | 286 | if (!empty($this->id)) { |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | // remove spaces at the beginning and the end of text in square brackets |
321 | 321 | $answer = preg_replace_callback( |
322 | 322 | "/".$blankStartSeparatorRegexp."[^]]+".$blankEndSeparatorRegexp."/", |
323 | - function ($matches) use ($blankStartSeparator, $blankEndSeparator) { |
|
323 | + function($matches) use ($blankStartSeparator, $blankEndSeparator) { |
|
324 | 324 | $matchingResult = $matches[0]; |
325 | 325 | $matchingResult = trim($matchingResult, $blankStartSeparator); |
326 | 326 | $matchingResult = trim($matchingResult, $blankEndSeparator); |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | if ($nb > 0) { |
366 | 366 | $answer .= '::'; |
367 | 367 | // weighting |
368 | - for ($i=0; $i < $nb; ++$i) { |
|
368 | + for ($i = 0; $i < $nb; ++$i) { |
|
369 | 369 | // enter the weighting of word $i |
370 | 370 | $answer .= $form->getSubmitValue('weighting['.$i.']'); |
371 | 371 | // not the last word, add "," |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | |
379 | 379 | // input width |
380 | 380 | $answer .= ":"; |
381 | - for ($i=0; $i < $nb; ++$i) { |
|
381 | + for ($i = 0; $i < $nb; ++$i) { |
|
382 | 382 | // enter the width of input for word $i |
383 | 383 | $answer .= $form->getSubmitValue('sizeofinput['.$i.']'); |
384 | 384 | // not the last word, add "," |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | |
404 | 404 | // Allow answers order switches |
405 | 405 | $is_multiple = $form -> getSubmitValue('multiple_answer'); |
406 | - $answer.= '@'.$is_multiple; |
|
406 | + $answer .= '@'.$is_multiple; |
|
407 | 407 | |
408 | 408 | $this->save(); |
409 | 409 | $objAnswer = new Answer($this->id); |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | public function return_header($feedback_type = null, $counter = null, $score = null) |
421 | 421 | { |
422 | 422 | $header = parent::return_header($feedback_type, $counter, $score); |
423 | - $header .= '<table class="'.$this->question_table_class .'"> |
|
423 | + $header .= '<table class="'.$this->question_table_class.'"> |
|
424 | 424 | <tr> |
425 | 425 | <th>'.get_lang("Answer").'</th> |
426 | 426 | </tr>'; |
@@ -464,13 +464,13 @@ discard block |
||
464 | 464 | // if display for student, shuffle the correct answer menu |
465 | 465 | $listMenu = self::getFillTheBlankMenuAnswers($inTeacherSolution, $displayForStudent); |
466 | 466 | $result .= '<select name="choice['.$questionId.'][]">'; |
467 | - for ($k=0; $k < count($listMenu); $k++) { |
|
467 | + for ($k = 0; $k < count($listMenu); $k++) { |
|
468 | 468 | $selected = ""; |
469 | 469 | if ($correctItem == $listMenu[$k]) { |
470 | 470 | $selected = " selected=selected "; |
471 | 471 | } |
472 | 472 | // if in teacher view, display the first item by default, which is the right answer |
473 | - if ($k==0 && !$displayForStudent) { |
|
473 | + if ($k == 0 && !$displayForStudent) { |
|
474 | 474 | $selected = " selected=selected "; |
475 | 475 | } |
476 | 476 | $optionMenu .= '<option '.$selected.' value="'.$listMenu[$k].'">'.$listMenu[$k].'</option>'; |
@@ -642,10 +642,10 @@ discard block |
||
642 | 642 | if (count($listDetails) < 3) { |
643 | 643 | $listWeightings = explode(',', $listDetails[0]); |
644 | 644 | $listSizeOfInput = array(); |
645 | - for ($i=0; $i < count($listWeightings); $i++) { |
|
645 | + for ($i = 0; $i < count($listWeightings); $i++) { |
|
646 | 646 | $listSizeOfInput[] = 200; |
647 | 647 | } |
648 | - $blankSeparatorNumber = 0; // 0 is [...] |
|
648 | + $blankSeparatorNumber = 0; // 0 is [...] |
|
649 | 649 | } else { |
650 | 650 | $listWeightings = explode(',', $listDetails[0]); |
651 | 651 | $listSizeOfInput = explode(',', $listDetails[1]); |
@@ -677,9 +677,9 @@ discard block |
||
677 | 677 | // remove [ and ] in string |
678 | 678 | array_walk( |
679 | 679 | $listWords[0], |
680 | - function (&$value, $key, $tabBlankChar) { |
|
680 | + function(&$value, $key, $tabBlankChar) { |
|
681 | 681 | $trimChars = ""; |
682 | - for ($i=0; $i < count($tabBlankChar); $i++) { |
|
682 | + for ($i = 0; $i < count($tabBlankChar); $i++) { |
|
683 | 683 | $trimChars .= $tabBlankChar[$i]; |
684 | 684 | } |
685 | 685 | $value = trim($value, $trimChars); |
@@ -699,18 +699,18 @@ discard block |
||
699 | 699 | // if student answer, the second [] is the student answer, |
700 | 700 | // the third is if student scored or not |
701 | 701 | $listBrackets = array(); |
702 | - $listWords = array(); |
|
702 | + $listWords = array(); |
|
703 | 703 | |
704 | 704 | if ($isStudentAnswer) { |
705 | - for ($i=0; $i < count($listAnswerResults['tabwords']); $i++) { |
|
705 | + for ($i = 0; $i < count($listAnswerResults['tabwords']); $i++) { |
|
706 | 706 | $listBrackets[] = $listAnswerResults['tabwordsbracket'][$i]; |
707 | 707 | $listWords[] = $listAnswerResults['tabwords'][$i]; |
708 | - if ($i+1 < count($listAnswerResults['tabwords'])) { |
|
708 | + if ($i + 1 < count($listAnswerResults['tabwords'])) { |
|
709 | 709 | // should always be |
710 | 710 | $i++; |
711 | 711 | } |
712 | 712 | $listAnswerResults['studentanswer'][] = $listAnswerResults['tabwords'][$i]; |
713 | - if ($i+1 < count($listAnswerResults['tabwords'])) { |
|
713 | + if ($i + 1 < count($listAnswerResults['tabwords'])) { |
|
714 | 714 | // should always be |
715 | 715 | $i++; |
716 | 716 | } |
@@ -802,9 +802,9 @@ discard block |
||
802 | 802 | break; |
803 | 803 | default : |
804 | 804 | if (FillBlanks::isGoodStudentAnswer($tabAnswer['studentanswer'][$bracketNumber], $tabAnswer['tabwords'][$bracketNumber])) { |
805 | - $tabUserResult[$data['user_id']][$bracketNumber] = 0; // right answer |
|
805 | + $tabUserResult[$data['user_id']][$bracketNumber] = 0; // right answer |
|
806 | 806 | } else { |
807 | - $tabUserResult[$data['user_id']][$bracketNumber] = -1; // wrong answer |
|
807 | + $tabUserResult[$data['user_id']][$bracketNumber] = -1; // wrong answer |
|
808 | 808 | } |
809 | 809 | } |
810 | 810 | } else { |
@@ -812,11 +812,11 @@ discard block |
||
812 | 812 | if ($useLastAnswerredAttempt) { |
813 | 813 | // if we take into account the last answered attempt |
814 | 814 | if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) { |
815 | - $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
815 | + $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
816 | 816 | } |
817 | 817 | } else { |
818 | 818 | // we take the last attempt, even if the student answer the question before |
819 | - $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
819 | + $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
820 | 820 | } |
821 | 821 | } |
822 | 822 | } |
@@ -837,10 +837,10 @@ discard block |
||
837 | 837 | { |
838 | 838 | $outRes = 0; |
839 | 839 | // for each student in group |
840 | - foreach($resultList as $userId => $tabValue) { |
|
840 | + foreach ($resultList as $userId => $tabValue) { |
|
841 | 841 | $trouve = false; |
842 | 842 | // for each bracket, if student has at leat one answer ( choice > -2) then he pass the question |
843 | - foreach($tabValue as $i => $choice) { |
|
843 | + foreach ($tabValue as $i => $choice) { |
|
844 | 844 | if ($choice > -2 && !$trouve) { |
845 | 845 | $outRes++; |
846 | 846 | $trouve = true; |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | $separatorEnd = $listWithStudentAnswer['blankseparatorend']; |
863 | 863 | // lets rebuild the sentence with [correct answer][student answer][answer is correct] |
864 | 864 | $result = ""; |
865 | - for ($i=0; $i < count($listWithStudentAnswer['commonwords']) - 1; $i++) { |
|
865 | + for ($i = 0; $i < count($listWithStudentAnswer['commonwords']) - 1; $i++) { |
|
866 | 866 | $result .= $listWithStudentAnswer['commonwords'][$i]; |
867 | 867 | $result .= $listWithStudentAnswer['tabwordsbracket'][$i]; |
868 | 868 | $result .= $separatorStart.$listWithStudentAnswer['studentanswer'][$i].$separatorEnd; |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | ")", |
945 | 945 | ]; |
946 | 946 | $result = $text; |
947 | - for ($i=0; $i < count($listRegexpCharacters); $i++) { |
|
947 | + for ($i = 0; $i < count($listRegexpCharacters); $i++) { |
|
948 | 948 | $result = str_replace($listRegexpCharacters[$i], "\\".$listRegexpCharacters[$i], $result); |
949 | 949 | } |
950 | 950 | |
@@ -1006,7 +1006,7 @@ discard block |
||
1006 | 1006 | { |
1007 | 1007 | $listResults = array(); |
1008 | 1008 | $fillBlanksAllowedSeparator = self::getAllowedSeparator(); |
1009 | - for ($i=0; $i < count($fillBlanksAllowedSeparator); $i++) { |
|
1009 | + for ($i = 0; $i < count($fillBlanksAllowedSeparator); $i++) { |
|
1010 | 1010 | $listResults[] = $fillBlanksAllowedSeparator[$i][0]."...".$fillBlanksAllowedSeparator[$i][1]; |
1011 | 1011 | } |
1012 | 1012 | |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | { |
1025 | 1025 | $listSeparators = self::getAllowedSeparator(); |
1026 | 1026 | $result = 0; |
1027 | - for ($i=0; $i < count($listSeparators); $i++) { |
|
1027 | + for ($i = 0; $i < count($listSeparators); $i++) { |
|
1028 | 1028 | if ($listSeparators[$i][0] == $startSeparator && |
1029 | 1029 | $listSeparators[$i][1] == $endSeparator |
1030 | 1030 | ) { |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | |
1050 | 1050 | // rebuild the answer with good HTML style |
1051 | 1051 | // this is the student answer, right or wrong |
1052 | - for ($i=0; $i < count($listStudentAnswerInfo['studentanswer']); $i++) { |
|
1052 | + for ($i = 0; $i < count($listStudentAnswerInfo['studentanswer']); $i++) { |
|
1053 | 1053 | if ($listStudentAnswerInfo['studentscore'][$i] == 1) { |
1054 | 1054 | $listStudentAnswerInfo['studentanswer'][$i] = self::getHtmlRightAnswer( |
1055 | 1055 | $listStudentAnswerInfo['studentanswer'][$i], |
@@ -1067,7 +1067,7 @@ discard block |
||
1067 | 1067 | |
1068 | 1068 | |
1069 | 1069 | // rebuild the sentence with student answer inserted |
1070 | - for ($i=0; $i < count($listStudentAnswerInfo['commonwords']); $i++) { |
|
1070 | + for ($i = 0; $i < count($listStudentAnswerInfo['commonwords']); $i++) { |
|
1071 | 1071 | $result .= isset($listStudentAnswerInfo['commonwords'][$i]) ? $listStudentAnswerInfo['commonwords'][$i] : ''; |
1072 | 1072 | $result .= isset($listStudentAnswerInfo['studentanswer'][$i]) ? $listStudentAnswerInfo['studentanswer'][$i] : ''; |
1073 | 1073 | } |
@@ -1100,7 +1100,7 @@ discard block |
||
1100 | 1100 | $listPossibleAnswers = FillBlanks::getFillTheBlankMenuAnswers($correct, false); |
1101 | 1101 | $correctAnswerHtml .= "<span style='color: green'>".$listPossibleAnswers[0]."</span>"; |
1102 | 1102 | $correctAnswerHtml .= " <span style='font-weight:normal'>("; |
1103 | - for ($i=1; $i < count($listPossibleAnswers); $i++) { |
|
1103 | + for ($i = 1; $i < count($listPossibleAnswers); $i++) { |
|
1104 | 1104 | $correctAnswerHtml .= $listPossibleAnswers[$i]; |
1105 | 1105 | if ($i != count($listPossibleAnswers) - 1) { |
1106 | 1106 | $correctAnswerHtml .= " | "; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * Sets the comment in the database for a particular path. |
95 | 95 | * @param string File path |
96 | 96 | * @param string Comment to set |
97 | - * @return string Result of the database operation (Database::query will output some message directly on error anyway) |
|
97 | + * @return Doctrine\DBAL\Driver\Statement|null Result of the database operation (Database::query will output some message directly on error anyway) |
|
98 | 98 | */ |
99 | 99 | function SetComment($path, $comment) |
100 | 100 | { |
@@ -112,6 +112,7 @@ discard block |
||
112 | 112 | /** |
113 | 113 | * Reads the file contents into a string. |
114 | 114 | * @param string Urlencoded path |
115 | + * @param string $full_file_path |
|
115 | 116 | * @return string The file contents or false on security error |
116 | 117 | */ |
117 | 118 | function ReadFileCont($full_file_path) |
@@ -257,6 +258,7 @@ discard block |
||
257 | 258 | * Searches for a node in the given array. |
258 | 259 | * @param reference Reference to the array to search |
259 | 260 | * @param string Node we are looking for in the array |
261 | + * @param string $node |
|
260 | 262 | * @return mixed Node name or false if not found |
261 | 263 | */ |
262 | 264 | function myarraysearch(&$array, $node) |
@@ -316,6 +318,8 @@ discard block |
||
316 | 318 | * Fills the folder name up to a certain length with "0". |
317 | 319 | * @param string Original folder name |
318 | 320 | * @param integer Length to reach |
321 | + * @param integer $name |
|
322 | + * @param integer $nsize |
|
319 | 323 | * @return string Modified folder name |
320 | 324 | */ |
321 | 325 | function FillFolderName($name, $nsize) |
@@ -344,7 +344,7 @@ |
||
344 | 344 | if (is_dir($full_name)) { |
345 | 345 | $filelist[] = $file; |
346 | 346 | } |
347 | - } |
|
347 | + } |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | if ($title == '') { |
67 | 67 | $title = basename($fname); |
68 | 68 | } |
69 | - return (string)$title; |
|
69 | + return (string) $title; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | if ($src == '') { |
177 | 177 | return ''; |
178 | 178 | } else { |
179 | - $tmp_src = basename($src) ; |
|
179 | + $tmp_src = basename($src); |
|
180 | 180 | if ($tmp_src == '') { |
181 | 181 | return $src; |
182 | 182 | } else { |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | { |
199 | 199 | // Select src tag from img tag. |
200 | 200 | $match = array(); |
201 | - preg_match("|(src=\".*\" )|U", $imgtag, $match); //src |
|
201 | + preg_match("|(src=\".*\" )|U", $imgtag, $match); //src |
|
202 | 202 | list($key, $srctag) = each($match); |
203 | 203 | $src = substr($srctag, 5, (strlen($srctag) - 7)); |
204 | 204 | if (stristr($src, 'http') === false) { |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | while (list($key, $imgtag) = each($match)) { |
231 | 231 | $imgname = GetImgName($imgtag); |
232 | 232 | if ($imgname != '' && !in_array($imgname, $imgparams)) { |
233 | - array_push($imgparams, $imgname); // name (+ type) of the images in the html test |
|
234 | - $imgcount = $imgcount + 1; // number of images in the html test |
|
233 | + array_push($imgparams, $imgname); // name (+ type) of the images in the html test |
|
234 | + $imgcount = $imgcount + 1; // number of images in the html test |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | if ($file != '..') { |
405 | 405 | $full_name = $folder.'/'.$file; |
406 | 406 | if (is_dir($full_name)) { |
407 | - $dflag = 1; // first directory |
|
407 | + $dflag = 1; // first directory |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | } |
@@ -18,6 +18,7 @@ |
||
18 | 18 | * Gets the results of all students (or just one student if access is limited) |
19 | 19 | * @param string The document path (for HotPotatoes retrieval) |
20 | 20 | * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null |
21 | + * @param string $document_path |
|
21 | 22 | */ |
22 | 23 | public function getExercisesReporting($document_path, $hotpotato_name) |
23 | 24 | { |
@@ -14,14 +14,14 @@ discard block |
||
14 | 14 | //stores the results |
15 | 15 | private $results = array(); |
16 | 16 | |
17 | - /** |
|
18 | - * Gets the results of all students (or just one student if access is limited) |
|
19 | - * @param string The document path (for HotPotatoes retrieval) |
|
20 | - * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null |
|
21 | - */ |
|
22 | - public function getExercisesReporting($document_path, $hotpotato_name) |
|
17 | + /** |
|
18 | + * Gets the results of all students (or just one student if access is limited) |
|
19 | + * @param string The document path (for HotPotatoes retrieval) |
|
20 | + * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null |
|
21 | + */ |
|
22 | + public function getExercisesReporting($document_path, $hotpotato_name) |
|
23 | 23 | { |
24 | - $return = array(); |
|
24 | + $return = array(); |
|
25 | 25 | $TBL_USER = Database::get_main_table(TABLE_MAIN_USER); |
26 | 26 | $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); |
27 | 27 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $hotpotato_name = Database::escape_string($hotpotato_name); |
34 | 34 | |
35 | 35 | if (!empty($exercise_id)) { |
36 | - $session_id_and .= " AND exe_exo_id = $exercise_id "; |
|
36 | + $session_id_and .= " AND exe_exo_id = $exercise_id "; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | if (empty($user_id)) { |
@@ -110,25 +110,25 @@ discard block |
||
110 | 110 | $this->results = $return; |
111 | 111 | |
112 | 112 | return true; |
113 | - } |
|
113 | + } |
|
114 | 114 | |
115 | 115 | |
116 | - /** |
|
117 | - * Exports the complete report as a CSV file |
|
118 | - * @param string Document path inside the document tool |
|
119 | - * @param integer Optional user ID |
|
120 | - * @param boolean Whether to include user fields or not |
|
121 | - * @return boolean False on error |
|
122 | - */ |
|
123 | - public function exportCompleteReportCSV($document_path='', $hotpotato_name) |
|
116 | + /** |
|
117 | + * Exports the complete report as a CSV file |
|
118 | + * @param string Document path inside the document tool |
|
119 | + * @param integer Optional user ID |
|
120 | + * @param boolean Whether to include user fields or not |
|
121 | + * @return boolean False on error |
|
122 | + */ |
|
123 | + public function exportCompleteReportCSV($document_path='', $hotpotato_name) |
|
124 | 124 | { |
125 | - global $charset; |
|
126 | - $this->getExercisesReporting($document_path, $hotpotato_name); |
|
127 | - $filename = 'exercise_results_'.date('YmdGis').'.csv'; |
|
128 | - if (!empty($user_id)) { |
|
129 | - $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv'; |
|
130 | - } |
|
131 | - $data = ''; |
|
125 | + global $charset; |
|
126 | + $this->getExercisesReporting($document_path, $hotpotato_name); |
|
127 | + $filename = 'exercise_results_'.date('YmdGis').'.csv'; |
|
128 | + if (!empty($user_id)) { |
|
129 | + $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv'; |
|
130 | + } |
|
131 | + $data = ''; |
|
132 | 132 | |
133 | 133 | if (api_is_western_name_order()) { |
134 | 134 | if(!empty($this->results[0]['first_name'])) { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | $data .= get_lang('Email').';'; |
149 | 149 | |
150 | - /*if ($export_user_fields) { |
|
150 | + /*if ($export_user_fields) { |
|
151 | 151 | //show user fields section with a big th colspan that spans over all fields |
152 | 152 | $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
153 | 153 | $num = count($extra_user_fields); |
@@ -156,25 +156,25 @@ discard block |
||
156 | 156 | } |
157 | 157 | }*/ |
158 | 158 | |
159 | - $data .= get_lang('Title').';'; |
|
160 | - $data .= get_lang('StartDate').';'; |
|
161 | - $data .= get_lang('Score').';'; |
|
162 | - $data .= get_lang('Total').';'; |
|
163 | - $data .= "\n"; |
|
159 | + $data .= get_lang('Title').';'; |
|
160 | + $data .= get_lang('StartDate').';'; |
|
161 | + $data .= get_lang('Score').';'; |
|
162 | + $data .= get_lang('Total').';'; |
|
163 | + $data .= "\n"; |
|
164 | 164 | |
165 | - //results |
|
166 | - foreach($this->results as $row) { |
|
165 | + //results |
|
166 | + foreach($this->results as $row) { |
|
167 | 167 | if (api_is_western_name_order()) { |
168 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
169 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
168 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
169 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
170 | 170 | } else { |
171 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
172 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
171 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
172 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';'; |
176 | 176 | |
177 | - /*if ($export_user_fields) { |
|
177 | + /*if ($export_user_fields) { |
|
178 | 178 | //show user fields data, if any, for this user |
179 | 179 | $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
180 | 180 | foreach($user_fields_values as $value) { |
@@ -182,40 +182,40 @@ discard block |
||
182 | 182 | } |
183 | 183 | }*/ |
184 | 184 | |
185 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; |
|
186 | - $data .= str_replace("\r\n",' ',$row['exe_date']).';'; |
|
187 | - $data .= str_replace("\r\n",' ',$row['result']).';'; |
|
188 | - $data .= str_replace("\r\n",' ',$row['max']).';'; |
|
189 | - $data .= "\n"; |
|
190 | - } |
|
191 | - |
|
192 | - //output the results |
|
193 | - $len = strlen($data); |
|
194 | - header('Content-type: application/octet-stream'); |
|
195 | - header('Content-Type: application/force-download'); |
|
196 | - header('Content-length: '.$len); |
|
197 | - if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) { |
|
198 | - header('Content-Disposition: filename= '.$filename); |
|
199 | - } else { |
|
200 | - header('Content-Disposition: attachment; filename= '.$filename); |
|
201 | - } |
|
202 | - if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { |
|
203 | - header('Pragma: '); |
|
204 | - header('Cache-Control: '); |
|
205 | - header('Cache-Control: public'); // IE cannot download from sessions without a cache |
|
206 | - } |
|
207 | - header('Content-Description: '.$filename); |
|
208 | - header('Content-transfer-encoding: binary'); |
|
209 | - // @todo add this utf-8 header for all csv files |
|
210 | - echo "\xEF\xBB\xBF"; // force utf-8 header of csv file |
|
211 | - echo $data; |
|
212 | - return true; |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * Exports the complete report as an XLS file |
|
217 | - * @return boolean False on error |
|
218 | - */ |
|
185 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; |
|
186 | + $data .= str_replace("\r\n",' ',$row['exe_date']).';'; |
|
187 | + $data .= str_replace("\r\n",' ',$row['result']).';'; |
|
188 | + $data .= str_replace("\r\n",' ',$row['max']).';'; |
|
189 | + $data .= "\n"; |
|
190 | + } |
|
191 | + |
|
192 | + //output the results |
|
193 | + $len = strlen($data); |
|
194 | + header('Content-type: application/octet-stream'); |
|
195 | + header('Content-Type: application/force-download'); |
|
196 | + header('Content-length: '.$len); |
|
197 | + if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) { |
|
198 | + header('Content-Disposition: filename= '.$filename); |
|
199 | + } else { |
|
200 | + header('Content-Disposition: attachment; filename= '.$filename); |
|
201 | + } |
|
202 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { |
|
203 | + header('Pragma: '); |
|
204 | + header('Cache-Control: '); |
|
205 | + header('Cache-Control: public'); // IE cannot download from sessions without a cache |
|
206 | + } |
|
207 | + header('Content-Description: '.$filename); |
|
208 | + header('Content-transfer-encoding: binary'); |
|
209 | + // @todo add this utf-8 header for all csv files |
|
210 | + echo "\xEF\xBB\xBF"; // force utf-8 header of csv file |
|
211 | + echo $data; |
|
212 | + return true; |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * Exports the complete report as an XLS file |
|
217 | + * @return boolean False on error |
|
218 | + */ |
|
219 | 219 | public function exportCompleteReportXLS( |
220 | 220 | $document_path = '', |
221 | 221 | $user_id = null, |
@@ -224,37 +224,37 @@ discard block |
||
224 | 224 | $exercise_id = 0, |
225 | 225 | $hotpotato_name = null |
226 | 226 | ) { |
227 | - global $charset; |
|
228 | - $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name); |
|
229 | - $filename = 'exercise_results_'.api_get_local_time().'.xls'; |
|
230 | - if (!empty($user_id)) { |
|
231 | - $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls'; |
|
232 | - } |
|
227 | + global $charset; |
|
228 | + $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name); |
|
229 | + $filename = 'exercise_results_'.api_get_local_time().'.xls'; |
|
230 | + if (!empty($user_id)) { |
|
231 | + $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls'; |
|
232 | + } |
|
233 | 233 | |
234 | 234 | $spreadsheet = new PHPExcel(); |
235 | 235 | $spreadsheet->setActiveSheetIndex(0); |
236 | 236 | $worksheet = $spreadsheet->getActiveSheet(); |
237 | 237 | |
238 | 238 | |
239 | - $line = 0; |
|
240 | - $column = 0; //skip the first column (row titles) |
|
239 | + $line = 0; |
|
240 | + $column = 0; //skip the first column (row titles) |
|
241 | 241 | |
242 | - // check if exists column 'user' |
|
243 | - $with_column_user = false; |
|
244 | - foreach ($this->results as $result) { |
|
245 | - if (!empty($result['last_name']) && !empty($result['first_name'])) { |
|
246 | - $with_column_user = true; |
|
247 | - break; |
|
248 | - } |
|
249 | - } |
|
242 | + // check if exists column 'user' |
|
243 | + $with_column_user = false; |
|
244 | + foreach ($this->results as $result) { |
|
245 | + if (!empty($result['last_name']) && !empty($result['first_name'])) { |
|
246 | + $with_column_user = true; |
|
247 | + break; |
|
248 | + } |
|
249 | + } |
|
250 | 250 | |
251 | - if ($with_column_user) { |
|
252 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email')); |
|
253 | - $column++; |
|
251 | + if ($with_column_user) { |
|
252 | + $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email')); |
|
253 | + $column++; |
|
254 | 254 | |
255 | 255 | if (api_is_western_name_order()) { |
256 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
257 | - $column++; |
|
256 | + $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
257 | + $column++; |
|
258 | 258 | $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName')); |
259 | 259 | $column++; |
260 | 260 | } else { |
@@ -263,36 +263,36 @@ discard block |
||
263 | 263 | $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
264 | 264 | $column++; |
265 | 265 | } |
266 | - } |
|
266 | + } |
|
267 | 267 | |
268 | - if ($export_user_fields) { |
|
269 | - //show user fields section with a big th colspan that spans over all fields |
|
270 | - $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
|
268 | + if ($export_user_fields) { |
|
269 | + //show user fields section with a big th colspan that spans over all fields |
|
270 | + $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
|
271 | 271 | |
272 | - //show the fields names for user fields |
|
273 | - foreach ($extra_user_fields as $field) { |
|
274 | - $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)); |
|
275 | - $column++; |
|
276 | - } |
|
277 | - } |
|
272 | + //show the fields names for user fields |
|
273 | + foreach ($extra_user_fields as $field) { |
|
274 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)); |
|
275 | + $column++; |
|
276 | + } |
|
277 | + } |
|
278 | 278 | |
279 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title')); |
|
280 | - $column++; |
|
281 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate')); |
|
279 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title')); |
|
280 | + $column++; |
|
281 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate')); |
|
282 | 282 | $column++; |
283 | 283 | $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('EndDate')); |
284 | 284 | $column++; |
285 | 285 | $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Duration').' ('.get_lang('MinMinutes').')'); |
286 | - $column++; |
|
287 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score')); |
|
288 | - $column++; |
|
289 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total')); |
|
290 | - $column++; |
|
286 | + $column++; |
|
287 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score')); |
|
288 | + $column++; |
|
289 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total')); |
|
290 | + $column++; |
|
291 | 291 | $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Status')); |
292 | - $line++; |
|
292 | + $line++; |
|
293 | 293 | |
294 | - foreach ($this->results as $row) { |
|
295 | - $column = 0; |
|
294 | + foreach ($this->results as $row) { |
|
295 | + $column = 0; |
|
296 | 296 | |
297 | 297 | if ($with_column_user) { |
298 | 298 | $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)); |
@@ -309,38 +309,38 @@ discard block |
||
309 | 309 | $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
310 | 310 | $column++; |
311 | 311 | } |
312 | - } |
|
312 | + } |
|
313 | 313 | |
314 | - if ($export_user_fields) { |
|
315 | - //show user fields data, if any, for this user |
|
316 | - $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
317 | - foreach($user_fields_values as $value) { |
|
318 | - $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
319 | - $column++; |
|
320 | - } |
|
321 | - } |
|
314 | + if ($export_user_fields) { |
|
315 | + //show user fields data, if any, for this user |
|
316 | + $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
317 | + foreach($user_fields_values as $value) { |
|
318 | + $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
319 | + $column++; |
|
320 | + } |
|
321 | + } |
|
322 | 322 | |
323 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
324 | - $column++; |
|
325 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']); |
|
323 | + $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
324 | + $column++; |
|
325 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']); |
|
326 | 326 | $column++; |
327 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']); |
|
327 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']); |
|
328 | + $column++; |
|
329 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']); |
|
330 | + $column++; |
|
331 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']); |
|
332 | + $column++; |
|
333 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']); |
|
328 | 334 | $column++; |
329 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']); |
|
330 | - $column++; |
|
331 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']); |
|
332 | - $column++; |
|
333 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']); |
|
334 | - $column++; |
|
335 | 335 | $worksheet->SetCellValueByColumnAndRow($line,$column,$row['status']); |
336 | - $line++; |
|
337 | - } |
|
336 | + $line++; |
|
337 | + } |
|
338 | 338 | |
339 | 339 | $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename); |
340 | 340 | $writer = new PHPExcel_Writer_Excel2007($spreadsheet); |
341 | 341 | $writer->save($file); |
342 | 342 | DocumentManager::file_send_for_download($file, true, $filename); |
343 | 343 | |
344 | - return true; |
|
345 | - } |
|
344 | + return true; |
|
345 | + } |
|
346 | 346 | } |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | { |
24 | 24 | $return = array(); |
25 | 25 | $TBL_USER = Database::get_main_table(TABLE_MAIN_USER); |
26 | - $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); |
|
26 | + $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); |
|
27 | 27 | |
28 | 28 | $cid = api_get_course_id(); |
29 | 29 | $course_id = api_get_course_int_id(); |
30 | 30 | //$user_id = intval($user_id); |
31 | 31 | $user_id = null; |
32 | - $session_id_and = ' AND te.session_id = ' . api_get_session_id() . ' '; |
|
32 | + $session_id_and = ' AND te.session_id = '.api_get_session_id().' '; |
|
33 | 33 | $hotpotato_name = Database::escape_string($hotpotato_name); |
34 | 34 | |
35 | 35 | if (!empty($exercise_id)) { |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | if (empty($user_id)) { |
40 | - $sql="SELECT firstname as userpart1, lastname as userpart2 , |
|
40 | + $sql = "SELECT firstname as userpart1, lastname as userpart2 , |
|
41 | 41 | email, |
42 | 42 | tth.exe_name, |
43 | 43 | tth.exe_result, |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | tth.exe_name = '$hotpotato_name' |
50 | 50 | ORDER BY tth.c_id ASC, tth.exe_date ASC"; |
51 | 51 | } else { |
52 | - $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' '; |
|
52 | + $user_id_and = ' AND te.exe_user_id = '.api_get_user_id().' '; |
|
53 | 53 | // get only this user's results |
54 | 54 | |
55 | 55 | $sql = "SELECT '', exe_name, exe_result , exe_weighting, exe_date |
56 | 56 | FROM $TBL_TRACK_HOTPOTATOES |
57 | 57 | WHERE |
58 | - exe_user_id = '" . $user_id . "' AND |
|
58 | + exe_user_id = '".$user_id."' AND |
|
59 | 59 | c_id = $course_id AND |
60 | 60 | tth.exe_name = '$hotpotato_name' |
61 | 61 | ORDER BY c_id ASC, exe_date ASC"; |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | $results = array(); |
65 | 65 | |
66 | 66 | $resx = Database::query($sql); |
67 | - while ($rowx = Database::fetch_array($resx,'ASSOC')) { |
|
67 | + while ($rowx = Database::fetch_array($resx, 'ASSOC')) { |
|
68 | 68 | $results[] = $rowx; |
69 | 69 | } |
70 | 70 | |
71 | 71 | $hpresults = array(); |
72 | 72 | $resx = Database::query($sql); |
73 | - while ($rowx = Database::fetch_array($resx,'ASSOC')) { |
|
73 | + while ($rowx = Database::fetch_array($resx, 'ASSOC')) { |
|
74 | 74 | $hpresults[] = $rowx; |
75 | 75 | } |
76 | 76 | |
@@ -89,19 +89,19 @@ discard block |
||
89 | 89 | |
90 | 90 | // Print the Result of Hotpotatoes Tests |
91 | 91 | if (is_array($hpresults)) { |
92 | - for($i = 0; $i < sizeof($hpresults); $i++) { |
|
92 | + for ($i = 0; $i < sizeof($hpresults); $i++) { |
|
93 | 93 | $return[$i] = array(); |
94 | 94 | $title = GetQuizName($hpresults[$i]['exe_name'], $document_path); |
95 | - if ($title =='') { |
|
95 | + if ($title == '') { |
|
96 | 96 | $title = basename($hpresults[$i]['exe_name']); |
97 | 97 | } |
98 | - if(empty($user_id)) { |
|
98 | + if (empty($user_id)) { |
|
99 | 99 | $return[$i]['email'] = $hpresults[$i]['email']; |
100 | 100 | $return[$i]['first_name'] = $hpresults[$i]['userpart1']; |
101 | 101 | $return[$i]['last_name'] = $hpresults[$i]['userpart2']; |
102 | 102 | } |
103 | 103 | $return[$i]['title'] = $title; |
104 | - $return[$i]['exe_date'] = $hpresults[$i]['exe_date']; |
|
104 | + $return[$i]['exe_date'] = $hpresults[$i]['exe_date']; |
|
105 | 105 | |
106 | 106 | $return[$i]['result'] = $hpresults[$i]['exe_result']; |
107 | 107 | $return[$i]['max'] = $hpresults[$i]['exe_weighting']; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @param boolean Whether to include user fields or not |
121 | 121 | * @return boolean False on error |
122 | 122 | */ |
123 | - public function exportCompleteReportCSV($document_path='', $hotpotato_name) |
|
123 | + public function exportCompleteReportCSV($document_path = '', $hotpotato_name) |
|
124 | 124 | { |
125 | 125 | global $charset; |
126 | 126 | $this->getExercisesReporting($document_path, $hotpotato_name); |
@@ -131,17 +131,17 @@ discard block |
||
131 | 131 | $data = ''; |
132 | 132 | |
133 | 133 | if (api_is_western_name_order()) { |
134 | - if(!empty($this->results[0]['first_name'])) { |
|
134 | + if (!empty($this->results[0]['first_name'])) { |
|
135 | 135 | $data .= get_lang('FirstName').';'; |
136 | 136 | } |
137 | - if(!empty($this->results[0]['last_name'])) { |
|
137 | + if (!empty($this->results[0]['last_name'])) { |
|
138 | 138 | $data .= get_lang('LastName').';'; |
139 | 139 | } |
140 | 140 | } else { |
141 | - if(!empty($this->results[0]['last_name'])) { |
|
141 | + if (!empty($this->results[0]['last_name'])) { |
|
142 | 142 | $data .= get_lang('LastName').';'; |
143 | 143 | } |
144 | - if(!empty($this->results[0]['first_name'])) { |
|
144 | + if (!empty($this->results[0]['first_name'])) { |
|
145 | 145 | $data .= get_lang('FirstName').';'; |
146 | 146 | } |
147 | 147 | } |
@@ -163,16 +163,16 @@ discard block |
||
163 | 163 | $data .= "\n"; |
164 | 164 | |
165 | 165 | //results |
166 | - foreach($this->results as $row) { |
|
166 | + foreach ($this->results as $row) { |
|
167 | 167 | if (api_is_western_name_order()) { |
168 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
169 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
168 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
169 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
170 | 170 | } else { |
171 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
172 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
171 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
172 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
173 | 173 | } |
174 | 174 | |
175 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';'; |
|
175 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';'; |
|
176 | 176 | |
177 | 177 | /*if ($export_user_fields) { |
178 | 178 | //show user fields data, if any, for this user |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | } |
183 | 183 | }*/ |
184 | 184 | |
185 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; |
|
186 | - $data .= str_replace("\r\n",' ',$row['exe_date']).';'; |
|
187 | - $data .= str_replace("\r\n",' ',$row['result']).';'; |
|
188 | - $data .= str_replace("\r\n",' ',$row['max']).';'; |
|
185 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; |
|
186 | + $data .= str_replace("\r\n", ' ', $row['exe_date']).';'; |
|
187 | + $data .= str_replace("\r\n", ' ', $row['result']).';'; |
|
188 | + $data .= str_replace("\r\n", ' ', $row['max']).';'; |
|
189 | 189 | $data .= "\n"; |
190 | 190 | } |
191 | 191 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | header('Content-Description: '.$filename); |
208 | 208 | header('Content-transfer-encoding: binary'); |
209 | 209 | // @todo add this utf-8 header for all csv files |
210 | - echo "\xEF\xBB\xBF"; // force utf-8 header of csv file |
|
210 | + echo "\xEF\xBB\xBF"; // force utf-8 header of csv file |
|
211 | 211 | echo $data; |
212 | 212 | return true; |
213 | 213 | } |
@@ -249,25 +249,25 @@ discard block |
||
249 | 249 | } |
250 | 250 | |
251 | 251 | if ($with_column_user) { |
252 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email')); |
|
252 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Email')); |
|
253 | 253 | $column++; |
254 | 254 | |
255 | 255 | if (api_is_western_name_order()) { |
256 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
256 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('FirstName')); |
|
257 | 257 | $column++; |
258 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName')); |
|
258 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('LastName')); |
|
259 | 259 | $column++; |
260 | 260 | } else { |
261 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName')); |
|
261 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('LastName')); |
|
262 | 262 | $column++; |
263 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
263 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('FirstName')); |
|
264 | 264 | $column++; |
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
268 | 268 | if ($export_user_fields) { |
269 | 269 | //show user fields section with a big th colspan that spans over all fields |
270 | - $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
|
270 | + $extra_user_fields = UserManager::get_extra_fields(0, 1000, 5, 'ASC', false, 1); |
|
271 | 271 | |
272 | 272 | //show the fields names for user fields |
273 | 273 | foreach ($extra_user_fields as $field) { |
@@ -276,63 +276,63 @@ discard block |
||
276 | 276 | } |
277 | 277 | } |
278 | 278 | |
279 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title')); |
|
279 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Title')); |
|
280 | 280 | $column++; |
281 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate')); |
|
281 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('StartDate')); |
|
282 | 282 | $column++; |
283 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('EndDate')); |
|
283 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('EndDate')); |
|
284 | 284 | $column++; |
285 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Duration').' ('.get_lang('MinMinutes').')'); |
|
285 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Duration').' ('.get_lang('MinMinutes').')'); |
|
286 | 286 | $column++; |
287 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score')); |
|
287 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Score')); |
|
288 | 288 | $column++; |
289 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total')); |
|
289 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Total')); |
|
290 | 290 | $column++; |
291 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Status')); |
|
291 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Status')); |
|
292 | 292 | $line++; |
293 | 293 | |
294 | 294 | foreach ($this->results as $row) { |
295 | 295 | $column = 0; |
296 | 296 | |
297 | 297 | if ($with_column_user) { |
298 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)); |
|
298 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)); |
|
299 | 299 | $column++; |
300 | 300 | |
301 | 301 | if (api_is_western_name_order()) { |
302 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
|
302 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
|
303 | 303 | $column++; |
304 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); |
|
304 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); |
|
305 | 305 | $column++; |
306 | 306 | } else { |
307 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); |
|
307 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); |
|
308 | 308 | $column++; |
309 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
|
309 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
|
310 | 310 | $column++; |
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | 314 | if ($export_user_fields) { |
315 | 315 | //show user fields data, if any, for this user |
316 | - $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
317 | - foreach($user_fields_values as $value) { |
|
318 | - $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
316 | + $user_fields_values = UserManager::get_extra_user_data($row['user_id'], false, false, false, true); |
|
317 | + foreach ($user_fields_values as $value) { |
|
318 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
319 | 319 | $column++; |
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
323 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
324 | 324 | $column++; |
325 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']); |
|
325 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['start_date']); |
|
326 | 326 | $column++; |
327 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']); |
|
327 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['end_date']); |
|
328 | 328 | $column++; |
329 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']); |
|
329 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['duration']); |
|
330 | 330 | $column++; |
331 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']); |
|
331 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['result']); |
|
332 | 332 | $column++; |
333 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']); |
|
333 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['max']); |
|
334 | 334 | $column++; |
335 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['status']); |
|
335 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['status']); |
|
336 | 336 | $line++; |
337 | 337 | } |
338 | 338 |