From eae6385937b6cad65ac1b93894a4e352499b5bb8 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 30 Nov 2010 12:25:36 +0100 Subject: [PATCH] Fixing error when adding time limits in an exercise see BT#1647 --- main/exercice/exercice.php | 22 ++++++++++------------ main/exercice/exercise_admin.php | 32 +++++++++++--------------------- 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/main/exercice/exercice.php b/main/exercice/exercice.php index fb9fc9a236..5bdc79876b 100755 --- a/main/exercice/exercice.php +++ b/main/exercice/exercice.php @@ -744,9 +744,9 @@ if ($show == 'test') { */ if ($origin != 'learnpath') { //avoid sending empty parameters - $myorigin = (empty ($origin) ? '' : '&origin=' . $origin); - $mylpid = (empty ($learnpath_id) ? '' : '&learnpath_id=' . $learnpath_id); - $mylpitemid = (empty ($learnpath_item_id) ? '' : '&learnpath_item_id=' . $learnpath_item_id); + $myorigin = (empty ($origin) ? '' : '&origin=' . $origin); + $mylpid = (empty ($learnpath_id) ? '' : '&learnpath_id=' . $learnpath_id); + $mylpitemid = (empty ($learnpath_item_id) ? '' : '&learnpath_item_id=' . $learnpath_item_id); $token = Security::get_token(); while ($row = Database :: fetch_array($result,'ASSOC')) { @@ -756,20 +756,18 @@ if ($show == 'test') { $time_limits = false; if ($row['start_time'] != '0000-00-00 00:00:00' && $row['end_time'] != '0000-00-00 00:00:00') { $time_limits = true; - } - + } if ($time_limits) { // check if start time - - $start_time = api_strtotime($row['start_time'],'UTC'); - $end_time = api_strtotime($row['end_time'], 'UTC'); - $now = time(); - - $is_actived_time = false; + $start_time = api_strtotime($row['start_time']); + $end_time = api_strtotime($row['end_time']); + $now = time(); + $is_actived_time = false; if ($now > $start_time && $end_time > $now ) { $is_actived_time = true; } - } + } + if ($i % 2 == 0) $s_class = "row_odd"; diff --git a/main/exercice/exercise_admin.php b/main/exercice/exercise_admin.php index 6b1452881b..742c6c75d6 100755 --- a/main/exercice/exercise_admin.php +++ b/main/exercice/exercise_admin.php @@ -12,11 +12,11 @@ // name of the language file that needs to be included $language_file='exercice'; -include 'exercise.class.php'; -include 'question.class.php'; -include 'answer.class.php'; -include '../inc/global.inc.php'; -include 'exercise.lib.php'; +require_once 'exercise.class.php'; +require_once 'question.class.php'; +require_once 'answer.class.php'; +require_once '../inc/global.inc.php'; +require_once 'exercise.lib.php'; $this_section=SECTION_COURSES; if(!api_is_allowed_to_edit(null,true)) { @@ -133,18 +133,12 @@ $(document).ready(function () { }); '; -/********************* - * INIT EXERCISE - *********************/ +// INIT EXERCISE require_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); $objExercise = new Exercise(); -/********************* - * INIT FORM - *********************/ - - +//INIT FORM if(isset($_GET['exerciseId'])) { $form = new FormValidator('exercise_admin', 'post', api_get_self().'?'.api_get_cidreq().'&exerciseId='.$_GET['exerciseId']); $objExercise -> read (intval($_GET['exerciseId'])); @@ -156,10 +150,8 @@ if(isset($_GET['exerciseId'])) { $objExercise -> createForm ($form); -/********************* - * VALIDATE FORM - *********************/ -if ($form -> validate()) { +// VALIDATE FORM +if ($form->validate()) { $objExercise -> processCreation($form); if ($form -> getSubmitValue('edit') == 'true') { header('Location:exercice.php?message=ExerciseEdited&'.api_get_cidreq()); @@ -168,10 +160,8 @@ if ($form -> validate()) { header('Location:admin.php?message=ExerciseAdded&exerciseId='.$objExercise->id); exit; } -} else { - /********************* - * DISPLAY FORM - *********************/ +} else { + // DISPLAY FORM if (isset($_SESSION['gradebook'])) { $gradebook= $_SESSION['gradebook']; }