Adding orig_lp_item_view_id in the track_e_exercises see #1334

Cleaning exercise_show.php, exercise_submit.php files
skala
Julio Montoya 15 years ago
parent 5f09391ccc
commit 8874d44634
  1. 233
      main/exercice/exercice.php
  2. 26
      main/exercice/exercice_submit.php
  3. 14
      main/exercice/exercise.class.php
  4. 13
      main/exercice/exercise.lib.php
  5. 26
      main/exercice/exercise_result.php
  6. 89
      main/exercice/exercise_show.php
  7. 110
      main/inc/lib/events.lib.inc.php
  8. 1
      main/install/db_stats.sql
  9. 2
      main/install/migrate-db-1.8.7-1.8.8-pre.sql
  10. 8
      main/newscorm/blank.php
  11. 16782
      main/newscorm/learnpath.class.php
  12. 4848
      main/newscorm/learnpathItem.class.php
  13. 4
      main/newscorm/lp_stats.php
  14. 58
      main/newscorm/lp_view.php

@ -128,11 +128,18 @@ if ($_GET['delete'] == 'delete' && ($is_allowedToEdit || api_is_coach()) && !emp
}
if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_GET['exeid']== strval(intval($_GET['exeid']))) {
$id = intval($_GET['exeid']); //filtered by post-condition
$id = intval($_GET['exeid']); //filtered by post-condition
$track_exercise_info = get_exercise_track_exercise_info($id);
if (empty($track_exercise_info)) {
api_not_allowed();
}
$test = $track_exercise_info['title'];
$my_user_id = $track_exercise_info['exe_user_id'];
$user_info = api_get_user_info($my_user_id);
$student_id = $track_exercise_info['exe_user_id'];
$lp_id = $track_exercise_info['orig_lp_id'];
$lp_item_id = $track_exercise_info['orig_lp_item_id'];
$lp_item_view_id = $track_exercise_info['orig_lp_item_view_id'];
$user_info = api_get_user_info($student_id);
$emailid = $user_info['mail'];
@ -159,7 +166,7 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit
} else {
$array_content_id_exe=$post_content_id;
}
var_dump($_POST);
for ($i=0;$i<$loop_in_track;$i++) {
$my_marks = Database::escape_string($_POST['marks_'.$array_content_id_exe[$i]]);
$contain_comments = Database::escape_string($_POST['comments_'.$array_content_id_exe[$i]]);
@ -175,83 +182,25 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit
$query = "UPDATE $TBL_TRACK_ATTEMPT SET marks = '$my_marks',teacher_comment = '$my_comments'
WHERE question_id = '".$my_questionid."' AND exe_id='".$id."'";
Database::query($query);
$qry = 'SELECT sum(marks) as tot FROM '.$TBL_TRACK_ATTEMPT.' WHERE exe_id = '.$id.' GROUP BY question_id';
//Not necessary to update the weight
/*
$qry = 'SELECT sum(marks) as tot FROM '.$TBL_TRACK_ATTEMPT.' WHERE exe_id = '.$id;
$res = Database::query($qry);
$tot = Database::result($res,0,'tot');
$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)."'
$totquery = "UPDATE $TBL_TRACK_EXERCICES SET exe_result = '".intval($tot)."', exe_weighting = '".Database::escape_string($total_weighting)."'
WHERE exe_Id='".$id."'";
Database::query($totquery);
*/
//@todo Why we insert this?
$recording_changes = 'INSERT INTO '.$TBL_TRACK_ATTEMPT_RECORDING.' (exe_id, question_id, marks, insert_date, author, teacher_comment) VALUES
('."'$id','".$my_questionid."','$my_marks','".api_get_utc_datetime()."','".api_get_user_id()."'".',"'.$my_comments.'")';
Database::query($recording_changes);
}
$post_content_id=array();
$array_content_id_exe=array();
/*foreach ($_POST as $key => $v) {
$keyexp = explode('_', $key);
$id = Database :: escape_string($id);
$v = Database :: escape_string($v);
$my_questionid = Database :: escape_string($keyexp[1]);
if ($keyexp[0] == "marks") {
$sql = "SELECT question from $TBL_QUESTIONS WHERE id = '$my_questionid'";
$result = Database::query($sql);
$ques_name = Database :: result($result, 0, "question");
$query = "UPDATE $TBL_TRACK_ATTEMPT SET marks = '" . $v . "'
WHERE question_id = '" . $my_questionid . "'
AND exe_id='" . $id . "'";
Database::query($query);
$qry = 'SELECT sum(marks) as tot
FROM ' . $TBL_TRACK_ATTEMPT . ' WHERE exe_id = ' . intval($id) . '
GROUP BY question_id';
$res = Database::query($qry);
$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) . "'";
Database::query($totquery);
$recording_changes = 'INSERT INTO ' . $TBL_RECORDING . ' ' .
'(exe_id,
question_id,
marks,
insert_date,
author)
VALUES
(' . "'$id','" . $my_questionid . "','$v','" . date('Y-m-d H:i:s') . "','" . api_get_user_id() . "'" . ')';
Database::query($recording_changes);
} else {
$query = "UPDATE $TBL_TRACK_ATTEMPT SET teacher_comment = '" . $v . "'
WHERE question_id = '" . $my_questionid . "'
AND exe_id = '" . $id . "'";
Database::query($query);
$recording_changes = 'INSERT INTO ' . $TBL_RECORDING . ' ' .
'(exe_id,
question_id,
teacher_comment,
insert_date,
author)
VALUES
(' . "'$id','" . $my_questionid . "','$v','" . date('Y-m-d H:i:s') . "','" . api_get_user_id() . "'" . ')';
Database::query($recording_changes);
}
}*/
$qry = 'SELECT DISTINCT question_id, marks
FROM ' . $TBL_TRACK_ATTEMPT . ' where exe_id = ' . intval($id) . '
FROM ' . $TBL_TRACK_ATTEMPT . ' where exe_id = ' . $id . '
GROUP BY question_id';
$res = Database::query($qry);
@ -259,10 +208,11 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit
while ($row = Database :: fetch_array($res, 'ASSOC')) {
$tot += $row['marks'];
}
$totquery = "UPDATE $TBL_TRACK_EXERCICES SET exe_result = '" . Database :: escape_string($tot) . "' WHERE exe_Id='" . Database :: escape_string($id) . "'";
$totquery = "UPDATE $TBL_TRACK_EXERCICES SET exe_result = '" . intval($tot) . "' WHERE exe_id='" . $id . "'";
Database::query($totquery);
//search items
/*
if (isset($_POST['my_exe_exo_id']) && isset($_POST['student_id'])) {
$sql_lp='SELECT li.id as lp_item_id,li.lp_id,li.item_type,li.path,liv.id AS lp_view_id,liv.user_id,max(liv.view_count) AS view_count FROM '.$TBL_LP_ITEM.' li
INNER JOIN '.$TBL_LP_VIEW.' liv ON li.lp_id=liv.lp_id WHERE li.path="'.Database::escape_string($_POST['my_exe_exo_id']).'" AND li.item_type="quiz" AND user_id="'.Database::escape_string($_POST['student_id']).'" ';
@ -274,7 +224,7 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit
$rs_lp_view=Database::query($sql_lp_view);
}
}
Database::query($totquery);
Database::query($totquery);*/
$subject = get_lang('ExamSheetVCC');
$htmlmessage = '<html>' .
@ -329,78 +279,41 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit
//mail($emailid, $subject, $mess,$headers);
@api_mail_html($emailid, $emailid, $subject, $mess, $from_name, $from);
//Updating LP score here
if (in_array($origin, array ('tracking_course','user_course'))) {
if (isset ($_POST['lp_item_id']) && isset ($_POST['lp_item_view_id']) && isset ($_POST['student_id']) && isset ($_POST['total_score']) && isset ($_POST['total_time']) && isset ($_POST['totalWeighting'])) {
$lp_item_id = $_POST['lp_item_id'];
$lp_item_view_id = $_POST['lp_item_view_id'];
$student_id = $_POST['student_id'];
$totalWeighting = $_POST['totalWeighting'];
if ($lp_item_id == strval(intval($lp_item_id)) && $lp_item_view_id == strval(intval($lp_item_view_id)) && $student_id == strval(intval($student_id))) {
$score = Database :: escape_string($_POST['total_score']); //This is the new note
$total_time = Database :: escape_string($_POST['total_time']);
//I need the lp_item_view_id in order to update the record
//@todo add the lp_item_view_id in the track_exercise table in order to have a real match between the lp_item_view and the track_exercise
//$my_real_lp_item_view_id = Database :: escape_string($_POST['real_lp_item_view_id']);
$lp_item_id = Database :: escape_string($lp_item_id);
$lp_item_view_id = Database :: escape_string($lp_item_view_id);
$student_id = Database :: escape_string($student_id);
$totalWeighting = Database :: escape_string($totalWeighting);
/*
$sql = "SELECT (view_count) FROM $TBL_LP_ITEM_VIEW
WHERE lp_item_id = '" . (int) $lp_item_view_id . "' AND lp_view_id = $my_real_lp_item_view_id ORDER BY id DESC LIMIT 1";
$res_view_count = Database::query($sql);
$res_view_count = Database :: fetch_row($res_view_count);
$my_view_count = intval($res_view_count[0]);
*/
//Checking if this is the lastest attempt
$sql = "SELECT exe_id FROM $TBL_TRACK_EXERCICES
WHERE exe_user_id = '" . Database :: escape_string($_POST['student_id']) . "' AND exe_cours_id = '" . api_get_course_id() . "' AND orig_lp_id = '$lp_item_id' AND orig_lp_item_id = '$lp_item_view_id' AND session_id = '" . api_get_session_id() . "' AND status = ''
ORDER BY exe_id DESC LIMIT 1 ";
$res_view_count = Database::query($sql);
$res_view_count = Database :: fetch_row($res_view_count);
$my_view_count = intval($res_view_count[0]);
//Update lp_item_view if this attempts is the latest
$sql = "SELECT MAX(view_count) FROM $TBL_LP_ITEM_VIEW
WHERE lp_item_id = '" . (int) $lp_item_view_id . "' AND lp_view_id = (SELECT id from $TBL_LP_VIEW WHERE user_id = '" . (int) $student_id . "' and lp_id='" . (int) $lp_item_id . "')";
$res_max_view_count = Database::query($sql);
$row_max_view_count = Database :: fetch_row($res_max_view_count);
$max_view_count = intval($row_max_view_count[0]);
//Only update if is the last attempt
if ($my_view_count == $_GET['exeid']) {
// update score and total_time from last attempt when you qualify the exercise in Learning path detail
$sql_update_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = '" . intval($tot) . "' WHERE lp_item_id = '" . (int) $lp_item_view_id . "'
AND lp_view_id = (SELECT id from $TBL_LP_VIEW WHERE user_id = '" . (int) $student_id . "' and lp_id='" . (int) $lp_item_id . "') AND view_count = '$max_view_count'";
Database::query($sql_update_score);
}
/*
/*
// update score and total_time from last attempt when you qualify the exercise in Learning path detail
$sql_update_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = '" . (float) $score . "',total_time = '" . (int) $total_time . "' WHERE lp_item_id = '" . (int) $lp_item_view_id . "'
AND lp_view_id = (SELECT id from $TBL_LP_VIEW WHERE user_id = '" . (int) $student_id . "' and lp_id='" . (int) $lp_item_id . "') AND view_count = '$max_view_count'";
Database::query($sql_update_score);*/
// update max_score from a exercise in lp
//$sql_update_max_score = "UPDATE $TBL_LP_ITEM SET max_score = '" . (float) $totalWeighting . "' WHERE id = '" . (int) $lp_item_view_id . "'";
//Database::query($sql_update_max_score);
}
}
if ($origin == 'tracking_course' && !empty($_POST['lp_item_id'])) {
/*
* We do not need this because lp_item_view_id comes to the rescue
//Checking if this is the lastest attempt
$sql = "SELECT exe_id FROM $TBL_TRACK_EXERCICES
WHERE exe_user_id = '" . Database :: escape_string($_POST['student_id']) . "' AND exe_cours_id = '" . api_get_course_id() . "' AND orig_lp_id = '$lp_item_id' AND orig_lp_item_id = '$lp_item_view_id' AND session_id = '" . api_get_session_id() . "' AND status = ''
ORDER BY exe_id DESC LIMIT 1 ";
$res_view_count = Database::query($sql);
$res_view_count = Database :: fetch_row($res_view_count);
$my_view_count = intval($res_view_count[0]);
//Update lp_item_view if this attempts is the latest
$sql = "SELECT MAX(view_count) FROM $TBL_LP_ITEM_VIEW
WHERE lp_item_id = '" . (int) $lp_item_view_id . "' AND lp_view_id = (SELECT id from $TBL_LP_VIEW WHERE user_id = '" . (int) $student_id . "' and lp_id='" . (int) $lp_item_id . "')";
$res_max_view_count = Database::query($sql);
$row_max_view_count = Database :: fetch_row($res_max_view_count);
$max_view_count = intval($row_max_view_count[0]);
//Only update if is the last attempt
if ($my_view_count == $_GET['exeid']) {
// update score and total_time from last attempt when you qualify the exercise in Learning path detail
$sql_update_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = '" . intval($tot) . "' WHERE lp_item_id = '" . (int) $lp_item_view_id . "'
AND lp_view_id = (SELECT id from $TBL_LP_VIEW WHERE user_id = '" . (int) $student_id . "' and lp_id='" . (int) $lp_item_id . "') AND view_count = '$max_view_count'";
Database::query($sql_update_score);
}*/
$sql_update_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = '" . intval($tot) . "' WHERE id = " .$lp_item_view_id;
Database::query($sql_update_score);
if ($origin == 'tracking_course') {
//Redirect to the course detail in lp
header('location: ../mySpace/lp_tracking.php?course=' . Security :: remove_XSS($_GET['course']) . '&origin=' . $origin . '&lp_id=' . Security :: remove_XSS($_POST['lp_item_id']) . '&student_id=' . Security :: remove_XSS($_GET['student']).'&from='.Security::remove_XSS($_GET['from']));
header('location: ../mySpace/lp_tracking.php?course=' . api_get_course_id() . '&origin=' . $origin . '&my_lp_id=' . $lp_item_id . '&lp_id=' . $lp_id . '&student_id=' . $student_id.'&extend_attempt=1&from='.Security::remove_XSS($_GET['from']));
exit;
} else {
//Redirect to the reporting
@ -843,9 +756,9 @@ if ($show == 'test') {
if ($time_limits) {
// check if start time
$start_time = api_strtotime(api_get_local_time($row['start_time']));
$end_time = api_strtotime(api_get_local_time($row['end_time']));
$now = api_strtotime(api_get_local_time());
$start_time = api_strtotime($row['start_time'],'UTC');
$end_time = api_strtotime($row['end_time'], 'UTC');
$now = time();
$is_actived_time = false;
if ($now > $start_time && $end_time > $now ) {
@ -1302,13 +1215,11 @@ if ($_configuration['tracking_enabled'] && ($show == 'result')) {
} else {
if ($revised) {
//echo "<a href='exercise_show.php?dt=$dt&res=$res&id=$id'>" . get_lang('Show') . "</a> ";
$html_link.="<a href='exercise_show.php?".api_get_cidreq()."&dt=$dt&res=$res&id=$id'>" . get_lang('Show') . "</a> ";
$html_link.="<a href='exercise_show.php?".api_get_cidreq()."&id=$id'>" . get_lang('Show') . "</a> ";
} else {
// echo '&nbsp;' . get_lang('NoResult');
$html_link.='&nbsp;' . get_lang('NoResult');
}
}
$more_details_list = $html_link;
if ($is_allowedToEdit || $is_tutor) {
@ -1347,17 +1258,21 @@ if ($_configuration['tracking_enabled'] && ($show == 'result')) {
$parameters=array('cidReq'=>Security::remove_XSS($_GET['cidReq']),'show'=>Security::remove_XSS($_GET['show']),'filter' => Security::remove_XSS($_GET['filter']),'gradebook' =>Security::remove_XSS($_GET['gradebook']));
$table = new SortableTableFromArrayConfig($list_info, 1,20,'quiz_table');
$table->set_additional_parameters($parameters);
if (api_is_western_name_order()) {
$table->set_header(0, get_lang('FirstName'));
$table->set_header(1, get_lang('LastName'));
$secuence = 0;
} else {
$table->set_header(0, get_lang('LastName'));
$table->set_header(1, get_lang('FirstName'));
$secuence = 0;
}
$secuence = 2;
if ($is_allowedToEdit || $is_tutor) {
$secuence = 0;
if (api_is_western_name_order()) {
$table->set_header(0, get_lang('FirstName'));
$table->set_header(1, get_lang('LastName'));
} else {
$table->set_header(0, get_lang('LastName'));
$table->set_header(1, get_lang('FirstName'));
}
}
$table->set_header(-$secuence + 2, get_lang('Exercice'));
$table->set_header(-$secuence + 3, get_lang('Duration'),false);

@ -39,6 +39,8 @@ api_protect_course_script(true);
$is_allowedToEdit = api_is_allowed_to_edit(null,true);
//Blocking access in LPs
//This funcionality has been moved to the get_link function in the learnpath_class.php
/*
if ($origin == 'learnpath' && isset ($_GET['not_multiple_attempt']) && $_GET['not_multiple_attempt'] == strval(intval($_GET['not_multiple_attempt']))) {
$not_multiple_attempt = (int) $_GET['not_multiple_attempt'];
if ($not_multiple_attempt === 1) {
@ -47,7 +49,7 @@ if ($origin == 'learnpath' && isset ($_GET['not_multiple_attempt']) && $_GET['no
Display :: display_warning_message(get_lang('ReachedOneAttempt'));
exit;
}
}
}*/
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
//$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.corners.min.js" type="text/javascript"></script>'; //Not necessary to use jquery corner to do that effect use CSS3
@ -81,6 +83,9 @@ if (empty ($learnpath_id)) {
if (empty ($learnpath_item_id)) {
$learnpath_item_id = intval($_REQUEST['learnpath_item_id']);
}
if (empty ($learnpath_item_view_id)) {
$learnpath_item_view_id = intval($_REQUEST['learnpath_item_view_id']);
}
if (empty ($formSent)) {
$formSent = $_REQUEST['formSent'];
}
@ -116,7 +121,7 @@ $error = '';
// if the user has clicked on the "Cancel" button
if ($buttonCancel) {
// returns to the exercise list
header("Location: exercice.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id");
header("Location: exercice.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
exit;
}
if ($origin == 'builder') {
@ -151,11 +156,12 @@ if ($origin == 'builder') {
if (isset ($_SESSION['exerciseResultCoordinates'])) {
api_session_unregister('exerciseResultCoordinates');
unset ($exerciseResultCoordinates);
}
}
}
$safe_lp_id = ($learnpath_id == '') ? 0 : $learnpath_id;
$safe_lp_item_id = ($learnpath_item_id == '') ? 0 : $learnpath_item_id;
$safe_lp_item_view_id = ($learnpath_item_view_id == '') ? 0 : $learnpath_item_view_id;
// Loading the $objExercise variable
@ -193,7 +199,7 @@ $exerciseType = $objExercise->type;
$current_timestamp = time();
//Getting track exercise info
$exercise_stat_info = $objExercise->get_stat_track_exercise_info($safe_lp_id, $safe_lp_item_id);
$exercise_stat_info = $objExercise->get_stat_track_exercise_info($safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id);
if ($debug) {error_log('$objExercise->get_stat_track_exercise_info function called:: '.print_r($exercise_stat_info, 1)); };
/*
@ -385,10 +391,10 @@ if ($formSent) {
if ( api_is_allowed_to_session_edit() ) {
// goes to the script that will show the result of the exercise
if ($exerciseType == ALL_ON_ONE_PAGE) {
header("Location: exercise_result.php?exerciseType=$exerciseType&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id");
header("Location: exercise_result.php?exerciseType=$exerciseType&origin=$origin&learnpath_id=$safe_lp_id&learnpath_item_id=$safe_lp_item_id&learnpath_item_view_id=$safe_lp_item_view_id");
exit;
} else {
if ($exe_id != '') {
if (!empty($exe_id) && is_numeric($exe_id)) {
//Verify if the current test is fraudulent
if (exercise_time_control_is_valid($exerciseId)) {
$sql_exe_result = "";
@ -397,11 +403,11 @@ if ($formSent) {
}
//Clean incomplete - @todo why setting to blank the data_tracking?
//$update_query = 'UPDATE ' . $stat_table . ' SET ' . "status = '', data_tracking='', exe_date = '" . api_get_utc_datetime() . "' $sql_exe_result " . ' WHERE exe_id = ' . Database::escape_string($exe_id);
$update_query = 'UPDATE ' . $stat_table . ' SET ' . "status = '', exe_date = '" . api_get_utc_datetime() . "' $sql_exe_result " . ' WHERE exe_id = ' . Database::escape_string($exe_id);
$update_query = "UPDATE $stat_table SET status = '', exe_date = '".api_get_utc_datetime() ."' , orig_lp_item_view_id = '$safe_lp_item_view_id' $sql_exe_result WHERE exe_id = ".$exe_id;
if ($debug) {error_log($update_query);};
Database::query($update_query);
}
header("Location: exercise_show.php?id=$exe_id&exerciseType=$exerciseType&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id");
header("Location: exercise_show.php?id=$exe_id&exerciseType=$exerciseType&origin=$origin&learnpath_id=$safe_lp_id&learnpath_item_id=$safe_lp_item_id&learnpath_item_view_id=$safe_lp_item_view_id");
exit;
}
} else {
@ -497,7 +503,7 @@ echo "<h2>" . $exerciseTitle . "</h2>";
$show_clock = true;
$user_id = api_get_user_id();
if ($objExercise->selectAttempts() > 0) {
$attempt_count = get_attempt_count($user_id, $exerciseId, $safe_lp_id, $safe_lp_item_id);
$attempt_count = get_attempt_count($user_id, $exerciseId, $safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id);
if ($attempt_count >= $objExercise->selectAttempts()) {
$show_clock = false;
if (!api_is_allowed_to_edit(null,true)) {
@ -648,7 +654,7 @@ if (!empty ($error)) {
}
if ($_configuration['live_exercise_tracking'] && $objExercise->feedbacktype != EXERCISE_FEEDBACK_TYPE_DIRECT) {
if (empty($exercise_stat_info)) {
$objExercise->save_stat_track_exercise_info($clock_expired_time, $safe_lp_id, $safe_lp_item_id,$questionList);
$objExercise->save_stat_track_exercise_info($clock_expired_time, $safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id, $questionList);
}
}
if ($origin != 'learnpath') {

@ -1354,7 +1354,7 @@ class Exercise {
$new_answer_obj->read();
$new_answer_obj->duplicate($new_id);
}
}
}
/**
* Changes the exercise id
@ -1374,20 +1374,24 @@ class Exercise {
$this->active = $status;
}
public function get_stat_track_exercise_info($lp_id = 0, $lp_item_id = 0) {
public function get_stat_track_exercise_info($lp_id = 0, $lp_item_id = 0, $lp_item_view_id = 0) {
$track_exercises = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
if (empty($lp_id)) {
$lp_id = 0;
}
if (empty($lp_item_id)) {
$lp_item_id = 0;
}
}
if (empty($lp_item_view_id)) {
$lp_item_view_id = 0;
}
$condition = ' WHERE exe_exo_id = ' . "'" . $this->id . "'" .' AND
exe_user_id = ' . "'" . api_get_user_id() . "'" . ' AND
exe_cours_id = ' . "'" . api_get_course_id() . "'" . ' AND
status = ' . "'incomplete'" . ' AND
orig_lp_id = ' . "'" . $lp_id . "'" . ' AND
orig_lp_item_id = ' . "'" . $lp_item_id . "'" . ' AND
orig_lp_item_id = ' . "'" . $lp_item_id . "'" . ' AND
orig_lp_item_view_id = ' . "'" . $lp_item_view_id . "'" . ' AND
session_id = ' . "'" . api_get_session_id() . "' LIMIT 1"; //Adding limit 1 just in case
$sql_track = 'SELECT * FROM '.$track_exercises.$condition;
@ -1401,7 +1405,7 @@ class Exercise {
}
public function save_stat_track_exercise_info($clock_expired_time = 0, $safe_lp_id = 0, $safe_lp_item_id = 0, $questionList = array()) {
public function save_stat_track_exercise_info($clock_expired_time = 0, $safe_lp_id = 0, $safe_lp_item_id = 0, $safe_lp_item_view_id = 0, $questionList = array()) {
$track_exercises = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
if (empty($safe_lp_id)) {

@ -541,11 +541,14 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
function get_exercise_track_exercise_info($exe_id) {
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$sql_fb_type='SELECT * FROM '.$TBL_EXERCICES.' as e INNER JOIN '.$TBL_TRACK_EXERCICES.' as te ON (e.id=te.exe_exo_id) WHERE te.exe_id='.Database::escape_string($exe_id);
$res_fb_type=Database::query($sql_fb_type);
$row_fb_type=Database::fetch_array($res_fb_type, 'ASSOC');
return $row_fb_type;
$exe_id = intval($exe_id);
$result = array();
if (!empty($exe_id)) {
$sql_fb_type = 'SELECT * FROM '.$TBL_EXERCICES.' as e INNER JOIN '.$TBL_TRACK_EXERCICES.' as te ON (e.id=te.exe_exo_id) WHERE te.exe_id='.$exe_id;
$res_fb_type = Database::query($sql_fb_type);
$result = Database::fetch_array($res_fb_type, 'ASSOC');
}
return $result;
}

@ -21,14 +21,14 @@ require_once 'question.class.php';
require_once 'answer.class.php';
if ($_GET['origin']=='learnpath') {
require_once ('../newscorm/learnpath.class.php');
require_once ('../newscorm/learnpathItem.class.php');
require_once ('../newscorm/scorm.class.php');
require_once ('../newscorm/scormItem.class.php');
require_once ('../newscorm/aicc.class.php');
require_once ('../newscorm/aiccItem.class.php');
require_once '../newscorm/learnpath.class.php';
require_once '../newscorm/learnpathItem.class.php';
require_once '../newscorm/scorm.class.php';
require_once '../newscorm/scormItem.class.php';
require_once '../newscorm/aicc.class.php';
require_once '../newscorm/aiccItem.class.php';
}
global $_cid;
// name of the language file that needs to be included
$language_file='exercice';
@ -63,11 +63,15 @@ if ( empty ( $origin ) ) {
$origin = Security::remove_XSS($_REQUEST['origin']);
}
if ( empty ( $learnpath_id ) ) {
$learnpath_id = Security::remove_XSS($_REQUEST['learnpath_id']);
$learnpath_id = intval($_REQUEST['learnpath_id']);
}
if ( empty ( $learnpath_item_id ) ) {
$learnpath_item_id = Security::remove_XSS($_REQUEST['learnpath_item_id']);
$learnpath_item_id = intval($_REQUEST['learnpath_item_id']);
}
if ( empty ( $learnpath_item_view_id ) ) {
$learnpath_item_view_id = intval($_REQUEST['learnpath_item_view_id']);
}
if ( empty ( $formSent ) ) {
$formSent = $_REQUEST['formSent'];
}
@ -341,6 +345,7 @@ $exerciseTitle=text_filter($exerciseTitle);
<input type="hidden" name="origin" value="<?php echo $origin; ?>" />
<input type="hidden" name="learnpath_id" value="<?php echo $learnpath_id; ?>" />
<input type="hidden" name="learnpath_item_id" value="<?php echo $learnpath_item_id; ?>" />
<input type="hidden" name="learnpath_item_view_id" value="<?php echo $learnpath_item_view_id; ?>" />
<?php
@ -915,9 +920,10 @@ if ($_configuration['tracking_enabled']) {
// Updates the empty exercise
$safe_lp_id = $learnpath_id==''?0:(int)$learnpath_id;
$safe_lp_item_id = $learnpath_item_id==''?0:(int)$learnpath_item_id;
$safe_lp_item_view_id = $learnpath_item_view_id==''?0:(int)$learnpath_item_view_id;
$quizDuration = (!empty($_SESSION['quizStartTime']) ? time() - $_SESSION['quizStartTime'] : 0);
if (api_is_allowed_to_session_edit() ) {
update_event_exercice($exeId, $objExercise->selectId(),$totalScore,$totalWeighting,api_get_session_id(),$safe_lp_id,$safe_lp_item_id,$quizDuration);
update_event_exercice($exeId, $objExercise->selectId(),$totalScore, $totalWeighting,api_get_session_id(),$safe_lp_id,$safe_lp_item_id,$safe_lp_item_view_id, $quizDuration);
}
}

@ -51,12 +51,6 @@ if($debug>0) {
}
// general parameters passed via POST/GET
if ( empty ( $learnpath_id ) ) {
$learnpath_id = $_REQUEST['learnpath_id'];
}
if ( empty ( $learnpath_item_id ) ) {
$learnpath_item_id = $_REQUEST['learnpath_item_id'];
}
if ( empty ( $formSent ) ) {
$formSent= $_REQUEST['formSent'];
}
@ -92,26 +86,52 @@ if ( empty ( $action ) ) {
$current_time = time();
$emailId = $_REQUEST['email'];
$id = $_REQUEST['id'];
$id = $_REQUEST['id']; //exe id
if (empty($id)) {
api_not_allowed();
}
$is_allowedToEdit=api_is_allowed_to_edit(null,true) || $is_courseTutor;
//Getting results
$track_exercise_info = get_exercise_track_exercise_info($id);
$exercise_id = $track_exercise_info['id'];
$course_code = api_get_course_id();
//No track info
if (empty($track_exercise_info)) {
api_not_allowed();
}
$exercise_id = $track_exercise_info['id'];
$student_id = $track_exercise_info['exe_user_id'];
$learnpath_id = $track_exercise_info['orig_lp_id'];
$learnpath_item_id = $track_exercise_info['orig_lp_item_id'];
$lp_item_view_id = $track_exercise_info['orig_lp_item_view_id'];
$course_code = api_get_course_id();
//Check if user can see the results
if (!$is_allowedToEdit) {
$current_user_id = api_get_user_id();
if ($student_id != $current_user_id) {
api_not_allowed();
}
}
if (!exercise_time_control_is_valid($exercise_id)) {
$sql_fraud = "UPDATE $TBL_TRACK_ATTEMPT SET answer = 0, marks=0, position=0 WHERE exe_id = '{$track_exercise_info['exe_id']}' ";
$sql_fraud = "UPDATE $TBL_TRACK_ATTEMPT SET answer = 0, marks=0, position=0 WHERE exe_id = $id ";
Database::query($sql_fraud);
}
//Unset session for clock time
exercise_time_control_delete($exercise_id);
$is_allowedToEdit=api_is_allowed_to_edit(null,true) || $is_courseTutor;
$nameTools=get_lang('CorrectTest');
if (isset($_SESSION['gradebook'])) {
$gradebook= $_SESSION['gradebook'];
$gradebook= Security::remove_XSS($_SESSION['gradebook']);
}
if (!empty($gradebook) && $gradebook=='view') {
@ -120,14 +140,14 @@ if (!empty($gradebook) && $gradebook=='view') {
$fromlink = '';
if($origin=='user_course') {
$interbreadcrumb[] = array ("url" => "../user/user.php?cidReq=".Security::remove_XSS($_GET['course']), "name" => get_lang("Users"));
$interbreadcrumb[] = array("url" => "../mySpace/myStudents.php?student=".Security::remove_XSS($_GET['student'])."&course=".$_course['id']."&details=true&origin=".Security::remove_XSS($_GET['origin']) , "name" => get_lang("DetailsStudentInCourse"));
$interbreadcrumb[] = array("url" => "../mySpace/myStudents.php?student=".$student_id."&course=".$_course['id']."&details=true&origin=".Security::remove_XSS($_GET['origin']) , "name" => get_lang("DetailsStudentInCourse"));
} else if($origin=='tracking_course') {
//$interbreadcrumb[] = array ("url" => "../mySpace/index.php", "name" => get_lang('MySpace'));
//$interbreadcrumb[] = array ("url" => "../mySpace/myStudents.php?student=".Security::remove_XSS($_GET['student']).'&details=true&origin='.$origin.'&course='.Security::remove_XSS($_GET['cidReq']), "name" => get_lang("DetailsStudentInCourse"));
//$interbreadcrumb[] = array ("url" => "../mySpace/myStudents.php?student=".Security::remove_XSS($student_id).'&details=true&origin='.$origin.'&course='.Security::remove_XSS($_GET['cidReq']), "name" => get_lang("DetailsStudentInCourse"));
$interbreadcrumb[] = array ("url" => api_get_path(WEB_COURSE_PATH).$_course['directory'], 'name' => $_course['title']);
$interbreadcrumb[] = array ("url" => "../tracking/courseLog.php?cidReq=".$cidReq.'&studentlist=true&id_session='.$_SESSION['id_session'], "name" => get_lang("Tracking"));
$interbreadcrumb[] = array ("url" => "../mySpace/myStudents.php?student=".Security::remove_XSS($_GET['student']).'&details=true&origin='.$origin.'&course='.Security::remove_XSS($_GET['cidReq']), "name" => get_lang("DetailsStudentInCourse"));
$interbreadcrumb[] = array ("url" => "../mySpace/lp_tracking.php?action=stats&course=".$cidReq."&student_id=".Security::remove_XSS($_GET['student'])."&lp_id=".Security::remove_XSS($_GET['my_lp_id'])."&origin=".Security::remove_XSS($_GET['origin']) , "name" => get_lang("LearningPathDetails"));
$interbreadcrumb[] = array ("url" => "../mySpace/myStudents.php?student=".$student_id.'&details=true&origin='.$origin.'&course='.Security::remove_XSS($_GET['cidReq']), "name" => get_lang("DetailsStudentInCourse"));
$interbreadcrumb[] = array ("url" => "../mySpace/lp_tracking.php?action=stats&course=".$cidReq."&student_id=".$student_id."&lp_id=".Security::remove_XSS($_GET['my_lp_id'])."&origin=".Security::remove_XSS($_GET['origin']) , "name" => get_lang("LearningPathDetails"));
$from_myspace = false;
if (isset ($_GET['from']) && $_GET['from'] == 'myspace') {
@ -238,24 +258,26 @@ if($num>1) {
<?php
$show_results = true;
// Avoiding the "Score 0/0" message when the exe_id is not set
if (!empty($track_exercise_info)) {
if (!empty($track_exercise_info)) {
$exerciseTitle = text_filter($track_exercise_info['title']);
$exerciseDescription = $track_exercise_info['description'];
// if the results_disabled of the Quiz is 1 when block the script
$result_disabled = $track_exercise_info['results_disabled'];
if (!(api_is_platform_admin() || api_is_course_admin()) ) {
if ($result_disabled==1) {
if ($result_disabled == 1) {
//api_not_allowed();
$show_results = false;
//Display::display_warning_message(get_lang('CantViewResults'));
if ($origin!='learnpath') {
if ($origin != 'learnpath') {
Display::display_warning_message(get_lang('ThankYouForPassingTheTest').'<br /><br /><a href="exercice.php">'.(get_lang('BackToExercisesList')).'</a>', false);
echo '</td>
</tr>
</table>';
}
}
}
} else {
Display::display_warning_message(get_lang('CantViewResults'));
@ -264,6 +286,7 @@ if (!empty($track_exercise_info)) {
</tr>
</table>';
}
if ($origin == 'learnpath' && !isset($_GET['fb_type']) ) {
$show_results = false;
}
@ -1012,20 +1035,19 @@ if (is_array($arrid) && is_array($arrmarks)) {
if ($is_allowedToEdit) {
if (in_array($origin, array('tracking_course','user_course'))) {
echo ' <form name="myform" id="myform" action="exercice.php?show=result&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">';
echo ' <form name="myform" id="myform" action="exercice.php?show=result&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">';
echo ' <input type = "hidden" name="totalWeighting" value="'.$totalWeighting.'">';
if (isset($_GET['myid']) && isset($_GET['my_lp_id']) && isset($_GET['student'])) {
?>
<input type = "hidden" name="lp_item_id" value="<?php echo Security::remove_XSS($_GET['myid']); ?>">
<input type = "hidden" name="lp_item_view_id" value="<?php echo Security::remove_XSS($_GET['my_lp_id']); ?>">
<input type = "hidden" name="student_id" value="<?php echo Security::remove_XSS($_GET['student']);?>">
<input type = "hidden" name="total_score" value="<?php echo $totalScore; ?>">
<input type = "hidden" name="total_time" value="<?php echo Security::remove_XSS($_GET['total_time']);?>">
<input type = "hidden" name="my_exe_exo_id" value="<?php echo Security::remove_XSS($_GET['my_exe_exo_id']); ?>">
<?php
if (!empty($learnpath_id) && !empty($_GET['my_lp_id']) && isset($_GET['student'])) {
echo '<input type = "hidden" name="lp_item_id" value="'.$lp_id.'">';
echo '<input type = "hidden" name="lp_item_view_id" value="'.$lp_item_view_id.'">';
echo '<input type = "hidden" name="student_id" value="'.$student_id.'">';
echo '<input type = "hidden" name="total_score" value="'.$totalScore.'"> ';
//echo '<input type = "hidden" name="total_time" value="'.Security::remove_XSS($_GET['total_time']).'"> ';
echo '<input type = "hidden" name="my_exe_exo_id" value="'.$exercise_id.'"> ';
}
} else {
echo ' <form name="myform" id="myform" action="exercice.php?show=result&comments=update&exeid='.$id.'&totalWeighting='.$totalWeighting.'" method="post">';
echo ' <form name="myform" id="myform" action="exercice.php?show=result&filter=2&comments=update&exeid='.$id.'&totalWeighting='.$totalWeighting.'" method="post">';
}
if ($origin!='learnpath' && $origin!='student_progress') {
?>
@ -1034,8 +1056,10 @@ if ($is_allowedToEdit) {
<?php
}
}
if ($origin=='student_progress' && !isset($_GET['my_lp_id'])) {?>
<button type="button" class="back" onclick="window.back();" value="<?php echo get_lang('Back'); ?>" ><?php echo get_lang('Backs');?></button>
//Came from lpstats in a lp
if ($origin =='student_progress') {?>
<button type="button" class="back" onclick="window.back();" value="<?php echo get_lang('Back'); ?>" ><?php echo get_lang('Back');?></button>
<?php
} else if($origin=='myprogress') {
?>
@ -1064,6 +1088,7 @@ if ($origin != 'learnpath') {
ExerciseShowFunctions::send_notification($arrques, $arrans, $to);
}
Display::display_normal_message(get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu'));
echo '<br />';
}
}

@ -31,14 +31,12 @@ $TABLETRACK_DEFAULT = $_configuration['statistics_database'].".track_e_default"
* @author Sebastien Piraux <piraux_seb@hotmail.com>
* @desc Record information for open event (when homepage is opened)
*/
function event_open()
{
function event_open() {
global $_configuration;
global $TABLETRACK_OPEN;
// if tracking is disabled record nothing
if (!$_configuration['tracking_enabled'])
{
if (!$_configuration['tracking_enabled']) {
return 0;
}
@ -48,9 +46,7 @@ function event_open()
if(isset($_SERVER['HTT_REFERER']))
{
$referer = Database::escape_string($_SERVER['HTTP_REFERER']);
}
else
{
} else {
$referer = '';
}
// record informations only if user comes from another site
@ -79,8 +75,7 @@ function event_open()
* @desc Record information for login event
* (when an user identifies himself with username & password)
*/
function event_login()
{
function event_login() {
global $_configuration;
global $_user;
global $TABLETRACK_LOGIN;
@ -89,12 +84,12 @@ function event_login()
if (!$_configuration['tracking_enabled']) {
return 0;
}
$reallyNow = time();
$reallyNow = api_get_utc_datetime();
$sql = "INSERT INTO ".$TABLETRACK_LOGIN." (login_user_id, login_ip, login_date, logout_date)
VALUES ('".$_user['user_id']."',
'".Database::escape_string($_SERVER['REMOTE_ADDR'])."',
FROM_UNIXTIME(".$reallyNow."),
FROM_UNIXTIME(".$reallyNow.")
'".$reallyNow."',
'".$reallyNow."'
)";
$res = Database::query($sql);
}
@ -130,7 +125,7 @@ function event_access_course() {
VALUES
(".$user_id.",
'".$_cid."',
FROM_UNIXTIME(".$reallyNow."),
'".$reallyNow."',
'".$id_session."')";
$res = Database::query($sql);
// added for "what's new" notification
@ -161,8 +156,7 @@ function event_access_course() {
*
* Functionality for "what's new" notification is added by Toon Van Hoecke
*/
function event_access_tool($tool, $id_session=0)
{
function event_access_tool($tool, $id_session=0) {
global $_configuration;
// if tracking is disabled record nothing
// if( ! $_configuration['tracking_enabled'] ) return 0; //commented because "what's new" notification must always occur
@ -173,10 +167,10 @@ function event_access_tool($tool, $id_session=0)
global $_course;
global $TABLETRACK_LASTACCESS; //for "what's new" notification
$id_session = api_get_session_id();
$tool = Database::escape_string($tool);
$reallyNow = api_get_utc_datetime();
$user_id = $_user['user_id'] ? "'".$_user['user_id']."'" : "0"; // no one
$id_session = api_get_session_id();
$tool = Database::escape_string($tool);
$reallyNow = api_get_utc_datetime();
$user_id = $_user['user_id'] ? "'".$_user['user_id']."'" : "0"; // no one
// record information
// only if user comes from the course $_cid
//if( eregi($_configuration['root_web'].$_cid,$_SERVER['HTTP_REFERER'] ) )
@ -185,8 +179,7 @@ function event_access_tool($tool, $id_session=0)
// added for "what's new" notification
$pos2 = strpos(strtolower($_SERVER['HTTP_REFERER']), strtolower($_configuration['root_web']."index"));
// end "what's new" notification
if ($_configuration['tracking_enabled'] && ($pos !== false || $pos2 !== false)) {
if ($_configuration['tracking_enabled'] && ($pos !== false || $pos2 !== false)) {
$sql = "INSERT INTO ".$TABLETRACK_ACCESS."
(access_user_id,
access_cours_code,
@ -235,6 +228,7 @@ function event_download($doc_url) {
if (!$_configuration['tracking_enabled']) {
return 0;
}
$doc_url = Database::escape_string($doc_url);
$reallyNow = api_get_utc_datetime();
if ($_user['user_id']) {
@ -252,7 +246,7 @@ function event_download($doc_url) {
VALUES (
".$user_id.",
'".$_cid."',
'".htmlspecialchars($doc_url, ENT_QUOTES)."',
'".$doc_url."',
'".$reallyNow."',
'".api_get_session_id()."'
)";
@ -267,8 +261,7 @@ function event_download($doc_url) {
* used in the works tool to record informations when
* an user upload 1 work
*/
function event_upload($doc_id)
{
function event_upload($doc_id) {
global $_configuration;
global $_user;
global $_cid;
@ -321,16 +314,13 @@ function event_link($link_id) {
// anonymous
$user_id = "0";
}
$sql = "INSERT INTO ".$TABLETRACK_LINKS."
( links_user_id,
links_cours_id,
links_link_id,
links_date,
links_session_id
)
VALUES
(
) VALUES (
".$user_id.",
'".api_get_course_id()."',
'".Database::escape_string($link_id)."',
@ -355,12 +345,12 @@ function event_link($link_id) {
*
* @author Sebastien Piraux <piraux_seb@hotmail.com>
* @author Julio Montoya Armas <gugli100@gmail.com> Reworked 2010
* @desc Record result of user when an exercice was done
* @desc Record result of user when an exercice was done
*/
function update_event_exercice($exeid,$exo_id, $score, $weighting,$session_id,$learnpath_id=0,$learnpath_item_id=0, $duration) {
function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$learnpath_id=0, $learnpath_item_id=0, $learnpath_item_view_id = 0, $duration) {
if ($exeid!='') {
// Validation in case of fraud with actived control time
// Validation in case of fraud with actived control time
if (!exercise_time_control_is_valid($exo_id)) {
$score = 0;
}
@ -383,15 +373,21 @@ function update_event_exercice($exeid,$exo_id, $score, $weighting,$session_id,$l
session_id = '".Database::escape_string($session_id)."',
orig_lp_id = '".Database::escape_string($learnpath_id)."',
orig_lp_item_id = '".Database::escape_string($learnpath_item_id)."',
orig_lp_item_view_id = '".Database::escape_string($learnpath_item_view_id)."',
exe_duration = '".Database::escape_string($duration)."',
exe_date = ".api_get_utc_datetime().",
status = '',
data_tracking = '',
start_date = '".api_get_utc_datetime($start_date)."')
exe_date = '".api_get_utc_datetime()."',
status = '',
start_date = '".api_get_utc_datetime($start_date)."'
WHERE exe_id = '".Database::escape_string($exeid)."'";
$res = @Database::query($sql);
$res = @Database::query($sql);
//Deleting control time session track
exercise_time_control_delete($exo_id);
error_log('update_event_exercice');
error_log($sql);
return $res;
} else
return false;
}
@ -405,6 +401,7 @@ function update_event_exercice($exeid,$exo_id, $score, $weighting,$session_id,$l
*/
function create_event_exercice($exo_id) {
global $_user, $_configuration;
error_log('create_event_exercice');
$TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$reallyNow = time();
@ -414,7 +411,7 @@ function create_event_exercice($exo_id) {
// anonymous
$user_id = "0";
}
//@todo who did this? should be remove, need other function instead
if(defined('ENABLED_LIVE_EXERCISE_TRACKING')){
$condition = ' WHERE ' .
'exe_exo_id = '."'".Database::escape_string($exo_id)."'".' AND ' .
@ -485,8 +482,7 @@ function exercise_attempt($score, $answer, $quesId, $exeId, $j, $exercise_id = 0
} else {
// anonymous
$user_id = api_get_anonymous_id();
}
$_SESSION['current_exercice_attempt'][$user_id] = $exeId;
}
$sql = "INSERT INTO $TBL_TRACK_ATTEMPT (
exe_id,
@ -508,14 +504,13 @@ function exercise_attempt($score, $answer, $quesId, $exeId, $j, $exercise_id = 0
'".$j."',
'".$reallyNow."'
)";
if (!empty($quesId) && !empty($exeId) && !empty($user_id)) {
$res = Database::query($sql);
if (defined('ENABLED_LIVE_EXERCISE_TRACKING')){
$TBL_RECORDING = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$recording_changes = "INSERT INTO $TBL_RECORDING (exe_id, question_id, marks, insert_date, author) VALUES ('$exeId','$quesId','$score','".api_get_utc_datetime()."','') ";
Database::query($recording_changes);
error_log($recording_changes);
Database::query($recording_changes);
}
return $res;
} else {
@ -568,8 +563,7 @@ function exercise_attempt_hotspot($exe_id, $question_id, $answer_id, $correct, $
* @param integer User ID (defaults to null)
* @param string Course code (defaults to null)
*/
function event_system($event_type, $event_value_type, $event_value, $timestamp = null, $user_id=null, $course_code=null)
{
function event_system($event_type, $event_value_type, $event_value, $timestamp = null, $user_id=null, $course_code=null) {
global $_configuration;
global $_user;
global $TABLETRACK_DEFAULT;
@ -580,26 +574,22 @@ function event_system($event_type, $event_value_type, $event_value, $timestamp =
$timestamp = Database::escape_string($timestamp);
$user_id = Database::escape_string($user_id);
$course_code = Database::escape_string($course_code);
// if tracking is disabled record nothing
if (!$_configuration['tracking_enabled']) {
return 0;
}
// if tracking is disabled record nothing
if (!$_configuration['tracking_enabled'])
{
return 0;
}
if(!isset($timestamp))
{
$timestamp = time();
if(!isset($timestamp)) {
$timestamp = api_get_utc_datetime();
}
if(!isset($user_id))
{
if(!isset($user_id)) {
$user_id = 0;
}
if(!isset($course_code))
{
if(!isset($course_code)) {
$course_code = '';
}
$sql = "INSERT INTO $TABLETRACK_DEFAULT
(default_user_id,
default_cours_code,
@ -611,7 +601,7 @@ function event_system($event_type, $event_value_type, $event_value, $timestamp =
VALUES
('$user_id.',
'$course_code',
FROM_UNIXTIME($timestamp),
'$timestamp',
'$event_type',
'$event_value_type',
'$event_value')";

@ -116,6 +116,7 @@ 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;
ALTER TABLE track_e_exercices ADD exe_duration int UNSIGNED NOT NULL default 0;
ALTER TABLE track_e_exercices ADD COLUMN expired_time_control datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE track_e_exercices ADD COLUMN orig_lp_item_view_id INT NOT NULL DEFAULT 0;
CREATE TABLE track_e_attempt (
exe_id int default NULL,

@ -30,6 +30,8 @@ ALTER TABLE sys_calendar ADD COLUMN access_url_id INT NOT NULL default 1;
-- xxSTATSxx
ALTER TABLE track_e_exercices ADD COLUMN orig_lp_item_view_id INT NOT NULL DEFAULT 0;
-- xxUSERxx

@ -7,14 +7,12 @@
* @author Yannick Warnier <ywarnier@beeznest.org>
*/
$language_file = array('learnpath', 'document');
$language_file = array('learnpath', 'document','exercice');
// Flag to allow for anonymous user - needs to be set before global.inc.php.
$use_anonymous = true;
require_once '../inc/global.inc.php';
require_once '../inc/reduced_header.inc.php';
echo '<body dir="'.api_get_text_direction().'">';
if (isset($_GET['error'])) {
@ -31,6 +29,10 @@ if (isset($_GET['error'])) {
echo '<br /><br />';
Display::display_normal_message(get_lang('FileNotFound'));
break;
case 'reached_one_attempt':
echo '<br /><br />';
Display::display_normal_message(get_lang('ReachedOneAttempt'));
break;
default:
break;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -678,13 +678,13 @@ if (is_array($list) && count($list) > 0) {
if (!$is_allowed_to_edit && $result_disabled_ext_all) {
$output .= '<td><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz_na.gif" alt="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'"></td>';
} else {
$output .= '<td><a href="../exercice/exercise_show.php?origin=student_progress&myid='.$my_orig_lp.'&my_lp_id='.$my_orig_lp_item.'&id=' . $my_exe_id . '&cidReq=' . $course_code . '&student=' . $student_id .$from_link. '" target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'"></a></td>';
$output .= '<td><a href="../exercice/exercise_show.php?origin=student_progress&id=' . $my_exe_id . '&cidReq=' . $course_code . $from_link. '" target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'"></a></td>';
}
} else {
if (!$is_allowed_to_edit && $result_disabled_ext_all ) {
$output .= '<td><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz_na.gif" alt="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'"></td>';
} else {
$output .= '<td><a href="../exercice/exercise_show.php?origin=tracking_course&myid='.$my_orig_lp.'&my_lp_id='.$my_orig_lp_item.'&id=' . $my_exe_id . '&cidReq=' . $course_code . '&student=' . $student_id . '&total_time='.$mytime.'&my_exe_exo_id='.$my_exo_exe_id.$from_link.' " target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'"></a></td>';
$output .= '<td><a href="../exercice/exercise_show.php?origin=tracking_course&id=' . $my_exe_id . '&cidReq=' . $course_code.$from_link.' " target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'"></a></td>';
}
}
$output .= '</tr>';

@ -11,7 +11,7 @@
* @author Denes Nagy, principal author
* @author Isthvan Mandak, several new features
* @author Roan Embrechts, code improvements and refactoring
* @license GNU/GPL - See Chamilo license directory for details
* @license GNU/GPL - See Chamilo license directory for details
*/
/* INIT SECTION */
@ -43,14 +43,14 @@ if (!empty($_SESSION['oLP']->encoding)) {
$charset = api_get_system_encoding();
}
$oLearnpath = false;
$course_code = api_get_course_id();
$user_id = api_get_user_id();
$oLearnpath = false;
$course_code = api_get_course_id();
$user_id = api_get_user_id();
$platform_theme = api_get_setting('stylesheets'); // Plataform's css.
$my_style = $platform_theme;
$my_style = $platform_theme;
// Escape external variables.
/* Header */
/* Header */
$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>';
@ -72,8 +72,10 @@ $htmlHeadXtra[] = '<script language="JavaScript" type="text/javascript">
</script>';
$_SESSION['oLP']->error = '';
$lp_type = $_SESSION['oLP']->get_type();
$lp_type = $_SESSION['oLP']->get_type();
$lp_item_id = $_SESSION['oLP']->get_current_item_id();
//$lp_item_id = learnpath::escape_string($_GET['item_id']);
//$_SESSION['oLP']->set_current_item($lp_item_id); // Already done by lp_controller.php.
@ -143,6 +145,12 @@ if (!isset($src)) {
$list = $_SESSION['oLP']->get_toc();
$type_quiz = false;
$current_item = $_SESSION['oLP']->items[$_SESSION['oLP']->get_current_item_id()];
$attempt_id = $current_item->get_attempt_id();
error_log('get attempts'.$current_item->get_attempt_id());
foreach($list as $toc) {
if ($toc['id'] == $lp_item_id && ($toc['type']=='quiz')) {
$type_quiz = true;
@ -154,22 +162,23 @@ $autostart = 'true';
if ($type_quiz && !empty($_REQUEST['exeId']) && isset($_GET['lp_id']) && isset($_GET['lp_item_id'])) {
global $src;
$_SESSION['oLP']->items[$_SESSION['oLP']->current]->write_to_db();
$TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TBL_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW);
$TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM);
$safe_item_id = Database::escape_string($_GET['lp_item_id']);
$safe_id = Database::escape_string($_GET['lp_id']);
$safe_exe_id = Database::escape_string($_REQUEST['exeId']);
$TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TBL_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW);
$TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM);
$safe_item_id = Database::escape_string($_GET['lp_item_id']);
$safe_id = Database::escape_string($_GET['lp_id']);
$safe_exe_id = intval($_REQUEST['exeId']);
if ($safe_id == strval(intval($safe_id)) && $safe_item_id == strval(intval($safe_item_id))) {
$sql = 'SELECT start_date,exe_date,exe_result,exe_weighting FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = '.(int)$safe_exe_id;
$sql = 'SELECT start_date,exe_date,exe_result,exe_weighting FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = '.$safe_exe_id;
$res = Database::query($sql);
$row_dates = Database::fetch_array($res);
$time_start_date = convert_mysql_date($row_dates['start_date']);
$time_exe_date = convert_mysql_date($row_dates['exe_date']);
$time_start_date = api_strtotime($row_dates['start_date'],'UTC');
$time_exe_date = api_strtotime($row_dates['exe_date'],'UTC');
$mytime = ((int)$time_exe_date-(int)$time_start_date);
$score = (float)$row_dates['exe_result'];
$max_score = (float)$row_dates['exe_weighting'];
@ -184,11 +193,16 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($_GET['lp_id']) && isset($
$sql_last_attempt = "SELECT id FROM $TBL_LP_ITEM_VIEW WHERE lp_item_id = '$safe_item_id' AND lp_view_id = '".$_SESSION['oLP']->lp_view_id."' order by id desc limit 1";
$res_last_attempt = Database::query($sql_last_attempt);
$row_last_attempt = Database::fetch_row($res_last_attempt);
$lp_item_view_id = $row_last_attempt[0];
if (Database::num_rows($res_last_attempt) > 0) {
$sql_upd_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = $score,total_time = $mytime WHERE id='".$row_last_attempt[0]."'";
$sql_upd_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = $score,total_time = $mytime WHERE id='".$lp_item_view_id."'";
Database::query($sql_upd_score);
}
$update_query = "UPDATE $TBL_TRACK_EXERCICES SET orig_lp_item_view_id = $lp_item_view_id WHERE exe_id = ".$safe_exe_id;
error_log('dddd-->'.$update_query);
Database::query($update_query);
}
}
if (intval($_GET['fb_type']) > 0) {
@ -286,11 +300,11 @@ if ($_SESSION['oLP']->mode == 'fullscreen') {
$lp_theme_css = $my_style;
}
$progress_bar = $_SESSION['oLP']->get_progress_bar('', -1, '', true);
$progress_bar = $_SESSION['oLP']->get_progress_bar('', -1, '', true);
$navigation_bar = $_SESSION['oLP']->get_navigation_bar();
$mediaplayer = $_SESSION['oLP']->get_mediaplayer($autostart);
$mediaplayer = $_SESSION['oLP']->get_mediaplayer($autostart);
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$show_audioplayer = false;
// Getting all the information about the item.
$sql = "SELECT audio FROM " . $tbl_lp_item . " WHERE lp_id = '" . $_SESSION['oLP']->lp_id."'";

Loading…
Cancel
Save