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') {
//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";

@ -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 () {
});
</script>';
/*********************
* 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'];
}

Loading…
Cancel
Save