Fixing error when adding time limits in an exercise see BT#1647

skala
Julio Montoya 15 years ago
parent 0b1d5446b5
commit eae6385937
  1. 22
      main/exercice/exercice.php
  2. 32
      main/exercice/exercise_admin.php

@ -744,9 +744,9 @@ if ($show == 'test') {
*/ */
if ($origin != 'learnpath') { if ($origin != 'learnpath') {
//avoid sending empty parameters //avoid sending empty parameters
$myorigin = (empty ($origin) ? '' : '&origin=' . $origin); $myorigin = (empty ($origin) ? '' : '&origin=' . $origin);
$mylpid = (empty ($learnpath_id) ? '' : '&learnpath_id=' . $learnpath_id); $mylpid = (empty ($learnpath_id) ? '' : '&learnpath_id=' . $learnpath_id);
$mylpitemid = (empty ($learnpath_item_id) ? '' : '&learnpath_item_id=' . $learnpath_item_id); $mylpitemid = (empty ($learnpath_item_id) ? '' : '&learnpath_item_id=' . $learnpath_item_id);
$token = Security::get_token(); $token = Security::get_token();
while ($row = Database :: fetch_array($result,'ASSOC')) { while ($row = Database :: fetch_array($result,'ASSOC')) {
@ -756,20 +756,18 @@ if ($show == 'test') {
$time_limits = false; $time_limits = false;
if ($row['start_time'] != '0000-00-00 00:00:00' && $row['end_time'] != '0000-00-00 00:00:00') { if ($row['start_time'] != '0000-00-00 00:00:00' && $row['end_time'] != '0000-00-00 00:00:00') {
$time_limits = true; $time_limits = true;
} }
if ($time_limits) { if ($time_limits) {
// check if start time // check if start time
$start_time = api_strtotime($row['start_time']);
$start_time = api_strtotime($row['start_time'],'UTC'); $end_time = api_strtotime($row['end_time']);
$end_time = api_strtotime($row['end_time'], 'UTC'); $now = time();
$now = time(); $is_actived_time = false;
$is_actived_time = false;
if ($now > $start_time && $end_time > $now ) { if ($now > $start_time && $end_time > $now ) {
$is_actived_time = true; $is_actived_time = true;
} }
} }
if ($i % 2 == 0) if ($i % 2 == 0)
$s_class = "row_odd"; $s_class = "row_odd";

@ -12,11 +12,11 @@
// name of the language file that needs to be included // name of the language file that needs to be included
$language_file='exercice'; $language_file='exercice';
include 'exercise.class.php'; require_once 'exercise.class.php';
include 'question.class.php'; require_once 'question.class.php';
include 'answer.class.php'; require_once 'answer.class.php';
include '../inc/global.inc.php'; require_once '../inc/global.inc.php';
include 'exercise.lib.php'; require_once 'exercise.lib.php';
$this_section=SECTION_COURSES; $this_section=SECTION_COURSES;
if(!api_is_allowed_to_edit(null,true)) { if(!api_is_allowed_to_edit(null,true)) {
@ -133,18 +133,12 @@ $(document).ready(function () {
}); });
</script>'; </script>';
/********************* // INIT EXERCISE
* INIT EXERCISE
*********************/
require_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); require_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
$objExercise = new Exercise(); $objExercise = new Exercise();
/********************* //INIT FORM
* INIT FORM
*********************/
if(isset($_GET['exerciseId'])) { if(isset($_GET['exerciseId'])) {
$form = new FormValidator('exercise_admin', 'post', api_get_self().'?'.api_get_cidreq().'&exerciseId='.$_GET['exerciseId']); $form = new FormValidator('exercise_admin', 'post', api_get_self().'?'.api_get_cidreq().'&exerciseId='.$_GET['exerciseId']);
$objExercise -> read (intval($_GET['exerciseId'])); $objExercise -> read (intval($_GET['exerciseId']));
@ -156,10 +150,8 @@ if(isset($_GET['exerciseId'])) {
$objExercise -> createForm ($form); $objExercise -> createForm ($form);
/********************* // VALIDATE FORM
* VALIDATE FORM if ($form->validate()) {
*********************/
if ($form -> validate()) {
$objExercise -> processCreation($form); $objExercise -> processCreation($form);
if ($form -> getSubmitValue('edit') == 'true') { if ($form -> getSubmitValue('edit') == 'true') {
header('Location:exercice.php?message=ExerciseEdited&'.api_get_cidreq()); 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); header('Location:admin.php?message=ExerciseAdded&exerciseId='.$objExercise->id);
exit; exit;
} }
} else { } else {
/********************* // DISPLAY FORM
* DISPLAY FORM
*********************/
if (isset($_SESSION['gradebook'])) { if (isset($_SESSION['gradebook'])) {
$gradebook= $_SESSION['gradebook']; $gradebook= $_SESSION['gradebook'];
} }

Loading…
Cancel
Save