[svn r16025] Bug when deleting attempts in track_e_attempt and track_e_exercices fixed.

skala
Julio Montoya 18 years ago
parent 4ba06da862
commit bf9f02b4d0
  1. 25
      main/exercice/exercise_result.php
  2. 57
      main/inc/lib/events.lib.inc.php

@ -29,7 +29,7 @@
* @author Olivier Brouckaert, main author
* @author Roan Embrechts, some refactoring
* @author Julio Montoya Armas switchable fill in blank option added
* @version $Id: exercise_result.php 16000 2008-08-15 04:26:07Z juliomontoya $
* @version $Id: exercise_result.php 16025 2008-08-19 18:29:30Z juliomontoya $
*
* @todo split more code up in functions, move functions to library?
*/
@ -427,10 +427,20 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
// added by Priya Saini
$sql = "select max(exe_Id) as id from ".$TBL_TRACK_EXERCICES;
$res = api_sql_query($sql, __FILE__, __LINE__);
$exeId =mysql_result($res,0,"id");
$exeId=$exeId+1;
//$sql = "select max(exe_Id) as id from ".$TBL_TRACK_EXERCICES;
/*
$sql = "select max(exe_Id) as id from ".$TBL_TRACK_ATTEMPT;
$res = api_sql_query($sql, __FILE__, __LINE__);
$exeId =mysql_result($res,0,"id");
$exeId=$exeId+1;
*/
if($_configuration['tracking_enabled'])
{
// Create an empty exercise
$exeId= create_event_exercice();
}
$counter=0;
foreach($questionList as $questionId)
@ -1046,9 +1056,8 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
if($_configuration['tracking_enabled'])
{
//include(api_get_path(LIBRARY_PATH).'events.lib.inc.php');
event_exercice($objExercise->selectId(),$totalScore,$totalWeighting,$answer,$question_id);
// Updates the empty exercise
update_event_exercice($exeId, $objExercise->selectId(),$totalScore,$totalWeighting,$answer,$question_id);
}
if($objExercise->results_disabled)

@ -1,4 +1,4 @@
<?php // $Id: events.lib.inc.php 15073 2008-04-24 22:46:42Z yannoo $
<?php // $Id: events.lib.inc.php 16025 2008-08-19 18:29:30Z juliomontoya $
/* See license terms in /dokeos_license.txt */
/**
==============================================================================
@ -413,23 +413,44 @@ function event_link($link_id)
}
/**
* @param exeid ( id of the exercise)
* @param exo_id ( id in courseDb exercices table )
* @param result ( score @ exercice )
* @param weighting ( higher score )
* @author Sebastien Piraux <piraux_seb@hotmail.com>
* @author Julio Montoya <gugli100@gmail.com>
* @desc Record result of user when an exercice was done
*/
function event_exercice($exo_id, $score, $weighting)
function update_event_exercice($exeid,$exo_id, $score, $weighting)
{
global $_configuration, $_user, $_cid;
$TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
// if tracking is disabled record nothing
if (!$_configuration['tracking_enabled'])
if ($exeid!='')
{
return 0;
$TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$reallyNow = time();
$sql = "UPDATE $TABLETRACK_EXERCICES SET
exe_exo_id = '".$exo_id."',
exe_result = '".$score."',
exe_weighting = '".$weighting."',
exe_date= FROM_UNIXTIME(".$reallyNow.")
WHERE exe_id = '".$exeid."'";
$res = @api_sql_query($sql,__FILE__,__LINE__);
return $res;
}
else
return false;
}
/**
* This function creates an empty Exercise in STATISTIC_TRACK_E_EXERCICES table.
* After that in exercise_result.php we call the update_event_exercice() to update the exercise
* @return $id the last id registered
* @author Julio Montoya <gugli100@gmail.com>
* @desc Record result of user when an exercice was done
*/
function create_event_exercice()
{
global $_user, $_cid;
$TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$reallyNow = time();
if ($_user['user_id'])
{
@ -442,26 +463,20 @@ function event_exercice($exo_id, $score, $weighting)
$sql = "INSERT INTO $TABLETRACK_EXERCICES
(
exe_user_id,
exe_cours_id,
exe_exo_id,
exe_result,
exe_weighting,
exe_date
)
exe_cours_id
)
VALUES
(
".$user_id.",
'".$_cid."',
'".$exo_id."',
'".$score."',
'".$weighting."',
FROM_UNIXTIME(".$reallyNow.")
'".$_cid."'
)";
$res = @api_sql_query($sql,__FILE__,__LINE__);
return $res;
$id= Database::get_last_insert_id();
return $id;
}
/**
* Record an event for this attempt at answering an exercise
* @param float Score achieved

Loading…
Cancel
Save