@ -4,7 +4,7 @@
*
* @package dokeos.exercise
* @author Julio Montoya Armas Added switchable fill in blank option added
* @version $Id: exercise_show.php 19897 2009-04-20 17:21:18Z cfasanando $
* @version $Id: exercise_show.php 19955 2009-04-21 21:04:23Z juliomontoya $
*
* @todo remove the debug code and use the general debug library
* @todo use the Database:: functions
@ -45,13 +45,11 @@ $TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTE
$dsp_percent = false;
$debug=0;
if($debug>0)
{
if($debug>0) {
echo str_repeat(' ',0).'Entered exercise_result.php'."< br / > \n";var_dump($_POST);
}
// general parameters passed via POST/GET
if ( empty ( $origin ) )
{
if ( empty ( $origin ) ) {
$origin = $_REQUEST['origin'];
}
if ( empty ( $learnpath_id ) ) {
@ -91,22 +89,16 @@ if ( empty ( $exeId ) ) {
$is_allowedToEdit=api_is_allowed_to_edit() || $is_courseTutor;
$nameTools=get_lang('CorrectTest');
if($origin=='user_course')
{
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')
{
} 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')
{
} 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 {
} else {
$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
$this_section=SECTION_COURSES;
}
@ -180,7 +172,7 @@ function get_comments($id,$question_id)
{
global $TBL_TRACK_ATTEMPT;
//$sql = "select teacher_comment from ".$TBL_TRACK_ATTEMPT." where exe_id='".Database::escape_string($id and question_id)."' = '".Database::escape_string($question_id)."' order by question_id";
$sql = "select teacher_comment from ".$TBL_TRACK_ATTEMPT." where exe_id='".Database::escape_string($id)."' and question_id = '".Database::escape_string($question_id)."' order by question_id";
$sql = "SELECT teacher_comment FROM ".$TBL_TRACK_ATTEMPT." where exe_id='".Database::escape_string($id)."' and question_id = '".Database::escape_string($question_id)."' order by question_id";
$sqlres = api_sql_query($sql, __FILE__, __LINE__);
$comm = Database::result($sqlres,0,"teacher_comment");
return $comm;
@ -201,7 +193,7 @@ function get_comments($id,$question_id)
function display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $id, $questionId, $ans)
{
?>
< tr valign = "top" >
< tr >
< td width = "5%" align = "center" >
< img src = "../img/ <?php echo ( $answerType == UNIQUE_ANSWER ) ? 'radio' : 'checkbox' ; echo $studentChoice ? '_on' : '_off' ; ?> .gif"
border="0" alt="" />
@ -210,16 +202,36 @@ function display_unique_or_multiple_answer($answerType, $studentChoice, $answer,
< img src = "../img/ <?php echo ( $answerType == UNIQUE_ANSWER ) ? 'radio' : 'checkbox' ; echo $answerCorrect ? '_on' : '_off' ; ?> .gif"
border="0" alt=" " />
< / td >
< td width = "45% " >
< td width = "40%" style = "border-bottom: 1px solid #4171B5; " >
<?php
$answer=api_parse_tex($answer);
echo $answer; ?>< hr style = "border-top: 0.5px solid #4171B5;" >
< / td >
<?php
if ($ans==1) {
$comm = get_comments($id,$questionId);
}
?>
echo $answer;
?>
< / td >
< td width = "20%" style = "border-bottom: 1px solid #4171B5;" >
<?php
$answerComment=api_parse_tex($answerComment);
if($studentChoice)
{
if(!$answerCorrect)
{
echo '< span style = "font-weight: bold; color: #FF0000;" > '.nl2br(make_clickable(stripslashes($answerComment))).'< / span > ';
}
else{
echo '< span style = "font-weight: bold; color: #008000;" > '.nl2br(make_clickable(stripslashes($answerComment))).'< / span > ';
}
}
else
{
echo ' ';
}
?>
< / td >
<?php
if ($ans==1) {
$comm = get_comments($id,$questionId);
}
?>
< / tr >
<?php
}
@ -262,8 +274,7 @@ function display_free_answer($answer,$id,$questionId) {
<?php echo nl2br ( stripslashes ( $answer )); ?>
</ td > <?php if ( ! api_is_allowed_to_edit ()) { ?>
< td >
<?php
<?php
$comm = get_comments($id,$questionId);
?>
< / td >
@ -296,25 +307,32 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
"#45C7F0",
"#F7BDE2");
?>
< tr >
< td valign = "top" align = "left" >
< div style = "width:100%;" >
< div style = "height:11px; width:11px; background-color: <?php echo $hotspot_colors [ $answerId ]; ?> ; float:left; margin:3px;" ></ div >
< div > <?php echo $answer ?> </ div >
< / div >
< / td >
< td valign = "top" align = "left" > <?php echo $answerId ; ?> </ td >
< td valign = "top" align = "left" >
<?php $studentChoice = ( $studentChoice ) ? get_lang ( 'Correct' ) : get_lang ( 'Fault' ); echo $studentChoice ; ?>
< / td >
< td valign = "top" >
<?php echo stripslashes ( $answerComment ); ?>
< / td >
< / tr >
< tr >
< td valign = "top" align = "left" >
< div style = "width:100%;" >
< div style = "height:11px; width:11px; background-color: <?php echo $hotspot_colors [ $answerId ]; ?> ; float:left; margin:3px;" ></ div >
< div > <?php echo $answer ?> </ div >
< / div >
< / td >
< td valign = "top" align = "left" > <?php echo $answerId ; ?> </ td >
< td valign = "top" align = "left" >
<?php $studentChoice = ( $studentChoice ) ? get_lang ( 'Correct' ) : get_lang ( 'Fault' ); echo $studentChoice ; ?>
< / td >
< td valign = "top" align = "left" >
<?php
$answerComment=api_parse_tex($answerComment);
if($studentChoice) {
echo '< span style = "font-weight: bold; color: #FF0000;" > '.nl2br(make_clickable(stripslashes($answerComment))).'< / span > ';
} else {
echo '< span style = "font-weight: bold; color: #008000;" > '.nl2br(make_clickable(stripslashes($answerComment))).'< / span > ';
}
?>
< / td >
< / tr >
<?php
}
/*
==============================================================================
MAIN CODE
@ -328,7 +346,7 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
<?php
$sql_test_name='SELECT title, description, results_disabled FROM '.$TBL_EXERCICES.' as exercises, '.$TBL_TRACK_EXERCICES.' as track_exercises WHERE exercises.id=track_exercises.exe_exo_id AND track_exercises.exe_id="'.Database::escape_string($id).'"';
$result=api_sql_query($sql_test_name);
$show_results = fals e;
$show_results = tru e;
// Avoiding the "Score 0/0" message when the exe_id is not set
if (Database::num_rows($result)>0 & & isset($id)) {
$test=Database::result($result,0,0);
@ -338,8 +356,10 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
// 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();
if ($result_disabled==1) {
//api_not_allowed();
$show_results = false;
Display::display_warning_message(get_lang('CantViewResults'));
}
}
$user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($_user['user_id'])." ";
@ -357,33 +377,30 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
echo '< / td >
< / tr >
< / table > ';
}
if ($origin != 'learnpath') {
$show_results = true;
?>
< table >
< tr >
< td style = "font-weight:bold" > <?php echo get_lang ( 'CourseTitle' ) ?> : </ td >
< td > <?php echo $_course [ 'name' ] ?> </ td >
< / tr >
< tr >
< td style = "font-weight:bold" > <?php echo get_lang ( 'User' ) ?> : </ td >
< td > <?php echo $user_name ?> </ td >
< / tr >
< tr >
< td style = "font-weight:bold" >
<?php echo get_lang ( "Exercise" ); ?>
< / td >
< td >
<?php echo stripslashes ( $test ) ?> < br />
<?php echo $exerciseDexcription ; ?>
< / td >
< / tr >
< / table >
< br / >
<?php
}
if ($show_results) {
?>
< table >
< tr >
< td style = "font-weight:bold" > <?php echo get_lang ( 'CourseTitle' ) ?> : </ td >
< td > <?php echo $_course [ 'name' ] ?> </ td >
< / tr >
< tr >
< td style = "font-weight:bold" > <?php echo get_lang ( 'User' ) ?> : </ td >
< td > <?php echo $user_name ?> </ td >
< / tr >
< tr >
< td style = "font-weight:bold" >
<?php echo get_lang ( "Exercise" ); ?>
< / td >
< td >
<?php echo stripslashes ( $test ) ?> < br />
<?php echo $exerciseDexcription ; ?>
< / td >
< / tr >
< / table >
< br / >
<?php
}
$i=$totalScore=$totalWeighting=0;
if($debug>0){echo "ExerciseResult: "; var_dump($exerciseResult); echo "QuestionList: ";var_dump($questionList);}
@ -398,9 +415,10 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
$exerciseResult[] = $row['answer'];
}
//echo '< pre > ';print_R($questionList);
//we hide the results
if ($show_results)
foreach($questionList as $questionId) {
foreach($questionList as $questionId) {
$counter++;
$k++;
$choice=$exerciseResult[$questionId];
@ -428,78 +446,80 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
$colspan=2;
}?>
< tr >
< td colspan = "2" height = "24px" >< div id = "question_title" class = "sectiontitle" > <?php echo get_lang ( "Question" ) . ' ' . ( $counter ) . ' : ' . $questionName ; ?> </ div ></ td >
< / tr >
< tr >
< td colspan = "2" > <?php echo $questionDescription ; ?> </ td >
< / tr >
< tr >
< td width = "200" height = "90" valign = "top" >
<?php
if($answerType == MULTIPLE_ANSWER)
{
$choice=array();
?>
< table width = "355" border = "0" cellspacing = "3" cellpadding = "3" >
< tr >
< td > < / td >
< / tr >
< tr >
< td >< i > <?php echo get_lang ( "Choice" ); ?> </ i > </ td >
< td >< i > <?php echo get_lang ( "ExpectedChoice" ); ?> </ i ></ td >
< td >< i > <?php echo get_lang ( "Answer" ); ?> </ i ></ td >
< / tr >
< tr >
< td > < / td >
< / tr >
<?php
// construction of the Answer object
$objAnswerTmp=new Answer($questionId);
$nbrAnswers=$objAnswerTmp->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;
}
?>
< tr >
< td > <?php
if($answerId==1)
display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId);
else
display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,"");
< tr >
< td colspan = "2" height = "24px" >< div id = "question_title" class = "sectiontitle" > <?php echo get_lang ( "Question" ) . ' ' . ( $counter ) . ' : ' . $questionName ; ?> </ div ></ td >
< / tr >
< tr >
< td colspan = "2" > <?php echo $questionDescription ; ?> </ td >
< / tr >
< tr >
< td width = "100%" height = "90" valign = "top" >
<?php
if($answerType == MULTIPLE_ANSWER) {
$choice=array();
?>
< / td >
< / tr >
<?php
$i++;
}?>
< / table >
<?php }
elseif ($answerType == UNIQUE_ANSWER)
{?>
< table width = "355" border = "0" >
< table width = "100%" border = "0" cellspacing = "3" cellpadding = "3" >
< tr >
< td > < / td >
< / tr >
< tr >
< td >< i > <?php echo get_lang ( "Choice" ); ?> </ i > </ td >
< td >< i > <?php echo get_lang ( "ExpectedChoice" ); ?> </ i ></ td >
< td >< i > <?php echo get_lang ( "Answer" ); ?> </ i ></ td >
< td >< i > <?php echo get_lang ( "Comment" ); ?> </ i ></ td >
< / tr >
< tr >
< td > < / td >
< / tr >
<?php
// construction of the Answer object
$objAnswerTmp=new Answer($questionId);
$nbrAnswers=$objAnswerTmp->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;
}
?>
< tr >
< td > <?php
if($answerId==1)
display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId);
else
display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,"");
?>
< / td >
< / tr >
<?php
$i++;
}?>
< / table >
<?php
} elseif ($answerType == UNIQUE_ANSWER) {
?>
< table width = "100%" border = "0" >
< tr >
< td > < / td >
< / tr >
< tr >
< td >< i > <?php echo get_lang ( "Choice" ); ?> </ i > </ td >
< td >< i > <?php echo get_lang ( "ExpectedChoice" ); ?> </ i ></ td >
< td >< i > <?php echo get_lang ( "Answer" ); ?> </ i ></ td >
< td >< i > <?php echo get_lang ( "Choice" ); ?> </ i > </ td >
< td >< i > <?php echo get_lang ( "ExpectedChoice" ); ?> </ i ></ td >
< td >< i > <?php echo get_lang ( "Answer" ); ?> </ i ></ td >
< td >< i > <?php echo get_lang ( "Comment" ); ?> </ i ></ td >
< / tr >
< tr >
< td > < / td >
@ -508,8 +528,7 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
$objAnswerTmp=new Answer($questionId);
$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
$questionScore=0;
for($answerId=1;$answerId < = $nbrAnswers;$answerId++)
{
for ($answerId=1;$answerId < = $nbrAnswers;$answerId++) {
$answer=$objAnswerTmp->selectAnswer($answerId);
$answerComment=$objAnswerTmp->selectComment($answerId);
$answerCorrect=$objAnswerTmp->isCorrect($answerId);
@ -518,29 +537,31 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
$resultans = api_sql_query($queryans, __FILE__, __LINE__);
$choice = Database::result($resultans,0,"answer");
$studentChoice=($choice == $answerId)?1:0;
if($studentChoice)
{
if ($studentChoice) {
$questionScore+=$answerWeighting;
$totalScore+=$answerWeighting;
}?>
}
?>
< tr >
< td > <?php if ( $answerId == 1 )
display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId);
< td >
<?php
if($answerId==1)
display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId);
else
display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,"");
?>
display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,"");
?>
< / td >
</ tr > <?php
$i++;
} ?>
< / tr >
<?php
$i++;
}
?>
< / table >
<?php }
elseif($answerType == FILL_IN_BLANKS)
{ ?>
< table width = "355 " border = "0" >
<?php
} elseif($answerType == FILL_IN_BLANKS){
?>
< table width = "100% " border = "0" >
< tr >
< td > < / td >
< / tr >
@ -555,8 +576,7 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
$questionScore=0;
for($answerId=1;$answerId < = $nbrAnswers;$answerId++)
{
for ($answerId=1;$answerId < = $nbrAnswers;$answerId++) {
$answer=$objAnswerTmp->selectAnswer($answerId);
$answerComment=$objAnswerTmp->selectComment($answerId);
$answerCorrect=$objAnswerTmp->isCorrect($answerId);
@ -573,8 +593,7 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
// is switchable fill blank or not
$is_set_switchable = explode('@', $pre_array[1]);
$switchable_answer_set=false;
if ($is_set_switchable[1]==1)
{
if ($is_set_switchable[1]==1) {
$switchable_answer_set=true;
}
@ -592,8 +611,7 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
// 1. find everything between the [tex] and [/tex] tags
$startlocations=strpos($temp,'[tex]');
$endlocations=strpos($temp,'[/tex]');
if($startlocations !== false & & $endlocations !== false)
{
if($startlocations !== false & & $endlocations !== false) {
$texstring=substr($temp,$startlocations,$endlocations-$startlocations+6);
// 2. replace this by {texcode}
$temp=str_replace($texstring,'{texcode}',$temp);
@ -602,13 +620,10 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
// the loop will stop at the end of the text
$i=0;
//normal fill in blank
if (!$switchable_answer_set)
{
while(1)
{
if (!$switchable_answer_set) {
while(1) {
// quits the loop if there are no more blanks
if(($pos = strpos($temp,'[')) === false)
{
if(($pos = strpos($temp,'[')) === false) {
// adds the end of the text
$answer.=$temp;
// TeX parsing
@ -617,8 +632,7 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
}
$temp=substr($temp,$pos+1);
// quits the loop if there are no more blanks
if(($pos = strpos($temp,']')) === false)
{
if(($pos = strpos($temp,']')) === false) {
break;
}
@ -630,8 +644,7 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
$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])))
{
if(strtolower(substr($temp,0,$pos)) == stripslashes(strtolower($choice[$j]))) {
// gives the related weighting to the student
$questionScore+=$answerWeighting[$j];
// increments total score
@ -643,11 +656,9 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
$i=$i+1;
}
$answer = $str;
}
else
{ //multiple fill in blank
while(1)
{
} else {
//multiple fill in blank
while(1) {
// quits the loop if there are no more blanks
if(($pos = strpos($temp,'[')) === false)
{
@ -698,20 +709,21 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
}
$answer = $str;
}
//echo $questionScore."-".$totalScore;
//echo $questionScore."-".$totalScore;
?>
< tr >
< td > <?php display_fill_in_blanks_answer ( $answer , $id , $questionId ); ?> </ td >
</ tr > <?php
< td >
<?php display_fill_in_blanks_answer ( $answer , $id , $questionId ); ?> </ td >
< / tr >
<?php
$i++;
}
?>
< / table >
<?php }
elseif($answerType == FREE_ANSWER)
{ ?>
< table width = "355 " border = "0" cellspacing = "0" cellpadding = "0" >
<?php
} elseif($answerType == FREE_ANSWER) {
?>
< table width = "100% " border = "0" cellspacing = "0" cellpadding = "0" >
< tr >
< td > < / td >
< / tr >
@ -741,10 +753,7 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
< td valign = "top" > <?php display_free_answer ( $choice , $id , $questionId ); ?> </ td >
< / tr >
< / table >
<?php }
elseif($answerType == MATCHING)
{
<?php } elseif ( $answerType == MATCHING ) {
$objAnswerTmp=new Answer($questionId);
$table_ans = Database :: get_course_table(TABLE_QUIZ_ANSWER);
$TBL_TRACK_ATTEMPT= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
@ -754,14 +763,13 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
$res_answer = api_sql_query($sql_answer, __FILE__, __LINE__);
// getting the real answer
$real_list =array();
while($real_answer = Database::fetch_array($res_answer))
{
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 '< table width = "355 " height = "71" border = "0" > ';
echo '< table width = "100% " height = "71" border = "0" > ';
echo '< tr > < td colspan = "2" > < / td > < / tr > ';
echo '< tr >
< td > < span style = "font-style: italic;" > '.get_lang("ElementList").'< / span > < / td >
@ -771,8 +779,7 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
$questionScore=0;
while($a_answers = Database::fetch_array($res_answers))
{
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
@ -817,45 +824,36 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
}
echo '< tr > ';
echo '< td > '.$s_answer_label.'< / td > < td > '.$s_user_answer.' / < b > < span style = "color: #008000;" > '.$s_correct_answer.'< / span > < / b > < / td > ';
echo '< / tr > ';
}
echo '< / table > ';
}
else if($answerType == HOTSPOT){
echo '< / tr > ';
}
echo '< / table > ';
} else if($answerType == HOTSPOT) {
?>
< table width = "355" border = "0" cellspacing = "0" cellpadding = "0" >
< table width = "355" border = "0" cellspacing = "0" cellpadding = "0" >
< tr >
< td > < / td >
< / tr >
<?php
$objAnswerTmp=new Answer($questionId);
$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
$questionScore=0;
?>
< tr >
< td valign = "top" align = "left" >
< table style = "border: 1px solid #4271b5;border-bottom:none" width = "556" >
< td valign = "top" align = "left" style = "padding-left:0px;" >
< table style = "border: 1px solid #4271b5;border-bottom:none" width = "556px " >
<?php
for($answerId=1;$answerId < = $nbrAnswers;$answerId++)
{
for($answerId=1;$answerId < = $nbrAnswers;$answerId++) {
$answer=$objAnswerTmp->selectAnswer($answerId);
$answerComment=$objAnswerTmp->selectComment($answerId);
$answerCorrect=$objAnswerTmp->isCorrect($answerId);
$answerWeighting=$objAnswerTmp->selectWeighting($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);
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)."'";
@ -873,133 +871,144 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
< object type = "application/x-shockwave-flash" data = "../plugin/hotspot/hotspot_solution.swf?modifyAnswers='.$questionId.'&exe_id='.$id.'&from_db=0" width = "556" height = "421" >
< param name = "movie" value = "../plugin/hotspot/hotspot_solution.swf?modifyAnswers='.$questionId.'&exe_id='.$id.'&from_db=1" / >
< / object >
< / td >
< / tr >
< / table > ';
< / table > < br / > ';
}
?>
< / td >
< td width = "346" valign = "top" > < i >
<?php echo get_lang ( "Comment" ); ?> </ i >
<?php if ( $is_allowedToEdit )
{
//if (isset($_REQUEST['showdiv']) & & $questionId==$_REQUEST['ques_id'])
//{
$name = "fckdiv".$questionId;
$marksname = "marksName".$questionId;
?>
< a href = "javascript://" onclick = "showfck(' <?php echo $name ; ?> ',' <?php echo $marksname ; ?> ');" > <?php if ( $answerType == FREE_ANSWER ) echo " " . get_lang ( 'EditCommentsAndMarks' ); else echo " " . get_lang ( 'AddComments' ); ?> </ a >
<?php
$comnt = get_comments($id,$questionId);
echo "< br > < br > ".$comnt;
?>
< div id = " <?php echo $name ; ?> " style = "visibility:hidden" >
<?php
$arrid[] = $questionId;
$fck_attribute['Width'] = '400';
$fck_attribute['Height'] = '150';
$fck_attribute['ToolbarSet'] = 'CommentAnswers';
$$questionId = new FormValidator('frmcomments'.$questionId,'post','');
$renderer =& $$questionId->defaultRenderer();
$renderer->setFormTemplate(
'< form { attributes } > < div align = "left" > {content}< / div > < / form > ');
$renderer->setElementTemplate(
'< div align = "left" > {element}< / div > '
);
$comnt =get_comments($id,$questionId);
${user.$questionId}['comments_'.$questionId] = $comnt;
$$questionId->addElement('html_editor','comments_'.$questionId,false);
//$$questionId->addElement('submit','submitQuestion',get_lang('Ok'));
$$questionId->setDefaults(${user.$questionId});
$$questionId->display();
?>
< / div >
< td width = "320" height = "90" valign = "top" >
< table width = "100%" border = "0" cellspacing = "3" cellpadding = "3" >
<?php
if($is_allowedToEdit) {
?>
< tr >
< td height = "28px" > < / td >
< / tr >
< tr >
< td >
<?php
//if (isset($_REQUEST['showdiv']) & & $questionId==$_REQUEST['ques_id'])
//{
$name = "fckdiv".$questionId;
$marksname = "marksName".$questionId;
?>
< i > <?php echo get_lang ( 'MoreFeedback' ); ?> </ i >
< br / > < br / >
< a href = "javascript://" onclick = "showfck(' <?php echo $name ; ?> ',' <?php echo $marksname ; ?> ');" > <?php if ( $answerType == FREE_ANSWER ) echo " " . get_lang ( 'EditCommentsAndMarks' ); else echo " " . get_lang ( 'AddComments' ); ?> </ a >
<?php
}
else
{
$comnt = get_comments($id,$questionId);
echo "< br > < br > ".$comnt;
}
?>
echo "< br / > < br / > ".$comnt;
?>
< div id = " <?php echo $name ; ?> " style = "visibility:hidden" >
<?php
$arrid[] = $questionId;
$fck_attribute['Width'] = '270';
$fck_attribute['Height'] = '120';
$fck_attribute['ToolbarSet'] = 'CommentAnswers';
$fck_attribute['Config']['ToolbarStartExpanded']='false';
$$questionId = new FormValidator('frmcomments'.$questionId,'post','');
$renderer =& $$questionId->defaultRenderer();
$renderer->setFormTemplate('< form { attributes } > < div align = "left" > {content}< / div > < / form > ');
$renderer->setElementTemplate('< div align = "left" > {element}< / div > ');
$comnt =get_comments($id,$questionId);
${user.$questionId}['comments_'.$questionId] = $comnt;
$$questionId->addElement('html_editor','comments_'.$questionId,false);
//$$questionId->addElement('submit','submitQuestion',get_lang('Ok'));
$$questionId->setDefaults(${user.$questionId});
$$questionId->display();
echo '< / div > ';
} else {
$comnt = get_comments($id,$questionId);
?>
< tr >
< td height = "28px" > < / td >
< / tr >
< tr >
< td >< i > <?php if ( ! empty ( $comnt )) echo get_lang ( 'MoreFeedback' ); ?> </ i ></ td >
< / tr >
< tr >
< td >
< br / > < br / >
<?php echo $comnt ;
echo '< / td > < td > ';
}
?>
< / td >
< / tr >
< / table >
< / td >
< / tr >
< tr >
< td > < / td >
< td align = "left" >
<?php
if($is_allowedToEdit)
{
if ($answerType == FREE_ANSWER)
{
$marksname = "marksName".$questionId;
?>
< div id = " <?php echo $marksname ; ?> " style = "visibility:hidden" >
< form name = "marksform_ <?php echo $questionId ; ?> " method = "post" action = "" >
<?php
$arrmarks[] = $questionId;
echo get_lang("AssignMarks");
echo "< select name = 'marks' id = 'marks' > ";
for($i=0;$i< =$questionWeighting;$i++)
{?>
< option <?php if ( $i == $questionScore ) echo "selected='selected'" ; ?> >
<?php echo $i ;
?>< / option >
<?php } ?>
< / select >
</ form ></ div > <?php
if($questionScore==-1){
$questionScore=0;
echo '< br > '.get_lang('notCorrectedYet');
}
}
else{
$arrmarks[] = $questionId;
echo '< div id = "'.$marksname.'" style = "visibility:hidden" > < form name = "marksform_'.$questionId.'" method = "post" action = "" > < select name = "marks" id = "marks" style = "display:none;" > < option > '.$questionScore.'< / option > < / select > < / form > < / div > ';
}
} else {
if($questionScore==-1) {
$questionScore=0;
}
}?>
</ td >< tr >< td align = "left" >< b > <?php echo get_lang ( 'Score' ) . " : $questionScore / $questionWeighting " ; ?> </ b >< br />< br /></ td >
if($is_allowedToEdit) {
if ($answerType == FREE_ANSWER) {
$marksname = "marksName".$questionId;
?>
< div id = " <?php echo $marksname ; ?> " style = "visibility:hidden" >
< form name = "marksform_ <?php echo $questionId ; ?> " method = "post" action = "" >
<?php
$arrmarks[] = $questionId;
echo get_lang("AssignMarks");
echo "< select name = 'marks' id = 'marks' > ";
for($i=0;$i< =$questionWeighting;$i++) {
?>
< option <?php if ( $i == $questionScore ) echo "selected='selected'" ; ?> >
<?php echo $i ;
?>< / option >
<?php } ?>
< / select >
</ form ></ div > <?php
if($questionScore==-1) {
$questionScore=0;
echo '< br > '.get_lang('notCorrectedYet');
}
} else {
$arrmarks[] = $questionId;
echo '< div id = "'.$marksname.'" style = "visibility:hidden" > < form name = "marksform_'.$questionId.'" method = "post" action = "" > < select name = "marks" id = "marks" style = "display:none;" > < option > '.$questionScore.'< / option > < / select > < / form > < / div > ';
}
} else {
if($questionScore==-1) {
$questionScore=0;
}
}
?>
< / td > < tr > < td align = "left" > < b >
<?php echo get_lang ( 'Score' ) . " : $questionScore / $questionWeighting " ; ?> </ b >< br />< br /></ td >
< / tr >
<?php unset ( $objAnswerTmp );
$i++;
$totalWeighting+=$questionWeighting;
}
?>
<?php if ( $origin != 'learnpath' ) { ?>
< tr >< td align = "left" >< b > <?php
if($origin!='learnpath') {?>
< tr > < td align = "left" > < b >
<?php
//$query = "update ".$TBL_TRACK_EXERCICES." set exe_result = $totalScore where exe_id = '$id'";
//api_sql_query($query,__FILE__,__LINE__);
echo '< br / > '.get_lang('YourTotalScore')." ";
if($dsp_percent == true)
{
echo number_format(($totalScore/$totalWeighting)*100,1,'.','')."%";
}
else
{
echo $totalScore."/".$totalWeighting;
if ($show_results) {
echo '< br / > '.get_lang('YourTotalScore')." ";
if($dsp_percent == true) {
echo number_format(($totalScore/$totalWeighting)*100,1,'.','')."%";
} else {
echo $totalScore."/".$totalWeighting;
}
?> !< / b >
echo '!< / b > ';
}
?>
< / td > < / tr >
<?php } else { ?>
< tr >< td >< br />< br /> <?php Display :: display_normal_message ( get_lang ( 'ExerciseFinished' )) ?> </ td ></ tr >
<?php } ?>
<?php } else { ?>
< tr >< td >< br />< br /> <?php Display :: display_normal_message ( get_lang ( 'ExerciseFinished' )) ?> </ td ></ tr >
<?php } ?>
< tr >
< td align = "left" >
< br / >
@ -1008,11 +1017,7 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
$strids = implode(",",$arrid);
$marksid = implode(",",$arrmarks);
}
if($is_allowedToEdit)
{
?>
<?php
if($is_allowedToEdit) {
if (in_array($origin, array('tracking_course','user_course'))) {
echo ' < form name = "myform" id = "myform" action = "exercice.php?show=result&comments=update&exeid='.$id.'&test='.urlencode($test).'&emailid='.$emailId.'&origin='.$origin.'&student='.$_GET['student'].'&details=true&course='.$_GET['cidReq'].'" method = "post" > ';
if (isset($_GET['myid']) & & isset($_GET['my_lp_id']) & & isset($_GET['student'])) {
@ -1027,16 +1032,14 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
}
} else {
echo ' < form name = "myform" id = "myform" action = "exercice.php?show=result&comments=update&exeid='.$id.'&test='.$test.'&emailid='.$emailId.'" method = "post" > ';
}
}
if ($origin!='learnpath' & & $origin!='student_progress') {
?>
< button type = "submit" class = "save" value = " <?php echo get_lang ( 'Ok' ); ?> " onclick = "getFCK(' <?php echo $strids ; ?> ',' <?php echo $marksid ; ?> ');" > <?php echo get_lang ( 'FinishTest' ); ?> </ button >
< / form >
<?php }
}
if ($origin=='learnpath' || $origin=='student_progress') {?>
if ($origin=='learnpath' || $origin=='student_progress') {?>
< button type = "button" class = "save" onclick = "top.location.href='../newscorm/lp_controller.php?cidReq= <?php echo api_get_course_id () ?> &action=view&lp_id= <?php echo $learnpath_id ?> &lp_item_id= <?php echo $learnpath_item_id ?> &exeId= <?php echo $exeId ?> '" value = " <?php echo get_lang ( 'Finish' ); ?> " > <?php echo get_lang ( 'Finish' ); ?> </ button >
<?php } else if ( $origin == 'myprogress' ) { ?>
< button type = "button" class = "save" onclick = "top.location.href='../auth/my_progress.php?course= <?php echo api_get_course_id () ?> '" value = " <?php echo get_lang ( 'Finish' ); ?> " > <?php echo get_lang ( 'Finish' ); ?> </ button >
@ -1059,5 +1062,4 @@ unset ($questionList);
api_session_unregister('exerciseResult');
unset ($exerciseResult);
?>