0) { echo str_repeat(' ',0).'Entered exercise_result.php'."
\n";var_dump($_POST); } // general parameters passed via POST/GET if ( empty ( $learnpath_id ) ) { $learnpath_id = $_REQUEST['learnpath_id']; } if ( empty ( $learnpath_item_id ) ) { $learnpath_item_id = $_REQUEST['learnpath_item_id']; } 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 = $_GET['action']; } $is_allowedToEdit=api_is_allowed_to_edit() || $is_courseTutor; $nameTools=get_lang('CorrectTest'); if (isset($_SESSION['gradebook'])){ $gradebook= $_SESSION['gradebook']; } if (!empty($gradebook) && $gradebook=='view') { $interbreadcrumb[]= array ( 'url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook') ); } 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=".Security::remove_XSS($_GET['student'])."&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($_GET['student']).'&details=true&origin='.$origin.'&course='.Security::remove_XSS($_GET['cidReq']), "name" => get_lang("DetailsStudentInCourse")); } else if($origin=='student_progress') { $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,"Exercise"); } $emailId = $_REQUEST['email']; $user_name = $_REQUEST['user']; $test = $_REQUEST['test']; $dt = $_REQUEST['dt']; $marks = $_REQUEST['res']; $id = $_REQUEST['id']; ?>  '.nl2br(make_clickable(stripslashes($answerComment))).''; } else{ echo ''.nl2br(make_clickable(stripslashes($answerComment))).''; } } else { echo ' '; } ?>
'.nl2br(make_clickable(stripslashes($answerComment))).''; } else { echo ''.nl2br(make_clickable(stripslashes($answerComment))).''; } ?>
0 && isset($id)) { $test=Database::result($result,0,0); $exerciseTitle=api_parse_tex($test); $exerciseDexcription=Database::result($result,0,1); // if the results_disabled of the Quiz is 1 when block the script $result_disabled=Database::result($result,0,2); 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')); if ($origin!='learnpath') { Display::display_warning_message(get_lang('ThankYouForPassingTheTest').'

'.(get_lang('BackToExercisesList')).'', false); echo '
'; } } } $user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($_user['user_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 =api_sql_query($query, __FILE__, __LINE__); } else { Display::display_warning_message(get_lang('CantViewResults')); $show_results = false; echo ' '; } if ($origin == 'learnpath') { $show_results = false; } if ($show_results) { ?>
:
:


0){echo "ExerciseResult: "; var_dump($exerciseResult); echo "QuestionList: ";var_dump($questionList);} // for each question $questionList = array(); $exerciseResult = array(); $k=0; $counter=0; while ($row = Database::fetch_array($result)) { $questionList[] = $row['question_id']; $exerciseResult[] = $row['answer']; } //echo '
';print_R($questionList);
		
		//we hide the results
		if ($show_results)
		foreach($questionList as $questionId) {
			$counter++;
			$k++;
			$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;
			}
			?>	
	    	
selectNbrAnswers(); $questionScore=0; for($answerId=1;$answerId <= $nbrAnswers;$answerId++) { $answer=$objAnswerTmp->selectAnswer($answerId); $answerComment=$objAnswerTmp->selectComment($answerId); $answerCorrect=$objAnswerTmp->isCorrect($answerId); $answerWeighting=$objAnswerTmp->selectWeighting($answerId); $queryans = "select * from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'"; $resultans = api_sql_query($queryans, __FILE__, __LINE__); while ($row = Database::fetch_array($resultans)) { $ind = $row['answer']; $choice[$ind] = 1; } $studentChoice=$choice[$answerId]; if($studentChoice) { $questionScore+=$answerWeighting; $totalScore+=$answerWeighting; } ?>
 
 
selectNbrAnswers(); $questionScore=0; for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) { $answer=$objAnswerTmp->selectAnswer($answerId); $answerComment=$objAnswerTmp->selectComment($answerId); $answerCorrect=$objAnswerTmp->isCorrect($answerId); $answerWeighting=$objAnswerTmp->selectWeighting($answerId); $queryans = "select answer from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'"; $resultans = api_sql_query($queryans, __FILE__, __LINE__); $choice = Database::result($resultans,0,"answer"); $studentChoice=($choice == $answerId)?1:0; if ($studentChoice) { $questionScore+=$answerWeighting; $totalScore+=$answerWeighting; } ?>
 
 
selectNbrAnswers(); $questionScore=0; for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) { $answer=$objAnswerTmp->selectAnswer($answerId); $answerComment=$objAnswerTmp->selectComment($answerId); $answerCorrect=$objAnswerTmp->isCorrect($answerId); $answerWeighting=$objAnswerTmp->selectWeighting($answerId); // the question is encoded like this // [A] B [C] D [E] F::10,10,10@1 // number 1 before the "@" means that is a switchable fill in blank question // [A] B [C] D [E] F::10,10,10@ or [A] B [C] D [E] F::10,10,10 // means that is a normal fill blank question $pre_array = explode('::', $answer); // is switchable fill blank or not $is_set_switchable = explode('@', $pre_array[1]); $switchable_answer_set=false; if ($is_set_switchable[1]==1) { $switchable_answer_set=true; } $answer = $pre_array[0]; // splits weightings that are joined with a comma $answerWeighting = explode(',',$is_set_switchable[0]); //list($answer,$answerWeighting)=explode('::',$multiple[0]); //$answerWeighting=explode(',',$answerWeighting); // we save the answer because it will be modified $temp=$answer; // TeX parsing // 1. find everything between the [tex] and [/tex] tags $startlocations=strpos($temp,'[tex]'); $endlocations=strpos($temp,'[/tex]'); if($startlocations !== false && $endlocations !== false) { $texstring=substr($temp,$startlocations,$endlocations-$startlocations+6); // 2. replace this by {texcode} $temp=str_replace($texstring,'{texcode}',$temp); } $j=0; // the loop will stop at the end of the text $i=0; //normal fill in blank if (!$switchable_answer_set) { while(1) { // quits the loop if there are no more blanks if(($pos = strpos($temp,'[')) === false) { // adds the end of the text $answer.=$temp; // TeX parsing $texstring = api_parse_tex($texstring); break; } $temp=substr($temp,$pos+1); // quits the loop if there are no more blanks if(($pos = strpos($temp,']')) === false) { break; } $queryfill = "select answer from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'"; $resfill = api_sql_query($queryfill, __FILE__, __LINE__); $str=Database::result($resfill,0,"answer"); preg_match_all ('#\[([^[/]*)/#', $str, $arr); $choice = $arr[1]; $choice[$j]=trim($choice[$j]); // if the word entered by the student IS the same as the one defined by the professor if(strtolower(substr($temp,0,$pos)) == stripslashes(strtolower($choice[$j]))) { // gives the related weighting to the student $questionScore+=$answerWeighting[$j]; // increments total score $totalScore+=$answerWeighting[$j]; } // else if the word entered by the student IS NOT the same as the one defined by the professor $j++; $temp=substr($temp,$pos+1); $i=$i+1; } $answer = $str; } else { //multiple fill in blank while(1) { // quits the loop if there are no more blanks if(($pos = strpos($temp,'[')) === false) { // adds the end of the text $answer.=$temp; // TeX parsing $texstring = api_parse_tex($texstring); //$answer=str_replace("{texcode}",$texstring,$answer); break; } // adds the piece of text that is before the blank and ended by [ $real_text[]=substr($temp,0,$pos+1); $answer.=substr($temp,0,$pos+1); $temp=substr($temp,$pos+1); // quits the loop if there are no more blanks if(($pos = strpos($temp,']')) === false) { // adds the end of the text //$answer.=$temp; break; } $queryfill = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'"; $resfill = api_sql_query($queryfill, __FILE__, __LINE__); $str=Database::result($resfill,0,"answer"); preg_match_all ('#\[([^[/]*)/#', $str, $arr); $choice = $arr[1]; $choice[$j]=trim($choice[$j]); $user_tags[]=stripslashes(strtolower($choice[$j])); $correct_tags[]=strtolower(substr($temp,0,$pos)); $j++; $temp=substr($temp,$pos+1); $i=$i+1; } $answer=''; for($i=0;$i
 
 
selectNbrAnswers(); $questionScore=0; $query = "select answer, marks from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'"; $resq=api_sql_query($query); $choice = Database::result($resq,0,"answer"); $questionScore = Database::result($resq,0,"marks"); if($questionScore==-1){ $totalScore+=0; } else{ $totalScore+=$questionScore; } ?>
 
 
0'; $sql_answer = 'SELECT position, answer FROM '.$table_ans.' WHERE question_id="'.Database::escape_string($questionId).'" AND correct=0'; $res_answer = api_sql_query($sql_answer, __FILE__, __LINE__); // getting the real answer $real_list =array(); while($real_answer = Database::fetch_array($res_answer)) { $real_list[$real_answer['position']]= $real_answer['answer']; } $res_answers = api_sql_query($sql_select_answer, __FILE__, __LINE__); echo ''; echo ''; echo ''; echo ''; $questionScore=0; while($a_answers = Database::fetch_array($res_answers)) { $i_answer_id = $a_answers['id']; //3 $s_answer_label = $a_answers['answer']; // your dady - you mother $i_answer_correct_answer = $a_answers['correct']; //1 - 2 $i_answer_position = $a_answers['position']; // 3 - 4 $sql_user_answer = 'SELECT answers.answer FROM '.$TBL_TRACK_ATTEMPT.' as track_e_attempt INNER JOIN '.$table_ans.' as answers ON answers.position = track_e_attempt.answer AND track_e_attempt.question_id=answers.question_id WHERE answers.correct = 0 AND track_e_attempt.exe_id = "'.Database::escape_string($id).'" AND track_e_attempt.question_id = "'.Database::escape_string($questionId).'" AND track_e_attempt.position="'.Database::escape_string($i_answer_position).'"'; $res_user_answer = api_sql_query($sql_user_answer, __FILE__, __LINE__); if (Database::num_rows($res_user_answer)>0 ) $s_user_answer = Database::result($res_user_answer,0,0); // rich - good looking else $s_user_answer = ''; //$s_correct_answer = $s_answer_label; // your ddady - your mother $s_correct_answer = $real_list[$i_answer_correct_answer]; $i_answerWeighting=$objAnswerTmp->selectWeighting($i_answer_id); //if($s_user_answer == $s_correct_answer) // rich == your ddady?? wrong //echo $s_user_answer.' - '.$real_list[$i_answer_correct_answer]; if($s_user_answer == $real_list[$i_answer_correct_answer]) // rich == your ddady?? wrong { $questionScore+=$i_answerWeighting; $totalScore+=$i_answerWeighting; } else { $s_user_answer = ''.$s_user_answer.''; } echo ''; echo ''; echo ''; } echo '
 
'.get_lang("ElementList").' '.get_lang("CorrespondsTo").'
 
'.$s_answer_label.''.$s_user_answer.' / '.$s_correct_answer.'
'; } else if($answerType == HOTSPOT) { ?> selectNbrAnswers(); $questionScore=0; ?>
 
selectAnswer($answerId); $answerComment=$objAnswerTmp->selectComment($answerId); $answerCorrect=$objAnswerTmp->isCorrect($answerId); $answerWeighting=$objAnswerTmp->selectWeighting($answerId); $TBL_TRACK_HOTSPOT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT); $query = "select hotspot_correct from ".$TBL_TRACK_HOTSPOT." where hotspot_exe_id = '".Database::escape_string($id)."' and hotspot_question_id= '".Database::escape_string($questionId)."' AND hotspot_answer_id='".Database::escape_string($answerId)."'"; $resq=api_sql_query($query); $choice = Database::result($resq,0,"hotspot_correct"); display_hotspot_answer($answerId,$answer,$choice,$answerComment); $i++; } $queryfree = "select marks from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'"; $resfree = api_sql_query($queryfree, __FILE__, __LINE__); $questionScore= Database::result($resfree,0,"marks"); $totalScore+=$questionScore; ?>

'; } ?>


'; } else { echo '
'.$comnt.'
'; } ?>
'; } else { $comnt = get_comments($id,$questionId); ?>

'.get_lang('Feedback').''; echo '
'.$comnt.'
'; } ?>
'.get_lang('notCorrectedYet'); } } else { $arrmarks[] = $questionId; echo ''; } } else { if($questionScore==-1) { $questionScore=0; } } ?>
'.get_lang('YourTotalScore')." "; if($dsp_percent == true) { $my_result = number_format(($totalScore/$totalWeighting)*100,1,'.',''); $my_result = float_format($my_result,1); echo $my_result."%"; } else { $my_total_score = float_format($totalScore,1); $my_total_weight = float_format($totalWeighting,1); echo $my_total_score."/".$my_total_weight; } 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'))) { echo '
'; if (isset($_GET['myid']) && isset($_GET['my_lp_id']) && isset($_GET['student'])) { ?> '; } if ($origin!='learnpath' && $origin!='student_progress') { ?>
'.$href.''."\n"; //record the results in the learning path, using the SCORM interface (API) echo ''."\n"; echo ''; } //destroying the session api_session_unregister('questionList'); unset ($questionList); api_session_unregister('exerciseResult'); unset ($exerciseResult); ?>