0) { error_log('Entered exercise_result.php: '.print_r($_POST,1)); }
if ( empty ( $formSent ) ) { $formSent = $_REQUEST['formSent']; }
if ( empty ( $exerciseResult ) ) { $exerciseResult = $_SESSION['exerciseResult'];}
if ( empty ( $questionId ) ) { $questionId = $_REQUEST['questionId'];}
if ( empty ( $choice ) ) { $choice = $_REQUEST['choice'];}
if ( empty ( $questionNum ) ) { $questionNum = $_REQUEST['questionNum'];}
if ( empty ( $nbrQuestions ) ) { $nbrQuestions = $_REQUEST['nbrQuestions'];}
if ( empty ( $questionList ) ) { $questionList = $_SESSION['questionList'];}
if ( empty ( $objExercise ) ) { $objExercise = $_SESSION['objExercise'];}
if ( empty ( $exeId ) ) { $exeId = $_REQUEST['id'];}
if ( empty ( $action ) ) { $action = $_REQUEST['action']; }
//$emailId = $_REQUEST['email'];
$id = intval($_REQUEST['id']); //exe id
$current_time = time();
if (empty($id)) {
api_not_allowed();
}
$is_allowedToEdit = api_is_allowed_to_edit(null,true) || $is_courseTutor;
//Getting results from the exe_id. This variable also contain all the information about the exercise
$track_exercise_info = get_exercise_track_exercise_info($id);
//No track info
if (empty($track_exercise_info)) {
api_not_allowed();
}
$exercise_id = $track_exercise_info['id'];
$exercise_date = $track_exercise_info['exe_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'];
$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();
if (empty($objExercise)) {
$objExercise = new Exercise();
$objExercise->read($exercise_id);
}
$feedback_type = $objExercise->feedbacktype;
//If is not valid
$session_control_key = get_session_time_control_key($exercise_id);
if (isset($session_control_key) && !exercise_time_control_is_valid($exercise_id) && !in_array($action, array('qualify','edit'))) {
$sql_fraud = "UPDATE $TBL_TRACK_ATTEMPT SET answer = 0, marks=0, position=0 WHERE exe_id = $id ";
Database::query($sql_fraud);
}
//Only users can see their own results
if (!$is_allowedToEdit) {
if ($student_id != $current_user_id) {
api_not_allowed();
}
}
//Unset session for clock time
exercise_time_control_delete($exercise_id);
$nameTools=get_lang('CorrectTest');
if (isset($_SESSION['gradebook'])) {
$gradebook= Security::remove_XSS($_SESSION['gradebook']);
}
if (!empty($gradebook) && $gradebook=='view') {
$interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'],'name' => get_lang('ToolGradebook'));
}
$fromlink = '';
if($origin=='user_course') {
$interbreadcrumb[] = array ("url" => "../user/user.php?cidReq=".Security::remove_XSS($_GET['course']), "name" => get_lang("Users"));
$interbreadcrumb[] = array("url" => "../mySpace/myStudents.php?student=".$student_id."&course=".$_course['id']."&details=true&origin=".Security::remove_XSS($_GET['origin']) , "name" => get_lang("DetailsStudentInCourse"));
} else if($origin=='tracking_course') {
//$interbreadcrumb[] = array ("url" => "../mySpace/index.php", "name" => get_lang('MySpace'));
//$interbreadcrumb[] = array ("url" => "../mySpace/myStudents.php?student=".Security::remove_XSS($student_id).'&details=true&origin='.$origin.'&course='.Security::remove_XSS($_GET['cidReq']), "name" => get_lang("DetailsStudentInCourse"));
$interbreadcrumb[] = array ("url" => api_get_path(WEB_COURSE_PATH).$_course['directory'], 'name' => $_course['title']);
$interbreadcrumb[] = array ("url" => "../tracking/courseLog.php?cidReq=".$cidReq.'&studentlist=true&id_session='.$_SESSION['id_session'], "name" => get_lang("Tracking"));
$interbreadcrumb[] = array ("url" => "../mySpace/myStudents.php?student=".$student_id.'&details=true&origin='.$origin.'&course='.Security::remove_XSS($_GET['cidReq']), "name" => get_lang("DetailsStudentInCourse"));
$interbreadcrumb[] = array ("url" => "../mySpace/lp_tracking.php?action=stats&course=".$cidReq."&student_id=".$student_id."&lp_id=".Security::remove_XSS($_GET['my_lp_id'])."&origin=".Security::remove_XSS($_GET['origin']) , "name" => get_lang("LearningPathDetails"));
$from_myspace = false;
if (isset ($_GET['from']) && $_GET['from'] == 'myspace') {
$fromlink = '&from=myspace';
$this_section = SECTION_TRACKING;
} else {
$this_section = SECTION_COURSES;
}
} elseif($origin=='student_progress') {
$this_section = SECTION_TRACKING;
$interbreadcrumb[] = array ("url" => "../auth/my_progress.php?id_session".Security::remove_XSS($_GET['id_session'])."&course=".$_cid, "name" => get_lang('MyProgress'));
unset($_cid);
} else {
$interbreadcrumb[]=array("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices'));
$this_section=SECTION_COURSES;
}
if ($origin != 'learnpath') {
Display::display_header($nameTools,get_lang('Exercise'));
} else {
Display::display_reduced_header();
}
?>
';
}
}
}
} else {
Display::display_warning_message(get_lang('CantViewResults'));
$show_results = false;
echo '
';
}
if ($origin == 'learnpath' && !isset($_GET['fb_type']) ) {
$show_results = false;
}
if ($show_results) {
?>
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;
$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
// destruction of the Question object
unset($objQuestionTmp);
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'];
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;
?>
|
|
|
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 '
';
$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 ' |
';
echo '
'.
'
|
';
}
echo '';
if ($is_allowedToEdit) {
echo '';
$name = "fckdiv".$questionId;
$marksname = "marksName".$questionId;
?>
'.get_lang('EditIndividualComment');
} else {
echo get_lang('AddComments');
}
}
echo '
';
$comnt = trim(get_comments($id,$questionId));
if (empty($comnt)) {
echo ' ';
} else {
echo ' '.$comnt.' ';
}
echo ' ';
$arrid[] = $questionId;
$feedback_form = new FormValidator('frmcomments'.$questionId,'post','');
$feedback_form->addElement('html',' ');
$renderer =& $feedback_form->defaultRenderer();
$renderer->setFormTemplate(' ');
$renderer->setElementTemplate(' {element} ');
$comnt = get_comments($id,$questionId);
${user.$questionId}['comments_'.$questionId] = $comnt;
$feedback_form->addElement('html_editor', 'comments_'.$questionId, null, null, array('ToolbarSet' => 'TestAnswerFeedback', 'Width' => '100%', 'Height' => '120'));
$feedback_form->addElement('html',' ');
//$feedback_form->addElement('submit','submitQuestion',get_lang('Ok'));
$feedback_form->setDefaults(${user.$questionId});
$feedback_form->display();
echo ' ';
} else {
$comnt = get_comments($id,$questionId);
echo ' |
';
if (!empty($comnt)) {
echo ''.get_lang('Feedback').'';
echo ''.$comnt.' ';
}
echo ' | ';
}
if ($is_allowedToEdit) {
if ($answerType == FREE_ANSWER) {
$marksname = "marksName".$questionId;
?>
';
if ($questionScore==-1 ) {
$questionScore=0;
echo ' '.get_lang('notCorrectedYet');
}
} else {
$arrmarks[] = $questionId;
echo '
';
}
} else {
if ($questionScore==-1) {
$questionScore=0;
}
}
?>
|
';
if ($objExercise->selectPropagateNeg() == 0 && $my_total_score < 0) {
$my_total_score = 0;
}
//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
if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
if ($show_results) {
echo ''.get_lang('YourTotalScore').": ";
$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 '
';
}
}
if (is_array($arrid) && is_array($arrmarks)) {
$strids = implode(",",$arrid);
$marksid = implode(",",$arrmarks);
}
if ($is_allowedToEdit) {
if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) {
echo '
'.$href.''."\n";
//record the results in the learning path, using the SCORM interface (API)
echo ''."\n";
echo '