[svn r11884] Fix multiple bugs in reporting (and bugs linked with exercises)

skala
Julian Prud'homme 19 years ago
parent 7ecb0ea6f2
commit f5d0eb8422
  1. 245
      main/exercice/exercice.php
  2. 33
      main/exercice/exercise_show.php
  3. 6
      main/exercice/unique_answer.class.php
  4. 21
      main/inc/lib/tracking.lib.php
  5. 14
      main/mySpace/myStudents.php
  6. 2
      main/mySpace/session.php
  7. 17
      main/mySpace/student.php

@ -24,7 +24,7 @@
* @author Olivier Brouckaert, original author * @author Olivier Brouckaert, original author
* @author Denes Nagy, HotPotatoes integration * @author Denes Nagy, HotPotatoes integration
* @author Wolfgang Schneider, code/html cleanup * @author Wolfgang Schneider, code/html cleanup
* @version $Id: exercice.php 11767 2007-03-29 09:22:59Z elixir_julian $ * @version $Id: exercice.php 11884 2007-04-05 12:46:00Z elixir_julian $
*/ */
@ -138,6 +138,123 @@ a.invisible:hover
--> -->
</style>'; </style>';
if ($show=='result' && $_REQUEST['comments']=='update' && $is_allowedToEdit)
{
$id = $_GET['exeid'];
$emailid = $_GET['emailid'];
$test = $_GET['test'];
$from = $_SESSION[_user]['mail'];
$from_name = $_SESSION[_user]['firstName']." ".$_SESSION[_user]['lastName'];
$url = $_SESSION['checkDokeosURL'].'claroline/exercice/exercice.php?'.api_get_cidreq().'&show=result';
foreach ($_POST as $key=>$v)
{
$keyexp = explode('_',$key);
if ($keyexp[0] == "marks")
{
$sql = "select question from $TBL_QUESTIONS where id = '$keyexp[1]'";
$result =api_sql_query($sql, __FILE__, __LINE__);
$ques_name = mysql_result($result,0,"question");
$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 = '.intval($id).'
GROUP BY question_id';
$res = api_sql_query($qry,__FILE__,__LINE__);
$tot = mysql_result($res,0,'tot');
$totquery = "update `$TBL_TRACK_EXERCICES` set exe_result = $tot where exe_Id=$id";
api_sql_query($totquery, __FILE__, __LINE__);
}
else
{
$query = "update `$TABLETRACK_ATTEMPT` set teacher_comment = '$v' where question_id = $keyexp[1] and exe_id = $id ";
api_sql_query($query, __FILE__, __LINE__);
}
}
$qry = 'SELECT DISTINCT question_id, marks
FROM `'.$TABLETRACK_ATTEMPT.'` where exe_id = '.intval($id).'
GROUP BY question_id';
$res = api_sql_query($qry,__FILE__,__LINE__);
$tot = 0;
while($row = mysql_fetch_assoc($res))
{
$tot += $row ['marks'];
}
$totquery = "update `$TBL_TRACK_EXERCICES` set exe_result = $tot where exe_Id=$id";
api_sql_query($totquery, __FILE__, __LINE__);
$subject = "Examsheet viewed/corrected/commented by teacher";
$message = "<html>
<head>
<style type='text/css'>
<!--
.body{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: Normal;
color: #000000;
}
.style8 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; color: #006699; }
.style10 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
}
.style16 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
-->
</style>
</head>
<body>
<DIV>
<p>Dear Student, </p>
<p class='style10'> Your following attempt has been viewed/commented/corrected by teacher </p>
<table width='417'>
<tr>
<td width='229' valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>Question</span></td>
<td width='469' valign='top' bgcolor='#F3F3F3'><span class='style16'>#ques_name#</span></td>
</tr>
<tr>
<td width='229' valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>Test</span></td>
<td width='469' valign='top' bgcolor='#F3F3F3'><span class='style16'>#test#</span></td>
</tr>
</table>
<p>Click the link below to access your account and view your commented Examsheet. <A href='#url#'>#url#</A><BR>
<BR>
Regards </p>
</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);
//$message= str_replace("#ques_name#",$ques_name,$mess);
$message = str_replace("#url#",$url,$mess);
$mess = stripslashes($message);
$headers = " MIME-Version: 1.0 \r\n";
$headers .= "User-Agent: Dokeos/1.6";
$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";
//mail($emailid, $subject, $mess,$headers);
if($_GET['origin']=='tests'){
//Redirect to the reporting
header('location: ../mySpace/myStudents.php?student='.$_GET['student'].'&details=true&course='.$_GET['course']);
}
}
if($show!='result') if($show!='result')
{ {
$nameTools=get_lang('Exercices'); $nameTools=get_lang('Exercices');
@ -679,133 +796,9 @@ if($show == 'test'){
// if tracking is enabled // if tracking is enabled
if($_configuration['tracking_enabled']) if($_configuration['tracking_enabled'])
{ {
?>
<h3><?php
//add link to breadcrumb
//$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('StudentScore'));
//echo $is_allowedToEdit?get_lang('StudentResults'):get_lang('YourResults'); ?></h3>
<?php
if($show == 'result'){ if($show == 'result'){
if($is_allowedToEdit)
{
if ($_REQUEST['comments']=='update')
{
$id = $_GET['exeid'];
$emailid = $_GET['emailid'];
$test = $_GET['test'];
$from = $_SESSION[_user]['mail'];
$from_name = $_SESSION[_user]['firstName']." ".$_SESSION[_user]['lastName'];
$url = $_SESSION['checkDokeosURL'].'claroline/exercice/exercice.php?'.api_get_cidreq().'&show=result';
foreach ($_POST as $key=>$v)
{
$keyexp = explode('_',$key);
if ($keyexp[0] == "marks")
{
$sql = "select question from $TBL_QUESTIONS where id = '$keyexp[1]'";
$result =api_sql_query($sql, __FILE__, __LINE__);
$ques_name = mysql_result($result,0,"question");
$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 = '.intval($id).'
GROUP BY question_id';
$res = api_sql_query($qry,__FILE__,__LINE__);
$tot = mysql_result($res,0,'tot');
$totquery = "update `$TBL_TRACK_EXERCICES` set exe_result = $tot where exe_Id=$id";
api_sql_query($totquery, __FILE__, __LINE__);
}
else
{
$query = "update `$TABLETRACK_ATTEMPT` set teacher_comment = '$v' where question_id = $keyexp[1] and exe_id = $id ";
api_sql_query($query, __FILE__, __LINE__);
}
}
$qry = 'SELECT DISTINCT question_id, marks
FROM `'.$TABLETRACK_ATTEMPT.'` where exe_id = '.intval($id).'
GROUP BY question_id';
$res = api_sql_query($qry,__FILE__,__LINE__);
$tot = 0;
while($row = mysql_fetch_assoc($res))
{
$tot += $row ['marks'];
}
$totquery = "update `$TBL_TRACK_EXERCICES` set exe_result = $tot where exe_Id=$id";
api_sql_query($totquery, __FILE__, __LINE__);
$subject = "Examsheet viewed/corrected/commented by teacher";
$message = "<html>
<head>
<style type='text/css'>
<!--
.body{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: Normal;
color: #000000;
}
.style8 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; color: #006699; }
.style10 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
}
.style16 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
-->
</style>
</head>
<body>
<DIV>
<p>Dear Student, </p>
<p class='style10'> Your following attempt has been viewed/commented/corrected by teacher </p>
<table width='417'>
<tr>
<td width='229' valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>Question</span></td>
<td width='469' valign='top' bgcolor='#F3F3F3'><span class='style16'>#ques_name#</span></td>
</tr>
<tr>
<td width='229' valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>Test</span></td>
<td width='469' valign='top' bgcolor='#F3F3F3'><span class='style16'>#test#</span></td>
</tr>
</table>
<p>Click the link below to access your account and view your commented Examsheet. <A href='#url#'>#url#</A><BR>
<BR>
Regards </p>
</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);
//$message= str_replace("#ques_name#",$ques_name,$mess);
$message = str_replace("#url#",$url,$mess);
$mess = stripslashes($message);
$headers = " MIME-Version: 1.0 \r\n";
$headers .= "User-Agent: Dokeos/1.6";
$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";
//mail($emailid, $subject, $mess,$headers);
}
}
?> ?>
<table class="data_table"> <table class="data_table">

@ -30,7 +30,7 @@
*/ */
// name of the language file that needs to be included // name of the language file that needs to be included
$language_file='exercice'; $language_file=array('exercice','tracking');
// including the global dokeos file // including the global dokeos file
include('../inc/global.inc.php'); include('../inc/global.inc.php');
@ -49,13 +49,8 @@ define('MATCHING', 4);
define('FREE_ANSWER', 5); define('FREE_ANSWER', 5);
define('HOTSPOT', 6); define('HOTSPOT', 6);
$this_section=SECTION_COURSES;
api_protect_course_script(); api_protect_course_script();
// Database table definitions // Database table definitions
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
@ -108,9 +103,19 @@ if ( empty ( $objExercise ) ) {
$objExercise = $_SESSION['objExercise']; $objExercise = $_SESSION['objExercise'];
} }
$is_allowedToEdit=$is_courseAdmin; $is_allowedToEdit=$is_courseAdmin;
$nameTools=get_lang('Exercice'); $nameTools=get_lang('CorrectTest');
$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices')); if($origin=='' || $origin!='tests'){
$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
$this_section=SECTION_COURSES;
}
else{
unset($_cid);
$interbreadcrumb[] = array ("url" => "../mySpace/index.php", "name" => get_lang('MySpace'));
$interbreadcrumb[] = array ("url" => "../mySpace/student.php", "name" => get_lang("MyStudents"));
$interbreadcrumb[] = array ("url" => "../mySpace/myStudents.php?student=".$_GET['student'].'&details=true&course='.$_GET['cidReq'].'', "name" => get_lang("StudentDetails"));
$this_section = "session_my_space";
}
Display::display_header($nameTools,"Exercise"); Display::display_header($nameTools,"Exercise");
//echo "<pre>"; //echo "<pre>";
@ -851,8 +856,16 @@ $totalWeighting+=$questionWeighting;
if($is_allowedToEdit) if($is_allowedToEdit)
{ {
?> ?>
<form name="myform" id="myform" action="exercice.php?show=result&comments=update&exeid=<?php echo $id; ?>&test=<?php echo $test; ?>&emailid=<?php echo $emailId;?>" method="post"> <?php
if($origin=='tests'){
echo ' <form name="myform" id="myform" action="exercice.php?show=result&comments=update&exeid='.$id.'&test='.$test.'&emailid='.$emailId.'&origin=tests&student='.$_GET['student'].'&details=true&course='.$_GET['cidReq'].'" method="post">';
}
else{
echo ' <form name="myform" id="myform" action="exercice.php?show=result&comments=update&exeid='.$id.'&test='.$test.'&emailid='.$emailId.'" method="post">';
}
?>
<input type="submit" value="<?php echo get_lang('Ok'); ?>" onclick="getFCK('<?php echo $strids; ?>','<?php echo $marksid; ?>');"/> <input type="submit" value="<?php echo get_lang('Ok'); ?>" onclick="getFCK('<?php echo $strids; ?>','<?php echo $marksid; ?>');"/>
</form> </form>
<?php } ?> <?php } ?>

@ -144,7 +144,11 @@ class UniqueAnswer extends Question {
$renderer->setElementTemplate('{element}&nbsp;','lessAnswers'); $renderer->setElementTemplate('{element}&nbsp;','lessAnswers');
$renderer->setElementTemplate('{element}','moreAnswers'); $renderer->setElementTemplate('{element}','moreAnswers');
$form -> addElement ('html', '</div></div>'); $form -> addElement ('html', '</div></div>');
//We check the first radio button to be sure a radio button will be check
if($correct==0){
$correct=1;
}
$defaults['correct'] = $correct; $defaults['correct'] = $correct;
$form -> setDefaults($defaults); $form -> setDefaults($defaults);

@ -104,7 +104,7 @@ class Tracking {
return $nb_seconds; return $nb_seconds;
} }
function get_last_connection_date($student_id) function get_last_connection_date($student_id, $warning_message=false)
{ {
$tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN); $tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = 'SELECT login_date FROM '.$tbl_track_login.' $sql = 'SELECT login_date FROM '.$tbl_track_login.'
@ -114,7 +114,22 @@ class Tracking {
$rs = api_sql_query($sql); $rs = api_sql_query($sql);
if($last_login_date = mysql_result($rs,0,0)) if($last_login_date = mysql_result($rs,0,0))
{ {
return $last_login_date; if(!$warning_message){
return format_locale_date(get_lang('DateFormatLongWithoutDay'),strtotime($last_login_date));
}
else{
$timestamp=strtotime($last_login_date);
$currentTimestamp=mktime();
//If the last connection is > than 7 days, the text is red
//345600 = 7 days in seconds
if($currentTimestamp-$timestamp>345600){
return '<span style="color: #F00;">'.format_locale_date(get_lang('DateFormatLongWithoutDay'),strtotime($last_login_date)).'</span>';
}
else{
return format_locale_date(get_lang('DateFormatLongWithoutDay'),strtotime($last_login_date));
}
}
} }
else else
{ {
@ -133,7 +148,7 @@ class Tracking {
$rs = api_sql_query($sql); $rs = api_sql_query($sql);
if($last_login_date = mysql_result($rs,0,0)) if($last_login_date = mysql_result($rs,0,0))
{ {
return $last_login_date; return format_locale_date(get_lang('dateTimeFormatLong'),strtotime($last_login_date));
} }
else else
{ {

@ -481,7 +481,7 @@ if(!empty($_GET['student']))
<?php echo $progress ?> <?php echo $progress ?>
</td> </td>
<td align="center"> <td align="center">
<?php if($start_time!='') echo date('Y-m-d',$start_time); else echo '-'; ?> <?php if($start_time!='') echo format_locale_date(get_lang('DateFormatLongWithoutDay'),$start_time); else echo '-'; ?>
</td> </td>
<td align="center"> <td align="center">
<?php <?php
@ -561,9 +561,8 @@ if(!empty($_GET['student']))
WHERE exe_user_id = ".$_GET['student']." WHERE exe_user_id = ".$_GET['student']."
AND exe_cours_id = '".$a_infosCours['code']."' AND exe_cours_id = '".$a_infosCours['code']."'
AND exe_exo_id = ".$a_exercices['id']." AND exe_exo_id = ".$a_exercices['id']."
ORDER BY exe_date DESC LIMIT 1" ORDER BY exe_date DESC LIMIT 1";
;
$resultScore = api_sql_query($sqlScore); $resultScore = api_sql_query($sqlScore);
$score = 0; $score = 0;
while($a_score = mysql_fetch_array($resultScore)) while($a_score = mysql_fetch_array($resultScore))
@ -604,7 +603,7 @@ if(!empty($_GET['student']))
<td align='center'> <td align='center'>
"; ";
if($a_essais['essais']>0) if($a_essais['essais']>0)
echo '<a href="../exercice/exercise_show.php?id='.$exe_id.'&cidReq='.$a_infosCours['code'].'"> <img src="'.api_get_path(WEB_IMG_PATH).'quiz.gif" border="0"> </a>'; echo '<a href="../exercice/exercise_show.php?id='.$a_exercices['id'].'&cidReq='.$a_infosCours['code'].'&student='.$_GET['student'].'&origin=tests"> <img src="'.api_get_path(WEB_IMG_PATH).'quiz.gif" border="0"> </a>';
echo " </td> echo " </td>
</tr> </tr>
"; ";
@ -717,7 +716,6 @@ if(!empty($_GET['student']))
$csv_content[] = array(get_lang('Course'),get_lang('Time'),get_lang('Progress'),get_lang('Score')); $csv_content[] = array(get_lang('Course'),get_lang('Time'),get_lang('Progress'),get_lang('Score'));
foreach($a_courses as $course_code) foreach($a_courses as $course_code)
{ {
$course_infos = CourseManager :: get_course_information($course_code); $course_infos = CourseManager :: get_course_information($course_code);
$time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($a_infosUser['user_id'], $course_code)); $time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($a_infosUser['user_id'], $course_code));
$progress = Tracking :: get_avg_student_progress($a_infosUser['user_id'], $course_code).' %'; $progress = Tracking :: get_avg_student_progress($a_infosUser['user_id'], $course_code).' %';
@ -761,9 +759,7 @@ if(!empty($_GET['student']))
if(!empty($_GET['details']) && $_GET['origin'] != 'tracking_course' && $_GET['origin'] != 'user_course') if(!empty($_GET['details']) && $_GET['origin'] != 'tracking_course' && $_GET['origin'] != 'user_course')
{ {
?> ?>
<div align="left">
<a href="<?php echo $_SERVER['PHP_SELF']; ?>?student=<?php echo $a_infosUser['user_id']; ?>#infosStudent"><?php echo get_lang('Back'); ?></a>
</div>
<br /><br /> <br /><br />
<?php <?php
} }

@ -90,7 +90,7 @@ if($nb_sessions > 0)
$row = array(); $row = array();
$row[] = $session['name']; $row[] = $session['name'];
$row[] = $session['status']; $row[] = $session['status'];
$row[] = get_lang('From').' '.format_locale_date("%B %Y %d",strtotime($session['date_start'])).' '.get_lang('To').' '.format_locale_date("%B %Y %d",strtotime($session['date_end'])); $row[] = get_lang('From').' '.format_locale_date(get_lang('DateFormatLongWithoutDay'),strtotime($session['date_start'])).' '.get_lang('To').' '.format_locale_date(get_lang('DateFormatLongWithoutDay'),strtotime($session['date_end']));
if($export_csv) if($export_csv)
{ {
$csv_content[] = $row; $csv_content[] = $row;

@ -144,22 +144,15 @@ if($isCoach)
$row[] = $student_datas['lastname']; $row[] = $student_datas['lastname'];
$row[] = $student_datas['firstname']; $row[] = $student_datas['firstname'];
$row[] = api_time_to_hms($avg_time_spent); $row[] = api_time_to_hms($avg_time_spent);
$row[] = $avg_student_progress.' %'; $row[] = round($avg_student_progress,2).' %';
$row[] = $avg_student_score.' %'; $row[] = round($avg_student_score,2).' %';
$row[] = $total_assignments; $row[] = $total_assignments;
$row[] = $total_messages; $row[] = $total_messages;
$string_date=Tracking :: get_last_connection_date($student_id); $string_date=Tracking :: get_last_connection_date($student_id,true);
$timestamp=strtotime($string_date);
$currentTimestamp=mktime(); $row[] = $string_date;
//If the last connection is > than 7 days, the text is red
if($currentTimestamp-$timestamp>345600){
$row[] = '<span style="color: #F00;">'.$string_date.'</span>';
}
else{
$row[] = $string_date;
}
if($export_csv) if($export_csv)
{ {

Loading…
Cancel
Save