Adding new type of question see #5012

skala
Julio Montoya 14 years ago
parent c55764765f
commit b1c1f6ce40
  1. 39
      main/exercice/answer_admin.inc.php
  2. 671
      main/exercice/exercise.class.php
  3. 752
      main/exercice/exercise.lib.php
  4. 207
      main/exercice/exercise_show.php
  5. 334
      main/exercice/global_multiple_answer.class.php
  6. 245
      main/exercice/question.class.php
  7. 1
      main/exercice/question_create.php
  8. 186
      main/exercice/result.php
  9. BIN
      main/img/icons/32/mcmagl.gif
  10. BIN
      main/img/mcmagl.gif

@ -64,9 +64,7 @@ if($modifyIn)
$objAnswer=new Answer($questionId);
}
if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_COMBINATION)
{
if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == GLOBAL_MULTIPLE_ANSWER) {
$correct=unserialize($correct);
$reponse=unserialize($reponse);
$comment=unserialize($comment);
@ -122,8 +120,8 @@ if($modifyIn)
// the answer form has been submitted
if($submitAnswers || $buttonBack)
{
if($debug>0){echo '$submitAnswers or $buttonBack was set'."<br />\n";}
if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_COMBINATION) {
if ($debug>0){echo '$submitAnswers or $buttonBack was set'."<br />\n";}
if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == GLOBAL_MULTIPLE_ANSWER) {
if($debug>0){echo '&nbsp;&nbsp;$answerType is UNIQUE_ANSWER or MULTIPLE_ANSWER'."<br />\n";}
$questionWeighting=$nbrGoodAnswers=0;
@ -154,8 +152,8 @@ if($submitAnswers || $buttonBack)
{
$questionWeighting+=$weighting[$i];
}
} elseif($answerType == MULTIPLE_ANSWER) {
if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is MULTIPLE_ANSWER'."<br />\n";}
} elseif($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) {
if ($debug>0){echo str_repeat('&nbsp;',4).'$answerType is MULTIPLE_ANSWER'."<br />\n";}
// a bad answer can't have a positive weighting
$weighting[$i]=0-abs($weighting[$i]);
}
@ -599,20 +597,18 @@ if($modifyAnswers)
Session::write('objAnswer', $objAnswer);
if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
{
if($debug>0){echo str_repeat('&nbsp;',2).'$answerType is UNIQUE_ANSWER or MULTIPLE_ANSWER'."<br />\n";}
if(!$nbrAnswers)
{
if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) {
if ($debug>0){echo str_repeat('&nbsp;',2).'$answerType is UNIQUE_ANSWER or MULTIPLE_ANSWER'."<br />\n";}
if(!$nbrAnswers) {
$nbrAnswers=$objAnswer->selectNbrAnswers();
$reponse=Array();
$comment=Array();
$weighting=Array();
// initializing
if($answerType == MULTIPLE_ANSWER)
// initializing + Modification de la ligne suivante
if($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER)
{
$correct=Array();
}
@ -626,9 +622,7 @@ if($modifyAnswers)
$reponse[$i]=$objAnswer->selectAnswer($i);
$comment[$i]=$objAnswer->selectComment($i);
$weighting[$i]=$objAnswer->selectWeighting($i);
if($answerType == MULTIPLE_ANSWER)
{
if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) {
$correct[$i]=$objAnswer->isCorrect($i);
}
elseif($objAnswer->isCorrect($i))
@ -862,13 +856,12 @@ if($modifyAnswers)
}
if(!$usedInSeveralExercises)
if (!$usedInSeveralExercises)
{
if($debug>0){echo str_repeat('&nbsp;',2).'$usedInSeveralExercises is untrue'."<br />\n";}
if ($debug>0){echo str_repeat('&nbsp;',2).'$usedInSeveralExercises is untrue'."<br />\n";}
if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_COMBINATION)
{
if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is UNIQUE_ANSWER or MULTIPLE_ANSWER'."<br />\n";}
if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == GLOBAL_MULTIPLE_ANSWER) {
if ($debug>0){echo str_repeat('&nbsp;',4).'$answerType is UNIQUE_ANSWER or MULTIPLE_ANSWER'."<br />\n";}
?>
<h3>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,14 +1,14 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Shows the exercise results
* Shows the exercise results
*
* @author Julio Montoya Armas Added switchable fill in blank option added
* @version $Id: exercise_show.php 22256 2009-07-20 17:40:20Z ivantcholakov $
* @package chamilo.exercise
* @todo remove the debug code and use the general debug library
* @todo small letters for table variables
*
*
*/
/**
* Code
@ -78,7 +78,7 @@ $exercise_id = $track_exercise_info['id'];
$exercise_date = $track_exercise_info['start_date'];
$student_id = $track_exercise_info['exe_user_id'];
$learnpath_id = $track_exercise_info['orig_lp_id'];
$learnpath_item_id = $track_exercise_info['orig_lp_item_id'];
$learnpath_item_id = $track_exercise_info['orig_lp_item_id'];
$lp_item_view_id = $track_exercise_info['orig_lp_item_view_id'];
$current_user_id = api_get_user_id();
@ -97,7 +97,7 @@ if (isset($session_control_key) && !exercise_time_control_is_valid($exercise_id)
Database::query($sql_fraud);
}
//Only users can see their own results
//Only users can see their own results
if (!$is_allowedToEdit) {
if ($student_id != $current_user_id) {
api_not_allowed();
@ -171,9 +171,9 @@ if (!empty($track_exercise_info)) {
$exerciseDescription = $track_exercise_info['description'];
// if the results_disabled of the Quiz is 1 when block the script
$result_disabled = $track_exercise_info['results_disabled'];
if (!(api_is_platform_admin() || api_is_course_admin()) ) {
if ($result_disabled == 1) {
if (!(api_is_platform_admin() || api_is_course_admin()) ) {
if ($result_disabled == 1) {
//api_not_allowed();
$show_results = false;
//Display::display_warning_message(get_lang('CantViewResults'));
@ -188,7 +188,7 @@ if (!empty($track_exercise_info)) {
}
} elseif ($result_disabled == 2) {
$show_results = false;
$show_only_total_score = true;
$show_only_total_score = true;
if ($origin != 'learnpath') {
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
@ -197,8 +197,8 @@ if (!empty($track_exercise_info)) {
echo '</td>
</tr>
</table>';
}
}
}
}
}
} else {
Display::display_warning_message(get_lang('CantViewResults'));
@ -225,11 +225,11 @@ $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
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
AND quizz_rel_questions.c_id=".api_get_course_int_id()."
INNER JOIN ".$TBL_QUESTIONS." AS questions
INNER JOIN ".$TBL_QUESTIONS." AS questions
ON questions.id=quizz_rel_questions.question_id
AND questions.c_id = ".api_get_course_int_id()."
WHERE attempts.exe_id='".Database::escape_string($id)."' $user_restriction
@ -237,7 +237,7 @@ $query = "SELECT attempts.question_id, answer FROM ".$TBL_TRACK_ATTEMPT." as at
//GROUP BY questions.position, attempts.question_id";
$result = Database::query($query);
$result = Database::query($query);
$questionList = array();
$exerciseResult = array();
@ -249,9 +249,9 @@ while ($row = Database::fetch_array($result)) {
//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;
}
if (is_array($tempquestionList) && count($tempquestionList) == count($questionList)) {
$questionList = $tempquestionList;
}
}
// Display the text when finished message if we are on a LP #4227
@ -265,74 +265,77 @@ if (!empty($end_of_message) && ($origin == 'learnpath')) {
$total_weighting = 0;
foreach ($questionList as $questionId) {
$objQuestionTmp = Question::read($questionId);
$total_weighting +=$objQuestionTmp->selectWeighting();
$total_weighting +=$objQuestionTmp->selectWeighting();
}
$counter = 1;
foreach ($questionList as $questionId) {
$choice = $exerciseResult[$questionId];
// destruction of the Question object
unset($objQuestionTmp);
// creates a temporary Question object
$objQuestionTmp = Question::read($questionId);
$objQuestionTmp = Question::read($questionId);
$questionWeighting = $objQuestionTmp->selectWeighting();
$answerType = $objQuestionTmp->selectType();
if ($show_results) {
// display question category, if any
Testcategory::displayCategoryAndTitle($questionId);
echo $objQuestionTmp->return_header("", $counter);
}
$counter++;
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());
$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'];
$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());
$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) {
$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'];
$totalScore += $question_result['score'];
echo '</table>';
} 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;
} elseif ($answerType == GLOBAL_MULTIPLE_ANSWER) {
$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 == ORAL_EXPRESSION) {
$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());
} 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) {
$totalScore += $question_result['score'];
} elseif ($answerType == HOT_SPOT) {
if ($show_results) {
echo '<table width="500" border="0"><tr>
<td valign="top" align="center" style="padding-left:0px;" >
<table border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;" width="552">';
}
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
}
$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 '</table></td></tr>';
if ($show_results) {
echo '</table></td></tr>';
echo '<tr>
<td colspan="2">'.
'<object type="application/x-shockwave-flash" data="'.api_get_path(WEB_CODE_PATH).'plugin/hotspot/hotspot_solution.swf?modifyAnswers='.Security::remove_XSS($questionId).'&exe_id='.$id.'&from_db=1" width="552" height="352">
@ -343,33 +346,33 @@ foreach ($questionList as $questionId) {
</table><br/>';
}
} else if($answerType == HOT_SPOT_DELINEATION) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg(), 'database');
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
$final_overlap = $question_result['extra']['final_overlap'];
$final_missing = $question_result['extra']['final_missing'];
$final_excess = $question_result['extra']['final_excess'];
$overlap_color = $question_result['extra']['overlap_color'];
$missing_color = $question_result['extra']['missing_color'];
$excess_color = $question_result['extra']['excess_color'];
$threadhold1 = $question_result['extra']['threadhold1'];
$threadhold1 = $question_result['extra']['threadhold1'];
$threadhold2 = $question_result['extra']['threadhold2'];
$threadhold3 = $question_result['extra']['threadhold3'];
if ($show_results) {
if ($overlap_color) {
$overlap_color='green';
} else {
$overlap_color='red';
}
if ($missing_color) {
$missing_color='green';
} else {
@ -380,48 +383,48 @@ foreach ($questionList as $questionId) {
} else {
$excess_color='red';
}
if (!is_numeric($final_overlap)) {
$final_overlap = 0;
}
if (!is_numeric($final_missing)) {
$final_missing = 0;
}
if (!is_numeric($final_excess)) {
$final_excess = 0;
}
if ($final_excess>100) {
$final_excess = 100;
}
$table_resume='<table class="data_table">
}
$table_resume='<table class="data_table">
<tr class="row_odd" >
<td></td>
<td ><b>'.get_lang('Requirements').'</b></td>
<td><b>'.get_lang('YourAnswer').'</b></td>
</tr>
<tr class="row_even">
<td><b>'.get_lang('Overlap').'</b></td>
<td>'.get_lang('Min').' '.$threadhold1.'</td>
<td><div style="color:'.$overlap_color.'">'.(($final_overlap < 0)?0:intval($final_overlap)).'</div></td>
</tr>
<tr>
<td><b>'.get_lang('Excess').'</b></td>
<td>'.get_lang('Max').' '.$threadhold2.'</td>
<td><div style="color:'.$excess_color.'">'.(($final_excess < 0)?0:intval($final_excess)).'</div></td>
</tr>
<tr class="row_even">
<td><b>'.get_lang('Missing').'</b></td>
<td>'.get_lang('Max').' '.$threadhold3.'</td>
<td><div style="color:'.$missing_color.'">'.(($final_missing < 0)?0:intval($final_missing)).'</div></td>
</tr></table>';
if ($answerType!= HOT_SPOT_DELINEATION) {
$item_list=explode('@@',$destination);
//print_R($item_list);
@ -439,46 +442,46 @@ foreach ($questionList as $questionId) {
} else {
//show if no error
//echo 'no error';
$comment=$answerComment=$objAnswerTmp->selectComment($nbrAnswers);
$comment=$answerComment=$objAnswerTmp->selectComment($nbrAnswers);
$answerDestination=$objAnswerTmp->selectDestination($nbrAnswers);
}
}
}
echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
if ($answerType == HOT_SPOT_DELINEATION) {
if ($answerType == HOT_SPOT_DELINEATION) {
if ($organs_at_risk_hit>0) {
$message='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
$message='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
$message.='<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
} else {
$message='<p>'.get_lang('YourDelineation').'</p>';
$message.=$table_resume;
$message.=$table_resume;
$message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
}
$message.='<p>'.$comment.'</p>';
echo $message;
$message.='<p>'.$comment.'</p>';
echo $message;
} else {
echo '<p>'.$comment.'</p>';
}
//showing the score
//showing the score
$queryfree = "select marks from ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
$resfree = Database::query($queryfree);
$questionScore= Database::result($resfree,0,"marks");
$totalScore+=$questionScore;
$totalScore+=$questionScore;
?>
</table>
</td></tr>
<?php
<?php
echo '<tr>
<td colspan="2">
<object type="application/x-shockwave-flash" data="../plugin/hotspot/hotspot_solution.swf?modifyAnswers='.$questionId.'&exe_id='.$id.'&from_db=1" width="556" height="350">
<param name="movie" value="../plugin/hotspot/hotspot_solution.swf?modifyAnswers='.$questionId.'&exe_id='.$id.'&from_db=1" />
</object>
</td>
</tr>
</table>';
}
}
}
if ($show_results) {
@ -486,12 +489,12 @@ foreach ($questionList as $questionId) {
echo '</table>';
}
}
if ($show_results) {
if ($show_results) {
echo '<table width="100%" border="0" cellspacing="3" cellpadding="0">';
if ($is_allowedToEdit && $locked == false) {
if ($is_allowedToEdit && $locked == false) {
echo '<tr><td>';
$name = "fckdiv".$questionId;
$marksname = "marksName".$questionId;
@ -531,7 +534,7 @@ foreach ($questionList as $questionId) {
$feedback_form->setDefaults(${user.$questionId});
$feedback_form->display();
echo '</div>';
} else {
$comnt = get_comments($id,$questionId);
echo '<tr><td><br />';
@ -541,7 +544,7 @@ foreach ($questionList as $questionId) {
}
echo '</td><td>';
}
if ($is_allowedToEdit) {
if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) {
$marksname = "marksName".$questionId;
@ -570,18 +573,18 @@ foreach ($questionList as $questionId) {
if ($questionScore==-1) {
$questionScore=0;
}
}
}
echo '</td>
</tr>
</table>';
</table>';
}
$my_total_score = $questionScore;
$my_total_weight = $questionWeighting;
$my_total_weight = $questionWeighting;
if ($objExercise->selectPropagateNeg() == 0 && $my_total_score < 0) {
$my_total_score = 0;
}
}
if ($show_results) {
echo '<div id="question_score">';
echo get_lang('Score')." : ".show_score($my_total_score, $my_total_weight, false, false);
@ -591,18 +594,18 @@ foreach ($questionList as $questionId) {
$i++;
$totalWeighting += $questionWeighting;
} // end of large foreach on questions
//Total score
if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
if ($show_results || $show_only_total_score ) {
if ($show_results || $show_only_total_score ) {
echo '<div id="question_score">'.get_lang('YourTotalScore').": ";
$my_total_score_temp = $totalScore;
$my_total_score_temp = $totalScore;
if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) {
$my_total_score_temp = 0;
}
echo show_score($my_total_score_temp, $totalWeighting, false);
}
echo show_score($my_total_score_temp, $totalWeighting, false);
echo '</div>';
}
}
@ -613,14 +616,14 @@ if (is_array($arrid) && is_array($arrmarks)) {
}
if ($is_allowedToEdit && $locked == false) {
if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) {
if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) {
echo ' <form name="myform" id="myform" action="exercise_report.php?exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">';
//echo ' <input type = "hidden" name="totalWeighting" value="'.$totalWeighting.'">';
echo '<input type = "hidden" name="lp_item_id" value="'.$lp_id.'">';
echo '<input type = "hidden" name="lp_item_view_id" value="'.$lp_item_view_id.'">';
echo '<input type = "hidden" name="student_id" value="'.$student_id.'">';
echo '<input type = "hidden" name="total_score" value="'.$totalScore.'"> ';
echo '<input type = "hidden" name="my_exe_exo_id" value="'.$exercise_id.'"> ';
echo '<input type = "hidden" name="my_exe_exo_id" value="'.$exercise_id.'"> ';
} else {
echo ' <form name="myform" id="myform" action="exercise_report.php?exerciseId='.$exercise_id.'&filter=1&comments=update&exeid='.$id.'" method="post">';
}
@ -654,9 +657,9 @@ if ($origin != 'learnpath') {
$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='.$feedback_type;
$href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" ';
echo '<script type="text/javascript">'.$href.'</script>';
//Record the results in the learning path, using the SCORM interface (API)
echo '<script type="text/javascript">'.$href.'</script>';
//Record the results in the learning path, using the SCORM interface (API)
echo '<script type="text/javascript">window.parent.API.void_save_asset('.$totalScore.','.$totalWeighting.');</script>'."\n";
echo '</body></html>';
} else {
@ -665,8 +668,8 @@ if ($origin != 'learnpath') {
}
}
if (!$is_allowedToEdit) {
$objExercise->send_notification($arrques, $arrans, $origin);
if (!$is_allowedToEdit) {
$objExercise->send_notification($arrques, $arrans, $origin);
}
//destroying the session

@ -0,0 +1,334 @@
<?php
if(!class_exists('GlobalMultipleAnswer')):
class GlobalMultipleAnswer extends Question {
static $typePicture = 'mcmagl.gif';
static $explanationLangVar = 'GlobalMultipleAnswer';
/*Constructor*/
function GlobalMultipleAnswer(){
parent::question();
$this -> type = GLOBAL_MULTIPLE_ANSWER;
$this -> isContent = $this-> getIsContent();
}
/**
* function which redifines Question::createAnswersForm
* @param the formvalidator instance
* @param the answers number to display
*/
function createAnswersForm ($form) {
$nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4;
$nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
$obj_ex = $_SESSION['objExercise'];
/* Mise en variable de Affichage "Reponses" et son icone, "N<EFBFBD>", "Vrai", "Reponse" */
$html='<table class="data_table">
<tr>
<th width="10px">
'.get_lang('Number').'
</th>
<th width="10px">
'.get_lang('True').'
</th>
<th width="50%">
'.get_lang('Answer').'
</th>';
// Espace entre l'entete et les r<EFBFBD>ponses
if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM ) {
$html .='<th>'.get_lang('Comment').'</th>';
}
/*$html .= '<th width="50px">
'.get_lang('Weighting').'
</th>
</tr>';
*/
$html .='</tr>';
/* Excution de l'affichage*/
$form -> addElement ('label', get_lang('Answers').'<br /> <img src="../img/fill_field.png">', $html);
/*Initialiation variable*/
$defaults = array();
$correct = 0;
/*Mise en variable du nombre de reponse */
if(!empty($this -> id)) {
$answer = new Answer($this -> id);
$answer -> read();
if(count($answer->nbrAnswers)>0 && !$form->isSubmitted()) {
$nb_answers = $answer->nbrAnswers;
}
}
#le nombre de r<EFBFBD>ponses est bien enregistr<EFBFBD> sous la forme int(nb)
/* Ajout mise en forme nb reponse */
$form -> addElement('hidden', 'nb_answers');
$boxes_names = array();
/* V<EFBFBD>rification : Cr<EFBFBD>action d'au moins une r<EFBFBD>ponse */
if ($nb_answers < 1) {
$nb_answers = 1;
Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
}
//---------------------------------- D<EFBFBD>but affichage score global dans la modification d'une question
$scoreA = "0"; //par reponse
$scoreG = "0"; //Global
//--------------------------------- Fin
/* boucle pour sauvegarder les donn<EFBFBD>es dans le tableau defaults */
for($i = 1 ; $i <= $nb_answers ; ++$i) {
/* si la reponse est de type objet */
if(is_object($answer)) {
$defaults['answer['.$i.']'] = $answer -> answer[$i];
$defaults['comment['.$i.']'] = $answer -> comment[$i];
$defaults['correct['.$i.']'] = $answer -> correct[$i];
//------------- D<EFBFBD>but
$scoreA = $answer -> weighting[$i];
}
if ($scoreA>0){
$scoreG = $scoreG + $scoreA ;
}
//------------- Fin
//------------- Debut si un des scores par reponse est egal <EFBFBD> 0 : la coche vaut 1 (coch<EFBFBD>)
if ($scoreA == 0)
$defaults['pts'] = 1;
else
$defaults['pts'] = 0;
//------------- Fin
$renderer = & $form->defaultRenderer();
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>');
//$answer_number=$form->addElement('text', null,null,'value="'.$i.'"');
$answer_number=$form->addElement('text', 'counter['.$i.']', null, 'value="'.$i.'"');
$answer_number->freeze();
$form->addElement('checkbox', 'correct['.$i.']', null, null, 'class="checkbox" style="margin-left: 2em;"');
$boxes_names[] = 'correct['.$i.']';
$form->addElement('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle"', array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
$form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
// show comment when feedback is enable
if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$form->addElement('html_editor', 'comment['.$i.']',null, 'style="vertical-align:middle"', array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
}
$form -> addElement ('html', '</tr>');
}
//--------- Mise en variable du score global lors d'une modification de la question/r<EFBFBD>ponse
$defaults['weighting[1]'] = (round($scoreG));
$form -> addElement ('html', '</div></div></table>');
//$form -> addElement ('html', '<br />');
$form -> add_multiple_required_rule ($boxes_names , get_lang('ChooseAtLeastOneCheckbox') , 'multiple_required');
//--------- Affichage score suivant la langue
$form -> addElement ('html', '<table><div class="row">
<tr>'.get_lang('Score').'</tr><tr><td>');
//only 1 answer the all deal ...
$form->addElement('text', 'weighting[1]');
$form -> addElement ('html', '</td><td width=18%></td><td width="1" align="right">');
global $pts;
//--------- Creation coche pour ne pas prendre en compte les n<EFBFBD>gatifs
$form -> addElement('checkbox', 'pts','',get_lang('SansNeg'));
$form -> addElement ('html', '</td></tr></div></table><br>');
//------------------------------------------------------------------------------
// Affiche un message si le score n'est pas renseign<EFBFBD>
$form->addRule('weighting[1]', get_lang('ScoreVide'), 'required');
$navigator_info = api_get_navigator();
global $text, $class, $show_quiz_edition;
//ie6 fix
if ($show_quiz_edition) {
if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') {
$form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'),'class="minus"');
$form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'),'class="plus"');
$form->addElement('submit','submitQuestion',$text, 'class="'.$class.'"');
} else {
$form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'),'class="minus"');
$form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'),'class="plus"');
$form->addElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"');
// setting the save button here and not in the question class.php
}
}
$renderer->setElementTemplate('{element}&nbsp;','lessAnswers');
$renderer->setElementTemplate('{element}&nbsp;','submitQuestion');
$renderer->setElementTemplate('{element}','moreAnswers');
$form -> addElement ('html', '</div></div>');
$defaults['correct'] = $correct;
if (!empty($this->id)) {
$form -> setDefaults($defaults);
} else {
if ($this -> isContent == 1) {
$form -> setDefaults($defaults);
}
}
$form->setConstants(array('nb_answers' => $nb_answers));
}
/**************************************************************************************************/
/**
* abstract function which creates the form to create / edit the answers of the question
* @param the formvalidator instance
* @param the answers number to display
*/
function processAnswersCreation($form) {
$questionWeighting = $nbrGoodAnswers = 0;
$objAnswer = new Answer($this->id);
$nb_answers = $form -> getSubmitValue('nb_answers');
// Score total
$answer_score = trim($form->getSubmitValue('weighting[1]'));
// Reponses correctes
$nbr_corrects = 0;
for ($i = 1; $i <= $nb_answers; $i++) {
$goodAnswer = trim($form->getSubmitValue('correct[' . $i . ']'));
if ($goodAnswer) {
$nbr_corrects++;
}
}
// Set question weighting (score total)
$questionWeighting = $answer_score;
// Set score per answer
$nbr_corrects = $nbr_corrects == 0 ? 1 : $nbr_corrects;
$answer_score = $nbr_corrects == 0 ? 0 : $answer_score;
//echo('affiche1');var_dump($answer_score);echo('<br>');
$answer_score = ($answer_score/$nbr_corrects);
//echo('affiche2');var_dump($answer_score);echo('<br>');
//$answer_score <EFBFBD>quivaut <EFBFBD> la valeur d'une bonne r<EFBFBD>ponse
// cr<EFBFBD>ation variable pour r<EFBFBD>cuperer la valeur de la coche pour la prise en compte des n<EFBFBD>gatifs
$test="";
$test = $form -> getSubmitValue('pts');
//---------------
for ($i = 1; $i <= $nb_answers; $i++) {
$answer = trim($form->getSubmitValue('answer[' . $i . ']'));
$comment = trim($form -> getSubmitValue('comment['.$i.']'));
$goodAnswer = trim($form->getSubmitValue('correct[' . $i . ']'));
if ($goodAnswer) {
$weighting = abs($answer_score);
}
else{
if ($test == 1)
{
$weighting = 0;
}else
$weighting = -abs($answer_score);
}
$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i);
}
// saves the answers into the data base
$objAnswer -> save();
// sets the total weighting of the question --> sert <EFBFBD> donner le score total pendant l'examen
$this -> updateWeighting($questionWeighting);
$this -> save();
}
/**************************************************************************************************/
function return_header($feedback_type = null, $counter = null) {
parent::return_header($feedback_type, $counter);
$header = '<table width="100%" class="data_table_exercise_result">
<tr>
<td><i>'.get_lang("Choice").'</i> </td>
<td><i>'. get_lang("ExpectedChoice").'</i></td>
<td><i>'. get_lang("Answer").'</i></td>';
if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
$header .= '<td><i>'.get_lang("Comment").'</i></td>';
} else {
$header .= '<td>&nbsp;</td>';
}
$header .= '</tr>';
return $header;
}
# Choice --> "Votre Choix"
# ExpectedChoice --> "choix attendu"
# Answer --> "Reponse"
/**********************************************************************************************************/
/**
* Display the question in tracking mode (use templates in tracking/questions_templates)
* @param $nbAttemptsInExercise the number of users who answered the quiz
*/
/*function displayTracking($exerciseId, $nbAttemptsInExercise) {
if (!class_exists('Answer'))
require_once(api_get_path(SYS_CODE_PATH) . 'exercice/answer.class.php');
$o_answer = new Answer($this->id);
$o_answer->stats = $this->getAverageStats($exerciseId, $nbAttemptsInExercise);
include(api_get_path(SYS_CODE_PATH) . 'exercice/tracking/questions_templates/multiple_answer.page');
}*/
/**********************************************************************************************************/
/**
* Returns learners choices for each question in percents
* @param $nbAttemptsInExercise the number of users who answered the quiz
* @return array the percents
*/
/* function getAverageStats($exerciseId, $nbAttemptsInExercise) {
$preparedSql = 'SELECT attempts.answer, COUNT(1) as nbAttempts
FROM ' . Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT) . ' as attempts
INNER JOIN ' . Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES) . ' as exercises
ON exercises.exe_id = attempts.exe_id
WHERE attempts.course_code LIKE "%s"
AND attempts.question_id = %d
AND exercises.exe_exo_id = %d
GROUP BY answer';
$sql = sprintf($preparedSql, api_get_course_id(), $this->id, $exerciseId);
$rs = Database::query($sql, __FILE__, __LINE__);
$totalAttempts = 0;
$stats = array();
while ($answer = Database::fetch_object($rs)) {
$stats[$answer->answer] = array();
$stats[$answer->answer]['total'] = $answer->nbAttempts;
}
foreach ($stats as $answerId => &$stat) {
$stat['average'] = $stat['total'] / $nbAttemptsInExercise * 100;
}
return $stats;
}*/
}
endif;
?>

@ -59,14 +59,15 @@ abstract class Question
public $exerciseList; // array with the list of exercises which this question is in
public $category;
private $isContent;
public $course;
public $course;
static $typePicture = 'new_question.png';
static $explanationLangVar = '';
static $questionTypes = array(
UNIQUE_ANSWER => array('unique_answer.class.php' , 'UniqueAnswer'),
MULTIPLE_ANSWER => array('multiple_answer.class.php' , 'MultipleAnswer'),
FILL_IN_BLANKS => array('fill_blanks.class.php' , 'FillBlanks'),
MULTIPLE_ANSWER => array('multiple_answer.class.php' , 'MultipleAnswer'),
GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php' , 'GlobalMultipleAnswer'),
FILL_IN_BLANKS => array('fill_blanks.class.php' , 'FillBlanks'),
MATCHING => array('matching.class.php' , 'Matching'),
FREE_ANSWER => array('freeanswer.class.php' , 'FreeAnswer'),
ORAL_EXPRESSION => array('oral_expression.class.php' , 'OralExpression'),
@ -75,7 +76,7 @@ abstract class Question
MULTIPLE_ANSWER_COMBINATION => array('multiple_answer_combination.class.php' , 'MultipleAnswerCombination'),
UNIQUE_ANSWER_NO_OPTION => array('unique_answer_no_option.class.php' , 'UniqueAnswerNoOption'),
MULTIPLE_ANSWER_TRUE_FALSE => array('multiple_answer_true_false.class.php' , 'MultipleAnswerTrueFalse'),
MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE => array('multiple_answer_combination_true_false.class.php' , 'MultipleAnswerCombinationTrueFalse')
MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE => array('multiple_answer_combination_true_false.class.php' , 'MultipleAnswerCombinationTrueFalse')
);
/**
@ -113,29 +114,29 @@ abstract class Question
* @return - boolean - true if question exists, otherwise false
*/
static function read($id, $course_id = null) {
$id = intval($id);
if (!empty($course_id)) {
$id = intval($id);
if (!empty($course_id)) {
$course_info = api_get_course_info_by_id($course_id);
} else {
} else {
$course_info = api_get_course_info();
}
}
$course_id = $course_info['real_id'];
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$sql = "SELECT question,description,ponderation,position,type,picture,level,extra FROM $TBL_QUESTIONS WHERE c_id = $course_id AND id = $id ";
$result = Database::query($sql);
// if the question has been found
if ($object = Database::fetch_object($result)) {
$objQuestion = Question::getInstance($object->type);
if (!empty($objQuestion)) {
$objQuestion->id = $id;
$objQuestion->question = $object->question;
$objQuestion->description = $object->description;
@ -246,12 +247,12 @@ abstract class Question
function selectPicture() {
return $this->picture;
}
function selectPicturePath() {
if (!empty($this->picture)) {
return api_get_path(WEB_COURSE_PATH).$this->course['path'].'/document/images/'.$this->picture;
}
return false;
return false;
}
/**
@ -312,7 +313,7 @@ abstract class Question
function updateCategory($in_category) {
$this->category=$in_category;
}
/**
* @author - Hubert Borderiou 12-10-2011
* @param - interger $in_positive
@ -320,7 +321,7 @@ abstract class Question
function updateScoreAlwaysPositive($in_positive) {
$this->scoreAlwaysPositive=$in_positive;
}
/**
* @author - Hubert Borderiou 12-10-2011
* @param - interger $in_positive
@ -328,7 +329,7 @@ abstract class Question
function updateUncheckedMayScore($in_positive) {
$this->uncheckedMayScore=$in_positive;
}
/**
* @author - Hubert Borderiou 12-10-2011
* @param - interger $in_positive
@ -340,7 +341,7 @@ abstract class Question
$this->deleteCategory();
} else {
// update or add category for a question
$TBL_QUESTION_REL_CATEGORY = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
$category_id = Database::escape_string($in_category);
$question_id = Database::escape_string($this->id);
@ -355,8 +356,8 @@ abstract class Question
$res = Database::query($sql);
}
}
}
}
/**
* @author hubert borderiou 12-10-2011
* delete any category entry for question id
@ -369,7 +370,7 @@ abstract class Question
$sql = "DELETE FROM $TBL_QUESTION_REL_CATEGORY WHERE question_id=$question_id AND c_id=".api_get_course_int_id();
$res = Database::query($sql);
}
/**
* changes the question position
@ -401,7 +402,7 @@ abstract class Question
function updateType($type) {
$TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
$course_id = $this->course['real_id'];
if (empty($course_id)) {
$course_id = api_get_course_int_id();
}
@ -442,8 +443,8 @@ abstract class Question
// if the question has got an ID
if ($this->id) {
$extension = pathinfo($PictureName, PATHINFO_EXTENSION);
$this->picture = 'quiz-'.$this->id.'.jpg';
$extension = pathinfo($PictureName, PATHINFO_EXTENSION);
$this->picture = 'quiz-'.$this->id.'.jpg';
$o_img = new Image($Picture);
$o_img->send_image($picturePath.'/'.$this->picture, -1, 'jpg');
$document_id = add_document($this->course, '/images/'.$this->picture, 'file', filesize($picturePath.'/'.$this->picture),$this->picture);
@ -470,10 +471,10 @@ abstract class Question
if($this->id) {
// Get dimensions from current image.
$my_image = new Image($picturePath.'/'.$this->picture);
$current_image_size = $my_image->get_image_size();
$current_width = $current_image_size['width'];
$current_height = $current_image_size['height'];
$current_height = $current_image_size['height'];
if($current_width < $Max && $current_height <$Max)
return true;
@ -509,10 +510,10 @@ abstract class Question
$new_height = ceil($current_height / $resize_scale);
}
}
$my_image->resize($new_width, $new_height);
$result = $my_image->send_image($picturePath.'/'.$this->picture);
if ($result) {
return true;
} else {
@ -565,7 +566,7 @@ abstract class Question
//If copy was correct then add to the database
if ($result) {
$sql = "UPDATE $TBL_QUESTIONS SET picture='".Database::escape_string($picture)."' WHERE c_id = $course_id AND id='".intval($questionId)."'";
Database::query($sql);
Database::query($sql);
$document_id = add_document($course_info, '/images/'.$picture, 'file', filesize($destination_path.'/'.$picture), $picture);
if ($document_id) {
@ -602,7 +603,7 @@ abstract class Question
public function setTitle($title) {
$this->question = $title;
}
/**
Sets the title
*/
@ -658,8 +659,8 @@ abstract class Question
$extra = $this->extra;
$c_id = $this->course['real_id'];
$category = $this->category;
// question already exists
if(!empty($id)) {
$sql="UPDATE $TBL_QUESTIONS SET
@ -689,8 +690,8 @@ abstract class Question
}
} else {
// creates a new question
$sql = "SELECT max(position) FROM $TBL_QUESTIONS as question, $TBL_EXERCICE_QUESTION as test_question
WHERE question.id = test_question.question_id AND
$sql = "SELECT max(position) FROM $TBL_QUESTIONS as question, $TBL_EXERCICE_QUESTION as test_question
WHERE question.id = test_question.question_id AND
test_question.exercice_id = '".Database::escape_string($exerciseId)."' AND
question.c_id = $c_id AND
test_question.c_id = $c_id ";
@ -698,7 +699,7 @@ abstract class Question
$current_position = Database::result($result,0,0);
$this->updatePosition($current_position+1);
$position = $this->position;
$sql = "INSERT INTO $TBL_QUESTIONS (c_id, question, description, ponderation, position, type, picture, extra, level) VALUES (
$sql = "INSERT INTO $TBL_QUESTIONS (c_id, question, description, ponderation, position, type, picture, extra, level) VALUES (
$c_id,
'".Database::escape_string($question)."',
'".Database::escape_string($description)."',
@ -708,7 +709,7 @@ abstract class Question
'".Database::escape_string($picture)."',
'".Database::escape_string($extra)."',
'".Database::escape_string($level)."'
)";
)";
Database::query($sql);
$this->id = Database::insert_id();
@ -718,18 +719,18 @@ abstract class Question
// If hotspot, create first answer
if ($type == HOT_SPOT || $type == HOT_SPOT_ORDER) {
$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
$sql = "INSERT INTO $TBL_ANSWERS (c_id, id, question_id , answer , correct , comment , ponderation , position , hotspot_coordinates , hotspot_type )
$sql = "INSERT INTO $TBL_ANSWERS (c_id, id, question_id , answer , correct , comment , ponderation , position , hotspot_coordinates , hotspot_type )
VALUES (".$c_id.", '1', '".Database::escape_string($this->id)."', '', NULL , '', '10' , '1', '0;0|0|0', 'square')";
Database::query($sql);
}
if ($type == HOT_SPOT_DELINEATION ) {
$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
$sql="INSERT INTO $TBL_ANSWERS (c_id, id, question_id , answer , correct , comment , ponderation , position , hotspot_coordinates , hotspot_type )
$sql="INSERT INTO $TBL_ANSWERS (c_id, id, question_id , answer , correct , comment , ponderation , position , hotspot_coordinates , hotspot_type )
VALUES (".$c_id.", '1', '".Database::escape_string($this->id)."', '', NULL , '', '10' , '1', '0;0|0|0', 'delineation')";
Database::query($sql);
}
if (api_get_setting('search_enabled')=='true') {
if ($exerciseId != 0) {
$this -> search_engine_edit($exerciseId, TRUE);
@ -873,16 +874,16 @@ abstract class Question
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$id = $this->id;
// checks if the exercise ID is not in the list
if (!in_array($exerciseId,$this->exerciseList)) {
$this->exerciseList[]=$exerciseId;
if (!in_array($exerciseId,$this->exerciseList)) {
$this->exerciseList[]=$exerciseId;
$new_exercise = new Exercise();
$new_exercise->read($exerciseId);
$count = $new_exercise->selectNbrQuestions();
$count++;
$sql="INSERT INTO $TBL_EXERCICE_QUESTION (c_id, question_id, exercice_id, question_order) VALUES
$sql="INSERT INTO $TBL_EXERCICE_QUESTION (c_id, question_id, exercice_id, question_order) VALUES
({$this->course['real_id']}, '".Database::escape_string($id)."','".Database::escape_string($exerciseId)."', '$count' )";
Database::query($sql);
// we do not want to reindex if we had just saved adnd indexed the question
if (!$fromSave) {
$this->search_engine_edit($exerciseId, TRUE);
@ -904,7 +905,7 @@ abstract class Question
// searches the position of the exercise ID in the list
$pos=array_search($exerciseId,$this->exerciseList);
$course_id = api_get_course_int_id();
// exercise not found
@ -919,7 +920,7 @@ abstract class Question
if (Database::num_rows($res)>0) {
$row = Database::fetch_array($res);
if (!empty($row['question_order'])) {
$sql = "UPDATE $TBL_EXERCICE_QUESTION SET question_order = question_order-1
$sql = "UPDATE $TBL_EXERCICE_QUESTION SET question_order = question_order-1
WHERE c_id = $course_id AND exercice_id='".Database::escape_string($exerciseId)."' AND question_order > ".$row['question_order'];
$res = Database::query($sql);
}
@ -940,14 +941,14 @@ abstract class Question
* @author - Olivier Brouckaert
* @param - integer $deleteFromEx - exercise ID if the question is only removed from one exercise
*/
function delete($deleteFromEx=0) {
function delete($deleteFromEx=0) {
$course_id = api_get_course_int_id();
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
$TBL_QUIZ_QUESTION_REL_CATEGORY = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
$id=$this->id;
// if the question must be removed from all exercises
@ -975,14 +976,14 @@ abstract class Question
// remove the category of this question in the question_rel_category table
$sql = "DELETE FROM $TBL_QUIZ_QUESTION_REL_CATEGORY WHERE c_id = $course_id AND question_id='".Database::escape_string($id)."' AND c_id=".api_get_course_int_id();
Database::query($sql);
api_item_property_update($this->course, TOOL_QUIZ, $id,'QuizQuestionDeleted',api_get_user_id());
$this->removePicture();
// resets the object
$this->Question();
} else {
// just removes the exercise from the list
// just removes the exercise from the list
$this->removeFromList($deleteFromEx);
if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) {
// disassociate question with this exercise
@ -999,8 +1000,8 @@ abstract class Question
* @param array Course info of the destination course
* @return int ID of the new question
*/
function duplicate($course_info = null) {
function duplicate($course_info = null) {
if (empty($course_info)) {
$course_info = $this->course;
} else {
@ -1016,35 +1017,35 @@ abstract class Question
$type = $this->type;
$level = intval($this->level);
$extra = $this->extra;
//Using the same method used in the course copy to transform URLs
require_once api_get_path(LIBRARY_PATH).'document.lib.php';
if ($course_info['db_name'] != $this->course['db_name']) {
$description = DocumentManager::replace_urls_inside_content_html_from_copy_course($description, $this->course['id'], $course_info['id']);
$question = DocumentManager::replace_urls_inside_content_html_from_copy_course($question, $this->course['id'], $course_info['id']);
}
$course_id = $course_info['real_id'];
$options = self::readQuestionOption($this->id, $course_id);
$options = self::readQuestionOption($this->id, $course_id);
//Inserting in the new course db / or the same course db
$sql = "INSERT INTO $TBL_QUESTIONS (c_id, question, description, ponderation, position, type, level, extra )
$sql = "INSERT INTO $TBL_QUESTIONS (c_id, question, description, ponderation, position, type, level, extra )
VALUES('$course_id', '".Database::escape_string($question)."','".Database::escape_string($description)."','".Database::escape_string($weighting)."','".Database::escape_string($position)."','".Database::escape_string($type)."' ,'".Database::escape_string($level)."' ,'".Database::escape_string($extra)."' )";
Database::query($sql);
$new_question_id = Database::insert_id();
Database::query($sql);
$new_question_id = Database::insert_id();
if (!empty($options)) {
//Saving the quiz_options
//Saving the quiz_options
foreach ($options as $item) {
$item['question_id'] = $new_question_id;
$item['c_id'] = $course_id;
unset($item['id']);
Database::insert($TBL_QUESTION_OPTIONS, $item);
unset($item['id']);
Database::insert($TBL_QUESTION_OPTIONS, $item);
}
}
// Duplicates the picture of the hotspot
$this->exportPicture($new_question_id, $course_info);
return $new_question_id;
@ -1058,15 +1059,15 @@ abstract class Question
function get_question_type($type) {
if ($type == ORAL_EXPRESSION && api_get_setting('enable_nanogong') != 'true') {
return null;
}
}
return self::$questionTypes[$type];
}
function get_question_type_list() {
if (api_get_setting('enable_nanogong') != 'true') {
self::$questionTypes[ORAL_EXPRESSION] = null;
unset(self::$questionTypes[ORAL_EXPRESSION]);
}
}
return self::$questionTypes;
}
@ -1076,14 +1077,14 @@ abstract class Question
* @return an instance of a Question subclass (or of Questionc class by default)
*/
static function getInstance($type) {
if (!is_null($type)) {
if (!is_null($type)) {
list($file_name, $class_name) = self::get_question_type($type);
if (!empty($file_name)) {
include_once $file_name;
if (class_exists($class_name)) {
return new $class_name();
} else {
echo 'Can\'t instanciate class '.$class_name.' of type '.$type;
echo 'Can\'t instanciate class '.$class_name.' of type '.$type;
}
}
}
@ -1096,7 +1097,7 @@ abstract class Question
* @param FormValidator $form the formvalidator instance (by reference)
*/
function createForm (&$form, $fck_config=0) {
echo ' <style>
echo ' <style>
.media { display:none;}
</style>';
echo '<script>
@ -1126,7 +1127,7 @@ abstract class Question
document.getElementById(\'media_icon\').innerHTML=\'&nbsp;<img style="vertical-align: middle;" src="../img/looknfeel.png" alt="" />&nbsp;'.get_lang('EnrichQuestion').'\';
}
}
// hub 13-12-2010
function visiblerDevisibler(in_id) {
if (document.getElementById(in_id)) {
@ -1143,11 +1144,11 @@ abstract class Question
}
}
}
}
}
</script>';
// question name
$form->addElement('text', 'questionName', get_lang('Question'), array('class' => 'span6'));
$form->addElement('text', 'questionName', get_lang('Question'), array('class' => 'span6'));
$form->addRule('questionName', get_lang('GiveQuestion'), 'required');
// default content
@ -1165,7 +1166,7 @@ abstract class Question
if(!api_is_allowed_to_edit(null,true)) $editor_config['UserStatus'] = 'student';
$form->addElement('advanced_settings','
<a href="javascript://" onclick=" return show_media()"><span id="media_icon"><img style="vertical-align: middle;" src="../img/looknfeel.png" alt="" />&nbsp;'.get_lang('EnrichQuestion').'</span></a>
<a href="javascript://" onclick=" return show_media()"><span id="media_icon"><img style="vertical-align: middle;" src="../img/looknfeel.png" alt="" />&nbsp;'.get_lang('EnrichQuestion').'</span></a>
');
$form -> addElement ('html','<div class="HideFCKEditor" id="HiddenFCKquestionDescription" >');
@ -1174,22 +1175,22 @@ abstract class Question
// Advanced parameters
$form->addElement('advanced_settings','<a href="javascript:void(0)" onclick="visiblerDevisibler(\'id_advancedOption\')"><img id="id_advancedOptionImg" style="vertical-align:middle;" src="../img/div_show.gif" alt="" />&nbsp;'.get_lang("AdvancedParameters").'</a>');
$select_level = array (1=>1,2=>2,3=>3,4=>4,5=>5);
$select_level = array (1=>1,2=>2,3=>3,4=>4,5=>5);
$form->addElement('html','<div id="id_advancedOption" style="display:none;">');
$form->addElement('select', 'questionLevel',get_lang('Difficulty'), $select_level);
// categories
$tabCat = array();
$tabCat = Testcategory::getCategoriesIdAndName();
$tabCat = Testcategory::getCategoriesIdAndName();
$form->addElement('select', 'questionCategory', get_lang('Category'), $tabCat);
// hidden values
$form->addElement('hidden','myid',$_REQUEST['myid']);
if (!isset($_GET['fromExercise'])) {
if (!isset($_GET['fromExercise'])) {
switch($answerType) {
case 1: $this->question = get_lang('langDefaultUniqueQuestion'); break;
case 2: $this->question = get_lang('langDefaultMultipleQuestion'); break;
@ -1199,19 +1200,19 @@ abstract class Question
case 9: $this->question = get_lang('langDefaultMultipleQuestion'); break;
}
}
$form->addElement('html','</div>');
// default values
$defaults = array();
$defaults = array();
$defaults['questionName'] = $this -> question;
$defaults['questionDescription'] = $this -> description;
$defaults['questionLevel'] = $this -> level;
$defaults['questionCategory'] = $this->category;
//Came from he question pool
if (isset($_GET['fromExercise'])) {
$form->setDefaults($defaults);
//Came from he question pool
if (isset($_GET['fromExercise'])) {
$form->setDefaults($defaults);
}
if (!empty($_REQUEST['myid'])) {
@ -1220,9 +1221,9 @@ abstract class Question
if ($isContent == 1) {
$form->setDefaults($defaults);
}
}
}
}
/**
* function which process the creation of questions
@ -1259,7 +1260,7 @@ abstract class Question
static function display_type_menu ($feedback_type = 0) {
global $exerciseId;
$course_id = api_get_course_int_id();
// 1. by default we show all the question types
$question_type_custom_list = self::get_question_type_list();
@ -1267,7 +1268,7 @@ abstract class Question
if ($feedback_type==1) {
//2. but if it is a feedback DIRECT we only show the UNIQUE_ANSWER type that is currently available
//$question_type_custom_list = array ( UNIQUE_ANSWER => self::$questionTypes[UNIQUE_ANSWER]);
$question_type_custom_list = array ( UNIQUE_ANSWER => self::$questionTypes[UNIQUE_ANSWER],HOT_SPOT_DELINEATION => self::$questionTypes[HOT_SPOT_DELINEATION]);
$question_type_custom_list = array ( UNIQUE_ANSWER => self::$questionTypes[UNIQUE_ANSWER],HOT_SPOT_DELINEATION => self::$questionTypes[HOT_SPOT_DELINEATION]);
} else {
unset($question_type_custom_list[HOT_SPOT_DELINEATION]);
}
@ -1322,48 +1323,48 @@ abstract class Question
echo Display::return_icon('database.png', get_lang('GetExistingQuestion'), '');
} else {
echo Display::return_icon('database_na.png', get_lang('GetExistingQuestion'), '');
}
}
echo '</a>';
echo '</div></li>';
echo '</ul>';
}
static function saveQuestionOption($question_id, $name, $course_id, $position = 0) {
$TBL_EXERCICE_QUESTION_OPTION = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
$TBL_EXERCICE_QUESTION_OPTION = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
$params['question_id'] = intval($question_id);
$params['name'] = $name;
$params['name'] = $name;
$params['position'] = $position;
$params['c_id'] = $course_id;
$params['c_id'] = $course_id;
$result = self::readQuestionOption($question_id, $course_id);
$last_id = Database::insert($TBL_EXERCICE_QUESTION_OPTION, $params);
return $last_id;
return $last_id;
}
static function deleteAllQuestionOptions($question_id, $course_id) {
$TBL_EXERCICE_QUESTION_OPTION = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
Database::delete($TBL_EXERCICE_QUESTION_OPTION, array('c_id = ? AND question_id = ?'=> array($course_id, $question_id)));
}
static function updateQuestionOption($id, $params, $course_id) {
$TBL_EXERCICE_QUESTION_OPTION = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
$result = Database::update($TBL_EXERCICE_QUESTION_OPTION, $params, array('c_id = ? AND id = ?'=>array($course_id, $id)));
return $result;
$result = Database::update($TBL_EXERCICE_QUESTION_OPTION, $params, array('c_id = ? AND id = ?'=>array($course_id, $id)));
return $result;
}
static function readQuestionOption($question_id, $course_id) {
$TBL_EXERCICE_QUESTION_OPTION = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
$TBL_EXERCICE_QUESTION_OPTION = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
$result = Database::select('*', $TBL_EXERCICE_QUESTION_OPTION, array('where'=>array('c_id = ? AND question_id = ?' =>array($course_id, $question_id)), 'order'=>'id ASC'));
return $result;
return $result;
}
function return_header($feedback_type = null, $counter = null) {
$counter_label = '';
if (!empty($counter)) {
$counter_label = 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'));
echo Display::div($this->description, array('id'=>'question_description'));
}
/**
* Create a question from a set of parameters
@ -1375,7 +1376,7 @@ abstract class Question
*/
function create_question ($quiz_id, $question_name, $max_score = 0, $type = 1, $level = 1) {
$course_id = api_get_course_int_id();
$tbl_quiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
$tbl_quiz_rel_question = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
@ -1392,7 +1393,7 @@ abstract class Question
$rs_max = Database::query($sql, __FILE__, __LINE__);
$row_max = Database::fetch_object($rs_max);
$max_position = $row_max->max_position +1;
// Insert the new question
$sql = "INSERT INTO $tbl_quiz_question (c_id, question, ponderation, position, type, level)
VALUES ($course_id, '".Database::escape_string($question_name)."', '$max_score', $max_position, $type, $level)";
@ -1413,15 +1414,15 @@ abstract class Question
$rs = Database::query($sql);
return $question_id;
}
/**
* return the image filename of the question type
*
*/
public function get_type_icon_html() {
$type = $this->selectType();
$type = $this->selectType();
$tabQuestionList = Question::get_question_type_list(); // [0]=file to include [1]=type name
require_once $tabQuestionList[$type][0];
eval('$img = '.$tabQuestionList[$type][1].'::$typePicture;');
eval('$explanation = get_lang('.$tabQuestionList[$type][1].'::$explanationLangVar);');

@ -126,6 +126,7 @@ $pictures_question_types[10] = 'mcuao.gif';
$pictures_question_types[11] = 'mcmao.gif';
$pictures_question_types[12] = 'mcmaco.gif';
$pictures_question_types[13] = 'audio_question.png';
$pictures_question_types[14] = 'mcmagl.gif'; //Ajout
$question_list = Question::get_question_type_list();
foreach ($question_list as $key=>$value) {

@ -1,10 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Shows the exercise results
* Shows the exercise results
*
* @author Julio Montoya Armas - Simple exercise result page
*
*
*/
/**
@ -26,7 +26,7 @@ if (empty($origin)) {
}
if ($origin == 'learnpath')
api_protect_course_script();
api_protect_course_script();
else
api_protect_course_script(true);
@ -54,7 +54,7 @@ $exercise_id = $track_exercise_info['id'];
$exercise_date = $track_exercise_info['start_date'];
$student_id = $track_exercise_info['exe_user_id'];
$learnpath_id = $track_exercise_info['orig_lp_id'];
$learnpath_item_id = $track_exercise_info['orig_lp_item_id'];
$learnpath_item_id = $track_exercise_info['orig_lp_item_id'];
$lp_item_view_id = $track_exercise_info['orig_lp_item_view_id'];
$course_code = api_get_course_id();
$current_user_id = api_get_user_id();
@ -64,7 +64,7 @@ if (empty($objExercise)) {
$objExercise->read($exercise_id);
}
//Only users can see their own results
//Only users can see their own results
if (!$is_allowedToEdit) {
if ($student_id != $current_user_id) {
api_not_allowed();
@ -75,11 +75,11 @@ if ($show_headers) {
$interbreadcrumb[] = array("url" => "exercice.php","name" => get_lang('Exercices'));
$interbreadcrumb[] = array("url" => "#","name" => get_lang('Result'));
$this_section = SECTION_COURSES;
Display::display_header();
} else {
Display::display_reduced_header();
}
}
$show_results = true;
$show_only_total_score = false;
@ -92,15 +92,15 @@ if (!empty($track_exercise_info)) {
// if the results_disabled of the Quiz is 1 when block the script
$result_disabled = $track_exercise_info['results_disabled'];
$display_category_name = $track_exercise_info['display_category_name'];
if (!(api_is_platform_admin() || api_is_course_admin()) ) {
if (!(api_is_platform_admin() || api_is_course_admin()) ) {
if ($result_disabled == EXERCISE_FEEDBACK_TYPE_DIRECT) {
$show_results = false;
$show_results = false;
Display::display_warning_message(get_lang('CantViewResults'));
} elseif ($result_disabled == EXERCISE_FEEDBACK_TYPE_EXAM) {
$show_results = false;
$show_only_total_score = true;
}
$show_only_total_score = true;
}
}
}
@ -123,68 +123,72 @@ if (!empty($question_list)) {
foreach ($question_list as $question_item) {
$objQuestionTmp = Question::read($question_item['question_id'], api_get_course_int_id());
$total_weighting += $objQuestionTmp->selectWeighting();
$total_weighting += $objQuestionTmp->selectWeighting();
}
foreach ($question_list as $question_item) {
foreach ($question_list as $question_item) {
$choice = $question_item['answer'];
// creates a temporary Question object
$questionId = $question_item['question_id'];
$objQuestionTmp = Question::read($questionId, api_get_course_int_id());
$objQuestionTmp = Question::read($questionId, api_get_course_int_id());
$questionName = $objQuestionTmp->selectTitle();
$questionDescription= $objQuestionTmp->selectDescription();
$questionWeighting = $objQuestionTmp->selectWeighting();
$answerType = $objQuestionTmp->selectType();
$quesId = $objQuestionTmp->selectId();
if ($show_results) {
$quesId = $objQuestionTmp->selectId();
if ($show_results) {
// display question category, if any
Testcategory::displayCategoryAndTitle($questionId, $display_category_name );
Testcategory::displayCategoryAndTitle($questionId, $display_category_name );
echo $objQuestionTmp->return_header($objExercise->feedback_type, $counter);
}
$counter++;
$counter++;
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());
$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 == GLOBAL_MULTIPLE_ANSWER) {
$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());
$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) {
$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'];
} 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'];
$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());
$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());
} 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'];
$totalScore += $question_result['score'];
} elseif ($answerType == HOT_SPOT) {
//@todo move this in the manage_answer function
//@todo move this in the manage_answer function
if ($show_results) {
echo '<table width="500" border="0"><tr>
<td valign="top" align="center" style="padding-left:0px;" >
<table border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;" width="552">';
}
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
}
$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 '</table></td></tr>';
if ($show_results) {
echo '</table></td></tr>';
echo '<tr>
<td colspan="2">'.
'<object type="application/x-shockwave-flash" data="'.api_get_path(WEB_CODE_PATH).'plugin/hotspot/hotspot_solution.swf?modifyAnswers='.Security::remove_XSS($questionId).'&exe_id='.$id.'&from_db=1" width="552" height="352">
@ -194,35 +198,35 @@ if (!empty($question_list)) {
</tr>
</table><br/>';
}
} else if($answerType == HOT_SPOT_DELINEATION) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg(), 'database');
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
$final_overlap = $question_result['extra']['final_overlap'];
$final_missing = $question_result['extra']['final_missing'];
$final_excess = $question_result['extra']['final_excess'];
$overlap_color = $question_result['extra']['overlap_color'];
$missing_color = $question_result['extra']['missing_color'];
$excess_color = $question_result['extra']['excess_color'];
$threadhold1 = $question_result['extra']['threadhold1'];
$threadhold1 = $question_result['extra']['threadhold1'];
$threadhold2 = $question_result['extra']['threadhold2'];
$threadhold3 = $question_result['extra']['threadhold3'];
if ($show_results) {
if ($overlap_color) {
$overlap_color='green';
} else {
$overlap_color='red';
}
if ($missing_color) {
$missing_color='green';
} else {
@ -233,48 +237,48 @@ if (!empty($question_list)) {
} else {
$excess_color='red';
}
if (!is_numeric($final_overlap)) {
$final_overlap = 0;
}
if (!is_numeric($final_missing)) {
$final_missing = 0;
}
if (!is_numeric($final_excess)) {
$final_excess = 0;
}
if ($final_excess>100) {
$final_excess = 100;
}
$table_resume='<table class="data_table">
}
$table_resume='<table class="data_table">
<tr class="row_odd" >
<td></td>
<td ><b>'.get_lang('Requirements').'</b></td>
<td><b>'.get_lang('YourAnswer').'</b></td>
</tr>
<tr class="row_even">
<td><b>'.get_lang('Overlap').'</b></td>
<td>'.get_lang('Min').' '.$threadhold1.'</td>
<td><div style="color:'.$overlap_color.'">'.(($final_overlap < 0)?0:intval($final_overlap)).'</div></td>
</tr>
<tr>
<td><b>'.get_lang('Excess').'</b></td>
<td>'.get_lang('Max').' '.$threadhold2.'</td>
<td><div style="color:'.$excess_color.'">'.(($final_excess < 0)?0:intval($final_excess)).'</div></td>
</tr>
<tr class="row_even">
<td><b>'.get_lang('Missing').'</b></td>
<td>'.get_lang('Max').' '.$threadhold3.'</td>
<td><div style="color:'.$missing_color.'">'.(($final_missing < 0)?0:intval($final_missing)).'</div></td>
</tr></table>';
if ($answerType!= HOT_SPOT_DELINEATION) {
$item_list=explode('@@',$destination);
//print_R($item_list);
@ -292,69 +296,69 @@ if (!empty($question_list)) {
} else {
//show if no error
//echo 'no error';
$comment=$answerComment=$objAnswerTmp->selectComment($nbrAnswers);
$comment=$answerComment=$objAnswerTmp->selectComment($nbrAnswers);
$answerDestination=$objAnswerTmp->selectDestination($nbrAnswers);
}
}
}
echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
if ($answerType == HOT_SPOT_DELINEATION) {
if ($answerType == HOT_SPOT_DELINEATION) {
if ($organs_at_risk_hit>0) {
$message='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
$message='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
$message.='<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
} else {
$message='<p>'.get_lang('YourDelineation').'</p>';
$message.=$table_resume;
$message.=$table_resume;
$message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
}
$message.='<p>'.$comment.'</p>';
echo $message;
$message.='<p>'.$comment.'</p>';
echo $message;
} else {
echo '<p>'.$comment.'</p>';
}
//showing the score
//showing the score
/*
$queryfree = "select marks from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
$resfree = Database::query($queryfree);
$questionScore= Database::result($resfree,0,"marks");
$totalScore+=$questionScore;*/
$questionScore= Database::result($resfree,0,"marks");
$totalScore+=$questionScore;*/
?>
</table>
</td></tr>
<?php
<?php
echo '<tr>
<td colspan="2">
<object type="application/x-shockwave-flash" data="../plugin/hotspot/hotspot_solution.swf?modifyAnswers='.$questionId.'&exe_id='.$id.'&from_db=1" width="556" height="350">
<param name="movie" value="../plugin/hotspot/hotspot_solution.swf?modifyAnswers='.$questionId.'&exe_id='.$id.'&from_db=1" />
</object>
</td>
</tr>
</table>';
}
}
}
if ($show_results) {
if ($answerType != HOT_SPOT) {
echo '</table>';
}
}
}
if ($show_results) {
$comnt = get_comments($id, $questionId);
$comnt = get_comments($id, $questionId);
if (!empty($comnt)) {
echo '<b>'.get_lang('Feedback').'</b>';
echo '<div id="question_feedback">'.$comnt.'</div>';
}
}
}
}
$my_total_score = $questionScore;
$my_total_weight = $questionWeighting;
$my_total_weight = $questionWeighting;
if ($objExercise->selectPropagateNeg() == 0 && $my_total_score < 0) {
$my_total_score = 0;
}
}
if ($show_results) {
echo '<div id="question_score">';
echo get_lang('Score')." : ".show_score($my_total_score, $my_total_weight, false, false);
@ -364,21 +368,21 @@ if (!empty($question_list)) {
unset($objQuestionTmp);
$i++;
$totalWeighting += $questionWeighting;
} // end of large foreach on questions
}
//Total score
if ($show_results || $show_only_total_score) {
if ($show_results || $show_only_total_score) {
echo '<div id="question_score">'.get_lang('YourTotalScore').": ";
$my_total_score_temp = $totalScore;
$my_total_score_temp = $totalScore;
if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) {
$my_total_score_temp = 0;
}
echo show_score($my_total_score_temp, $totalWeighting, false, true, true, $objExercise->selectPassPercentage());
}
echo show_score($my_total_score_temp, $totalWeighting, false, true, true, $objExercise->selectPassPercentage());
echo '</div>';
}
if ($show_headers) {
Display::display_footer();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Loading…
Cancel
Save