Should fix problems when adding a work in the agenda see #3692

skala
Julio Montoya 13 years ago
parent 25eeeea708
commit f839aade63
  1. 74
      main/work/work.lib.php
  2. 64
      main/work/work.php

@ -481,7 +481,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$mydir_temp = '/'.$my_sub_dir.$dir;
}
$sql_select_directory = "SELECT prop.lastedit_date, work.id, author, has_properties, view_properties, description, qualification, weight FROM ".$iprop_table." prop INNER JOIN ".$work_table." work ON (prop.ref=work.id) WHERE ";
$sql_select_directory = "SELECT prop.insert_date, prop.lastedit_date, work.id, author, has_properties, view_properties, description, qualification, weight FROM ".$iprop_table." prop INNER JOIN ".$work_table." work ON (prop.ref=work.id) WHERE ";
if (!empty($_SESSION['toolgroup'])) {
$sql_select_directory .= " work.post_group_id = '".$_SESSION['toolgroup']."' "; // set to select only messages posted by the user's group
} else {
@ -553,7 +553,6 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$form_folder -> addGroup($qualification_input, 'qualification', get_lang('QualificationNumeric'), 'size="10"');
if ((int)$row['weight'] == 0) {
$form_folder -> addElement('checkbox', 'make_calification', null, get_lang('MakeQualifiable'), 'onclick="javascript: if(this.checked){document.getElementById(\'option3\').style.display = \'block\';}else{document.getElementById(\'option3\').style.display = \'none\';}"');
$form_folder -> addElement('html', '<div id=\'option3\' style="display:none">');
$weight_input2[] = FormValidator :: createElement('text', 'weight');
@ -562,29 +561,55 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
} else {
$weight_input[] = FormValidator :: createElement('text', 'weight');
$form_folder -> addGroup($weight_input, 'weight', get_lang('WeightInTheGradebook'), 'size="10"');
//$form_folder->freeze();
}
if ($homework['expires_on'] != '0000-00-00 00:00:00') {
$homework['expires_on'] = api_get_local_time($homework['expires_on']);
$there_is_a_expire_date = true;
$defaults['enableExpiryDate'] = true;
$form_folder -> addElement('checkbox', 'enableExpiryDate',null,get_lang('EnableExpiryDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option1\').style.display = \'block\';}else{document.getElementById(\'option1\').style.display = \'none\';}"');
$form_folder -> addElement('html', '<div id=\'option1\' style="display:block">');
$form_folder -> addGroup(create_group_date_select(), 'expires', get_lang('ExpiresAt'));
$form_folder -> addElement('html', '</div>');
} else {
$homework['expires_on'] = api_get_local_time();
$there_is_a_expire_date = true;
$expires_date_array = convert_date_to_array(api_get_local_time(), 'expires');
$defaults = array_merge($defaults, $expires_date_array);
$there_is_a_expire_date = false;
$form_folder -> addElement('checkbox', 'enableExpiryDate',null,get_lang('EnableExpiryDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option1\').style.display = \'block\';}else{document.getElementById(\'option1\').style.display = \'none\';}"');
$form_folder -> addElement('html', '<div id=\'option1\' style="display:none">');
$form_folder -> addGroup(create_group_date_select(), 'expires', get_lang('ExpiresAt'));
$form_folder -> addElement('html', '</div>');
}
if ($homework['ends_on'] != '0000-00-00 00:00:00') {
$homework['ends_on'] = api_get_local_time($homework['ends_on']);
$there_is_a_end_date = true;
$defaults['enableEndDate'] = true;
$form_folder -> addElement('checkbox', 'enableEndDate', null, get_lang('EnableEndDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option2\').style.display = \'block\';}else{document.getElementById(\'option2\').style.display = \'none\';}"');
$form_folder -> addElement('html', '<div id=\'option2\' style="display:block">');
$form_folder -> addGroup(create_group_date_select(), 'ends', get_lang('EndsAt'));
$form_folder -> addElement('html', '</div>');
$form_folder -> addRule(array('expires', 'ends'), get_lang('DateExpiredNotBeLessDeadLine'), 'comparedate');
} else {
$homework['ends_on'] = api_get_local_time();
$there_is_a_end_date = true;
$expires_date_array = convert_date_to_array(api_get_local_time(), 'ends');
$defaults = array_merge($defaults, $expires_date_array);
$there_is_a_end_date = false;
$form_folder -> addElement('checkbox', 'enableEndDate', null, get_lang('EnableEndDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option2\').style.display = \'block\';}else{document.getElementById(\'option2\').style.display = \'none\';}"');
$form_folder -> addElement('html', '<div id=\'option2\' style="display:none">');
$form_folder -> addGroup(create_group_date_select(), 'ends', get_lang('EndsAt'));
@ -599,14 +624,17 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$form_folder -> addElement('html', '</div>');
$form_folder -> addElement('style_submit_button', 'submit', get_lang('ModifyDirectory'), 'class="save"');
if ($there_is_a_end_date) {
$end_date_array = convert_date_to_array($homework['ends_on'], 'ends');
$defaults = array_merge($defaults, $end_date_array);
}
if ($there_is_a_expire_date) {
$expires_date_array = convert_date_to_array($homework['expires_on'], 'expires');
$defaults = array_merge($defaults, $expires_date_array);
}
if (!empty($row['qualification'])) {
$defaults = array_merge($defaults, array('qualification[qualification]' => $row['qualification']));
}
@ -617,6 +645,18 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$display_edit_form = true;
if ($form_folder->validate()) {
if ($_POST['enableExpiryDate'] == '1') {
$there_is_a_expire_date = true;
} else {
$there_is_a_expire_date = false;
}
if ($_POST['enableEndDate'] == '1') {
$there_is_a_end_date = true;
} else {
$there_is_a_end_date = false;
}
$values = $form_folder -> exportValues();
$values = $values['my_group'];
$dir_name = replace_dangerous_char($values['dir_name']);
@ -634,30 +674,31 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
if ($edit_check) {
$TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);
if ($there_is_a_end_date || $there_is_a_expire_date) {
/*
if ($row['view_properties'] == '1') {
//@todo check this condition When this code happens???
$sql_add_publication = "UPDATE ".$work_table." SET has_properties = '".$row['has_properties']. "', view_properties=1 where id ='".$row['id']."'";
Database::query($sql_add_publication);
$expires_query = ' SET expires_on = '."'".($there_is_a_expire_date ? api_get_utc_datetime(get_date_from_group('expires')) : '0000-00-00 00:00:00')."'".',';
$ends_query = ' ends_on = '."'".($there_is_a_end_date ? api_get_utc_datetime(get_date_from_group('ends')) : '0000-00-00 00:00:00')."'";
Database::query('UPDATE '.$work_assigment.$expires_query.$ends_query.' WHERE id = '."'".$row['has_properties']."'");
} elseif ($row['view_properties'] == '0') {
if ($_POST['enableExpiryDate'] == '1') {
*/
$expires_query = ' SET expires_on = '."'".($there_is_a_expire_date ? api_get_utc_datetime(get_date_from_group('expires')) : '0000-00-00 00:00:00')."'";
Database::query('UPDATE '.$work_assigment.$expires_query.' WHERE id = '."'".$row['has_properties']."'");
$sql_add_publication = "UPDATE ".$work_table." SET has_properties = '".$row['has_properties']. "', view_properties=1 where id ='".$row['id']."'";
Database::query($sql_add_publication);
}
if ($_POST['enableEndDate'] == '1') {
//$expires_query = ' SET expires_on = '."'".($there_is_a_expire_date ? get_date_from_group('expires') : '0000-00-00 00:00:00')."'".',';
$ends_query = ' SET ends_on = '."'".($there_is_a_end_date ? api_get_utc_datetime(get_date_from_group('ends')) : '0000-00-00 00:00:00')."'";
Database::query('UPDATE '.$work_assigment.$ends_query.' WHERE id = '."'".$row['has_properties']."'");
$sql_add_publication = "UPDATE ".$work_table." SET has_properties = '".$row['has_properties']. "', view_properties=1 where id ='".$row['id']."'";
Database::query($sql_add_publication);
}
}
}
//if($_POST['qualification']['qualification']!='')
//}
Database::query('UPDATE '.$work_table.' SET description = '."'".Database::escape_string($_POST['description'])."'".', qualification = '."'".Database::escape_string($_POST['qualification']['qualification'])."'".',weight = '."'".Database::escape_string($_POST['weight']['weight'])."'".' WHERE id = '."'".$row['id']."'");
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
@ -688,9 +729,9 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$calendar_id = Database::fetch_row($res);
$dir_name = sprintf(get_lang('HandingOverOfTaskX'), $dir_name);
$end_date = "0000-00-00 00:00:00";
$end_date = $row['insert_date'];
if ($_POST['enableExpiryDate'] == '1' || $there_is_a_end_date) {
if ($_POST['enableExpiryDate'] == '1') {
$end_date = Database::escape_string(api_get_utc_datetime(get_date_from_group('expires')));
}
@ -699,6 +740,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$sql = "UPDATE ".$TABLEAGENDA."
SET title='".$dir_name."',
content = '".Database::escape_string($_POST['description'])."',
start_date = '".$end_date."',
end_date = '".$end_date."'
WHERE id='".$calendar_id[0]."'";
Database::query($sql);

@ -22,8 +22,7 @@
*
* GOALS
* *****
* Allow student to quickly send documents immediately
* visible on the course website.
* Allow student to quickly send documents immediately visible on the Course
*
* The script does 5 things:
*
@ -37,22 +36,6 @@
* establish a correspondence between RealServer Content Path and the user's
* documents path.
*
* All documents are sent to the address /$_configuration['root_sys']/$currentCourseID/document/
* where $currentCourseID is the web directory for the course and $_configuration['root_sys']
* usually /var/www/html
*
* Modified by Patrick Cool, february 2004:
* Allow course managers to specify wether newly uploaded documents should
* be visible or unvisible by default
* This is ideal for reviewing the uploaded documents before the document
* is available for everyone.
*
* note: maybe the form to change the behaviour should go into the course
* properties page?
* note 2: maybe a new field should be created in the course table for
* this behaviour.
*
* We now use the show_score field since this is not used.
*
*/
@ -464,24 +447,9 @@ if (!empty($_REQUEST['new_dir'])) {
} else {
$dir_name_sql = '/'.$created_dir;
}
$time = time();
$today = api_get_utc_datetime($time);
// Insert into agenda
$agenda_id = 0;
$end_date = '';
if (isset($_POST['add_to_calendar']) && $_POST['add_to_calendar'] == 1) {
require_once api_get_path(SYS_CODE_PATH).'calendar/agenda.inc.php';
require_once api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php';
$course = isset($course_info) ? $course_info : null;
$date = time();
$title = sprintf(get_lang('HandingOverOfTaskX'), $_POST['new_dir']);
if (!empty($_POST['type1'])) {
$end_date = get_date_from_select('expires');
}
$description = isset($_POST['description']) ? $_POST['description'] : '';
$content = '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;curdirpath='.api_substr($dir_name_sql, 1).'" >'.$_POST['new_dir'].'</a>'.$description;
$agenda_id = agenda_add_item($course, $title, $content, $date, $end_date, array('GROUP:'.$toolgroup), 0);
}
$sql_add_publication = "INSERT INTO " . $work_table . " SET
url = '".Database::escape_string($dir_name_sql)."',
title = '".Database::escape_string($_POST['new_dir'])."',
@ -491,7 +459,7 @@ if (!empty($_REQUEST['new_dir'])) {
accepted = '1',
filetype = 'folder',
post_group_id = '".$toolgroup."',
sent_date = '".api_get_utc_datetime()."',
sent_date = '".$today."',
qualification = '".(($_POST['qualification_value']!='') ? Database::escape_string($_POST['qualification_value']) : '') ."',
parent_id = '',
qualificator_id = '',
@ -504,6 +472,30 @@ if (!empty($_REQUEST['new_dir'])) {
// add the directory
$id = Database::insert_id();
if ($id) {
// Insert into agenda
$agenda_id = 0;
$end_date = '';
if (isset($_POST['add_to_calendar']) && $_POST['add_to_calendar'] == 1) {
require_once api_get_path(SYS_CODE_PATH).'calendar/agenda.inc.php';
require_once api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php';
$course = isset($course_info) ? $course_info : null;
// Setting today date
$date = $end_date = $time;
$title = sprintf(get_lang('HandingOverOfTaskX'), $_POST['new_dir']);
if (!empty($_POST['type1'])) {
$end_date = get_date_from_select('expires');
$date = $end_date;
}
$description = isset($_POST['description']) ? $_POST['description'] : '';
$content = '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;curdirpath='.api_substr($dir_name_sql, 1).'" >'.$_POST['new_dir'].'</a>'.$description;
$agenda_id = agenda_add_item($course, $title, $content, $date, $end_date, array('GROUP:'.$toolgroup), 0);
}
}
//Folder created
api_item_property_update($_course, 'work', $id, 'DirectoryCreated', $user_id);
Display :: display_confirmation_message(get_lang('DirectoryCreated'), false);

Loading…
Cancel
Save