PHP warning/notices avoided

skala
Julio Montoya 14 years ago
parent 2bd9f4775c
commit a17a9c687a
  1. 971
      main/exercice/exercice.php
  2. 35
      main/exercice/exercise.class.php
  3. 5
      main/exercice/exercise.lib.php
  4. 23
      main/exercice/exercise_submit.php
  5. 13
      main/gradebook/lib/be/linkfactory.class.php
  6. 328
      main/inc/ajax/exercise.ajax.php
  7. 80
      main/inc/lib/events.lib.inc.php
  8. 13
      main/inc/lib/main_api.lib.php

File diff suppressed because it is too large Load Diff

@ -1091,20 +1091,9 @@ class Exercise {
$form->addElement('text', 'enabletimercontroltotalminutes',get_lang('ExerciseTotalDurationInMinutes'),array('style' => 'width : 35px','id' => 'enabletimercontroltotalminutes'));
$form->addElement('html','</div>');
//Pass percentage
/*$options = array('' => '-');
for ($i = 0; $i <= 20 ; $i++) {
$options[$i*5] = $i*5;
}
$form->addElement('select', 'pass_percentage', array(get_lang('PassPercentage'), null, '%'), $options, array('id' => 'pass_percentage', 'class' => 'chzn-select'));
*/
$form->addElement('text', 'pass_percentage', array(get_lang('PassPercentage'), null, '%'), array('id' => 'pass_percentage'));
$form->addRule('pass_percentage', get_lang('Numeric'), 'numeric');
//$form->addElement('text', 'exerciseAttempts', get_lang('ExerciseAttempts').' : ',array('size'=>'2'));
// add the text_when_finished textbox
$form -> add_html_editor('text_when_finished', get_lang('TextWhenFinished'), false, false, $editor_config);
@ -1919,6 +1908,16 @@ class Exercise {
if ($debug) error_log('manage_answer $learnpath_item_id: '.$learnpath_item_id);
$extra_data = array();
$final_overlap = 0;
$final_missing =0;
$final_excess =0;
$overlap_color =0;
$missing_color =0;
$excess_color =0;
$threadhold1 =0;
$threadhold2 =0;
$threadhold3 = 0;
$arrques = null;
$arrans = null;
@ -2959,7 +2958,6 @@ class Exercise {
}
}
//we add the total score after dealing with the answers
if ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
if ($final_answer) {
@ -3001,9 +2999,15 @@ class Exercise {
}
}
$extra_data = array('final_overlap' => $final_overlap, 'final_missing'=>$final_missing, 'final_excess'=> $final_excess,
'overlap_color' => $overlap_color, 'missing_color'=>$missing_color, 'excess_color'=> $excess_color,
'threadhold1' => $threadhold1, 'threadhold2'=>$threadhold2, 'threadhold3'=> $threadhold3,
$extra_data = array('final_overlap' => $final_overlap,
'final_missing'=>$final_missing,
'final_excess'=> $final_excess,
'overlap_color' => $overlap_color,
'missing_color'=>$missing_color,
'excess_color'=> $excess_color,
'threadhold1' => $threadhold1,
'threadhold2'=>$threadhold2,
'threadhold3'=> $threadhold3,
);
if ($from == 'exercise_result') {
@ -3155,7 +3159,6 @@ class Exercise {
}
}
unset ($objAnswerTmp);
$i++;
$totalWeighting += $questionWeighting;
// Store results directly in the database

@ -793,8 +793,11 @@ function get_time_control_key($exercise_id, $lp_id = 0, $lp_item_id = 0) {
* Get session time control
*/
function get_session_time_control_key($exercise_id, $lp_id = 0, $lp_item_id = 0) {
$return_value = 0;
$time_control_key = get_time_control_key($exercise_id, $lp_id, $lp_item_id);
$return_value = $_SESSION['expired_time'][$time_control_key];
if (isset($_SESSION['expired_time']) && isset($_SESSION['expired_time'][$time_control_key])) {
$return_value = $_SESSION['expired_time'][$time_control_key];
}
return $return_value;
}

@ -74,18 +74,12 @@ $reminder = isset($_REQUEST['reminder']) ? intval($_REQUEST['reminder']) : 0
$remind_question_id = isset($_REQUEST['remind_question_id']) ? intval($_REQUEST['remind_question_id']) : 0;
$exerciseId = isset($_REQUEST['exerciseId']) ? intval($_REQUEST['exerciseId']) : 0;
if (empty ($formSent)) {
$formSent = $_REQUEST['formSent'];
}
if (empty($exerciseResult)) {
$exerciseResult = $_REQUEST['exerciseResult'];
}
if (empty ($exerciseResultCoordinates)) {
$exerciseResultCoordinates = $_REQUEST['exerciseResultCoordinates'];
}
$formSent = isset($_REQUEST['formSent']) ? $_REQUEST['formSent'] : null;
$exerciseResult = isset($_REQUEST['exerciseResult']) ? $_REQUEST['exerciseResult'] : null;
$exerciseResultCoordinates = isset($_REQUEST['exerciseResultCoordinates']) ? $_REQUEST['exerciseResultCoordinates'] : null;
$choice = isset($_REQUEST['choice']) ? $_REQUEST['choice'] : null;
$choice = empty($choice) ? $_REQUEST['choice2'] : null;
$choice = empty($choice) ? isset($_REQUEST['choice2']) ? $_REQUEST['choice2'] : null : null;
//From submit modal
$current_question = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : null;
@ -97,7 +91,7 @@ $error = '';
$exercice_attemp_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
/* Teacher takes an exam and want to see a preview, we delete the objExercise from the session in order to get the latest changes in the exercise */
if (api_is_allowed_to_edit(null,true) && $_GET['preview'] == 1 ) {
if (api_is_allowed_to_edit(null,true) && isset($_GET['preview']) && $_GET['preview'] == 1 ) {
Session::erase('objExercise');
}
@ -225,6 +219,8 @@ if ($debug) { error_log("4. Setting the exe_id: $exe_id");} ;
//var_dump($learnpath_id.' - '.$learnpath_item_id.' - '.$learnpath_item_view_id);
$exercise_stat_info = $objExercise->get_stat_track_exercise_info($learnpath_id, $learnpath_item_id, $learnpath_item_view_id);
$clock_expired_time = null;
if (empty($exercise_stat_info)) {
if ($debug) error_log('5 $exercise_stat_info is empty ');
$total_weight = 0;
@ -233,7 +229,6 @@ if (empty($exercise_stat_info)) {
$objQuestionTmp = Question::read($question_id);
$total_weight += floatval($objQuestionTmp->weighting);
}
$clock_expired_time = '';
if ($time_control) {
$expected_time = $current_timestamp + $total_seconds;
@ -579,7 +574,7 @@ $interbreadcrumb[] = array ("url" => "exercice.php?gradebook=$gradebook", "name"
$interbreadcrumb[] = array ("url" => "#","name" => $objExercise->name);
if ($origin != 'learnpath') { //so we are not in learnpath tool
Display :: display_header($nameTools,'Exercises');
Display :: display_header(null,'Exercises');
if (!api_is_allowed_to_session_edit() ) {
Display :: display_warning_message(get_lang('SessionIsReadOnly'));
}
@ -986,7 +981,7 @@ if (!empty($error)) {
}
}
$user_choice = $attempt_list[$questionId];
$user_choice = isset($attempt_list[$questionId]) ? $attempt_list[$questionId] : null;
$remind_highlight = '';

@ -11,15 +11,6 @@
// - define a unique type id
// - add include
// - change create() and get_all_types()
// Please do not change existing values, they are used in the database !
define('LINK_EXERCISE', 1);
define('LINK_DROPBOX', 2);
define('LINK_STUDENTPUBLICATION', 3);
define('LINK_LEARNPATH', 4);
define('LINK_FORUM_THREAD', 5);
//define('LINK_WORK',6);
define('LINK_ATTENDANCE', 7);
define('LINK_SURVEY', 8);
require_once 'gradebookitem.class.php';
require_once 'abstractlink.class.php';
@ -115,9 +106,9 @@ class LinkFactory
LINK_SURVEY
);
}
public function delete() {
}
}

@ -21,213 +21,213 @@ switch ($action) {
case 'get_live_stats':
if (!api_is_allowed_to_edit(null, true)) {
break;
}
// 1. Setting variables needed by jqgrid
}
// 1. Setting variables needed by jqgrid
$action = $_GET['a'];
$exercise_id = intval($_GET['exercise_id']);
$page = intval($_REQUEST['page']); //page
$limit = intval($_REQUEST['rows']); //quantity of rows
$sidx = $_REQUEST['sidx']; //index to filter
$sidx = $_REQUEST['sidx']; //index to filter
$sord = $_REQUEST['sord']; //asc or desc
if (!in_array($sord, array('asc','desc'))) {
$sord = 'desc';
$sord = 'desc';
}
// get index row - i.e. user click to sort $sord = $_GET['sord'];
// get the direction
// get index row - i.e. user click to sort $sord = $_GET['sord'];
// get the direction
if (!$sidx) $sidx = 1;
$track_exercise = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$track_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$minutes = intval($_REQUEST['minutes']);
$minutes = intval($_REQUEST['minutes']);
$now = time() - 60*$minutes; //1 hour
$now = api_get_utc_datetime($now);
$where_condition = " orig_lp_id = 0 AND exe_exo_id = $exercise_id AND start_date > '$now' ";
$sql = "SELECT COUNT(DISTINCT exe_id) FROM $track_exercise WHERE $where_condition ";
$result = Database::query($sql);
$count = Database::fetch_row($result);
$count = $count[0];
$count = $count[0];
//3. Calculating first, end, etc
$total_pages = 0;
if ($count > 0) {
if ($count > 0) {
if (!empty($limit)) {
$total_pages = ceil($count/$limit);
}
}
if ($page > $total_pages) {
if ($page > $total_pages) {
$page = $total_pages;
}
}
$start = $limit * $page - $limit;
if ($start < 0 ) {
$start = 0;
}
$sql = "SELECT exe_id,
exe_user_id,
firstname,
lastname,
aa.status,
start_date,
exe_result,
exe_weighting,
exe_result/exe_weighting as score,
exe_duration,
questions_to_check,
}
$sql = "SELECT exe_id,
exe_user_id,
firstname,
lastname,
aa.status,
start_date,
exe_result,
exe_weighting,
exe_result/exe_weighting as score,
exe_duration,
questions_to_check,
orig_lp_id
FROM $user_table u
FROM $user_table u
INNER JOIN (
SELECT t.exe_id, t.exe_user_id, status,
start_date, exe_result, exe_weighting, exe_result/exe_weighting as score, exe_duration, questions_to_check, orig_lp_id
FROM $track_exercise t LEFT JOIN $track_attempt a ON (a.exe_id = t.exe_id AND t.exe_user_id = a.user_id )
FROM $track_exercise t LEFT JOIN $track_attempt a ON (a.exe_id = t.exe_id AND t.exe_user_id = a.user_id )
WHERE t.status = 'incomplete' AND
$where_condition
$where_condition
GROUP BY exe_user_id
) as aa
ON aa.exe_user_id = user_id
ORDER BY $sidx $sord LIMIT $start, $limit";
ON aa.exe_user_id = user_id
ORDER BY $sidx $sord LIMIT $start, $limit";
$result = Database::query($sql);
$results = array();
$results = array();
while ($row = Database::fetch_array($result, 'ASSOC')){
$results[] = $row;
}
}
$oExe = new exercise();
$oExe->read($exercise_id);
$response = new stdClass();
$response->page = $page;
$response->total = $total_pages;
$response->records = $count;
$response = new stdClass();
$response->page = $page;
$response->total = $total_pages;
$response->records = $count;
$i=0;
if (!empty($results)) {
foreach($results as $row) {
foreach($results as $row) {
$sql = "SELECT SUM(count_question_id) as count_question_id FROM (
SELECT 1 as count_question_id FROM $track_attempt a
SELECT 1 as count_question_id FROM $track_attempt a
WHERE user_id = {$row['exe_user_id']} and exe_id = {$row['exe_id']}
GROUP by question_id
) as count_table";
) as count_table";
$result_count = Database::query($sql);
$count_questions = Database::fetch_array($result_count,'ASSOC');
$count_questions = Database::fetch_array($result_count,'ASSOC');
$count_questions = $count_questions['count_question_id'];
$row['count_questions'] = $count_questions;
$response->rows[$i]['id'] = $row['exe_id'];
$remaining = strtotime($row['start_date'])+($oExe->expired_time*60) - strtotime(api_get_utc_datetime(time()));
$h = floor($remaining/3600);
$m = floor(($remaining - ($h*3600))/60);
$s = ($remaining - ($h*3600) - ($m*60));
$array = array( $row['firstname'],
$row['lastname'],
$array = array( $row['firstname'],
$row['lastname'],
api_format_date($row['start_date'], DATE_TIME_FORMAT_LONG).' ['.($h>0?$h.':':'').sprintf("%02d",$m).':'.sprintf("%02d",$s).']',
$row['count_questions'],
$row['count_questions'],
round($row['score']*100).'%'
);
$response->rows[$i]['cell'] = $array;
$i++;
$i++;
}
}
}
echo json_encode($response);
break;
break;
case 'update_question_order':
if (api_is_allowed_to_edit(null, true)) {
if (api_is_allowed_to_edit(null, true)) {
$new_question_list = $_POST['question_id_list'];
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$counter = 1;
foreach ($new_question_list as $new_order_id) {
foreach ($new_question_list as $new_order_id) {
Database::update($TBL_QUESTIONS, array('question_order'=>$counter), array('question_id = ? AND c_id = ? '=>array(intval($new_order_id), $course_id)));
$counter++;
}
Display::display_confirmation_message(get_lang('Saved'));
}
break;
case 'add_question_to_reminder':
$objExercise = $_SESSION['objExercise'];
case 'add_question_to_reminder':
$objExercise = $_SESSION['objExercise'];
if (empty($objExercise)) {
echo 0;
exit;
} else {
$objExercise->edit_question_to_remind($_REQUEST['exe_id'], $_REQUEST['question_id'], $_REQUEST['action']);
$objExercise->edit_question_to_remind($_REQUEST['exe_id'], $_REQUEST['question_id'], $_REQUEST['action']);
}
break;
case 'save_exercise_by_now':
//Use have permissions?
if (api_is_allowed_to_session_edit()) {
//"all" or "simple" strings means that there's one or all questions exercise type
$type = $_REQUEST['type'];
//"all" or "simple" strings means that there's one or all questions exercise type
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null;
//Questions choices
$choice = $_REQUEST['choice'];
//Hotspot coordinates from all questions
$hot_spot_coordinates = $_REQUEST['hotspot'];
$choice = isset($_REQUEST['choice']) ? $_REQUEST['choice'] : null;
//Hotspot coordinates from all questions
$hot_spot_coordinates = isset($_REQUEST['hotspot']) ? $_REQUEST['hotspot'] : null;
//There is a reminder?
$remind_list = isset($_REQUEST['remind_list']) && !empty($_REQUEST['remind_list'])? array_keys($_REQUEST['remind_list']) : null;
//Needed in manage_answer
$learnpath_id = isset($_REQUEST['learnpath_id']) ? intval($_REQUEST['learnpath_id']) : 0;
$learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? intval($_REQUEST['learnpath_item_id']) : 0;
$learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? intval($_REQUEST['learnpath_item_id']) : 0;
//Attempt id
$exe_id = $_REQUEST['exe_id'];
if ($debug) error_log("exe_id = $exe_id ");
if ($debug) error_log("type = $type ");
if ($debug) error_log("choice = ".print_r($choice, 1)." ");
if ($debug) error_log("hot_spot_coordinates = ".print_r($hot_spot_coordinates,1));
if ($debug) error_log("remind_list = ".print_r($remind_list));
//Exercise information
$objExercise = $_SESSION['objExercise'];
//Exercise information
$objExercise = isset($_SESSION['objExercise']) ? $_SESSION['objExercise'] : null;
//Question info
$question_id = intval($_REQUEST['question_id']);
$question_id = intval($_REQUEST['question_id']);
$question_list = $_SESSION['questionList'];
//If exercise or question is not set then exit
if (empty($question_list) || empty($objExercise)) {
echo 'error';
exit;
}
//Getting information of the current exercise
//Getting information of the current exercise
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
$exercise_id = $exercise_stat_info['exe_exo_id'];
$attempt_list = array();
//First time here we create an attempt (getting the exe_id)
if (empty($exercise_stat_info)) {
} else {
if (empty($exercise_stat_info)) {
} else {
//We know the user we get the exe_id
$exe_id = $exercise_stat_info['exe_id'];
$total_score = $exercise_stat_info['exe_result'];
//Getting the list of attempts
$attempt_list = get_all_exercise_event_by_exe_id($exe_id);
}
}
//Updating Reminder algorythm
if ($objExercise->type == ONE_PER_PAGE) {
$bd_reminder_list = explode(',', $exercise_stat_info['questions_to_check']);
if (empty($remind_list)) {
$remind_list = $bd_reminder_list;
$new_list = array();
foreach($bd_reminder_list as $item) {
if ($item != $question_id) {
@ -244,129 +244,135 @@ switch ($action) {
}
}
}
//No exe id? Can't save answer.
if (empty($exe_id)) {
//Fires an error
//Fires an error
echo 'error';
exit;
} else {
$_SESSION['exe_id'] = $exe_id;
}
// Getting the total weight if the request is simple
$total_weight = 0;
if ($type == 'simple') {
if ($type == 'simple') {
foreach ($question_list as $my_question_id) {
$objQuestionTmp = Question :: read($my_question_id);
$total_weight += $objQuestionTmp->selectWeighting();
}
}
unset($objQuestionTmp);
}
unset($objQuestionTmp);
//Looping the question list
foreach ($question_list as $my_question_id) {
if ($debug) error_log("Saving question_id = $my_question_id ");
if ($debug) error_log("Saving question_id = $my_question_id ");
if ($type == 'simple' && $question_id != $my_question_id) {
continue;
}
}
$my_choice = $choice[$my_question_id];
if ($debug) error_log("my_choice = ".print_r($my_choice, 1)."");
// creates a temporary Question object
$objQuestionTmp = Question::read($my_question_id);
//Getting free choice data
if ($objQuestionTmp->type == FREE_ANSWER && $type == 'all') {
$my_choice = isset($_REQUEST['free_choice'][$my_question_id]) && !empty($_REQUEST['free_choice'][$my_question_id])? $_REQUEST['free_choice'][$my_question_id]: null;
}
$my_choice = isset($_REQUEST['free_choice'][$my_question_id]) && !empty($_REQUEST['free_choice'][$my_question_id])? $_REQUEST['free_choice'][$my_question_id]: null;
}
if ($type == 'all') {
$total_weight += $objQuestionTmp->selectWeighting();
}
}
//this variable commes from exercise_submit_modal.php
$hotspot_delineation_result = $_SESSION['hotspot_delineation_result'][$objExercise->selectId()][$my_question_id];
$hotspot_delineation_result = null;
if (isset($_SESSION['hotspot_delineation_result']) && isset($_SESSION['hotspot_delineation_result'][$objExercise->selectId()])) {
$hotspot_delineation_result = $_SESSION['hotspot_delineation_result'][$objExercise->selectId()][$my_question_id];
}
if ($type == 'simple') {
//Getting old attempt in order to decrees the total score
$old_result = $objExercise->manage_answer($exe_id, $my_question_id, null, 'exercise_show', array(), false, true, false, $objExercise->selectPropagateNeg());
//Getting old attempt in order to decrees the total score
$old_result = $objExercise->manage_answer($exe_id, $my_question_id, null, 'exercise_show', array(), false, true, false, $objExercise->selectPropagateNeg());
//Removing old score
$total_score = $total_score - $old_result['score'];
$total_score = $total_score - $old_result['score'];
}
// Deleting old attempt
if (isset($attempt_list) && !empty($attempt_list[$my_question_id])) {
if (isset($attempt_list) && !empty($attempt_list[$my_question_id])) {
if ($debug) error_log("delete_attempt exe_id : $exe_id, my_question_id: $my_question_id");
delete_attempt($exe_id, api_get_user_id() , api_get_course_id(), api_get_session_id(), $my_question_id);
if ($objQuestionTmp->type == HOT_SPOT) {
if ($objQuestionTmp->type == HOT_SPOT) {
delete_attempt_hotspot($exe_id, api_get_user_id() , api_get_course_id(), $my_question_id);
}
$total_score -= $attempt_list[$my_question_id]['marks'];
if (isset($attempt_list[$my_question_id]) && isset($attempt_list[$my_question_id]['marks'])) {
$total_score -= $attempt_list[$my_question_id]['marks'];
}
}
// We're inside *one* question. Go through each possible answer for this question
$result = $objExercise->manage_answer($exe_id, $my_question_id, $my_choice, 'exercise_result', $hot_spot_coordinates, true, false, false, $objExercise->selectPropagateNeg(), $hotspot_delineation_result, true);
//Adding the new score
$total_score += $result['score'];
//Adding the new score
$total_score += $result['score'];
if ($debug) error_log("total_score: $total_score ");
if ($debug) error_log("total_weight: $total_weight ");
$duration = 0;
$now = time();
if ($type == 'all') {
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
}
$key = get_time_control_key($exercise_id, $exercise_stat_info['orig_lp_id'], $exercise_stat_info['orig_lp_item_id']);
if (isset($_SESSION['duration_time'][$key]) && !empty($_SESSION['duration_time'][$key])) {
$duration = $now - $_SESSION['duration_time'][$key];
if (!empty($exercise_stat_info['exe_duration'])) {
if (!empty($exercise_stat_info['exe_duration'])) {
$duration += $exercise_stat_info['exe_duration'];
}
$duration = intval($duration);
} else {
$duration = intval($duration);
} else {
if (!empty($exercise_stat_info['exe_duration'])) {
$duration = $exercise_stat_info['exe_duration'];
}
}
}
$_SESSION['duration_time'][$key] = time();
update_event_exercice( $exe_id,
$objExercise->selectId(),
$total_score,
$total_weight,
update_event_exercice( $exe_id,
$objExercise->selectId(),
$total_score,
$total_weight,
api_get_session_id(),
$exercise_stat_info['orig_lp_id'],
$exercise_stat_info['orig_lp_item_id'],
$exercise_stat_info['orig_lp_item_view_id'],
$duration,
$question_list,
'incomplete',
$exercise_stat_info['orig_lp_id'],
$exercise_stat_info['orig_lp_item_id'],
$exercise_stat_info['orig_lp_item_view_id'],
$duration,
$question_list,
'incomplete',
$remind_list);
// Destruction of the Question object
unset($objQuestionTmp);
unset($objQuestionTmp);
if ($debug) error_log(" -- end question -- ");
}
if ($debug) error_log(" ------ end ajax call ------- ");
if ($debug) error_log(" ------ end ajax call ------- ");
}
if ($objExercise->type == ONE_PER_PAGE) {
echo 'one_per_page';
exit;

@ -76,7 +76,7 @@ function event_login() {
global $TABLETRACK_LOGIN;
$reallyNow = api_get_utc_datetime();
$sql = "INSERT INTO ".$TABLETRACK_LOGIN." (login_user_id, login_ip, login_date, logout_date) VALUES
$sql = "INSERT INTO ".$TABLETRACK_LOGIN." (login_user_id, login_ip, login_date, logout_date) VALUES
('".$_user['user_id']."',
'".Database::escape_string(api_get_real_ip())."',
'".$reallyNow."',
@ -322,15 +322,15 @@ function event_link($link_id) {
* @author Julio Montoya Armas <gugli100@gmail.com> Reworked 2010
* @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, $learnpath_item_view_id = 0, $duration = 0, $question_list = array(), $status = '', $remind_list = array() , $end_date = null) {
function update_event_exercice($exeid, $exo_id, $score, $weighting, $session_id, $learnpath_id = 0, $learnpath_item_id = 0, $learnpath_item_view_id = 0, $duration = 0, $question_list = array(), $status = '', $remind_list = array() , $end_date = null) {
require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
global $debug;
if ($debug) error_log('Called to update_event_exercice');
if ($debug) error_log('duration:' . $duration);
if ($debug) error_log('duration:' . $duration);
if ($exeid != '') {
// Validation in case of fraud with actived control time
if (!exercise_time_control_is_valid($exo_id, $learnpath_id, $learnpath_item_id)) {
// Validation in case of fraud with actived control time
if (!exercise_time_control_is_valid($exo_id, $learnpath_id, $learnpath_item_id)) {
$score = 0;
}
@ -341,7 +341,7 @@ function update_event_exercice($exeid, $exo_id, $score, $weighting, $session_id,
}
$TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
if (!empty($question_list)) {
$question_list = array_map('intval', $question_list);
}
@ -397,7 +397,7 @@ function create_event_exercice($exo_id) {
if (empty($exo_id) or (intval($exo_id)!=$exo_id)) { return false; }
//error_log('create_event_exercice');
$tbl_track_exe = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$tbl_exe = Database::get_course_table(TABLE_QUIZ_TEST);
$tbl_exe = Database::get_course_table(TABLE_QUIZ_TEST);
$uid = api_get_user_id();
$course_id = api_get_course_int_id();
@ -500,7 +500,7 @@ function exercise_attempt($score, $answer, $question_id, $exe_id, $position, $ex
)";
if ($debug) error_log("Saving question attempt: ");
if ($debug) error_log($sql);
if ($debug) error_log($sql);
if (!empty($question_id) && !empty($exe_id) && !empty($user_id)) {
$res = Database::query($sql);
@ -635,8 +635,8 @@ function get_all_event_types() {
INNER JOIN '.Database::get_main_table(TABLE_MAIN_LANGUAGE).' l
ON etm.language_id = l.id';
$events_types = Database::store_result(Database::query($sql),'ASSOC');
$events_types = Database::store_result(Database::query($sql),'ASSOC');
$to_return = array();
foreach ($events_types as $et) {
$et['nameLangVar'] = $event_config[$et["event_type_name"]]["name_lang_var"];
@ -671,14 +671,14 @@ function get_users_subscribed_to_event($event_name) {
*/
function get_event_users($event_name) {
$event_name = Database::escape_string($event_name);
$sql = 'SELECT user.user_id, user.firstname, user.lastname FROM '.Database::get_main_table(TABLE_MAIN_USER).' user JOIN '.Database::get_main_table(TABLE_EVENT_TYPE_REL_USER).' relUser
$sql = 'SELECT user.user_id, user.firstname, user.lastname FROM '.Database::get_main_table(TABLE_MAIN_USER).' user JOIN '.Database::get_main_table(TABLE_EVENT_TYPE_REL_USER).' relUser
ON relUser.user_id = user.user_id
WHERE user.status <> '.ANONYMOUS.' AND relUser.event_type_name = "'.$event_name.'"';
WHERE user.status <> '.ANONYMOUS.' AND relUser.event_type_name = "'.$event_name.'"';
//For tests
//$sql = 'SELECT user.user_id, user.firstname, user.lastname FROM '.Database::get_main_table(TABLE_MAIN_USER);
$user_list = Database::store_result(Database::query($sql), 'ASSOC');
return json_encode($user_list);
$user_list = Database::store_result(Database::query($sql), 'ASSOC');
return json_encode($user_list);
}
/**
@ -695,7 +695,7 @@ function save_event_type_message($event_name, $users, $message, $subject, $event
$event_name = Database::escape_string($event_name);
$activated = intval($activated);
$event_message_language = Database::escape_string($event_message_language);
// Deletes then re-adds the users linked to the event
$sql = 'DELETE FROM '.Database::get_main_table(TABLE_EVENT_TYPE_REL_USER).' WHERE event_type_name = "'.$event_name.'" ';
Database::query($sql);
@ -708,7 +708,7 @@ function save_event_type_message($event_name, $users, $message, $subject, $event
// check if this template in this language already exists or not
$sql = 'SELECT COUNT(id) as total FROM '.Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE).'
WHERE event_type_name = "'.$event_name.'" AND language_id = '.$language_id;
$sql = Database::store_result(Database::query($sql),'ASSOC');
// if already exists, we update
@ -722,10 +722,10 @@ function save_event_type_message($event_name, $users, $message, $subject, $event
Database::query($sql);
} else { // else we create a new record
// gets the language_-_id
$lang_id = '(SELECT id FROM '.Database::get_main_table(TABLE_MAIN_LANGUAGE).'
$lang_id = '(SELECT id FROM '.Database::get_main_table(TABLE_MAIN_LANGUAGE).'
WHERE dokeos_folder = "'.$event_message_language.'")';
$lang_id = Database::store_result(Database::query($lang_id),'ASSOC');
if (!empty($lang_id[0]["id"])) {
$sql = 'INSERT INTO '.Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE).' (event_type_name, language_id, message, subject, activated)
VALUES("'.$event_name.'", '.$lang_id[0]["id"].', "'.Database::escape_string($message).'", "'.Database::escape_string($subject).'", '.$activated.')';
@ -766,7 +766,7 @@ function eventType_mod($etId, $users, $message, $subject) {
function get_last_attempt_date_of_exercise($exe_id) {
$exe_id = intval($exe_id);
$track_attempts = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$sql_track_attempt = 'SELECT max(tms) as last_attempt_date FROM '.$track_attempts.' WHERE exe_id='.$exe_id;
$rs_last_attempt = Database::query($sql_track_attempt);
@ -845,7 +845,7 @@ function delete_student_lp_events($user_id, $lp_id, $course, $session_id) {
$lp_view_table = Database::get_course_table(TABLE_LP_VIEW);
$lp_item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$course_id = $course['real_id'];
if (empty($course_id)) {
$course_id = api_get_course_int_id();
}
@ -859,18 +859,18 @@ function delete_student_lp_events($user_id, $lp_id, $course, $session_id) {
$session_id = intval($session_id);
//Make sure we have the exact lp_view_id
$sql = "SELECT id FROM $lp_view_table WHERE c_id = $course_id AND user_id = $user_id AND lp_id = $lp_id AND session_id = $session_id ";
$sql = "SELECT id FROM $lp_view_table WHERE c_id = $course_id AND user_id = $user_id AND lp_id = $lp_id AND session_id = $session_id ";
$result = Database::query($sql);
if (Database::num_rows($result)) {
$view = Database::fetch_array($result, 'ASSOC');
$lp_view_id = $view['id'];
$sql = "DELETE FROM $lp_item_view_table WHERE c_id = $course_id AND lp_view_id = $lp_view_id ";
$sql = "DELETE FROM $lp_item_view_table WHERE c_id = $course_id AND lp_view_id = $lp_view_id ";
Database::query($sql);
}
$sql = "DELETE FROM $lp_view_table WHERE c_id = $course_id AND user_id = $user_id AND lp_id= $lp_id AND session_id = $session_id ";
$sql = "DELETE FROM $lp_view_table WHERE c_id = $course_id AND user_id = $user_id AND lp_id= $lp_id AND session_id = $session_id ";
Database::query($sql);
$sql = "SELECT exe_id FROM $track_e_exercises WHERE exe_user_id = $user_id AND session_id = $session_id AND exe_cours_id = '{$course['code']}' AND orig_lp_id = $lp_id";
@ -901,7 +901,7 @@ function delete_student_lp_events($user_id, $lp_id, $course, $session_id) {
* @param int session id
*/
function delete_all_incomplete_attempts($user_id, $exercise_id, $course_code, $session_id = 0) {
$track_e_exercises = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$track_e_exercises = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$user_id = intval($user_id);
$exercise_id = intval($exercise_id);
$course_code = Database::escape_string($course_code);
@ -1120,7 +1120,7 @@ function get_exercise_results_by_user($user_id, $exercise_id, $course_code, $ses
*
*/
function count_exercise_attempts_by_user($user_id, $exercise_id, $course_code, $session_id = 0) {
$TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$course_code = Database::escape_string($course_code);
$exercise_id = intval($exercise_id);
$session_id = intval($session_id);
@ -1232,8 +1232,6 @@ function count_exercise_result_not_validated($exercise_id, $course_code, $sessio
$session_id = intval($session_id);
$exercise_id = intval($exercise_id);
$status = Database::escape_string($status);
$sql = "SELECT count(e.exe_id) as count FROM $table_track_exercises e LEFT JOIN $table_track_attempt a ON e.exe_id = a.exe_id
WHERE exe_exo_id = $exercise_id AND
exe_cours_id = '$course_code' AND
@ -1329,7 +1327,7 @@ function get_all_exercises_from_lp($lp_id, $course_id) {
*/
function get_comments($exe_id, $question_id) {
$table_track_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$sql = "SELECT teacher_comment FROM ".$table_track_attempt."
$sql = "SELECT teacher_comment FROM ".$table_track_attempt."
WHERE exe_id='".Database::escape_string($exe_id)."' AND question_id = '".Database::escape_string($question_id)."' ORDER by question_id";
$sqlres = Database::query($sql);
$comm = Database::result($sqlres, 0, "teacher_comment");
@ -1404,11 +1402,11 @@ function event_course_login($course_code, $user_id, $session_id) {
* For the sake of genericity, this function is a switch.
* It's called by EventsDispatcher and fires the good function
* with the good require_once.
*
*
* @param string $event_name
* @param array $params
* @param array $params
*/
function event_send_mail($event_name, $params) {
function event_send_mail($event_name, $params) {
EventsMail::send_mail($event_name, $params);
}
@ -1417,24 +1415,24 @@ function event_send_mail($event_name, $params) {
* @param string $event_name
* @param int $user_from
* @param int $user_to
* @return boolean
* @return boolean
*/
function check_if_mail_already_sent($event_name, $user_from, $user_to = null) {
if ($user_to == null) {
$sql = 'SELECT COUNT(*) as total FROM ' . Database::get_main_table(TABLE_EVENT_SENT) . '
$sql = 'SELECT COUNT(*) as total FROM ' . Database::get_main_table(TABLE_EVENT_SENT) . '
WHERE user_from = '.$user_from.' AND event_type_name = "'.$event_name.'"';
} else {
$sql = 'SELECT COUNT(*) as total FROM ' . Database::get_main_table(TABLE_EVENT_SENT) . '
$sql = 'SELECT COUNT(*) as total FROM ' . Database::get_main_table(TABLE_EVENT_SENT) . '
WHERE user_from = '.$user_from.' AND user_to = '.$user_to.' AND event_type_name = "'.$event_name.'"';
}
}
$result = Database::store_result(Database::query($sql), 'ASSOC');
return $result[0]["total"];
}
/*
*
/*
*
* Filter EventEmailTemplate Filters see the main/inc/conf/events.conf.dist.php
*
*
*/
/**
@ -1467,7 +1465,7 @@ function portal_homepage_edited_event_send_mail_filter_func(&$values) {
}
/**
*
*
*/
/* End of filters */

@ -272,6 +272,19 @@ define('USER_RELATION_TYPE_ENEMY', 5); // should be deprecated is useless
define('USER_RELATION_TYPE_DELETED', 6);
define('USER_RELATION_TYPE_RRHH', 7);
//Gradebook link constants
// Please do not change existing values, they are used in the database !
define('LINK_EXERCISE', 1);
define('LINK_DROPBOX', 2);
define('LINK_STUDENTPUBLICATION', 3);
define('LINK_LEARNPATH', 4);
define('LINK_FORUM_THREAD', 5);
//define('LINK_WORK',6);
define('LINK_ATTENDANCE', 7);
define('LINK_SURVEY', 8);
/**
* Inclusion of internationalization libraries

Loading…
Cancel
Save