Exercise report: ordering question depending in the media see #5714

skala
Julio Montoya 13 years ago
parent 0a8def7494
commit dcbbbcf7af
  1. 15
      main/exercice/exercise.lib.php
  2. 42
      main/exercice/exercise_show.php
  3. 16
      main/exercice/exercise_submit.php
  4. 4
      main/exercice/fill_blanks.class.php
  5. 4
      main/exercice/freeanswer.class.php
  6. 4
      main/exercice/global_multiple_answer.class.php
  7. 7
      main/exercice/matching.class.php
  8. 6
      main/exercice/multiple_answer.class.php
  9. 4
      main/exercice/multiple_answer_combination.class.php
  10. 4
      main/exercice/multiple_answer_true_false.class.php
  11. 4
      main/exercice/oral_expression.class.php
  12. 24
      main/exercice/question.class.php
  13. 4
      main/exercice/unique_answer.class.php
  14. 4
      main/exercice/unique_answer_no_option.class.php

@ -2078,7 +2078,8 @@ function display_question_list_by_attempt($objExercise, $exe_id, $save_user_resu
$user_info = api_get_user_info($exercise_stat_info['exe_user_id']);
//Shows exercise header
$objExercise->description = '';
echo $objExercise->show_exercise_result_header(api_get_person_name($user_info['firstName'], $user_info['lastName']), api_convert_and_format_date($exercise_date, DATE_TIME_FORMAT_LONG));
//var_dump($exercise_stat_info);
echo $objExercise->show_exercise_result_header($user_info['complete_name'], api_convert_and_format_date($exercise_stat_info['exe_date'], DATE_TIME_FORMAT_LONG));
}
if ($save_user_result) {
@ -2093,6 +2094,7 @@ function display_question_list_by_attempt($objExercise, $exe_id, $save_user_resu
}
$question_list_answers = array();
$media_list = array();
// Loop over all question to show results for each of them, one by one
if (!empty($question_list)) {
@ -2144,9 +2146,16 @@ function display_question_list_by_attempt($objExercise, $exe_id, $save_user_resu
$question_content = '<div class="question_row">';
if ($show_results) {
if ($show_results) {
$show_media = false;
if ($objQuestionTmp->parent_id != 0 && !in_array($objQuestionTmp->parent_id, $media_list)) {
$show_media = true;
$media_list[] = $objQuestionTmp->parent_id;
}
//Shows question title an description
$question_content .= $objQuestionTmp->return_header(null, $counter, $score);
$question_content .= $objQuestionTmp->return_header(null, $counter, $score, $show_media);
// display question category, if any
$question_content .= Testcategory::getCategoryNamesForQuestion($questionId);

@ -241,25 +241,19 @@ $query = "SELECT attempts.question_id, answer FROM ".$TBL_TRACK_ATTEMPT." as att
GROUP BY quizz_rel_questions.question_order, attempts.question_id";
//GROUP BY questions.position, attempts.question_id";
$result = Database::query($query);
$questionList = array();
$result = Database::query($query);
$exerciseResult = array();
while ($row = Database::fetch_array($result)) {
$questionList[] = $row['question_id'];
while ($row = Database::fetch_array($result)) {
$exerciseResult[$row['question_id']] = $row['answer'];
}
//Fixing #2073 Fixing order of questions
if (!empty($track_exercise_info['data_tracking']) && !empty($track_exercise_info['random']) ) {
$temp_question_list = explode(',',$track_exercise_info['data_tracking']);
if (is_array($temp_question_list) && count($temp_question_list) == count($questionList)) {
$questionList = $temp_question_list;
}
}
// always getting question list from the DB
$questionList = explode(',',$track_exercise_info['data_tracking']);
// Display the text when finished message if we are on a LP #4227
$end_of_message = $objExercise->selectTextWhenFinished();
if (!empty($end_of_message) && ($origin == 'learnpath')) {
Display::display_normal_message($end_of_message, false);
echo "<div class='clear'>&nbsp;</div>";
@ -269,30 +263,34 @@ 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;
$exercise_content = null;
$media_list = array();
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();
// Start buffer
ob_start();
/* Use switch
switch ($answerType) {
}*/
}*/
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'];
@ -370,7 +368,6 @@ foreach ($questionList as $questionId) {
$threadhold3 = $question_result['extra']['threadhold3'];
if ($show_results) {
if ($overlap_color) {
$overlap_color='green';
} else {
@ -597,9 +594,15 @@ foreach ($questionList as $questionId) {
$question_content = '<div class="question_row">';
$show_media = false;
if ($objQuestionTmp->parent_id != 0 && !in_array($objQuestionTmp->parent_id, $media_list)) {
$show_media = true;
$media_list[] = $objQuestionTmp->parent_id;
}
if ($show_results) {
//Shows question title an description
$question_content .= $objQuestionTmp->return_header(null, $counter, $score);
$question_content .= $objQuestionTmp->return_header(null, $counter, $score, $show_media);
// display question category, if any
$question_content .= Testcategory::getCategoryNamesForQuestion($questionId);
@ -646,8 +649,7 @@ if (is_array($arrid) && is_array($arrmarks)) {
if ($is_allowedToEdit && $locked == false && !api_is_drh()) {
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 '<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="lp_item_id" value="'.$learnpath_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.'">';

@ -463,7 +463,7 @@ if ($formSent && isset($_POST)) {
}
}
}
header("Location: exercise_result.php?exe_id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
header("Location: exercise_result.php?".api_get_cidreq()."&exe_id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
exit;
} else {
//Time control is only enabled for ONE PER PAGE
@ -486,12 +486,12 @@ if ($formSent && isset($_POST)) {
}
if ($debug) { error_log('10. Redirecting to exercise_show.php'); }
//header("Location: exercise_show.php?id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
header("Location: exercise_result.php?exe_id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
header("Location: exercise_result.php?".api_get_cidreq()."&exe_id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
exit;
}
} else {
if ($debug) { error_log('10. Redirecting to exercise_submit.php'); }
header("Location: exercise_submit.php?exerciseId=$exerciseId&origin=$origin");
header("Location: exercise_submit.php?".api_get_cidreq()."&exerciseId=$exerciseId&origin=$origin");
exit;
}
}
@ -519,7 +519,6 @@ if ($question_count != 0) {
//We check if the user attempts before sending to the exercise_result.php
if ($objExercise->selectAttempts() > 0) {
$attempt_count = get_attempt_count(api_get_user_id(), $exerciseId, $learnpath_id, $learnpath_item_id, $learnpath_item_view_id);
if ($attempt_count >= $objExercise->selectAttempts()) {
Display :: display_warning_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), false);
@ -551,7 +550,7 @@ if ($question_count != 0) {
header('Location: exercise_reminder.php?'.$params);
exit;
} else {
header("Location: exercise_result.php?exe_id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
header("Location: exercise_result.php?".api_get_cidreq()."&exe_id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
}
}
} else {
@ -601,7 +600,6 @@ if (api_is_course_admin() && $origin != 'learnpath') {
//echo '<a href="exercice.php?show=test&id_session='.api_get_session_id().'">' . Display :: return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>';
if ($show_quiz_edition == false) {
echo '<a href="exercise_admin.php?' . api_get_cidreq() . '&modifyExercise=yes&exerciseId=' . $objExercise->id . '">'.Display :: return_icon('settings.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
//echo Display :: return_icon('wizard.gif', get_lang('QuestionList')) . '<a href="exercice/admin.php?' . api_get_cidreq() . '&exerciseId=' . $objExercise->id . '">' . get_lang('QuestionList') . '</a>';
} else {
echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
}
@ -773,7 +771,6 @@ if (!empty($error)) {
}
echo '<script>
$(function() {
//$(".exercise_save_now_button").hide();
$(".main_question").mouseover(function() {
@ -992,9 +989,8 @@ function render_question_list($objExercise, $questionList, $current_question, $e
$counter = 1;
if ($objQuestionTmp->type == MEDIA_QUESTION) {
echo Display::page_subheader($objQuestionTmp->selectTitle());
echo $objQuestionTmp->selectDescription();
echo $objQuestionTmp->show_media_content();
$count_of_questions_inside_media = count($media_question_list);
//var_dump($media_question_list);
//Show questions that belongs to a media

@ -191,8 +191,8 @@ class FillBlanks extends Question
$objAnswer->save();
}
function return_header($feedback_type = null, $counter = null, $score = null) {
$header = parent::return_header($feedback_type, $counter, $score);
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false) {
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header .= '<table class="'.$this->question_table_class .'">
<tr>
<th>'.get_lang("Answer").'</th>

@ -58,13 +58,13 @@ if (!class_exists('FreeAnswer')):
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null) {
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false) {
if (!empty($score['comments']) || $score['score'] > 0) {
$score['revised'] = true;
} else {
$score['revised'] = false;
}
$header = parent::return_header($feedback_type, $counter, $score);
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header .= '<table class="' . $this->question_table_class . '" >
<tr>
<th>' . get_lang("Answer") . '</th>

@ -236,8 +236,8 @@ if (!class_exists('GlobalMultipleAnswer')):
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null) {
$header = parent::return_header($feedback_type, $counter, $score);
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false) {
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header .= '<table class="'.$this->question_table_class .'">
<tr>
<th>' . get_lang("Choice") . '</th>

@ -232,8 +232,8 @@ class Matching extends Question {
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null) {
$header = parent::return_header($feedback_type, $counter, $score);
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false) {
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header .= '<table class="'.$this->question_table_class .'">';
$header .= '<tr>
<th>'.get_lang('ElementList').'</th>
@ -242,5 +242,4 @@ class Matching extends Question {
return $header;
}
}
endif;
?>
endif;

@ -206,8 +206,8 @@ class MultipleAnswer extends Question {
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null) {
$header = parent::return_header($feedback_type, $counter, $score);
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false) {
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header .= '<table class="'.$this->question_table_class .'">
<tr>
<th>'.get_lang("Choice").'</th>
@ -222,4 +222,4 @@ class MultipleAnswer extends Question {
return $header;
}
}
endif;
endif;

@ -211,8 +211,8 @@ class MultipleAnswerCombination extends Question {
$this -> save();
}
function return_header($feedback_type = null, $counter = null, $score = null) {
$header = parent::return_header($feedback_type, $counter, $score);
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false) {
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header .= '<table class="'.$this->question_table_class .'">
<tr>
<th>'.get_lang("Choice").'</th>

@ -283,8 +283,8 @@ class MultipleAnswerTrueFalse extends Question {
$this -> save();
}
function return_header($feedback_type = null, $counter = null, $score = null) {
$header = parent::return_header($feedback_type, $counter, $score);
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false) {
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header .= '<table class="'.$this->question_table_class .'">
<tr>
<th>'.get_lang("Choice").'</th>

@ -56,8 +56,8 @@ class OralExpression extends Question {
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null) {
$header = parent::return_header($feedback_type, $counter, $score);
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false) {
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header .= '<table class="'.$this->question_table_class.'">
<tr>
<th>&nbsp;</th>

@ -1426,7 +1426,7 @@ abstract class Question
$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;
}
}
static function readQuestionOption($question_id, $course_id) {
$TBL_EXERCICE_QUESTION_OPTION = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
@ -1441,8 +1441,7 @@ abstract class Question
* @param type $counter
* @param type $score
*/
function return_header($feedback_type = null, $counter = null, $score = null) {
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false) {
$counter_label = '';
if (!empty($counter)) {
$counter_label = intval($counter);
@ -1461,12 +1460,15 @@ abstract class Question
} else {
$score_label = get_lang('NotRevised');
$class = 'error';
}
}
}
$question_title = $this->question;
$header = Display::div('<div class="rib rib-'.$class.'"><h3>'.$score_label.'</h3></div> <h4>'.get_lang("Question").' '.($counter_label).' </h4><h5 class="'.$class.'">'.$score['result'].' </h5>', array('class'=>'ribbon'));
$header .= '<div class="page-header"><h4>'.$question_title.'</h4></div>';
if ($show_media) {
$header .= $this->show_media_content();
}
$header .= Display::page_subheader3($question_title);
$header .= Display::div($this->description, array('id'=>'question_description'));
return $header;
}
@ -1589,5 +1591,17 @@ abstract class Question
);
return $select_level;
}
function show_media_content() {
$html = null;
if ($this->parent_id != 0) {
$parent_question = Question::read($this->parent_id);
$html = $parent_question->show_media_content();
} else {
$html .= Display::page_subheader($this->selectTitle());
$html .= $this->selectDescription();
}
return $html;
}
}
endif;

@ -350,8 +350,8 @@ class UniqueAnswer extends Question {
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null) {
$header = parent::return_header($feedback_type, $counter, $score);
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false) {
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header .= '<table class="'.$this->question_table_class .'">
<tr>
<th>'.get_lang("Choice").'</th>

@ -399,8 +399,8 @@ class UniqueAnswerNoOption extends Question {
$this -> save();
}
function return_header($feedback_type = null, $counter = null, $score = null) {
$header = parent::return_header($feedback_type, $counter, $score);
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false) {
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header .= '<table class="'.$this->question_table_class .'">
<tr>
<th>'.get_lang("Choice").'</th>

Loading…
Cancel
Save