Adding default visibility for some tools see BT#4386 configure the "tool_visible_by_default_at_creation" admin option

skala
Julio Montoya 13 years ago
parent 8c8f1aef39
commit 902607ba97
  1. 6
      main/announcements/announcements.inc.php
  2. 2
      main/coursecopy/classes/CourseRestorer.class.php
  3. 4
      main/document/create_document.php
  4. 4
      main/document/document.php
  5. 37
      main/exercice/exercice.php
  6. 10
      main/exercice/exercise.class.php
  7. 60
      main/forum/forumfunction.inc.php
  8. 8
      main/forum/index.php
  9. 2
      main/gradebook/gradebook_add_cat.php
  10. 18
      main/gradebook/lib/be/category.class.php
  11. 10
      main/gradebook/lib/be/evallink.class.php
  12. 9
      main/gradebook/lib/fe/catform.class.php
  13. 8
      main/gradebook/lib/fe/evalform.class.php
  14. 9
      main/gradebook/lib/fe/linkaddeditform.class.php
  15. 14
      main/inc/lib/fileUpload.lib.php
  16. 4
      main/inc/lib/link.lib.php
  17. 53
      main/inc/lib/main_api.lib.php
  18. 7
      main/newscorm/learnpath.class.php
  19. 5
      main/newscorm/lp_controller.php

@ -254,9 +254,7 @@ class AnnouncementManager {
*/
public static function add_announcement($emailTitle, $newContent, $order, $to, $file = array(), $file_comment='') {
global $_course;
$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
// filter data
$emailTitle = Database::escape_string($emailTitle);
@ -279,7 +277,7 @@ class AnnouncementManager {
//Store the attach file
$last_id = Database::insert_id();
if (!empty($file)) {
$save_attachment = self::add_announcement_attachment_file($last_id, $file_comment, $_FILES['user_upload']);
self::add_announcement_attachment_file($last_id, $file_comment, $_FILES['user_upload']);
}
// store in item_property (first the groups, then the users

@ -337,7 +337,7 @@ class CourseRestorer
$title = str_replace('/', '', $new);
// This code fixes the possibility for a file without a directory entry to be
$document_id = add_document($course_info, $new, 'folder', 0, $title);
$document_id = add_document($course_info, $new, 'folder', 0, $title, null, null, false);
api_item_property_update($course_info, TOOL_DOCUMENT, $document_id, 'FolderCreated', $document->item_properties[0]['insert_user_id'], $document->item_properties[0]['to_group_id'], $document->item_properties[0]['to_user_id'], null, null, $my_session_id);
}
} else {

@ -545,8 +545,8 @@ if ($form->validate()) {
$certificate_condition = '';
if ($is_certificate_mode) {
$df = DocumentManager::get_default_certificate_id($_course['code']);
if (!isset($df)) {
DocumentManager::attach_gradebook_certificate ($_course['code'],$document_id);
if (!isset($df)) {
DocumentManager::attach_gradebook_certificate ($_course['code'],$document_id);
}
$certificate_condition = '&certificate=true';
}

@ -231,9 +231,7 @@ switch ($action) {
if (!copy($file, $copyfile)) {
$message = Display::return_message(get_lang('CopyFailed'), 'error');
} else {
$message = Display::return_message(get_lang('CopyMade') . ' ' . $file_link, 'confirmation', false);
/* $doc_id = add_document($_course, $copyfile , 'file', filesize($copyfile), $document_info['title']);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], null, null, null, null, $session_id); */
$message = Display::return_message(get_lang('CopyMade') . ' ' . $file_link, 'confirmation', false);
}
}
}

@ -170,7 +170,6 @@ if ($is_allowedToEdit && !empty ($choice) && $choice == 'exportqti2') {
}
$htmlHeadXtra[] = '<script>
$(document).ready(function() {
//this makes google chrome to crash ...
/* $(".link_tooltip").each(function(){
@ -234,14 +233,14 @@ if ($is_allowedToEdit) {
case 'enable' : // enables an exercise
$objExerciseTmp->enable();
$objExerciseTmp->save();
api_item_property_update($course_info, TOOL_QUIZ, $objExerciseTmp->id,'visible', api_get_user_id());
api_item_property_update($course_info, TOOL_QUIZ, $objExerciseTmp->id, 'visible', api_get_user_id());
// "WHAT'S NEW" notification: update table item_property (previously last_tooledit)
Display :: display_confirmation_message(get_lang('VisibilityChanged'));
break;
case 'disable' : // disables an exercise
$objExerciseTmp->disable();
$objExerciseTmp->save();
api_item_property_update($course_info, TOOL_QUIZ, $objExerciseTmp->id,'invisible', api_get_user_id());
api_item_property_update($course_info, TOOL_QUIZ, $objExerciseTmp->id, 'invisible', api_get_user_id());
Display :: display_confirmation_message(get_lang('VisibilityChanged'));
break;
case 'disable_results' : //disable the results for the learners
@ -328,6 +327,7 @@ $from = $page * $limit;
HotPotGCt($documentPath, 1, api_get_user_id());
//condition for the session
$course_code = api_get_course_id();
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id,true,true);
@ -343,6 +343,7 @@ if ($is_allowedToEdit) {
WHERE c_id = $course_id AND
active='1' $condition_session
ORDER BY title LIMIT ".$from."," .$limit;
}
$result = Database::query($sql);
@ -368,7 +369,7 @@ if ($is_allowedToEdit) {
d.path LIKE '" . Database :: escape_string($uploadPath) . "/%/%' AND
ip.visibility ='1' AND
d.c_id = ".$course_id." AND
ip.c_id = ".$course_id;
ip.c_id = ".$course_id;
$res = Database::query($sql);
$hp_count = Database :: num_rows($res);
}
@ -425,9 +426,9 @@ while ($row = Database :: fetch_array($result,'ASSOC')) {
}
echo '<table class="'.Display::return_default_table_class().'">';
if (!empty($exercise_list)) {
/* Listing exercises */
/* Listing exercises */
if (!empty($exercise_list)) {
if ($origin != 'learnpath') {
//avoid sending empty parameters
$myorigin = (empty ($origin) ? '' : '&origin=' . $origin);
@ -543,9 +544,11 @@ if (!empty($exercise_list)) {
if ($session_id == $row['session_id']) {
//Settings
//echo Display::url(Display::return_icon('settings.png',get_lang('Edit'), array('width'=>'22px'))." ".get_lang('Edit'), 'exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$row['id']);
}
}
$visibility = api_get_item_visibility($course_info, TOOL_QUIZ, $my_exercise_id);
if ($row['active'] == 0) {
if ($row['active'] == 0 || $visibility == 0) {
$title = Display::tag('font', $cut_title, array('style'=>'color:grey'));
} else {
$title = $cut_title;
@ -568,7 +571,6 @@ if (!empty($exercise_list)) {
$item = Display::tag('td', $url.' '.$session_img.$lp_blocked);
//count number exercice - teacher
$sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE c_id = $course_id AND exercice_id = $my_exercise_id";
$sqlresult = Database::query($sqlquery);
@ -583,6 +585,7 @@ if (!empty($exercise_list)) {
//Export
$actions .= Display::url(Display::return_icon('cd.gif', get_lang('CopyExercise')), '', array('onclick'=>"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset))." ".addslashes($row['title'])."?"."')) return false;",'href'=>'exercice.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$row['id']));
//Clean exercise
if ($locked == false) {
$actions .= Display::url(Display::return_icon('clean.png', get_lang('CleanStudentResults'),'',ICON_SIZE_SMALL),'', array('onclick'=>"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToDeleteResults'),ENT_QUOTES,$charset))." ".addslashes($row['title'])."?"."')) return false;",'href'=>'exercice.php?'.api_get_cidreq().'&choice=clean_results&sec_token='.$token.'&exerciseId='.$row['id']));
@ -595,10 +598,10 @@ if (!empty($exercise_list)) {
if ($added_to_lp) {
$actions .= Display::return_icon('invisible.png', get_lang('AddedToLPCannotBeAccessed'),'',ICON_SIZE_SMALL);
} else {
if ($row['active']) {
$actions .= Display::url(Display::return_icon('visible.png', get_lang('Deactivate'),'',ICON_SIZE_SMALL) , 'exercice.php?'.api_get_cidreq().'&choice=disable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']);
if ($row['active'] == 0 || $visibility == 0) {
$actions .= Display::url(Display::return_icon('invisible.png', get_lang('Activate'),'',ICON_SIZE_SMALL) , 'exercice.php?'.api_get_cidreq().'&choice=enable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']);
} else { // else if not active
$actions .= Display::url(Display::return_icon('invisible.png', get_lang('Activate'),'',ICON_SIZE_SMALL) , 'exercice.php?'.api_get_cidreq().'&choice=enable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']);
$actions .= Display::url(Display::return_icon('visible.png', get_lang('Deactivate'),'',ICON_SIZE_SMALL) , 'exercice.php?'.api_get_cidreq().'&choice=disable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']);
}
}
// Export qti ...
@ -646,7 +649,7 @@ if (!empty($exercise_list)) {
} else {
$number_of_questions = $rowi;
}
//Attempts
//$attempts = get_count_exam_results($row['id']).' '.get_lang('Attempts');
@ -654,7 +657,13 @@ if (!empty($exercise_list)) {
$item .= Display::tag('td', $number_of_questions);
} else {
// --- Student only
// Student only
$visibility = api_get_item_visibility($course_info, TOOL_QUIZ, $my_exercise_id);
if ($visibility == 0) {
continue;
}
// if time is actived show link to exercise

@ -743,7 +743,8 @@ class Exercise {
$this->id = Database::insert_id();
// insert into the item_property table
api_item_property_update($this->course, TOOL_QUIZ, $this->id,'QuizAdded',api_get_user_id());
api_item_property_update($this->course, TOOL_QUIZ, $this->id, 'QuizAdded', api_get_user_id());
api_set_default_visibility($this->id, TOOL_QUIZ);
if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) {
$this->search_engine_save();
}
@ -3393,6 +3394,13 @@ class Exercise {
return array('value' => true, 'message' => '');
}
}
//Checking visibility in the item_property table
$visibility = api_get_item_visibility(api_get_course_info(), TOOL_QUIZ, $this->id, api_get_session_id());
if ($visibility == 0) {
$this->active = 0;
}
//2. If the exercise is not active
if (empty($lp_id)) {

@ -185,7 +185,7 @@ function show_add_forum_form($inputvalues = array(), $lp_id) {
$form_title = get_lang('AddForum');
}
$session_header = isset($_SESSION['session_name']) ? ' ('.$_SESSION['session_name'].') ' : '';
$form->addElement('header', '', $form_title.$session_header);
$form->addElement('header', $form_title.$session_header);
// We have a hidden field if we are editing.
if (!empty($inputvalues) && is_array($inputvalues)) {
@ -218,8 +218,8 @@ function show_add_forum_form($inputvalues = array(), $lp_id) {
//$form->addElement('radio', 'allow_anonymous', '', get_lang('No'), 0);
// This is for horizontal
$group = '';
$group[] =& HTML_QuickForm::createElement('radio', 'allow_anonymous', null, get_lang('Yes'), 1);
$group[] =& HTML_QuickForm::createElement('radio', 'allow_anonymous', null, get_lang('No'), 0);
$group[] =$form->createElement('radio', 'allow_anonymous', null, get_lang('Yes'), 1);
$group[] =$form->createElement('radio', 'allow_anonymous', null, get_lang('No'), 0);
$form->addGroup($group, 'allow_anonymous_group', get_lang('AllowAnonymousPosts'), '&nbsp;');
}
@ -240,8 +240,8 @@ function show_add_forum_form($inputvalues = array(), $lp_id) {
$form->addElement('html', '<div id="options" style="display:none">');
$group = '';
$group[] =& HTML_QuickForm::createElement('radio', 'students_can_edit', null, get_lang('Yes'), 1);
$group[] =& HTML_QuickForm::createElement('radio', 'students_can_edit', null, get_lang('No'), 0);
$group[] = $form->createElement('radio', 'students_can_edit', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'students_can_edit', null, get_lang('No'), 0);
$form->addGroup($group, 'students_can_edit_group', get_lang('StudentsCanEdit'), '&nbsp;');
// This is for vertical.
@ -249,8 +249,8 @@ function show_add_forum_form($inputvalues = array(), $lp_id) {
//$form->addElement('radio', 'approval_direct', '', get_lang('Direct'), 0);
// This is for horizontal.
$group = '';
$group[] =& HTML_QuickForm::createElement('radio', 'approval_direct', null, get_lang('Approval'), 1);
$group[] =& HTML_QuickForm::createElement('radio', 'approval_direct', null, get_lang('Direct'), 0);
$group[] = $form->createElement('radio', 'approval_direct', null, get_lang('Approval'), 1);
$group[] = $form->createElement('radio', 'approval_direct', null, get_lang('Direct'), 0);
//$form->addGroup($group, 'approval_direct_group', get_lang('ApprovalDirect'), '&nbsp;');
// This is for vertical.
@ -258,8 +258,8 @@ function show_add_forum_form($inputvalues = array(), $lp_id) {
//$form->addElement('radio', 'allow_attachments', '', get_lang('No'), 0);
// This is for horizontal.
$group = '';
$group[] =& HTML_QuickForm::createElement('radio', 'allow_attachments', null, get_lang('Yes'), 1);
$group[] =& HTML_QuickForm::createElement('radio', 'allow_attachments', null, get_lang('No'), 0);
$group[] = $form->createElement('radio', 'allow_attachments', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'allow_attachments', null, get_lang('No'), 0);
//$form->addGroup($group, 'allow_attachments_group', get_lang('AllowAttachments'), '&nbsp;');
// This is for vertical.
@ -267,14 +267,14 @@ function show_add_forum_form($inputvalues = array(), $lp_id) {
//$form->addElement('radio', 'allow_new_threads', '', 0, get_lang('No'));
// This is for horizontal.
$group = '';
$group[] =& HTML_QuickForm::createElement('radio', 'allow_new_threads', null, get_lang('Yes'),1 );
$group[] =& HTML_QuickForm::createElement('radio', 'allow_new_threads', null, get_lang('No'), 0);
$group[] = $form->createElement('radio', 'allow_new_threads', null, get_lang('Yes'),1 );
$group[] = $form->createElement('radio', 'allow_new_threads', null, get_lang('No'), 0);
$form->addGroup($group, 'allow_new_threads_group', get_lang('AllowNewThreads'), '&nbsp;');
$group = '';
$group[] =& HTML_QuickForm::createElement('radio', 'default_view_type', null, get_lang('Flat'), 'flat');
$group[] =& HTML_QuickForm::createElement('radio', 'default_view_type', null, get_lang('Threaded'), 'threaded');
$group[] =& HTML_QuickForm::createElement('radio', 'default_view_type', null, get_lang('Nested'), 'nested');
$group[] = $form->createElement('radio', 'default_view_type', null, get_lang('Flat'), 'flat');
$group[] = $form->createElement('radio', 'default_view_type', null, get_lang('Threaded'), 'threaded');
$group[] = $form->createElement('radio', 'default_view_type', null, get_lang('Nested'), 'nested');
$form->addGroup($group, 'default_view_type_group', get_lang('DefaultViewType'), '&nbsp;');
//$form->addElement('static','Group', '<br /><strong>'.get_lang('GroupSettings').'</strong>');
@ -289,8 +289,8 @@ function show_add_forum_form($inputvalues = array(), $lp_id) {
// Public or private group forum
$group='';
$group[] =& HTML_QuickForm::createElement('radio', 'public_private_group_forum', null, get_lang('Public'), 'public');
$group[] =& HTML_QuickForm::createElement('radio', 'public_private_group_forum', null, get_lang('Private'), 'private');
$group[] = $form->createElement('radio', 'public_private_group_forum', null, get_lang('Public'), 'public');
$group[] = $form->createElement('radio', 'public_private_group_forum', null, get_lang('Private'), 'private');
$form->addGroup($group, 'public_private_group_forum_group', get_lang('PublicPrivateGroupForum'), '&nbsp;');
// Forum image
@ -490,6 +490,7 @@ function store_forumcategory($values) {
$last_id = Database::insert_id();
if ($last_id > 0) {
api_item_property_update(api_get_course_info(), TOOL_FORUM_CATEGORY, $last_id, 'ForumCategoryAdded', api_get_user_id());
api_set_default_visibility($last_id, TOOL_FORUM_CATEGORY);
}
$return_message = get_lang('ForumCategoryAdded');
}
@ -626,6 +627,7 @@ function store_forum($values) {
$last_id = Database::insert_id();
if ($last_id > 0) {
api_item_property_update($_course, TOOL_FORUM, $last_id, 'ForumAdded', api_get_user_id());
api_set_default_visibility($last_id, TOOL_FORUM);
}
$return_message = get_lang('ForumAdded');
}
@ -1924,16 +1926,22 @@ function store_thread($values) {
add_resource_to_course_gradebook($values['category_id'], $coursecode, $resourcetype, $resourceid, $resourcename, $weigthqualify, $maxqualify, $resourcedescription, 0, api_get_session_id());
}
api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id, 'ForumThreadAdded', api_get_user_id());
// If the forum properties tell that the posts have to be approved we have to put the whole thread invisible,
// because otherwise the students will see the thread and not the post in the thread.
// We also have to change $visible because the post itself has to be visible in this case (otherwise the teacher would have
// to make the thread visible AND the post.
if ($visible == 0) {
api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id, 'invisible', api_get_user_id());
$visible = 1;
}
if ($last_thread_id) {
api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id, 'ForumThreadAdded', api_get_user_id());
// If the forum properties tell that the posts have to be approved we have to put the whole thread invisible,
// because otherwise the students will see the thread and not the post in the thread.
// We also have to change $visible because the post itself has to be visible in this case (otherwise the teacher would have
// to make the thread visible AND the post.
//Default behaviour
api_set_default_visibility($last_thread_id, TOOL_FORUM_THREAD);
if ($visible == 0) {
api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id, 'invisible', api_get_user_id());
$visible = 1;
}
}
// We now store the content in the table_post table.
$sql = "INSERT INTO $table_posts (c_id, post_title, post_text, thread_id, forum_id, poster_id, poster_name, post_date, post_notification, post_parent_id, visible)
VALUES (

@ -31,7 +31,7 @@ $language_file = 'forum';
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_FORUM;
$htmlHeadXtra[] = '<script type="text/javascript">
$htmlHeadXtra[] = '<script>
$(document).ready(function(){ $(\'.hide-me\').slideUp() });
function hidecontent(content){ $(content).slideToggle(\'normal\'); }
</script>';
@ -45,7 +45,7 @@ $htmlHeadXtra[] = '<script type="text/javascript">
document.getElementById(\'plus_minus\').innerHTML=\'&nbsp;'.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'\';
}
}
</script>';
</script>';
// The section (tabs).
$this_section = SECTION_COURSES;
@ -62,10 +62,6 @@ $nameTools = get_lang('Forums');
require_once 'forumconfig.inc.php';
require_once 'forumfunction.inc.php';
/* MAIN DISPLAY SECTION */
/* Header */
if (!empty($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
$_SESSION['gradebook'] = Security::remove_XSS($_GET['gradebook']);
$gradebook = $_SESSION['gradebook'];

@ -24,7 +24,7 @@ block_students();
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>';
$htmlHeadXtra[] = '<link href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
$htmlHeadXtra[] = '<script type="text/javascript">
$htmlHeadXtra[] = '<script>
$(document).ready(function () {
$("#skills").fcbkcomplete({
json_url: "'.api_get_path(WEB_AJAX_PATH).'skill.ajax.php?a=find_skills",

@ -324,12 +324,23 @@ class Category implements GradebookItem
if (isset($this->grade_model_id)) {
$sql .= ', grade_model_id ';
}
}
/*
$setting = api_get_setting('tool_visible_by_default_at_creation');
$visible = 1;
if (isset($setting['gradebook'])) {
if ($setting['gradebook'] == 'false') {
$visible = 0;
}
}*/
$visible = intval($this->is_visible());
$sql .= ") VALUES ('".Database::escape_string($this->get_name())."'"
.','.intval($this->get_user_id())
.','.Database::escape_string($this->get_weight())
.','.intval($this->is_visible());
.','.$visible;
if (isset($this->description)) {
$sql .= ",'".Database::escape_string($this->get_description())."'";
}
@ -350,7 +361,8 @@ class Category implements GradebookItem
$id = Database::insert_id();
$this->set_id($id);
if (!empty($id)) {
if (!empty($id)) {
$parent_id = $this->get_parent_id();
$grade_model_id = $this->get_grade_model_id();
if ($parent_id == 0) {

@ -75,7 +75,6 @@ abstract class EvalLink extends AbstractLink
return true;
}
public function add_linked_data() {
if ($this->is_valid_link()) {
$this->evaluation->add();
@ -95,7 +94,6 @@ abstract class EvalLink extends AbstractLink
}
}
public function set_name ($name) {
if ($this->is_valid_link()) {
$this->evaluation->set_name($name);
@ -113,7 +111,8 @@ abstract class EvalLink extends AbstractLink
$this->evaluation->set_max($max);
}
}
// Functions overriding non-trivial implementations from AbstractLink
// Functions overriding non-trivial implementations from AbstractLink
public function set_date ($date) {
$this->created_at = $date;
if ($this->is_valid_link()) {
@ -135,10 +134,6 @@ abstract class EvalLink extends AbstractLink
}
}
// INTERNAL FUNCTIONS
/**
* Lazy load function to get the linked evaluation
*/
@ -158,7 +153,6 @@ abstract class EvalLink extends AbstractLink
$eval->set_course_code($this->get_course_code());
$this->evaluation = $eval;
$this->set_ref_id($eval->get_id());
}
}
return $this->evaluation;

@ -240,8 +240,15 @@ class CatForm extends FormValidator {
//$this->addRule('weight',get_lang('NoDecimals'),'nopunctuation');
$this->addRule(array ('weight', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
//}
$setting = api_get_setting('tool_visible_by_default_at_creation');
$visibility_default = 1;
if (isset($setting['gradebook']) && $setting['gradebook'] == 'false') {
$visibility_default = 0;
}
$this->setDefaults(array('visible' => $visibility_default));
}
/**
* This function builds an 'select course' form in the add category process,
* if parent id is 0, it will only show courses

@ -515,6 +515,14 @@ class EvalForm extends FormValidator
$this->addRule(array('weight_mask', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
$this->addRule('max', get_lang('OnlyNumbers'), 'numeric');
$this->addRule(array('max', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
$setting = api_get_setting('tool_visible_by_default_at_creation');
$visibility_default = 1;
if (isset($setting['gradebook']) && $setting['gradebook'] == 'false') {
$visibility_default = 0;
}
$this->setDefaults(array('visible' => $visibility_default));
}
function display() {

@ -172,6 +172,15 @@ class LinkAddEditForm extends FormValidator
} else {
$this->addElement('style_submit_button', 'submit', get_lang('LinkMod'),'class="save"');
}
if ($form_type == self :: TYPE_ADD) {
$setting = api_get_setting('tool_visible_by_default_at_creation');
$visibility_default = 1;
if (isset($setting['gradebook']) && $setting['gradebook'] == 'false') {
$visibility_default = 0;
}
$defaults['visible'] = $visibility_default;
}
// set default values
$this->setDefaults($defaults);

@ -834,7 +834,7 @@ function filter_extension(&$filename) {
* @param string $title
* @return id if inserted document
*/
function add_document($_course, $path, $filetype, $filesize, $title, $comment = null, $readonly = 0) {
function add_document($_course, $path, $filetype, $filesize, $title, $comment = null, $readonly = 0, $save_visibility = true) {
$session_id = api_get_session_id();
$readonly = intval($readonly);
$comment = Database::escape_string($comment);
@ -850,10 +850,14 @@ function add_document($_course, $path, $filetype, $filesize, $title, $comment =
VALUES ($c_id, '$path','$filetype','$filesize','$title', '$comment', $readonly, $session_id)";
if (Database::query($sql)) {
//display_message("Added to database (id ".Database::insert_id().")!");
return Database::insert_id();
} else {
//display_error("The uploaded file could not be added to the database (".Database::error().")!");
$document_id = Database::insert_id();
if ($document_id) {
if ($save_visibility) {
api_set_default_visibility($document_id, TOOL_DOCUMENT);
}
}
return $document_id;
} else {
return false;
}
}

@ -116,6 +116,10 @@ function addlinkcategory($type) {
$catlinkstatus = get_lang('LinkAdded');
Database :: query($sql);
$link_id = Database :: insert_id();
if ($link_id) {
api_set_default_visibility($link_id, TOOL_LINK);
}
if ((api_get_setting('search_enabled') == 'true') && $link_id && extension_loaded('xapian')) {
require_once api_get_path(LIBRARY_PATH) . 'search/DokeosIndexer.class.php';

@ -2914,7 +2914,7 @@ function api_get_item_visibility($_course, $tool, $id, $session=0) {
(id_session = $session OR id_session = 0)
ORDER BY id_session DESC, lastedit_date DESC";
$res = Database::query($sql);
if ($res === false || Database::num_rows($res) == 0) { return -1; }
if ($res === false || Database::num_rows($res) == 0) { return -1; }
$row = Database::fetch_array($res);
return $row['visibility'];
}
@ -2932,7 +2932,7 @@ function api_get_item_visibility($_course, $tool, $id, $session=0) {
* @param $to_group_id : id of the intended group ( 0 = for everybody), only relevant for $type (1)
* @param $to_user_id : id of the intended user (always has priority over $to_group_id !), only relevant for $type (1)
* @param string $start_visible 0000-00-00 00:00:00 format
* @param unknown_type $end_visible 0000-00-00 00:00:00 format
* @param string $end_visible 0000-00-00 00:00:00 format
* @return boolean False if update fails.
* @author Toon Van Hoecke <Toon.VanHoecke@UGent.be>, Ghent University
* @version January 2005
@ -6034,3 +6034,52 @@ function api_is_global_chat_enabled(){
$global_chat_is_enabled = !api_is_anonymous() && api_get_setting('allow_global_chat') == 'true' && api_get_setting('allow_social_tool') == 'true';
return $global_chat_is_enabled;
}
/**
* @todo Fix tool_visible_by_default_at_creation labels
*/
function api_set_default_visibility($item_id, $tool_id) {
$original_tool_id = $tool_id;
switch ($tool_id) {
case TOOL_LINK:
$tool_id = 'links';
break;
case TOOL_DOCUMENT:
$tool_id = 'documents';
break;
case TOOL_LEARNPATH:
$tool_id = 'learning';
break;
case TOOL_ANNOUNCEMENT:
$tool_id = 'announcements';
break;
case TOOL_FORUM:
case TOOL_FORUM_CATEGORY:
case TOOL_FORUM_THREAD:
$tool_id = 'forums';
break;
case TOOL_QUIZ:
$tool_id = 'quiz';
break;
/*case TOOL_GRADEBOOK:
$tool_id = 'gradebook'; */
break;
}
$setting = api_get_setting('tool_visible_by_default_at_creation');
if (isset($setting[$tool_id])) {
//$visibility_boolean = false;
$visibility = 'invisible';
if ($setting[$tool_id] == 'true') {
$visibility = 'visible';
//$visibility_boolean = true;
}
//Hack for gradebook because we don't use the item property table
/*
if ($tool_id == TOOL_GRADEBOOK) {
return $visibility_boolean;
}*/
api_item_property_update(api_get_course_info(), $original_tool_id, $item_id, $visibility, api_get_user_id(), api_get_group_id(), null, null, null, api_get_session_id());
}
}

@ -671,6 +671,7 @@ class learnpath {
case 'aicc':
break;
}
switch ($origin) {
case 'zip':
// Check zipname string. If empty, we are currently creating a new Chamilo learnpath.
@ -689,11 +690,13 @@ class learnpath {
$sql_insert = "INSERT INTO $tbl_lp (c_id, lp_type,name,description,path,default_view_mod, default_encoding,display_order,content_maker,content_local,js_lib,session_id, created_on, publicated_on, expired_on) " .
"VALUES ($course_id, $type,'$name','$description','','embedded','UTF-8','$dsp','Chamilo','local','','".$session_id."', '".api_get_utc_datetime()."' , '".$publicated_on."' , '".$expired_on."')";
$res_insert = Database::query($sql_insert);
Database::query($sql_insert);
$id = Database :: insert_id();
if ($id > 0) {
$course_info = api_get_course_info();
// Insert into item_property.
api_item_property_update(api_get_course_info(), TOOL_LEARNPATH, $id, 'LearnpathAdded', api_get_user_id());
api_item_property_update($course_info, TOOL_LEARNPATH, $id, 'LearnpathAdded', api_get_user_id());
api_set_default_visibility($id, TOOL_LEARNPATH);
return $id;
}
break;

@ -52,7 +52,6 @@ $(window).load(function () {
});
</script>
<style>
form .label {
padding: 1px 3px 2px;
font-size: 100%;
@ -96,10 +95,6 @@ $session_id = api_get_session_id();
api_protect_course_script(true);
/*if (!$is_allowed_in_course) {
api_not_allowed(true);
}*/
require_once api_get_path(LIBRARY_PATH).'fckeditor/fckeditor.php';
$lpfound = false;

Loading…
Cancel
Save