[svn r17484] I added thwo fields named orig_lp_id and orig_lp_item_id into track_e_exercises table, that will allow to link learning path with exercise attempt see FS#2624

skala
Cristian Fasanando 16 years ago
parent f2a40742fc
commit 9757e1f7ab
  1. 8
      main/exercice/exercice.php
  2. 31
      main/exercice/exercice_submit.php
  3. 7
      main/exercice/exercise_result.php
  4. 8
      main/inc/lib/events.lib.inc.php
  5. 4
      main/inc/lib/tracking.lib.php
  6. 2
      main/install/dokeos_stats.sql
  7. 3
      main/install/migrate-db-1.8.5-1.8.6-pre.sql
  8. 8
      main/mySpace/myStudents.php
  9. 14
      main/newscorm/lp_stats.php

@ -1,4 +1,4 @@
<?php // $Id: exercice.php 17450 2008-12-24 10:00:19Z pcool $
<?php // $Id: exercice.php 17484 2008-12-30 21:47:26Z cfasanando $
/*
==============================================================================
@ -786,7 +786,7 @@ $eid = $row['id'];
$uid= api_get_user_id();
//this query might be improved later on by ordering by the new "tms" field rather than by exe_id
$qry = "SELECT * FROM $TBL_TRACK_EXERCICES " .
"WHERE exe_exo_id = '".Database::escape_string($eid)."' and exe_user_id = '".Database::escape_string($uid)."' and exe_cours_id = '".api_get_course_id()."' AND session_id = '".api_get_session_id()."' ORDER BY exe_id DESC";
"WHERE exe_exo_id = '".Database::escape_string($eid)."' and exe_user_id = '".Database::escape_string($uid)."' AND exe_cours_id = '".api_get_course_id()."' AND orig_lp_id = 0 AND orig_lp_item_id = 0 AND session_id = '".api_get_session_id()."' ORDER BY exe_id DESC";
$qryres = api_sql_query($qry);
$num = Database::num_rows($qryres);
if ($num>0) {
@ -971,7 +971,7 @@ if ($_configuration['tracking_enabled'] AND ($show == 'result') )
te.exe_weighting, UNIX_TIMESTAMP(te.exe_date), te.exe_id, email,UNIX_TIMESTAMP(te.start_date),steps_counter,user_id
FROM $TBL_EXERCICES AS ce , $TBL_TRACK_EXERCICES AS te, $TBL_USER AS user
WHERE te.exe_exo_id = ce.id AND te.status != 'incomplete' AND user_id=te.exe_user_id AND te.exe_cours_id='".Database::escape_string($_cid)."'
AND user.status<>1 $user_id_and $session_id_and AND ce.active <>-1
AND user.status<>1 $user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0
ORDER BY users, te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC";
@ -988,7 +988,7 @@ if ($_configuration['tracking_enabled'] AND ($show == 'result') )
te.exe_weighting, UNIX_TIMESTAMP(te.exe_date),te.exe_id,email,UNIX_TIMESTAMP(te.start_date),steps_counter,user_id
FROM $TBL_EXERCICES AS ce , $TBL_TRACK_EXERCICES AS te, $TBL_USER AS user
WHERE te.exe_exo_id = ce.id AND te.status != 'incomplete' AND user_id=te.exe_user_id AND te.exe_cours_id='".Database::escape_string($_cid)."'
AND user.status<>1 $user_id_and $session_id_and AND ce.active <>-1
AND user.status<>1 $user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0
ORDER BY users, te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC";
$hpsql="SELECT '',exe_name, exe_result , exe_weighting, UNIX_TIMESTAMP(exe_date)

@ -1,4 +1,4 @@
<?php // $Id: exercice_submit.php 17317 2008-12-16 14:05:45Z cfasanando $
<?php // $Id: exercice_submit.php 17484 2008-12-30 21:47:26Z cfasanando $
/*
==============================================================================
@ -42,7 +42,7 @@
* @package dokeos.exercise
* @author Olivier Brouckaert
* @author Julio Montoya multiple fill in blank option added
* @version $Id: exercice_submit.php 17317 2008-12-16 14:05:45Z cfasanando $
* @version $Id: exercice_submit.php 17484 2008-12-30 21:47:26Z cfasanando $
*/
@ -150,12 +150,15 @@ if ($origin=='builder') {
if(isset($_SESSION['exerciseResult'])) { api_session_unregister('exerciseResult'); unset($exerciseResult); }
if(isset($_SESSION['exerciseResultCoordinates'])) { api_session_unregister('exerciseResultCoordinates'); unset($exerciseResultCoordinates); }
}
$safe_lp_id = ($learnpath_id=='')?0:(int)$learnpath_id;
$safe_lp_item_id = ($learnpath_item_id=='')?0:(int)$learnpath_item_id;
$condition = ' WHERE ' .
'exe_exo_id = '."'".$exerciseId."'".' AND ' .
'exe_user_id = '."'".api_get_user_id()."'".' AND ' .
'exe_cours_id = '."'".$_course['id']."'".' AND ' .
'status = '."'incomplete'".' AND '.
'orig_lp_id = '."'".$safe_lp_id."'".' AND '.
'orig_lp_item_id = '."'".$safe_lp_item_id."'".' AND '.
'session_id = '."'".(int)$_SESSION['id_session']."'";
if (empty($exerciseType)) {
@ -815,12 +818,12 @@ echo "<h3>".$exerciseTitle."</h3>";
if( $exerciseAttempts > 0){
$user_id = api_get_user_id();
$course_code = api_get_course_id();
$sql = 'SELECT count(*)
FROM '.Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES).'
WHERE exe_exo_id = '.$quizID.' '.
'and exe_user_id = '.$user_id.' '.
"and status != 'incomplete' ".
"and exe_cours_id = '$course_code'".' and session_id = '."'".(int)$_SESSION['id_session']."'";
$sql = "SELECT count(*) FROM $stat_table WHERE exe_exo_id = '$quizID'
AND exe_user_id = '$user_id'
AND status != 'incomplete'
AND orig_lp_id = $safe_lp_id
AND orig_lp_item_id = $safe_lp_item_id
AND exe_cours_id = '$course_code' AND session_id = '".(int)$_SESSION['id_session']."'";
$aquery = api_sql_query($sql, __FILE__, __LINE__);
$attempt = Database::fetch_array($aquery);
@ -1023,13 +1026,11 @@ else
//if($questionNum < 2){
if($table_recorded_not_exist){
if($exerciseType == 2){
api_sql_query('INSERT INTO '.$stat_table.' ' .
'(exe_exo_id,exe_user_id,exe_cours_id,status,session_id,data_tracking,start_date) ' .
'VALUES ' .
'('."'$exerciseId','".api_get_user_id()."','".$_course['id']."','incomplete','".api_get_session_id()."','".implode(',',$questionList)."','".date('Y-m-d H:i:s')."'".') ',__FILE__,__LINE__);
api_sql_query("INSERT INTO $stat_table(exe_exo_id,exe_user_id,exe_cours_id,status,session_id,data_tracking,start_date,orig_lp_id,orig_lp_item_id)
VALUES('$exerciseId','".api_get_user_id()."','".$_course['id']."','incomplete','".api_get_session_id()."','".implode(',',$questionList)."','".date('Y-m-d H:i:s')."',$safe_lp_id,$safe_lp_item_id)",__FILE__,__LINE__);
} else {
api_sql_query("INSERT INTO $stat_table (exe_exo_id,exe_user_id,exe_cours_id,status,session_id,start_date)
VALUES('$exerciseId','".api_get_user_id()."','".$_course['id']."','incomplete','".api_get_session_id()."','".date('Y-m-d H:i:s')."')",__FILE__,__LINE__);
api_sql_query("INSERT INTO $stat_table (exe_exo_id,exe_user_id,exe_cours_id,status,session_id,start_date,orig_lp_id,orig_lp_item_id)
VALUES('$exerciseId','".api_get_user_id()."','".$_course['id']."','incomplete','".api_get_session_id()."','".date('Y-m-d H:i:s')."',$safe_lp_id,$safe_lp_item_id)",__FILE__,__LINE__);
}
}
endif;

@ -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 16751 2008-11-14 21:41:05Z juliomontoya $
* @version $Id: exercise_result.php 17484 2008-12-30 21:47:26Z cfasanando $
*
* @todo split more code up in functions, move functions to library?
*/
@ -1081,8 +1081,9 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
if($_configuration['tracking_enabled'])
{
// Updates the empty exercise
//update_event_exercice($exeId, $objExercise->selectId(),$totalScore,$totalWeighting,$answer,$question_id);
update_event_exercice($exeId, $objExercise->selectId(),$totalScore,$totalWeighting,api_get_session_id());
$safe_lp_id = $learnpath_id==''?0:(int)$learnpath_id;
$safe_lp_item_id = $learnpath_item_id==''?0:(int)$learnpath_item_id;
update_event_exercice($exeId, $objExercise->selectId(),$totalScore,$totalWeighting,api_get_session_id(),$safe_lp_id,$safe_lp_item_id);
}
if($objExercise->results_disabled)

@ -1,4 +1,4 @@
<?php // $Id: events.lib.inc.php 17317 2008-12-16 14:05:45Z cfasanando $
<?php // $Id: events.lib.inc.php 17484 2008-12-30 21:47:26Z cfasanando $
/* See license terms in /dokeos_license.txt */
/**
==============================================================================
@ -418,11 +418,13 @@ function event_link($link_id)
* @param result ( score @ exercice )
* @param weighting ( higher score )
* @param session_id
* @param learnpath_id (id of the learnpath)
* @param learnpath_item_id (id of the learnpath_item)
* @author Sebastien Piraux <piraux_seb@hotmail.com>
* @author Julio Montoya <gugli100@gmail.com>
* @desc Record result of user when an exercice was done
*/
function update_event_exercice($exeid,$exo_id, $score, $weighting,$session_id)
function update_event_exercice($exeid,$exo_id, $score, $weighting,$session_id,$learnpath_id=0,$learnpath_item_id=0)
{
if ($exeid!='')
{
@ -433,6 +435,8 @@ function update_event_exercice($exeid,$exo_id, $score, $weighting,$session_id)
exe_result = '".$score."',
exe_weighting = '".$weighting."',
session_id = '".$session_id."',
orig_lp_id = '".$learnpath_id."',
orig_lp_item_id = '".$learnpath_item_id."',
exe_date= FROM_UNIXTIME(".$reallyNow."),status = '', data_tracking='',start_date ='".$_SESSION['exercice_start_date']."'
WHERE exe_id = '".$exeid."'";
$res = @api_sql_query($sql,__FILE__,__LINE__);

@ -395,10 +395,10 @@ class Tracking {
';
$rsScores = api_sql_query($sql, __FILE__, __LINE__);
// Real max score - this was implemented because of the random exercises
$sql_last_attempt = 'SELECT exe_id FROM '. $tbl_stats_exercices. ' ' .
'WHERE exe_exo_id="' .$item['path']. '" AND exe_user_id="' . $student_id . '" AND exe_cours_id="' . $course_code . '" ORDER BY exe_date DESC limit 1';
'WHERE exe_exo_id="' .$item['path']. '" AND exe_user_id="' . $student_id . '" AND orig_lp_id = "'.$a_learnpath['id'].'" AND orig_lp_item_id = "'.$item['item_id'].'" AND exe_cours_id="' . $course_code . '" ORDER BY exe_date DESC limit 1';
$resultLastAttempt = api_sql_query($sql_last_attempt, __FILE__, __LINE__);
$num = Database :: num_rows($resultLastAttempt);

@ -110,6 +110,8 @@ ALTER TABLE track_e_exercices ADD start_date datetime NOT NULL default '0000-00-
ALTER TABLE track_e_exercices ADD steps_counter SMALLINT UNSIGNED NOT NULL default 0;
ALTER TABLE track_e_exercices ADD session_id SMALLINT UNSIGNED NOT NULL default 0;
ALTER TABLE track_e_exercices ADD INDEX ( session_id ) ;
ALTER TABLE track_e_exercices ADD orig_lp_id int NOT NULL default 0;
ALTER TABLE track_e_exercices ADD orig_lp_item_id int NOT NULL default 0;
CREATE TABLE track_e_attempt (
exe_id int default NULL,

@ -60,7 +60,8 @@ ALTER TABLE track_e_exercices ADD INDEX ( session_id ) ;
CREATE TABLE track_e_attempt_recording (exe_id int unsigned NOT NULL, question_id int unsigned NOT NULL, marks int NOT NULL, insert_date datetime NOT NULL default '0000-00-00 00:00:00', author int unsigned NOT NULL, teacher_comment text NOT NULL);
ALTER TABLE track_e_attempt_recording ADD INDEX (exe_id);
ALTER TABLE track_e_hotspot CHANGE hotspot_coordinate hotspot_coordinate text NOT NULL;
ALTER TABLE track_e_exercices ADD orig_lp_id int NOT NULL default 0;
ALTER TABLE track_e_exercices ADD orig_lp_item_id int NOT NULL default 0;
-- xxUSERxx
-- xxCOURSExx

@ -1,4 +1,4 @@
<?php //$Id: myStudents.php 17481 2008-12-29 23:12:00Z cfasanando $
<?php //$Id: myStudents.php 17484 2008-12-30 21:47:26Z cfasanando $
/* For licensing terms, see /dokeos_license.txt */
/**
* Implements the tracking of students in the Reporting pages
@ -754,6 +754,8 @@ if(!empty($_GET['student']))
FROM $tbl_stats_exercices AS ex
WHERE ex.exe_cours_id = '".$a_infosCours['code']."'
AND ex.exe_exo_id = ".$a_exercices['id']."
AND orig_lp_id = 0
AND orig_lp_item_id = 0
AND exe_user_id='".$_GET["student"]."'"
;
$resultEssais = api_sql_query($sqlEssais,__FILE__,__LINE__);
@ -764,6 +766,8 @@ if(!empty($_GET['student']))
WHERE exe_user_id = ".$_GET['student']."
AND exe_cours_id = '".$a_infosCours['code']."'
AND exe_exo_id = ".$a_exercices['id']."
AND orig_lp_id = 0
AND orig_lp_item_id = 0
ORDER BY exe_date DESC LIMIT 1";
$resultScore = api_sql_query($sqlScore,__FILE__,__LINE__);
@ -810,7 +814,7 @@ if(!empty($_GET['student']))
<td align='center'>
";
$sql_last_attempt='SELECT exe_id FROM '.$tbl_stats_exercices.' WHERE exe_exo_id="'.$a_exercices['id'].'" AND exe_user_id="'.$_GET['student'].'" AND exe_cours_id="'.$a_infosCours['code'].'" ORDER BY exe_date DESC LIMIT 1';
$sql_last_attempt='SELECT exe_id FROM '.$tbl_stats_exercices.' WHERE exe_exo_id="'.$a_exercices['id'].'" AND exe_user_id="'.$_GET['student'].'" AND exe_cours_id="'.$a_infosCours['code'].'" AND orig_lp_id = 0 AND orig_lp_item_id = 0 ORDER BY exe_date DESC LIMIT 1';
$resultLastAttempt = api_sql_query($sql_last_attempt,__FILE__,__LINE__);
if(Database::num_rows($resultLastAttempt)>0)
{

@ -213,15 +213,15 @@ foreach ($list as $my_item_id) {
if (empty ($title)) {
$title = rl_get_resource_name(api_get_course_id(), $lp_id, $row['myid']);
}
if ($row['item_type'] != 'dokeos_chapter') {
$correct_test_link = array ();
if ($row['item_type'] == 'quiz')
{
if ($origin != 'tracking') {
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . api_get_user_id() . '" AND exe_cours_id="' . $course_code . '" ORDER BY exe_date DESC limit 1';
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . api_get_user_id() . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" ORDER BY exe_date DESC limit 1';
} else {
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $_GET['student_id'] . '" AND exe_cours_id="' . $course_code . '" ORDER BY exe_date DESC limit 1';
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $_GET['student_id'] . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" ORDER BY exe_date DESC limit 1';
}
$resultLastAttempt = api_sql_query($sql_last_attempt, __FILE__, __LINE__);
@ -420,9 +420,9 @@ foreach ($list as $my_item_id) {
// selecting the exe_id from stats attempts tables in order to look the max score value
if ($origin != 'tracking') {
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . api_get_user_id() . '" AND exe_cours_id="' . $course_code . '" ORDER BY exe_date DESC limit 1';
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . api_get_user_id() . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" ORDER BY exe_date DESC limit 1';
} else {
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $_GET['student_id'] . '" AND exe_cours_id="' . $course_code . '" ORDER BY exe_date DESC limit 1';
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $_GET['student_id'] . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" ORDER BY exe_date DESC limit 1';
}
$resultLastAttempt = api_sql_query($sql_last_attempt, __FILE__, __LINE__);
@ -500,9 +500,9 @@ foreach ($list as $my_item_id) {
$correct_test_link = '';
if ($origin != 'tracking' && $origin != 'tracking_course') {
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . api_get_user_id() . '" AND exe_cours_id="' . $course_code . '" ORDER BY exe_date ASC';
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . api_get_user_id() . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" ORDER BY exe_date ASC';
} else {
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . Database :: escape_string($_GET['student_id']) . '" AND exe_cours_id="' . Database :: escape_string($_GET['course']) . '" ORDER BY exe_date';
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . Database :: escape_string($_GET['student_id']) . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . Database :: escape_string($_GET['course']) . '" ORDER BY exe_date';
}
$resultLastAttempt = api_sql_query($sql_last_attempt, __FILE__, __LINE__);

Loading…
Cancel
Save