2 important changes:

1. Implements feature #2800 (Code added but commented) when the LP/exercise start time is not set the item is not visible for students

2. Now we can add a start date or an end date independently in a LP
skala
Julio Montoya 15 years ago
parent 366a861e2c
commit 949b3db6b8
  1. 12
      main/exercice/exercice.php
  2. 3
      main/exercice/exercise.class.php
  3. 9
      main/exercice/exercise_submit.php
  4. 49
      main/newscorm/learnpath.class.php
  5. 40
      main/newscorm/lp_add.php
  6. 54
      main/newscorm/lp_controller.php
  7. 55
      main/newscorm/lp_edit.php
  8. 17
      main/newscorm/lp_view.php

@ -773,7 +773,15 @@ if ($show == 'test') {
}
}
}
}
}
//Blocking empty start times see BT#2800
/*
if (empty($row['start_time']) || $row['start_time'] == '0000-00-00 00:00:00') {
$time_limits = true;
$is_actived_time = false;
}*/
// Teacher only
if ($is_allowedToEdit) {
@ -859,7 +867,7 @@ if ($show == 'test') {
} else {
// --- Student only
$row['title'] = text_filter(cut($row['title'], EXERCISE_MAX_NAME_SIZE));
$row['title'] = cut($row['title'], EXERCISE_MAX_NAME_SIZE);
// if time is actived show link to exercise
if ($time_limits) {

@ -3232,5 +3232,8 @@ class Exercise {
}
return $result;
}
public function is_visible_for_student() {
}
}
endif;

@ -568,6 +568,15 @@ if ($limit_time_exists) {
}
}
/*
* Blocking empty start times see BT#2800
if (empty($objExercise->start_time) || $objExercise->start_time == '0000-00-00 00:00:00') {
Display :: display_warning_message(sprintf(get_lang('ExerciseNoStartedYet'), $exerciseTitle, $objExercise->selectAttempts()));
if ($origin != 'learnpath') {
Display :: display_footer();
}
}*/
//Timer control
if ($time_control) {
echo '<div align="left" id="wrapper-clock"><div id="square" class="rounded"><div id="text-content" align="center" class="count_down"></div></div></div>';

@ -603,7 +603,8 @@ class learnpath {
if ($publicated_on == '0000-00-00 00:00:00' || empty($publicated_on)) {
//by default the publication date is the same that the creation date
$publicated_on = api_get_utc_datetime();
//The behaviour above was changed due BT#2800
$publicated_on = '';
} else {
$publicated_on = Database::escape_string(api_get_utc_datetime($publicated_on));
}
@ -1985,12 +1986,10 @@ class learnpath {
// Get current prerequisite
$sql = "SELECT id, prerequisite, publicated_on, expired_on FROM $tbl_learnpath WHERE id = $lp_id";
$rs = Database::query($sql);
$now = time();
if (Database::num_rows($rs)>0) {
$row = Database::fetch_array($rs);
$prerequisite = $row['prerequisite'];
$find = array(' ','-',':');
$from = str_replace($find,'',api_get_local_time($row['publicated_on']));
$to = str_replace($find,'',api_get_local_time($row['expired_on']));
$row = Database::fetch_array($rs, 'ASSOC');
$prerequisite = $row['prerequisite'];
$is_visible = true;
$progress = 0;
@ -2001,13 +2000,33 @@ class learnpath {
$is_visible = false;
}
}
// Also check the time availability of the learning path
// Also check the time availability of the LP
if ($is_visible) {
$now = str_replace($find,'',api_get_local_time());
if ((($row['publicated_on']!='0000-00-00 00:00:00') && ($now<$from)) or (($row['expired_on']!='0000-00-00 00:00:00') && ($now>$to))) {
$is_visible = false;
}
//Adding visibility reestrinctions
if (!empty($row['publicated_on']) && $row['publicated_on'] != '0000-00-00 00:00:00') {
if ($now < api_strtotime($row['publicated_on'], 'UTC')) {
//api_not_allowed();
$is_visible = false;
}
}
//Blocking empty start times see BT#2800
/*
if (empty($row['publicated_on']) || $row['publicated_on'] == '0000-00-00 00:00:00') {
//api_not_allowed();
$is_visible = false;
}*/
if (!empty($row['expired_on']) && $row['expired_on'] != '0000-00-00 00:00:00') {
if ($now > api_strtotime($row['expired_on'], 'UTC')) {
//api_not_allowed();
$is_visible = false;
}
}
}
return $is_visible;
}
return false;
@ -2692,12 +2711,17 @@ class learnpath {
if ($item['id'] == $this->current) {
$style = 'scorm_item_highlight';
$scorm_color_background = 'scorm_item_highlight';
} else
} else {
if ($color_counter % 2 == 0) {
$scorm_color_background = 'scorm_item_1';
} else {
$scorm_color_background = 'scorm_item_2';
}
if ($item['type'] == 'dokeos_module' || $item['type'] == 'dokeos_chapter') {
$scorm_color_background =' scorm_item_section ';
}
}
if ($scorm_color_background != '') {
$html .= '<div id="toc_' . $item['id'] . '" class="' . $scorm_color_background . '">';
@ -8665,7 +8689,6 @@ EOD;
// Return the previous item ID
return $row_max->previous;
}
}
if (!function_exists('trim_value')) {

@ -41,13 +41,21 @@ $("#learnpath_title").focus();
$(document).ready(function () {
setFocus();
});
function timelimit() {
if(document.getElementById(\'options2\').style.display == \'none\')
{
document.getElementById(\'options2\').style.display = \'block\';
function activate_start_date() {
if(document.getElementById(\'start_date_div\').style.display == \'none\') {
document.getElementById(\'start_date_div\').style.display = \'block\';
} else {
document.getElementById(\'start_date_div\').style.display = \'none\';
}
}
function activate_end_date() {
if(document.getElementById(\'end_date_div\').style.display == \'none\') {
document.getElementById(\'end_date_div\').style.display = \'block\';
} else {
document.getElementById(\'options2\').style.display = \'none\';
document.getElementById(\'end_date_div\').style.display = \'none\';
}
}
@ -125,16 +133,20 @@ $form->addRule('lp_name', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('hidden', 'post_time', time());
$form->addElement('hidden', 'action', 'add_lp');
$form->addElement('checkbox', 'enabletimelimit',get_lang('EnableTimeLimits'),null,'onclick = " return timelimit() "');
$form->addElement('html','<div id="options2" style="display:none;">');
//Start date
$form->addElement('checkbox', 'activate_start_date_check',get_lang('EnableStartTime'),null, array('onclick' => 'activate_start_date()'));
$form->addElement('html','<div id="start_date_div" style="display:block;">');
$form->addElement('datepicker', 'publicated_on', get_lang('PublicationDate'), array('form_name'=>'exercise_admin'), 5);
$form->addElement('datepicker', 'expired_on', get_lang('ExpirationDate'), array('form_name'=>'exercise_admin'), 5);
$form->addElement('html','</div>');
//End date
$form->addElement('checkbox', 'activate_end_date_check', get_lang('EnableEndTime'), null,array('onclick' => 'activate_end_date()'));
$form->addElement('html','<div id="end_date_div" style="display:none;">');
$form->addElement('datepicker', 'expired_on', get_lang('ExpirationDate'), array('form_name'=>'exercise_admin'), 5);
$form->addElement('html','</div>');
$defaults['activate_start_date_check'] = 1;
$defaults['publicated_on'] = date('Y-m-d 12:00:00');
$defaults['expired_on'] = date('Y-m-d 12:00:00',time()+84600);
@ -144,4 +156,4 @@ $form->addElement('style_submit_button', 'Submit',get_lang('CreateLearningPath')
$form->display();
// Footer
Display::display_footer();
Display::display_footer();

@ -261,31 +261,31 @@ switch ($action) {
} else {
$_SESSION['post_time'] = $_REQUEST['post_time'];
if (!$_REQUEST['enabletimelimit']) {
$_REQUEST['publicated_on'] = null;
$_REQUEST['expired_on'] = null;
if (isset($_REQUEST['activate_start_date_check']) && $_REQUEST['activate_start_date_check'] == 1) {
$publicated_on = $_REQUEST['publicated_on'];
$publicated_on = $publicated_on['Y'].'-'.$publicated_on['F'].'-'.$publicated_on['d'].' '.$publicated_on['H'].':'.$publicated_on['i'].':00';
} else {
$publicated_on = $_REQUEST['publicated_on'];
$publicated_on = $publicated_on['Y'].'-'.$publicated_on['F'].'-'.$publicated_on['d'].' '.$publicated_on['H'].':'.$publicated_on['i'].':00';
$expired_on = $_REQUEST['expired_on'];
$expired_on = $expired_on['Y'].'-'.$expired_on['F'].'-'.$expired_on['d'].' '.$expired_on['H'].':'.$expired_on['i'].':00';
$publicated_on = null;
}
if (isset($_REQUEST['activate_end_date_check']) && $_REQUEST['activate_end_date_check'] == 1) {
$expired_on = $_REQUEST['expired_on'];
$expired_on = $expired_on['Y'].'-'.$expired_on['F'].'-'.$expired_on['d'].' '.$expired_on['H'].':'.$expired_on['i'].':00';
} else {
$expired_on = null;
}
// Kevin Van Den Haute: Changed $_REQUEST['learnpath_description'] by '' because it's not used.
//old->$new_lp_id = learnpath::add_lp(api_get_course_id(), $_REQUEST['learnpath_name'], $_REQUEST['learnpath_description'], 'dokeos', 'manual', '');
$new_lp_id = learnpath::add_lp(api_get_course_id(), Security::remove_XSS($_REQUEST['lp_name']), '', 'chamilo', 'manual', '', $publicated_on, $expired_on);
//learnpath::toggle_visibility($new_lp_id,'v');
// Kevin Van Den Haute: Only go further if learnpath::add_lp has returned an id.
if (is_numeric($new_lp_id)) {
// TODO: Maybe create a first module directly to avoid bugging the user with useless queries
$_SESSION['oLP'] = new learnpath(api_get_course_id(),$new_lp_id,api_get_user_id());
//$_SESSION['oLP']->add_item(0, -1, 'dokeos_chapter', $_REQUEST['path'], 'Default');
require 'lp_build.php';
}
}
}
else
} else {
require 'lp_add.php';
}
break;
@ -597,25 +597,25 @@ switch ($action) {
$_SESSION['oLP']->set_prerequisite($_REQUEST['prerequisites']);
$_SESSION['oLP']->set_use_max_score($_REQUEST['use_max_score']);
if (!$_REQUEST['enabletimelimit']) {
//there will be always a publication date
$publicated_on = $_REQUEST['publicated_on'];
$publicated_on = $publicated_on['Y'].'-'.$publicated_on['F'].'-'.$publicated_on['d'].' '.$publicated_on['H'].':'.$publicated_on['i'].':00';
$expired_on = null;
if (isset($_REQUEST['activate_start_date_check']) && $_REQUEST['activate_start_date_check'] == 1) {
$publicated_on = $_REQUEST['publicated_on'];
$publicated_on = $publicated_on['Y'].'-'.$publicated_on['F'].'-'.$publicated_on['d'].' '.$publicated_on['H'].':'.$publicated_on['i'].':00';
} else {
$publicated_on = $_REQUEST['publicated_on'];
$publicated_on = $publicated_on['Y'].'-'.$publicated_on['F'].'-'.$publicated_on['d'].' '.$publicated_on['H'].':'.$publicated_on['i'].':00';
$expired_on = $_REQUEST['expired_on'];
$expired_on = $expired_on['Y'].'-'.$expired_on['F'].'-'.$expired_on['d'].' '.$expired_on['H'].':'.$expired_on['i'].':00';
$publicated_on = null;
}
if (isset($_REQUEST['activate_end_date_check']) && $_REQUEST['activate_end_date_check'] == 1) {
$expired_on = $_REQUEST['expired_on'];
$expired_on = $expired_on['Y'].'-'.$expired_on['F'].'-'.$expired_on['d'].' '.$expired_on['H'].':'.$expired_on['i'].':00';
} else {
$expired_on = null;
}
$_SESSION['oLP']->set_modified_on();
$_SESSION['oLP']->set_publicated_on($publicated_on);
$_SESSION['oLP']->set_expired_on($expired_on);
if ($_REQUEST['remove_picture']) {
$_SESSION['oLP']->delete_lp_image();
}

@ -31,14 +31,22 @@ $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => g
$interbreadcrumb[] = array('url' => api_get_self()."?action=admin_view&lp_id=$learnpath_id", 'name' => $_SESSION['oLP']->get_name());
$htmlHeadXtra[] = '<script type="text/javascript">
function timelimit() {
if(document.getElementById(\'options2\').style.display == \'none\')
{
document.getElementById(\'options2\').style.display = \'block\';
} else {
document.getElementById(\'options2\').style.display = \'none\';
}
}
function activate_start_date() {
if(document.getElementById(\'start_date_div\').style.display == \'none\') {
document.getElementById(\'start_date_div\').style.display = \'block\';
} else {
document.getElementById(\'start_date_div\').style.display = \'none\';
}
}
function activate_end_date() {
if(document.getElementById(\'end_date_div\').style.display == \'none\') {
document.getElementById(\'end_date_div\').style.display = \'block\';
} else {
document.getElementById(\'end_date_div\').style.display = \'none\';
}
}
</script>';
@ -186,23 +194,30 @@ $publicated_on = $_SESSION['oLP'] ->publicated_on;
$form->addElement('html', '<div class="row"><div class="label">'.get_lang('Prerequisites').'</div><div class="formw">'.$_SESSION['oLP']->display_lp_prerequisites_list().'</div></div>');
$form->addElement('static', null, null, get_lang('LpPrerequisiteDescription'));
$form->addElement('checkbox', 'enabletimelimit',get_lang('EnableTimeLimits'),null,'onclick = " return timelimit() "');
if( ($publicated_on!='0000-00-00 00:00:00' && !empty($publicated_on)) && ( $expired_on!='0000-00-00 00:00:00' && !empty($expired_on)) )
$defaults['enabletimelimit'] = 1;
$display_date = 'none';
if ($defaults['enabletimelimit'] ) {
$display_date = 'block';
//Start date
$form->addElement('checkbox', 'activate_start_date_check', get_lang('EnableStartTime'),null, array('onclick' => 'activate_start_date()'));
$display_date = 'none';
if ($publicated_on!='0000-00-00 00:00:00' && !empty($publicated_on)) {
$display_date = 'block';
$defaults['activate_start_date_check'] = 1;
}
$form->addElement('html','<div id="options2" style="display:'.$display_date.';">');
$form->addElement('html','<div id="start_date_div" style="display:'.$display_date.';">');
$form->addElement('datepicker', 'publicated_on', get_lang('PublicationDate'), array('form_name'=>'exercise_admin'), 5);
$form->addElement('datepicker', 'expired_on', get_lang('ExpirationDate'), array('form_name'=>'exercise_admin'), 5);
$form->addElement('html','</div>');
//End date
$form->addElement('checkbox', 'activate_end_date_check', get_lang('EnableEndTime'), null,array('onclick' => 'activate_end_date()'));
$display_date = 'none';
if ($expired_on!='0000-00-00 00:00:00' && !empty($expired_on)) {
$display_date = 'block';
$defaults['activate_end_date_check'] = 1;
}
$form->addElement('html','</div>');
$form->addElement('html','<div id="end_date_div" style="display:'.$display_date.';">');
$form->addElement('datepicker', 'expired_on', get_lang('ExpirationDate'), array('form_name'=>'exercise_admin'), 5);
$form->addElement('html','</div>');
if (api_is_platform_admin()) {
$form->addElement('checkbox', 'use_max_score', get_lang('UseMaxScore100'));

@ -65,23 +65,6 @@ $htmlHeadXtra[] = '<script language="JavaScript" type="text/javascript">
</script>';
$_SESSION['oLP']->error = '';
$now = time();
if (!api_is_allowed_to_edit(null, true)) {
//Adding visibility reestrinctions
if (!empty($_SESSION['oLP']->publicated_on) && $_SESSION['oLP']->publicated_on != '0000-00-00 00:00:00') {
if ($now < api_strtotime($_SESSION['oLP']->publicated_on, 'UTC')) {
api_not_allowed();
}
}
if (!empty($_SESSION['oLP']->expired_on) && $_SESSION['oLP']->expired_on != '0000-00-00 00:00:00') {
if ($now > api_strtotime($_SESSION['oLP']->expired_on, 'UTC')) {
api_not_allowed();
}
}
}
$lp_item_id = $_SESSION['oLP']->get_current_item_id();
$lp_type = $_SESSION['oLP']->get_type();
$lp_id = intval($_GET['lp_id']);

Loading…
Cancel
Save