From 009a93e9212701c38b4ecc7aee9e32f2f66fc58e Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 18 Feb 2011 14:22:39 +0100 Subject: [PATCH] Cleaning exercises + adding third option in the \"show score to learner\" exercise setting see #2539 --- main/exercice/exercise.class.php | 101 +++-- main/exercice/exercise_result.php | 240 ++++------ main/exercice/exercise_show.php | 426 +++++++----------- main/exercice/fill_blanks.class.php | 17 +- main/exercice/freeanswer.class.php | 38 +- main/exercice/matching.class.php | 19 +- main/exercice/multiple_answer.class.php | 42 +- .../multiple_answer_combination.class.php | 24 +- .../multiple_answer_true_false.class.php | 23 + main/exercice/question.class.php | 16 +- main/exercice/unique_answer.class.php | 24 +- .../unique_answer_no_option.class.php | 26 +- 12 files changed, 480 insertions(+), 516 deletions(-) diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 8080010f63..eed5499ea0 100755 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -1678,6 +1678,8 @@ class Exercise { */ function manage_answer($exeId, $questionId, $choice, $from = 'exercise_show', $exerciseResultCoordinates = array(), $saved_results = true, $from_database = false, $show_result = true, $propagate_neg = 0) { global $_configuration, $feedback_type; + + $html = ''; $questionId = intval($questionId); $exeId = intval($exeId); @@ -1787,10 +1789,8 @@ class Exercise { } else { $questionScore += $doubt_score; } - } - //$questionWeighting+=$true_score; - $totalScore +=$true_score; - //echo $studentChoice.' - '.$answerCorrect.' '.$questionScore.' - '.$questionWeighting.'
'; + } + $totalScore +=$true_score; break; case MULTIPLE_ANSWER : if ($from_database) { @@ -1829,8 +1829,7 @@ class Exercise { $numAnswer=$objAnswerTmp->selectAutoId($answerId); $studentChoice=$choice[$numAnswer]; - //echo $studentChoice.' - '.$answerCorrect.'
'; - + if ($answerCorrect == 1) { if ($studentChoice == 1) { //true value see MultipleAnswerCombinationTrueFalse class $real_answers[$answerId] = true; @@ -2102,8 +2101,8 @@ class Exercise { } break; // for matching - case MATCHING : - if ($from_database) { + case MATCHING : + if ($from_database) { $sql_answer = 'SELECT id, answer FROM '.$table_ans.' WHERE question_id="'.$questionId.'" AND correct=0'; $res_answer = Database::query($sql_answer); // getting the real answer @@ -2116,15 +2115,8 @@ class Exercise { WHERE question_id="'.$questionId.'" AND correct <> 0 ORDER BY id_auto'; $res_answers = Database::query($sql_select_answer); - if ($show_result) { - echo ''; - echo ''; - echo ' - - - '; - echo ''; - } + + $questionScore = 0; while ($a_answers = Database::fetch_array($res_answers)) { @@ -2331,13 +2323,14 @@ class Exercise { } } - if ($from == 'exercise_result') { - global $colspan; + if ($from == 'exercise_result') { // if answer is hotspot. To the difference of exercise_show.php, we use the results from the session (from_db=0) // TODO Change this, because it is wrong to show the user some results that haven't been stored in the database yet if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER) { - // We made an extra table for the answers - if($origin != 'learnpath') { + // We made an extra table for the answers + if ($show_result) { + if ($origin != 'learnpath') { + echo '
 
'.get_lang('ElementList').' '.get_lang('CorrespondsTo').'
 
'; echo ' '; @@ -2346,28 +2339,26 @@ class Exercise { echo ' - '; + '; + } - } + } + } if ($origin != 'learnpath') { - ?> - - - '; if ($this->type == ALL_ON_ONE_PAGE) { echo '
'; if ($propagate_neg == 0 && $questionScore < 0) { $questionScore = 0; } - echo get_lang('Score').": ".show_score($questionScore, $questionWeighting,false, false); + echo get_lang('Score').": ".show_score($questionScore, $questionWeighting, false, false); echo '
'; } - ?>
- - - - '; + } + } } unset ($objAnswerTmp); $i++; @@ -2588,6 +2579,50 @@ class Exercise { $result = @api_mail_html('', $to, $subject, $mail_content, $sender_name, $email_admin, array('charset'=>$mycharset)); } } + + function show_exercise_result_header($user_data, $date = null) { + $description = ''; + if (!empty($this->description)) { + $description = ' + +  '.get_lang("Description").' : + + + '.$this->description.' + + '; + } + $date_data = ''; + if (!empty($date)) { + $date_data = ' + +  '.get_lang("Date").' : + + + '.$date.' + + '; + } + + + $html = ' + + + + + + + + '.$date_data.' + '.$description.' +
+

'.Display::return_icon('quiz_big.png', get_lang('Result')).' '.$this->exercise.' : '.get_lang('Result').'

+
 '.get_lang('User').' : + '.$user_data.' +
+
'; + return $html; + } } endif; ?> diff --git a/main/exercice/exercise_result.php b/main/exercice/exercise_result.php index 105a6e4307..bfd0b6e9aa 100755 --- a/main/exercice/exercise_result.php +++ b/main/exercice/exercise_result.php @@ -135,10 +135,18 @@ if ($origin != 'learnpath') { results_disabled) { - ob_start(); +if ($objExercise->results_disabled == 0) { + $show_results = true; } + +if ($objExercise->results_disabled == 2) { + $show_only_score = true; +} + /* DISPLAY AND MAIN PROCESS */ // I'm in a preview mode as course admin. Display the action menu. @@ -153,31 +161,34 @@ $exerciseTitle=text_filter($objExercise->selectTitle()); $feedback_type = $objExercise->feedbacktype; //show exercise title -if($origin != 'learnpath') {?> -

:

- selectDescription(); ?> - - +if($origin == 'learnpath') { ?>
- 0){error_log ("ExerciseResult: ".print_r($exerciseResult,1)); error_log("QuestionList: ".print_r($questionList,1));} -if ($_configuration['tracking_enabled']) { - // Create an empty exercise - if (api_is_allowed_to_session_edit() ) - $exeId= create_event_exercice($objExercise->selectId()); +// Create an empty exercise +if (api_is_allowed_to_session_edit()) { + $exeId= create_event_exercice($objExercise->selectId()); } $counter=0; +$user_info = api_get_user_info(api_get_user_id()); +if ($show_results || $show_only_score) { + echo $exercise_header = $objExercise->show_exercise_result_header(api_get_person_name($user_info['firstName'], $user_info['lastName'])); +} + + // Loop over all question to show results for each of them, one by one foreach ($questionList as $questionId) { + // destruction of the Question object + unset($objQuestionTmp); + $counter++; // gets the student choice for this question $choice = $exerciseResult[$questionId]; @@ -189,134 +200,54 @@ foreach ($questionList as $questionId) { $questionDescription = $objQuestionTmp->selectDescription(); $questionWeighting = $objQuestionTmp->selectWeighting(); $answerType = $objQuestionTmp->selectType(); - $quesId = $objQuestionTmp->selectId(); //added by priya saini - - // destruction of the Question object - unset($objQuestionTmp); - - // decide how many columns we want to use to show the results of each type - if (in_array($answerType, array(UNIQUE_ANSWER, MULTIPLE_ANSWER, MULTIPLE_ANSWER_COMBINATION, MULTIPLE_ANSWER_TRUE_FALSE, MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE,UNIQUE_ANSWER_NO_OPTION))) { - $colspan=4; - } elseif($answerType == MATCHING || $answerType == FREE_ANSWER) { - $colspan=2; - } elseif($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER) { - $colspan=4; - $rowspan=$nbrAnswers+1; - } else { - $colspan=1; - } - // show titles - if ($origin != 'learnpath') {?> - - - - - - - - - - - - - feedbacktype != EXERCISE_FEEDBACK_TYPE_EXAM) { ?> - - - - - - - - - - - - - feedbacktype != EXERCISE_FEEDBACK_TYPE_EXAM) { ?> - - - - - - - -
-
- -
-
- -
- - - - - - - -  
- -
- - - -  
- - - - - feedbacktype != EXERCISE_FEEDBACK_TYPE_EXAM) { ?> - - - - - - - - - - - selectId(); + + if ($show_results) { + // show titles + if ($origin != 'learnpath') { + echo $objQuestionTmp->return_header($objExercise->feedbacktype); + if ($answerType == HOT_SPOT) { + ?> + + - -
-

-
-

-
-

-
 
- - - -
+ + + + + feedbacktype != EXERCISE_FEEDBACK_TYPE_EXAM) { ?> + + + + + + manage_answer($exeId, $questionId, $choice,'exercise_result', $exerciseResultCoordinates, true, false, true, $objExercise->selectPropagateNeg()); + $result = $objExercise->manage_answer($exeId, $questionId, $choice,'exercise_result', $exerciseResultCoordinates, true, false, $show_results, $objExercise->selectPropagateNeg()); $totalScore += $result['score']; - $totalWeighting += $result['weight']; - + $totalWeighting += $result['weight']; } // end huge foreach() block that loops over all questions -if($origin != 'learnpath') { - echo '
'; - echo get_lang('YourTotalScore')." "; - if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) { - $totalScore = 0; - } - echo show_score($totalScore, $totalWeighting, false); - echo '
'; - ?> - -'; + echo get_lang('YourTotalScore')." "; + if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) { + $totalScore = 0; + } + echo show_score($totalScore, $totalWeighting, false); + echo ''; + } + /* */ } // Tracking of results @@ -330,35 +261,18 @@ if (api_is_allowed_to_session_edit() ) { update_event_exercice($exeId, $objExercise->selectId(), $totalScore, $totalWeighting,api_get_session_id(),$safe_lp_id,$safe_lp_item_id,$safe_lp_item_view_id, $quizDuration); } - -if ($objExercise->results_disabled) { - ob_end_clean(); - if ($origin != 'learnpath') { - Display :: display_normal_message(get_lang('ExerciseFinished').'
'.get_lang('Back').'',false); - } else { - Display :: display_normal_message(get_lang('ExerciseFinished').'

',false); - - $lp_mode = $_SESSION['lp_mode']; - $url = '../newscorm/lp_controller.php?cidReq='.api_get_course_id().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$objExercise->feedbacktype; - $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" '; - echo ''."\n"; - //record the results in the learning path, using the SCORM interface (API) - echo ''."\n"; - echo ''; - } +if ($origin != 'learnpath') { + Display :: display_normal_message(get_lang('ExerciseFinished').'
'.get_lang('Back').'',false); } else { - //show score - if ($origin == 'learnpath') { - Display::display_normal_message(get_lang('ExerciseFinished')); - $lp_mode = $_SESSION['lp_mode']; - $url = '../newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$objExercise->feedbacktype; - $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" '; - echo ''."\n"; - - //record the results in the learning path, using the SCORM interface (API) - echo ''."\n"; - echo ''; - } + Display :: display_normal_message(get_lang('ExerciseFinished').'

',false); + + $lp_mode = $_SESSION['lp_mode']; + $url = '../newscorm/lp_controller.php?cidReq='.api_get_course_id().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$objExercise->feedbacktype; + $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" '; + echo ''."\n"; + //record the results in the learning path, using the SCORM interface (API) + echo ''."\n"; + echo ''; } if ($origin != 'learnpath') { diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php index 799da09a82..cae98172a9 100755 --- a/main/exercice/exercise_show.php +++ b/main/exercice/exercise_show.php @@ -201,11 +201,10 @@ function getFCK(vals,marksid) { //f.submit(); } -
+

+
+

+
+

+
 
- - +
+
'; Display::display_warning_message(get_lang('ThankYouForPassingTheTest').'

'.(get_lang('BackToExercisesList')).'', false); echo '
'; } } elseif ($result_disabled == 2) { - $show_results = false; + $show_results = false; + $show_only_total_score = true; if ($origin != 'learnpath') { - Display::display_warning_message(get_lang('ThankYouForPassingTheTest').'

'.(get_lang('BackToExercisesList')).'', false); + echo ' + +
'; + Display::display_warning_message(get_lang('ThankYouForPassingTheTest'), false); echo '
'; } } - } + //} } else { Display::display_warning_message(get_lang('CantViewResults')); $show_results = false; - echo '
'; } +//var_dump($show_results); + if ($origin == 'learnpath' && !isset($_GET['fb_type']) ) { $show_results = false; } +$html = ''; +if ($show_results || $show_only_total_score) { + $user_info = api_get_user_info($student_id); + //Shows exercise header + echo $objExercise->show_exercise_result_header(api_get_person_name($user_info['firstName'], $user_info['lastName']), api_convert_and_format_date($exercise_date)); +} -if ($show_results) { - ?> - - - - - - - - - - - - - - - - - - -
-

-
: - -
: - -
- - - -
-
-
- 0){error_log("ExerciseResult: ".print_r($exerciseResult,1)); error_log("QuestionList: ".print_r($questionList,1));} - if($debug>0){error_log("ExerciseResult: ".print_r($exerciseResult,1)); error_log("QuestionList: ".print_r($questionList,1));} - - $arrques = array(); - $arrans = array(); - - $user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($student_id)." "; - $query = "SELECT attempts.question_id, answer from ".$TBL_TRACK_ATTEMPT." as attempts - INNER JOIN ".$TBL_TRACK_EXERCICES." as stats_exercices ON stats_exercices.exe_id=attempts.exe_id - INNER JOIN ".$TBL_EXERCICE_QUESTION." as quizz_rel_questions ON quizz_rel_questions.exercice_id=stats_exercices.exe_exo_id AND quizz_rel_questions.question_id = attempts.question_id - INNER JOIN ".$TBL_QUESTIONS." as questions ON questions.id=quizz_rel_questions.question_id - WHERE attempts.exe_id='".Database::escape_string($id)."' $user_restriction - GROUP BY quizz_rel_questions.question_order, attempts.question_id"; - //GROUP BY questions.position, attempts.question_id"; - - $result =Database::query($query); - $questionList = array(); - $exerciseResult = array(); - - while ($row = Database::fetch_array($result)) { - $questionList[] = $row['question_id']; - $exerciseResult[$row['question_id']] = $row['answer']; - } - - //Fixing #2073 Fixing order of questions - if (!empty($track_exercise_info['data_tracking']) && !empty($track_exercise_info['random']) ) { - $tempquestionList = explode(',',$track_exercise_info['data_tracking']); - if (is_array($tempquestionList) && count($tempquestionList) == count($questionList)) { - $questionList = $tempquestionList; - } - } - - // for each question - $counter=0; +$arrques = array(); +$arrans = array(); - $total_weighting = 0; - foreach ($questionList as $questionId) { - $objQuestionTmp = Question::read($questionId); - $total_weighting +=$objQuestionTmp->selectWeighting(); - } - - foreach ($questionList as $questionId) { - $counter++; - $choice=$exerciseResult[$questionId]; - // creates a temporary Question object - $objQuestionTmp = Question::read($questionId); - $questionName = $objQuestionTmp->selectTitle(); - $questionDescription= $objQuestionTmp->selectDescription(); - $questionWeighting = $objQuestionTmp->selectWeighting(); - $answerType = $objQuestionTmp->selectType(); - $quesId = $objQuestionTmp->selectId(); //added by priya saini - +$user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($student_id)." "; +$query = "SELECT attempts.question_id, answer from ".$TBL_TRACK_ATTEMPT." as attempts + INNER JOIN ".$TBL_TRACK_EXERCICES." as stats_exercices ON stats_exercices.exe_id=attempts.exe_id + INNER JOIN ".$TBL_EXERCICE_QUESTION." as quizz_rel_questions ON quizz_rel_questions.exercice_id=stats_exercices.exe_exo_id AND quizz_rel_questions.question_id = attempts.question_id + INNER JOIN ".$TBL_QUESTIONS." as questions ON questions.id=quizz_rel_questions.question_id + WHERE attempts.exe_id='".Database::escape_string($id)."' $user_restriction + GROUP BY quizz_rel_questions.question_order, attempts.question_id"; + //GROUP BY questions.position, attempts.question_id"; - // destruction of the Question object - unset($objQuestionTmp); +$result =Database::query($query); +$questionList = array(); +$exerciseResult = array(); - if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) { - $colspan=2; - } - if($answerType == MATCHING || $answerType == FREE_ANSWER) { - $colspan=2; - } else { - $colspan=2; - } - - echo '
'; - echo get_lang("Question").' '.($counter).' : '.$questionName; - echo '
'; - echo '
'; - echo $questionDescription; - echo '
'; - - if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) { - ?> - - - - - - - - - - - - - - - - - - manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, true, $objExercise->selectPropagateNeg()); - //var_dump($question_result); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; - //$questionWeighting += $question_result['weight']; - - echo '
 
 
 
'; - } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { - $choice=array(); - ?> - - - - - - - - - - - - - - manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, true, $objExercise->selectPropagateNeg()); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; +while ($row = Database::fetch_array($result)) { + $questionList[] = $row['question_id']; + $exerciseResult[$row['question_id']] = $row['answer']; +} - echo '
 
 
'; - } elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) { - ?> - - - - - - - - - - - - - - - - - - manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, true, $objExercise->selectPropagateNeg()); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; - echo '
 
 
 
'; - - } elseif ($answerType == FILL_IN_BLANKS) { - ?> - - - - - - - - - - - manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, true, $objExercise->selectPropagateNeg()); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; - - echo '
 
 
'; - } elseif ($answerType == FREE_ANSWER) { - $answer = $str; - ?> - - - - - - - - - - +//Fixing #2073 Fixing order of questions +if (!empty($track_exercise_info['data_tracking']) && !empty($track_exercise_info['random']) ) { + $tempquestionList = explode(',',$track_exercise_info['data_tracking']); + if (is_array($tempquestionList) && count($tempquestionList) == count($questionList)) { + $questionList = $tempquestionList; + } +} - manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, true, $objExercise->selectPropagateNeg()); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; - - } elseif ($answerType == MATCHING) { - $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, true, $objExercise->selectPropagateNeg()); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; - echo '
 
 
'; - } elseif ($answerType == HOT_SPOT) { - - echo ' - +// for each question +$counter=0; + +$total_weighting = 0; +foreach ($questionList as $questionId) { + $objQuestionTmp = Question::read($questionId); + $total_weighting +=$objQuestionTmp->selectWeighting(); +} + +foreach ($questionList as $questionId) { + $counter++; + $choice=$exerciseResult[$questionId]; + // destruction of the Question object + unset($objQuestionTmp); + + // creates a temporary Question object + $objQuestionTmp = Question::read($questionId); + $questionName = $objQuestionTmp->selectTitle(); + $questionDescription= $objQuestionTmp->selectDescription(); + $questionWeighting = $objQuestionTmp->selectWeighting(); + $answerType = $objQuestionTmp->selectType(); + $quesId = $objQuestionTmp->selectId(); + + if ($show_results) { + echo $objQuestionTmp->return_header($feedback_type); + } + if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) { + $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); + $questionScore = $question_result['score']; + $totalScore += $question_result['score']; + } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { + $choice=array(); + $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); + $questionScore = $question_result['score']; + $totalScore += $question_result['score']; + } elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) { + $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); + $questionScore = $question_result['score']; + $totalScore += $question_result['score']; + echo '
'; + } elseif ($answerType == FILL_IN_BLANKS) { + $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); + $questionScore = $question_result['score']; + $totalScore += $question_result['score']; + + } elseif ($answerType == FREE_ANSWER) { + $answer = $str; + $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); + $questionScore = $question_result['score']; + $totalScore += $question_result['score']; + } elseif ($answerType == MATCHING) { + $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); + $questionScore = $question_result['score']; + $totalScore += $question_result['score']; + } elseif ($answerType == HOT_SPOT) { + if ($show_results) { + echo ''; echo '
- '; - $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, true, $objExercise->selectPropagateNeg()); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; +
'; + } + $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); + $questionScore = $question_result['score']; + $totalScore += $question_result['score']; + + if ($show_results) { echo '
'. @@ -499,7 +364,16 @@ if ($show_results) {

'; - } + } + } + + if ($show_results) { + if ($answerType != HOT_SPOT) { + echo ''; + } + } + + if ($show_results) { echo ''; @@ -552,6 +426,7 @@ if ($show_results) { } echo ' - -
'; } + if ($is_allowedToEdit) { if ($answerType == FREE_ANSWER) { $marksname = "marksName".$questionId; @@ -581,40 +456,43 @@ if ($show_results) { $questionScore=0; } } - ?> -
- '; - if ($objExercise->selectPropagateNeg() == 0 && $my_total_score < 0) { - $my_total_score = 0; - } - + echo ' + + '; + } + + + /* + Do not convert question results + $my_total_score = convert_score($questionScore, $total_weighting); + $my_total_weight = convert_score($questionWeighting, $total_weighting);*/ + + $my_total_score = $questionScore; + $my_total_weight = $questionWeighting; + + if ($objExercise->selectPropagateNeg() == 0 && $my_total_score < 0) { + $my_total_score = 0; + } + if ($show_results) { + echo '
'; //echo get_lang('Score')." : $my_total_score / $my_total_weight"; echo get_lang('Score')." : ".show_score($my_total_score, $my_total_weight, false, false); //echo get_lang('Score')." : ".show_score($my_total_score, $total_weighting, false); echo '
'; + } - unset($objAnswerTmp); - $i++; - $totalWeighting+=$questionWeighting; - - } // end of large foreach on questions -} //end of condition if $show_results + unset($objAnswerTmp); + $i++; + + $totalWeighting+=$questionWeighting; + +} // end of large foreach on questions +//Total score if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) { - if ($show_results) { + if ($show_results || $show_only_total_score ) { echo '
'.get_lang('YourTotalScore').": "; $my_total_score_temp = $totalScore; if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) { diff --git a/main/exercice/fill_blanks.class.php b/main/exercice/fill_blanks.class.php index b9cb0d1d54..7d49acd71a 100755 --- a/main/exercice/fill_blanks.class.php +++ b/main/exercice/fill_blanks.class.php @@ -4,7 +4,7 @@ /** * File containing the FillBlanks class. -* @package dokeos.exercise +* @package chamilo.exercise * @author Eric Marguin * @author Julio Montoya Armas switchable fill in blank option added * @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $ @@ -200,6 +200,21 @@ class FillBlanks extends Question $objAnswer->createAnswer($answer,0,'',0,''); $objAnswer->save(); } + + function return_header($feedback_type, $counter = null) { + parent::return_header($feedback_type, $counter); + $header = ' + + + + + + + + + '; + return $header; + } } endif; diff --git a/main/exercice/freeanswer.class.php b/main/exercice/freeanswer.class.php index ced0ec374f..33f13abbe8 100755 --- a/main/exercice/freeanswer.class.php +++ b/main/exercice/freeanswer.class.php @@ -1,28 +1,10 @@ weighting = $form -> getSubmitValue('weighting'); $this->save(); } + + function return_header($feedback_type, $counter = null) { + parent::return_header($feedback_type, $counter); + $header = '
 
 
+ + + + + + + + + '; + return $header; + } + } endif; ?> \ No newline at end of file diff --git a/main/exercice/matching.class.php b/main/exercice/matching.class.php index 7a4749c8cf..4a8d67f9df 100755 --- a/main/exercice/matching.class.php +++ b/main/exercice/matching.class.php @@ -236,8 +236,7 @@ class Matching extends Question { } // insert the answers - for($i=1 ; $i<=$nb_matches ; ++$i) - { + for($i=1 ; $i<=$nb_matches ; ++$i) { $position++; $answer = $form -> getSubmitValue('answer['.$i.']'); $matches = $form -> getSubmitValue('matches['.$i.']'); @@ -245,11 +244,23 @@ class Matching extends Question { $this -> weighting += $weighting; $objAnswer->createAnswer($answer,$matches,'',$weighting,$position); } - $objAnswer->save(); $this->save(); - } + + function return_header($feedback_type, $counter = null) { + parent::return_header($feedback_type, $counter); + + echo '
 
 
'; + echo ''; + echo ' + + + '; + echo ''; + + } + } diff --git a/main/exercice/multiple_answer.class.php b/main/exercice/multiple_answer.class.php index 25504d8ae1..86754cf0a6 100755 --- a/main/exercice/multiple_answer.class.php +++ b/main/exercice/multiple_answer.class.php @@ -181,13 +181,10 @@ class MultipleAnswer extends Question { function processAnswersCreation($form) { $questionWeighting = $nbrGoodAnswers = 0; + $objAnswer = new Answer($this->id); + $nb_answers = $form->getSubmitValue('nb_answers'); - $objAnswer = new Answer($this->id); - - $nb_answers = $form -> getSubmitValue('nb_answers'); - - for($i=1 ; $i <= $nb_answers ; $i++) - { + for($i=1 ; $i <= $nb_answers ; $i++) { $answer = trim($form -> getSubmitValue('answer['.$i.']')); $comment = trim($form -> getSubmitValue('comment['.$i.']')); $weighting = trim($form -> getSubmitValue('weighting['.$i.']')); @@ -199,22 +196,41 @@ class MultipleAnswer extends Question { $weighting = abs($weighting); $weighting = -$weighting; } - if($weighting > 0) - { + if($weighting > 0) { $questionWeighting += $weighting; } - $objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i); - } // saves the answers into the data base $objAnswer -> save(); // sets the total weighting of the question - $this -> updateWeighting($questionWeighting); - $this -> save(); - + $this->updateWeighting($questionWeighting); + $this->save(); + } + + function return_header($feedback_type, $counter = null) { + parent::return_header($feedback_type, $counter); + $header = '
 
'.get_lang('ElementList').' '.get_lang('CorrespondsTo').'
 
+ + + + + + + '; + if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { + $header .= ''; + } else { + $header .= ''; + } + $header .= ' + + + + '; + return $header; } } diff --git a/main/exercice/multiple_answer_combination.class.php b/main/exercice/multiple_answer_combination.class.php index 705c1fe92e..f3fd5d390b 100755 --- a/main/exercice/multiple_answer_combination.class.php +++ b/main/exercice/multiple_answer_combination.class.php @@ -221,7 +221,29 @@ class MultipleAnswerCombination extends Question { // sets the total weighting of the question $this -> updateWeighting($questionWeighting); $this -> save(); - + } + + function return_header($feedback_type, $counter = null) { + parent::return_header($feedback_type, $counter); + $header = '
 
'.get_lang("Choice").' '. get_lang("ExpectedChoice").''. get_lang("Answer").''.get_lang("Comment").' 
 
+ + + + + + + '; + if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { + $header .= ''; + } else { + $header .= ''; + } + $header .= ' + + + + '; + return $header; } } diff --git a/main/exercice/multiple_answer_true_false.class.php b/main/exercice/multiple_answer_true_false.class.php index 9b95ff00c5..38bf2f4a0b 100755 --- a/main/exercice/multiple_answer_true_false.class.php +++ b/main/exercice/multiple_answer_true_false.class.php @@ -275,5 +275,28 @@ class MultipleAnswerTrueFalse extends Question { $this -> updateWeighting($questionWeighting); $this -> save(); } + + function return_header($feedback_type, $counter = null) { + parent::return_header($feedback_type, $counter); + $header = '
 
'.get_lang("Choice").' '. get_lang("ExpectedChoice").''. get_lang("Answer").''.get_lang("Comment").' 
 
+ + + + + + + '; + if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { + $header .= ''; + } else { + $header .= ''; + } + $header .= ' + + + + '; + return $header; + } } endif; \ No newline at end of file diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php index 6a3fa55971..63157ae300 100755 --- a/main/exercice/question.class.php +++ b/main/exercice/question.class.php @@ -1218,13 +1218,11 @@ abstract class Question echo ''; } - static function get_types_information() - { + static function get_types_information(){ return self::$questionTypes; } - static function updateId() - { + static function updateId() { return self::$questionTypes; } @@ -1259,6 +1257,16 @@ abstract class Question $result = Database::select('*', $TBL_EXERCICE_QUESTION_OPTION, array('where'=>array('question_id = ?' =>$question_id), 'order'=>'id ASC')); return $result; } + + function return_header($feedback_type, $counter = null) { + $counter_label = ''; + if (!is_null($counter)) { + $counter = intval($counter); + } + echo Display::div(get_lang("Question").' '.($counter_label).' : '.$this->question, array('id'=>'question_title', 'class'=>'sectiontitle')); + echo Display::div($this->description, array('id'=>'question_description')); + } + } endif; ?> \ No newline at end of file diff --git a/main/exercice/unique_answer.class.php b/main/exercice/unique_answer.class.php index 46c4474499..dbe672607d 100755 --- a/main/exercice/unique_answer.class.php +++ b/main/exercice/unique_answer.class.php @@ -370,7 +370,29 @@ class UniqueAnswer extends Question { // sets the total weighting of the question $this -> updateWeighting($questionWeighting); $this -> save(); - + } + + function return_header($feedback_type, $counter = null) { + parent::return_header($feedback_type, $counter); + $header = '
 
'.get_lang("Choice").' '. get_lang("ExpectedChoice").''. get_lang("Answer").''.get_lang("Comment").' 
 
+ + + + + + + '; + if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { + $header .= ''; + } else { + $header .= ''; + } + $header .= ' + + + + '; + return $header; } } endif; diff --git a/main/exercice/unique_answer_no_option.class.php b/main/exercice/unique_answer_no_option.class.php index 8360893b76..e328f7916e 100755 --- a/main/exercice/unique_answer_no_option.class.php +++ b/main/exercice/unique_answer_no_option.class.php @@ -449,7 +449,7 @@ class UniqueAnswerNoOption extends Question { $comment = trim($form -> getSubmitValue('comment['.$i.']')); $weighting = trim($form -> getSubmitValue('weighting['.$i.']')); $goodAnswer= ($correct == $i) ? true : false; - $dest = ''; + $dest = ''; $objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest); @@ -459,7 +459,29 @@ class UniqueAnswerNoOption extends Question { // sets the total weighting of the question $this -> updateWeighting($questionWeighting); $this -> save(); - + } + + function return_header($feedback_type, $counter = null) { + parent::return_header($feedback_type, $counter); + $header = '
 
'.get_lang("Choice").' '. get_lang("ExpectedChoice").''. get_lang("Answer").''.get_lang("Comment").' 
 
+ + + + + + + '; + if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { + $header .= ''; + } else { + $header .= ''; + } + $header .= ' + + + + '; + return $header; } } endif; \ No newline at end of file
 
'.get_lang("Choice").' '. get_lang("ExpectedChoice").''. get_lang("Answer").''.get_lang("Comment").'