skala
Yannick Warnier 14 years ago
commit f321e2ca9e
  1. 17
      main/exercice/exercise.lib.php
  2. 9
      main/exercice/exercise_show.php
  3. 15
      main/inc/lib/events.lib.inc.php
  4. 13
      main/inc/lib/sessionmanager.lib.php
  5. 10
      main/inc/lib/tracking.lib.php
  6. 2
      main/mySpace/myStudents.php
  7. 2
      main/work/work.lib.php

@ -500,9 +500,9 @@ function exercise_time_control_is_valid($exercise_id) {
$sql = "SELECT expired_time FROM $TBL_EXERCICES WHERE id = $exercise_id";
$result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC');
if (!empty($row['expired_time']) ) {
$current_expired_time_key = get_time_control_key($exercise_id);
if (isset($_SESSION['expired_time'][$current_expired_time_key])) {
if (!empty($row['expired_time']) ) {
$current_expired_time_key = get_time_control_key($exercise_id);
if (isset($_SESSION['expired_time'][$current_expired_time_key])) {
$current_time = time();
$expired_time = api_strtotime($_SESSION['expired_time'][$current_expired_time_key], 'UTC');
$total_time_allowed = $expired_time + 30;
@ -537,8 +537,17 @@ function generate_time_control_key($exercise_id) {
}
/**
Returns the time controller key
@todo this function is the same as generate_time_control_key
*/
function get_time_control_key($exercise_id){
function get_time_control_key($exercise_id) {
$exercise_id = intval($exercise_id);
return api_get_course_int_id().'_'.api_get_session_id().'_'.$exercise_id.'_'.api_get_user_id();
}
/**
* @todo use this function instead of get_time_control_key
*/
function get_session_time_control_key($exercise_id) {
$time_control_key = get_time_control_key($exercise_id);
$return_value = $_SESSION['expired_time'][$time_control_key];
return $return_value;
}

@ -61,7 +61,7 @@ if ( empty ( $nbrQuestions ) ) { $nbrQuestions = $_REQUEST['nbrQuestion
if ( empty ( $questionList ) ) { $questionList = $_SESSION['questionList'];}
if ( empty ( $objExercise ) ) { $objExercise = $_SESSION['objExercise'];}
if ( empty ( $exeId ) ) { $exeId = $_REQUEST['id'];}
if ( empty ( $action ) ) { $action = $_GET['action']; }
if ( empty ( $action ) ) { $action = $_REQUEST['action']; }
//$emailId = $_REQUEST['email'];
$id = intval($_REQUEST['id']); //exe id
@ -95,7 +95,9 @@ if (empty($objExercise)) {
$objExercise->read($exercise_id);
}
if (!exercise_time_control_is_valid($exercise_id)) {
//If is not valid
$session_control_key = get_session_time_control_key($exercise_id);
if (isset($session_control_key) && !exercise_time_control_is_valid($exercise_id) && !in_array($action, array('qualify','edit'))) {
$sql_fraud = "UPDATE $TBL_TRACK_ATTEMPT SET answer = 0, marks=0, position=0 WHERE exe_id = $id ";
Database::query($sql_fraud);
}
@ -895,6 +897,7 @@ if (is_array($arrid) && is_array($arrmarks)) {
if ($is_allowedToEdit) {
if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) {
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.'">';
echo '<input type = "hidden" name="lp_item_id" value="'.$lp_id.'">';
@ -903,7 +906,7 @@ if ($is_allowedToEdit) {
echo '<input type = "hidden" name="total_score" value="'.$totalScore.'"> ';
echo '<input type = "hidden" name="my_exe_exo_id" value="'.$exercise_id.'"> ';
} else {
echo ' <form name="myform" id="myform" action="exercice.php?show=result&filter=2&comments=update&exeid='.$id.'&totalWeighting='.$totalWeighting.'" method="post">';
echo ' <form name="myform" id="myform" action="exercice.php?show=result&action=qualify&filter=2&comments=update&exeid='.$id.'&totalWeighting='.$totalWeighting.'" method="post">';
}
if ($origin!='learnpath' && $origin!='student_progress') {
?>

@ -481,18 +481,9 @@ function exercise_attempt($score, $answer, $quesId, $exeId, $j, $exercise_id = 0
} else {
// anonymous
$user_id = api_get_anonymous_id();
}
}
$sql = "INSERT INTO $TBL_TRACK_ATTEMPT (
exe_id,
user_id,
question_id,
answer,
marks,
course_code,
position,
tms
)
$sql = "INSERT INTO $TBL_TRACK_ATTEMPT (exe_id, user_id, question_id, answer, marks, course_code, position, tms )
VALUES (
".$exeId.",
".$user_id.",
@ -503,7 +494,7 @@ function exercise_attempt($score, $answer, $quesId, $exeId, $j, $exercise_id = 0
'".$j."',
'".$reallyNow."'
)";
error_log($sql);
if (!empty($quesId) && !empty($exeId) && !empty($user_id)) {
$res = Database::query($sql);
if (defined('ENABLED_LIVE_EXERCISE_TRACKING')){

@ -448,9 +448,16 @@ class SessionManager {
}
// update number of users in the session
$nbr_users = count($user_list);
$update_sql = "UPDATE $tbl_session SET nbr_users= $nbr_users WHERE id='$id_session' ";
Database::query($update_sql);
$nbr_users = count($user_list);
if ($empty_users) {
// update number of users in the session
$update_sql = "UPDATE $tbl_session SET nbr_users= $nbr_users WHERE id='$id_session' ";
Database::query($update_sql);
} else {
echo $update_sql = "UPDATE $tbl_session SET nbr_users= nbr_users + $nbr_users WHERE id='$id_session' ";
Database::query($update_sql);
}
}
/**

@ -500,11 +500,12 @@ class Tracking {
* 1. The score average from all SCORM Test items in all LP in a course-> All the answers / All the max scores.
* 2. The score average from all Tests (quiz) in all LP in a course-> All the answers / All the max scores.
* 3. And finally it will return the average between 1. and 2.
* @todo improve performance, when loading 1500 users with 20 lps the script dies
* This function does not take the results of a Test out of a LP
*
* @param int|array Student id(s)
* @param mixed Array of user ids or an user id
* @param string Course code
* @param array Limit average to listed lp ids
* @param array List of LP ids
* @param int Session id (optional), if param $session_id is null(default) it'll return results including sessions, 0 = session is not filtered
* @param bool Returns an array of the type [sum_score, num_score] if set to true
* @return string Value (number %) Which represents a round integer explain in got in 3.
@ -521,6 +522,7 @@ class Tracking {
$course = CourseManager :: get_course_information($course_code);
if (!empty($course['db_name'])) {
// get course tables names
$tbl_quiz_questions = Database :: get_course_table(TABLE_QUIZ_QUESTION,$course['db_name']);
$lp_table = Database :: get_course_table(TABLE_LP_MAIN,$course['db_name']);
@ -580,11 +582,11 @@ class Tracking {
} else {
$condition_user1 =" AND user_id = '$student_id' ";
}
//var_dump($student_id);
if ($count_row_lp>0 && !empty($student_id)) {
// Get all views through learning paths filter
//@todo problem whe course have more than 1500 users
//@todo problem when a course have more than 1500 users
$sql = "SELECT MAX(view_count) as vc, id, progress, lp_id, user_id FROM $lp_view_table ".
"WHERE lp_id IN (".implode(',',$lp_list).") $condition_user1 AND session_id= $session_id GROUP BY lp_id,user_id";
//var_dump( $sql );

@ -50,7 +50,7 @@ if (isset ($_GET['from']) && $_GET['from'] == 'myspace') {
}
$nameTools = get_lang('StudentDetails');
$cidReset = true;
//$cidReset = true;
$get_course_code = Security :: remove_XSS($_GET['course']);
if (isset ($_GET['details'])) {
if (!empty ($_GET['origin']) && $_GET['origin'] == 'user_course') {

@ -681,7 +681,7 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC
while($row_admin = Database::fetch_row($res)) {
$admin_course .= '\''.$row_admin[0].'\',';
}
$sql_document = "SELECT count(*) FROM $work_table s, $iprop_table p WHERE s.id = p.ref AND p.tool='work' AND lastedit_user_id IN(".$admin_course.'\''.api_get_user_id().'\''.") AND s.accepted='1' AND url NOT LIKE '".$sub_course_dir.$dir."/%/%' AND url LIKE '".$sub_course_dir.$dir."/%'";
$sql_document = "SELECT count(*) FROM $work_table s, $iprop_table p WHERE s.id = p.ref AND p.tool='work' AND lastedit_user_id IN(".$admin_course.'\''.api_get_user_id().'\''.") AND s.accepted='1' AND url NOT LIKE '".$sub_course_dir.$dir."/%/%' AND url LIKE '".$sub_course_dir.$dir."/%'";
}
//count documents
$res_document = Database::query($sql_document);

Loading…
Cancel
Save