0){echo str_repeat(' ',0).'Entered exercise_result.php'."
\n";var_dump($_POST);} // general parameters passed via POST/GET if ( empty ( $origin ) ) { $origin = $_REQUEST['origin']; } if ( empty ( $learnpath_id ) ) { $learnpath_id = mysql_real_escape_string($_REQUEST['learnpath_id']); } if ( empty ( $learnpath_item_id ) ) { $learnpath_item_id = mysql_real_escape_string($_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 = mysql_real_escape_string($_REQUEST['questionNum']); } if ( empty ( $nbrQuestions ) ) { $nbrQuestions = mysql_real_escape_string($_REQUEST['nbrQuestions']); } if ( empty ( $questionList ) ) { $questionList = $_SESSION['questionList']; } if ( empty ( $objExercise ) ) { $objExercise = $_SESSION['objExercise']; } $main_user_table = Database :: get_main_table(TABLE_MAIN_USER); $main_admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN); $courseName = $_SESSION[_course][name]; $query = "select user_id from $main_admin_table"; $admin_id = mysql_result(api_sql_query($query),0,"user_id"); $query1 = "select email,firstname,lastname from $main_user_table where user_id = $admin_id"; $rs = api_sql_query($query1); $row = mysql_fetch_array($rs); $from = $row['email']; $from_name = $row['firstname'].' '.$row['lastname']; $str = $_SERVER['REQUEST_URI']; $arr = explode('/',$str); $url = api_get_path(WEB_CODE_PATH).'exercice/exercice.php?'.api_get_cidreq().'&show=result'; //$url = $_SERVER['SERVER_NAME'].'/'.$arr[1].'/'; // if the above variables are empty or incorrect, stops the script if(!is_array($exerciseResult) || !is_array($questionList) || !is_object($objExercise)) { header('Location: exercice.php'); exit(); } $exerciseTitle=$objExercise->selectTitle(); $nameTools=get_lang('Exercice'); $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices')); if ($origin != 'learnpath') { //so we are not in learnpath tool Display::display_header($nameTools,"Exercise"); } else { if(empty($charset)) { $charset = 'ISO-8859-15'; } header('Content-Type: text/html; charset='. $charset); @$document_language = Database::get_language_isocode($language_interface); if(empty($document_language)) { //if there was no valid iso-code, use the english one $document_language = 'en'; } /* * HTML HEADER */ ?>

:

0){echo "ExerciseResult: "; var_dump($exerciseResult); echo "QuestionList: ";var_dump($questionList);} // added by Priya Saini $sql = "select max(exe_Id) as id from `".$TABLETRACK_EXERCICES."`"; $res = api_sql_query($sql, __FILE__, __LINE__); $exeId =mysql_result($res,0,"id"); $exeId=$exeId+1; $counter=0; foreach($questionList as $questionId) { $counter++; // gets the student choice for this question $choice=$exerciseResult[$questionId]; // creates a temporary Question object $objQuestionTmp = Question :: read($questionId); $questionName=$objQuestionTmp->selectTitle(); $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=4; } elseif($answerType == MATCHING || $answerType == FREE_ANSWER) { $colspan=2; } elseif($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER) { $colspan=4; $rowspan=$nbrAnswers+1; } else { $colspan=1; } ?>


selectNbrAnswers(); $questionScore=0; if($answerType == FREE_ANSWER) $nbrAnswers = 1; for($answerId=1;$answerId <= $nbrAnswers;$answerId++) { $answer=$objAnswerTmp->selectAnswer($answerId); $answerComment=$objAnswerTmp->selectComment($answerId); $answerCorrect=$objAnswerTmp->isCorrect($answerId); $answerWeighting=$objAnswerTmp->selectWeighting($answerId); switch($answerType) { // for unique answer case UNIQUE_ANSWER : $studentChoice=($choice == $answerId)?1:0; if($studentChoice) { $questionScore+=$answerWeighting; $totalScore+=$answerWeighting; } break; // for multiple answers case MULTIPLE_ANSWER : $studentChoice=$choice[$answerId]; if($studentChoice) { $questionScore+=$answerWeighting; $totalScore+=$answerWeighting; } break; // for fill in the blanks case FILL_IN_BLANKS : // splits text and weightings that are joined with the character '::' list($answer,$answerWeighting)=explode('::',$answer); // splits weightings that are joined with a comma $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); } $answer=''; $j=0; // the loop will stop at the end of the text 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 [ $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; } $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]; // adds the word in green at the end of the string $answer.=stripslashes($choice[$j]); } // else if the word entered by the student IS NOT the same as the one defined by the professor elseif(!empty($choice[$j])) { // adds the word in red at the end of the string, and strikes it $answer.=''.stripslashes($choice[$j]).''; } else { // adds a tabulation if no word has been typed by the student $answer.='   '; } // adds the correct word, followed by ] to close the blank $answer.=' / '.substr($temp,0,$pos).']'; $j++; $temp=substr($temp,$pos+1); } break; // for free answer case FREE_ANSWER : $studentChoice=$choice; if($studentChoice) { $questionScore=0; $totalScore+=0; } break; // for matching case MATCHING : if($answerCorrect) { if($answerCorrect == $choice[$answerId]) { $questionScore+=$answerWeighting; $totalScore+=$answerWeighting; $choice[$answerId]=$matching[$choice[$answerId]]; } elseif(!$choice[$answerId]) { $choice[$answerId]='   '; } else { $choice[$answerId]=''.$matching[$choice[$answerId]].''; } } else { $matching[$answerId]=$answer; } break; // for hotspot with no order case HOT_SPOT : $studentChoice=$choice[$answerId]; if($studentChoice) { $questionScore+=$answerWeighting; $totalScore+=$answerWeighting; } break; // for hotspot with fixed order case HOT_SPOT_ORDER : $studentChoice=$choice['order'][$answerId]; if($studentChoice == $answerId) { $questionScore+=$answerWeighting; $totalScore+=$answerWeighting; $studentChoice = true; } else { $studentChoice = false; } break; } // end switch Answertype if($answerType != MATCHING || $answerCorrect) { if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) { display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect); } elseif($answerType == FILL_IN_BLANKS) { display_fill_in_blanks_answer($answer); } elseif($answerType == FREE_ANSWER) { // to store the details of open questions in an array to be used in mail $arrques[] = $questionName; $arrans[] = $choice; $firstName = $_SESSION['_user']['firstName']; $lastName = $_SESSION['_user']['lastName']; $mail = $_SESSION['_user']['mail']; $coursecode = $_SESSION['_course']['official_code']; $query1 = "SELECT user_id from $main_course_user_table where course_code= '$coursecode' and status = '1' LIMIT 0,1"; $result1 = api_sql_query($query1, __FILE__, __LINE__); $temp = mysql_result($result1,0,"user_id"); $query = "select email from $main_user_table where user_id =".$temp ; $result = api_sql_query($query, __FILE__, __LINE__); $to = mysql_result($result,0,"email"); display_free_answer($choice); } elseif($answerType == HOT_SPOT) { display_hotspot_answer($answerId, $answer, $studentChoice, $answerComment); } elseif($answerType == HOT_SPOT_ORDER) { display_hotspot_order_answer($answerId, $answer, $studentChoice, $answerComment); } else { ?> "; } ?>








/
([0-9a-z ]*)#', $val, $arr1)) $val = $arr1[1][0]; $val=addslashes($val); $sql = "select position from $table_ans where question_id=$questionId and answer='$val'"; $res = api_sql_query($sql, __FILE__, __LINE__); $answer = mysql_result($res,0,"position"); exercise_attempt($questionScore,$answer,$quesId,$exeId,$j); } } elseif ($answerType==5) { $answer = $choice; exercise_attempt($questionScore,$answer,$quesId,$exeId); } elseif ($answerType==1) { $sql = "select id from $table_ans where question_id=$questionId and position=$choice"; $res = api_sql_query($sql, __FILE__, __LINE__); $answer = mysql_result($res,0,"id"); exercise_attempt($questionScore,$answer,$quesId,$exeId); } else { exercise_attempt($questionScore,$answer,$quesId,$exeId); } } } // end huge foreach() block that loops over all questions ?>
!


selectId(),$totalScore,$totalWeighting,$answer,$question_id); } if ($origin != 'learnpath') { //we are not in learnpath tool Display::display_footer(); }else{ $user_id = (!empty($_SESSION['_user']['id'])?$_SESSION['_user']['id']:0); $lp_item = Database::get_course_table('lp_item'); $lp_item_view = Database::get_course_table('lp_item_view'); $sql2 = "UPDATE $lp_item SET max_score = '$totalWeighting' WHERE id = '$learnpath_item_id'"; api_sql_query($sql2,__FILE__,__LINE__); $sql2 = "UPDATE $lp_item_view SET score = '$totalScore' WHERE lp_item_id = '$learnpath_item_id' AND lp_view_id = '".$_SESSION['scorm_view_id']."'"; api_sql_query($sql2,__FILE__,__LINE__); } $csspath = "http://portal.dokeos.com/demo/main/css/default.css"; if (!empty($arrques)) { $msg = " "; /**/ /*$msg .= "

".get_lang('OpenQuestionsAttempted')."

Attempt Details :

  Course Name #course#
  ".get_lang('TestAttempted')." #exercise#
  Student's Name #firstName# #lastName#
  Student's Email ID #mail#


".get_lang('OpenQuestionsAttemptedAre')." :

"; for($i=0;$i

".get_lang('OpenQuestionsAttempted')."

Attempt Details : >

  Course Name #course#
  ".get_lang('TestAttempted')."Test Attempted #exercise#
  Student's Name #firstName# #lastName#
  Student's Email ID #mail#


".get_lang('OpenQuestionsAttemptedAre')." :

"; for($i=0;$i