[svn r10547] exercises :

- repair the scoring
- avoid sql errors when we don't answer all the questions
skala
Eric Marguin 18 years ago
parent 9710466b12
commit c674661b85
  1. 11
      main/exercice/exercice.php
  2. 9
      main/exercice/exercice_submit.php
  3. 31
      main/exercice/exercise_result.php
  4. 10
      main/exercice/exercise_show.php

@ -743,6 +743,7 @@ if($_configuration['tracking_enabled'])
$from = $_SESSION[_user]['mail'];
$from_name = $_SESSION[_user]['firstName']." ".$_SESSION[_user]['lastName'];
$url = $_SESSION['checkDokeosURL'].'claroline/exercice/exercice.php?'.api_get_cidreq().'&show=result';
print_r($_POST);
foreach ($_POST as $key=>$v)
{
$keyexp = explode('_',$key);
@ -755,7 +756,9 @@ if($_configuration['tracking_enabled'])
$query = "update `$TABLETRACK_ATTEMPT` set marks = '$v' where question_id = $keyexp[1] and exe_id=$id";
api_sql_query($query, __FILE__, __LINE__);
$qry = "select sum(marks) as tot from `".$TABLETRACK_ATTEMPT."` where exe_id = $id";
$qry = 'SELECT sum(marks) as tot
FROM `'.$TABLETRACK_ATTEMPT.'` where exe_id = '.intval($id).'
GROUP BY question_id';
$res = api_sql_query($qry,__FILE__,__LINE__);
$tot = mysql_result($res,0,'tot');
@ -773,7 +776,7 @@ if($_configuration['tracking_enabled'])
}
$subject = "Examsheet viewed/corrected/commented by teacher";
/*$message = "<html>
$message = "<html>
<head>
<style type='text/css'>
<!--
@ -814,7 +817,7 @@ color: #000000;
</DIV>
</body>
</html>
";*/
";
$message = "<p>You attempt for the test #test# has been viewed/commented/corrected by the teacher. Click the link below to access your account and view your Examsheet. <A href='#url#'>#url#</A></p>
<BR>";
$mess= str_replace("#test#",$test,$message);
@ -826,7 +829,7 @@ $message = "<p>You attempt for the test #test# has been viewed/commented/correct
$headers .= "Content-Transfer-Encoding: 7bit";
$headers .= 'From: '.$from_name.' <'.$from.'>' . "\r\n";
$headers="From:$from_name\r\nReply-to: $to\r\nContent-type: text/html; charset=iso-8859-15";
echo 'envoi d\'un mail à '.$emailid;
//mail($emailid, $subject, $mess,$headers);

@ -1,4 +1,4 @@
<?php // $Id: exercice_submit.php 10422 2006-12-07 16:44:39Z elixir_inter $
<?php // $Id: exercice_submit.php 10547 2006-12-22 15:03:14Z elixir_inter $
/*
==============================================================================
Dokeos - elearning and course management software
@ -78,6 +78,7 @@ $TBL_QUESTIONS = $_course['dbNameGlu'].'quiz_question';
$TBL_REPONSES = $_course['dbNameGlu'].'quiz_answer';
// general parameters passed via POST/GET
if ( empty ( $origin ) ) {
$origin = $_REQUEST['origin'];
}
@ -221,6 +222,9 @@ if(!isset($_SESSION['objExercise']))
}
if(!isset($objExcercise) && isset($_SESSION['objExercise'])){
$objExercise = $_SESSION['objExercise'];
}
if(!is_object($objExercise))
{
header('Location: exercice.php');
@ -242,6 +246,9 @@ if(!isset($_SESSION['questionList']))
api_session_register('questionList');
if($debug>0){echo str_repeat('&nbsp;',0).'$_SESSION[questionList] was unset - set now - end'."<br />\n";}
}
if(!isset($objExcercise) && isset($_SESSION['objExercise'])){
$questionList = $_SESSION['questionList'];
}
$nbrQuestions=sizeof($questionList);

@ -1,4 +1,4 @@
<?php // $Id: exercise_result.php 10280 2006-11-30 23:02:34Z develop-it $
<?php // $Id: exercise_result.php 10547 2006-12-22 15:03:14Z elixir_inter $
/*
==============================================================================
Dokeos - elearning and course management software
@ -679,6 +679,9 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
//added by priya saini
if($_configuration['tracking_enabled'])
{
if(empty($choice)){
$choice = 0;
}
if ($answerType==2 )
{
$reply = array_keys($choice);
@ -689,33 +692,35 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
}
}
elseif ($answerType==4)
{
{
$j=3;
for ($i=0;$i<sizeof($choice);$i++,$j++)
{
$val = $choice[$j];
if (preg_match_all ('#<font color="red"><s>([0-9a-z ]*)</s></font>#', $val, $arr1))
$val = $arr1[1][0];
$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);
$val = $choice[$j];
if (preg_match_all ('#<font color="red"><s>([0-9a-z ]*)</s></font>#', $val, $arr1))
$val = $arr1[1][0];
$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)
}
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";
$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
else
{
exercise_attempt($questionScore,$answer,$quesId,$exeId);
}

@ -674,11 +674,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
$answerComment=$objAnswerTmp->selectComment($answerId);
$answerCorrect=$objAnswerTmp->isCorrect($answerId);
$answerWeighting=$objAnswerTmp->selectWeighting($answerId);
$queryfree = "select marks from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
$resfree = api_sql_query($queryfree, __FILE__, __LINE__);
$questionScore= mysql_result($resfree,0,"marks");
//to assign marks to open question
$totalScore+=$questionScore;
$query = "select answer from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
$resq=api_sql_query($query);
$choice = mysql_result($resq,0,"answer");
@ -687,6 +683,10 @@ $result =api_sql_query($query, __FILE__, __LINE__);
$i++;
}
$queryfree = "select marks from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
$resfree = api_sql_query($queryfree, __FILE__, __LINE__);
$questionScore= mysql_result($resfree,0,"marks");
$totalScore+=$questionScore;
?>
</table></td></tr></table>

Loading…
Cancel
Save