[svn r20100] logic changes - fixed bug in historical exercice - (partial FS#4016)

skala
Isaac Flores 16 years ago
parent 3aad1ac9fc
commit 5ffaba556a
  1. 70
      main/exercice/exercice.php
  2. 18
      main/exercice/exercice_history.php
  3. 6
      main/exercice/exercise.class.php
  4. 4
      main/exercice/exercise_show.php

@ -1,5 +1,5 @@
<?php
// $Id: exercice.php 20089 2009-04-24 21:12:54Z cvargas1 $
// $Id: exercice.php 20100 2009-04-24 23:55:22Z iflorespaz $
/*
==============================================================================
@ -159,8 +159,70 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit
$url = api_get_path(WEB_CODE_PATH) . 'exercice/exercice.php?' . api_get_cidreq() . '&show=result';
$TBL_RECORDING = Database :: get_statistic_table('track_e_attempt_recording');
$total_weighting = $_REQUEST['totalWeighting'];
$my_post_info=array();
$post_content_id=array();
$comments_exist=false;
foreach ($_POST as $key_index=>$key_value) {
$my_post_info=explode('_',$key_index);
$post_content_id[]=$my_post_info[1];
if ($my_post_info[0]=='comments') {
$comments_exist=true;
}
}
//var_dump($comments_exist);
$loop_in_track=($comments_exist===true) ? (count($_POST)/2) : count($_POST);
//var_dump($loop_in_track);
$k=$post_content_id[0];
for ($i=$k;$i<($loop_in_track+$k);$i++) {
//echo $_POST['marks_'.$i].' y '.$_POST['comments_'.$i].'<br/>';
$my_marks=$_POST['marks_'.$i];
$contain_comments=$_POST['comments_'.$i];
if (isset($contain_comments)) {
$my_comments=$_POST['comments_'.$i];
} else {
$my_comments='';
}
$my_questionid=$i;
$sql = "SELECT question from $TBL_QUESTIONS WHERE id = '$my_questionid'";
$result =api_sql_query($sql, __FILE__, __LINE__);
$ques_name = Database::result($result,0,"question");
$query = "UPDATE $TBL_TRACK_ATTEMPT SET marks = '".$my_marks."',teacher_comment = '".$my_comments."'
WHERE question_id = '".$my_questionid."'
AND exe_id='".$id."'";
api_sql_query($query, __FILE__, __LINE__);
$qry = 'SELECT sum(marks) as tot
FROM '.$TBL_TRACK_ATTEMPT.' WHERE exe_id = '.intval($id).'
GROUP BY question_id';
$res = api_sql_query($qry,__FILE__,__LINE__);
$tot = Database::result($res,0,'tot');
//updating also the total weight
$totquery = "UPDATE $TBL_TRACK_EXERCICES SET exe_result = '".Database::escape_string($tot)."', exe_weighting = '".Database::escape_string($total_weighting)."'
WHERE exe_Id='".Database::escape_string($id)."'";
api_sql_query($totquery, __FILE__, __LINE__);
foreach ($_POST as $key => $v) {
$recording_changes = 'INSERT INTO '.$TBL_RECORDING.' ' .
'(exe_id,
question_id,
marks,
insert_date,
author,
teacher_comment)
VALUES
('."'$id','".$my_questionid."','$my_marks','".date('Y-m-d H:i:s')."','".api_get_user_id()."'".',"'.$my_comments.'")';
api_sql_query($recording_changes, __FILE__, __LINE__);
}
$post_content_id=array();
/*foreach ($_POST as $key => $v) {
$keyexp = explode('_', $key);
$id = Database :: escape_string($id);
@ -214,7 +276,7 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit
(' . "'$id','" . $my_questionid . "','$v','" . date('Y-m-d H:i:s') . "','" . api_get_user_id() . "'" . ')';
api_sql_query($recording_changes, __FILE__, __LINE__);
}
}
}*/
$qry = 'SELECT DISTINCT question_id, marks
FROM ' . $TBL_TRACK_ATTEMPT . ' where exe_id = ' . intval($id) . '
@ -1036,7 +1098,7 @@ if ($show == 'test') {
<td><?php echo ($ind+($page*$limitExPage)).'.'; ?><!--<img src="../img/jqz.jpg" alt="HotPotatoes" />--></td>
<td>&nbsp;</td>
<td><a href="showinframes.php?<?php echo api_get_cidreq()."&amp;file=".$path."&amp;cid=".$_course['official_code']."&amp;uid=".$_user['user_id'].'"'; if(!$active) echo 'class="invisible"'; ?>"><?php echo $title;?></a></td>
<td>&nbsp;</td><td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td>float_format
</tr>
<?php

@ -82,15 +82,16 @@ $TBL_TRACK_ATTEMPT_RECORDING= Database::get_statistic_table(TABLE_STATISTIC_TRAC
//event_access_tool(TOOL_QUIZ);
?>
<div class="actions">
<a href="exercice.php?cidReq=<?php echo $_GET['cidReq'] ?>&show=result"><< <?php echo get_lang('Back') ?></a>
</div>
<table class="data_table">
<tr class="row_odd">
<th><?php echo get_lang('Question'); ?></th>
<th><?php echo get_lang('Value'); ?></th>
<th width="50px"><?php echo get_lang('Value'); ?></th>
<th><?php echo get_lang('Feedback'); ?></th>
<th><?php echo get_lang('Date'); ?></th>
<th><?php echo get_lang('Author'); ?></th>
<th width="150px"><?php echo get_lang('Date'); ?></th>
<th ><?php echo get_lang('Author'); ?></th>
</tr>
<?php
@ -100,18 +101,17 @@ $sql = 'SELECT * FROM '.$TBL_EXERCICES;
$query = api_sql_query($sql,__FILE__,__LINE__);
*/
$sql = "SELECT *, quiz_question.question, CONCAT(firstname,' ',lastname) as full_name FROM $TBL_TRACK_ATTEMPT_RECORDING,$TBL_USER,$TBL_EXERCICES_QUESTION quiz_question WHERE quiz_question.id = question_id AND user_id = author AND exe_id = '".(int)$_GET['exe_id']."' ORDER BY question ASC";
$sql = "SELECT *, quiz_question.question, CONCAT(firstname,' ',lastname) as full_name FROM $TBL_TRACK_ATTEMPT_RECORDING t,$TBL_USER,$TBL_EXERCICES_QUESTION quiz_question WHERE quiz_question.id = question_id AND user_id = author AND exe_id = '".(int)$_GET['exe_id']."' ORDER BY t.insert_date desc,question ASC";
$query = api_sql_query($sql,__FILE__,__LINE__);
while($row = mysql_fetch_array($query)){
while($row = Database::fetch_array($query)){
echo '<tr';
if($i%2==0) echo 'class="row_odd"'; else echo 'class="row_even"';
echo '>';
echo '<td>'.$row['question'].'</td>';
echo '<td>'.get_lang('NewScore').': '.$row['marks'].'</td>';
echo '<td>'.$row['marks'].'</td>';
if(!empty($row['teacher_comment'])){
echo '<td>'.get_lang('NewComment').': '.$row['teacher_comment'].'</td>';
echo '<td>'.$row['teacher_comment'].'</td>';
} else {
echo '<td>'.get_lang('WithoutComment').'</td>';
}

@ -25,7 +25,7 @@
* Exercise class: This class allows to instantiate an object of type Exercise
* @package dokeos.exercise
* @author Olivier Brouckaert
* @version $Id: exercise.class.php 20092 2009-04-24 21:35:40Z juliomontoya $
* @version $Id: exercise.class.php 20100 2009-04-24 23:55:22Z iflorespaz $
*/
@ -891,11 +891,11 @@ class Exercise
if($type=='full') {
// feedback type
$radios_feedback = array();
$radios_feedback[] = FormValidator :: createElement ('radio', 'exerciseFeedbackType', null, get_lang('Feedback'),'0');
$radios_feedback[] = FormValidator :: createElement ('radio', 'exerciseFeedbackType', null, get_lang('ExerciceAtEndOfTest'),'0');
$radios_feedback[] = FormValidator :: createElement ('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'),'2');
$form -> addGroup($radios_feedback, null, get_lang('FeedbackType'));
$feedback_option[0]=get_lang('Feedback');
$feedback_option[0]=get_lang('ExerciceAtEndOfTest');
$feedback_option[1]=get_lang('DirectFeedback');
$feedback_option[2]=get_lang('NoFeedback');

@ -4,7 +4,7 @@
*
* @package dokeos.exercise
* @author Julio Montoya Armas Added switchable fill in blank option added
* @version $Id: exercise_show.php 20089 2009-04-24 21:12:54Z cvargas1 $
* @version $Id: exercise_show.php 20100 2009-04-24 23:55:22Z iflorespaz $
*
* @todo remove the debug code and use the general debug library
* @todo use the Database:: functions
@ -967,7 +967,7 @@ if($is_allowedToEdit) {
<br />
<?php
if (!empty($comnt)) {
echo '<b>'.get_lang('FeedbackType').'</b>';
echo '<b>'.get_lang('Feedback').'</b>';
echo '<div id="question_feedback">'.$comnt.'</div>';
}
?>

Loading…
Cancel
Save