Fix fill course with content.

1.10.x
Julio Montoya 11 years ago
parent 67ee519ab9
commit 701fb5d3c1
  1. 13
      main/exercice/answer.class.php
  2. 42
      main/exercice/exercise.class.php
  3. 219
      main/forum/forumfunction.inc.php
  4. 31
      main/inc/introductionSection.inc.php
  5. 197
      main/inc/lib/add_course.lib.inc.php
  6. 17
      main/inc/lib/api.lib.php
  7. 6
      main/inc/lib/course.lib.php
  8. 2
      src/Chamilo/CourseBundle/Entity/CToolIntro.php
  9. 3
      tests/datafiller/fill_courses.php

@ -508,8 +508,17 @@ class Answer
* @param string $hotspot_coordinates * @param string $hotspot_coordinates
* @param string $hotspot_type * @param string $hotspot_type
*/ */
public function updateAnswers($autoId, $answer, $comment, $correct, $weighting, $position, $destination, $hotspot_coordinates, $hotspot_type) public function updateAnswers(
{ $autoId,
$answer,
$comment,
$correct,
$weighting,
$position,
$destination,
$hotspot_coordinates,
$hotspot_type
) {
$answerTable = Database :: get_course_table(TABLE_QUIZ_ANSWER); $answerTable = Database :: get_course_table(TABLE_QUIZ_ANSWER);
//$id = $this->getQuestionType() == FILL_IN_BLANKS ? $idAnswer[0] : Database::escape_string($position); //$id = $this->getQuestionType() == FILL_IN_BLANKS ? $idAnswer[0] : Database::escape_string($position);
$autoId = intval($autoId); $autoId = intval($autoId);

@ -51,7 +51,7 @@ class Exercise
* *
* @author Olivier Brouckaert * @author Olivier Brouckaert
*/ */
public function Exercise($course_id = null) public function __construct($course_id = null)
{ {
$this->id = 0; $this->id = 0;
$this->exercise = ''; $this->exercise = '';
@ -431,7 +431,8 @@ class Exercise
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$sql = "SELECT DISTINCT e.question_order $sql = "SELECT DISTINCT e.question_order
FROM $TBL_EXERCICE_QUESTION e INNER JOIN $TBL_QUESTIONS q FROM $TBL_EXERCICE_QUESTION e
INNER JOIN $TBL_QUESTIONS q
ON (e.question_id = q.id AND e.c_id = ".$this->course_id." AND q.c_id = ".$this->course_id.") ON (e.question_id = q.id AND e.c_id = ".$this->course_id." AND q.c_id = ".$this->course_id.")
WHERE e.exercice_id = ".intval($this->id).""; WHERE e.exercice_id = ".intval($this->id)."";
$result = Database::query($sql); $result = Database::query($sql);
@ -439,7 +440,8 @@ class Exercise
$count_question_orders = Database::num_rows($result); $count_question_orders = Database::num_rows($result);
$sql = "SELECT e.question_id, e.question_order $sql = "SELECT e.question_id, e.question_order
FROM $TBL_EXERCICE_QUESTION e INNER JOIN $TBL_QUESTIONS q FROM $TBL_EXERCICE_QUESTION e
INNER JOIN $TBL_QUESTIONS q
ON (e.question_id= q.id AND e.c_id = ".$this->course_id." AND q.c_id = ".$this->course_id.") ON (e.question_id= q.id AND e.c_id = ".$this->course_id." AND q.c_id = ".$this->course_id.")
WHERE e.exercice_id = ".intval($this->id)." WHERE e.exercice_id = ".intval($this->id)."
ORDER BY question_order"; ORDER BY question_order";
@ -462,8 +464,10 @@ class Exercise
$question_list = $temp_question_list; $question_list = $temp_question_list;
} }
} }
return $question_list; return $question_list;
} }
return $this->questionList; return $this->questionList;
} }
@ -752,7 +756,7 @@ class Exercise
*/ */
public function save($type_e = '') public function save($type_e = '')
{ {
$_course = api_get_course_info(); $_course = $this->course;
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$id = $this->id; $id = $this->id;
@ -771,7 +775,7 @@ class Exercise
$text_when_finished = $this->text_when_finished; $text_when_finished = $this->text_when_finished;
$display_category_name = intval($this->display_category_name); $display_category_name = intval($this->display_category_name);
$pass_percentage = intval($this->pass_percentage); $pass_percentage = intval($this->pass_percentage);
$session_id = api_get_session_id(); $session_id = $this->sessionId;
//If direct we do not show results //If direct we do not show results
if ($feedback_type == EXERCISE_FEEDBACK_TYPE_DIRECT) { if ($feedback_type == EXERCISE_FEEDBACK_TYPE_DIRECT) {
@ -824,16 +828,24 @@ class Exercise
Database::query($sql); Database::query($sql);
// update into the item_property table // update into the item_property table
api_item_property_update($_course, TOOL_QUIZ, $id, 'QuizUpdated', api_get_user_id()); api_item_property_update(
$_course,
TOOL_QUIZ,
$id,
'QuizUpdated',
api_get_user_id()
);
if (api_get_setting('search_enabled')=='true') { if (api_get_setting('search_enabled')=='true') {
$this->search_engine_edit(); $this->search_engine_edit();
} }
} else { } else {
// creates a new exercise // Creates a new exercise
// In this case of new exercise, we don't do the api_get_utc_datetime() for date because, bellow, we call function api_set_default_visibility() // In this case of new exercise, we don't do the api_get_utc_datetime()
// In this function, api_set_default_visibility, the Quiz is saved too, with an $id and api_get_utc_datetime() is done. // for date because, bellow, we call function api_set_default_visibility()
// In this function, api_set_default_visibility,
// the Quiz is saved too, with an $id and api_get_utc_datetime() is done.
// If we do it now, it will be done twice (cf. https://support.chamilo.org/issues/6586) // If we do it now, it will be done twice (cf. https://support.chamilo.org/issues/6586)
if (!empty($this->start_time) && $this->start_time != '0000-00-00 00:00:00') { if (!empty($this->start_time) && $this->start_time != '0000-00-00 00:00:00') {
$start_time = Database::escape_string($this->start_time); $start_time = Database::escape_string($this->start_time);
@ -888,12 +900,14 @@ class Exercise
// This function save the quiz again, carefull about start_time // This function save the quiz again, carefull about start_time
// and end_time if you remove this line (see above) // and end_time if you remove this line (see above)
api_set_default_visibility($this->id, TOOL_QUIZ, null, true); api_set_default_visibility(
$this->id,
TOOL_QUIZ,
null,
$this->course
);
if (api_get_setting( if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
'search_enabled'
) == 'true' && extension_loaded('xapian')
) {
$this->search_engine_save(); $this->search_engine_save();
} }
} }

@ -499,17 +499,22 @@ function show_edit_forumcategory_form($inputvalues = array())
} }
/** /**
* This function stores the forum category in the database. The new category is added to the end. * This function stores the forum category in the database.
* The new category is added to the end.
* *
* @param array * @param array $values
* @param array $courseInfo
* @param bool $showMessage
* @return void HMTL language variable * @return void HMTL language variable
* *
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8 * @version february 2006, dokeos 1.8
*/ */
function store_forumcategory($values) function store_forumcategory($values, $courseInfo = array(), $showMessage = true)
{ {
$course_id = api_get_course_int_id(); $courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo;
$course_id = $courseInfo['real_id'];
$table_categories = Database::get_course_table(TABLE_FORUM_CATEGORY); $table_categories = Database::get_course_table(TABLE_FORUM_CATEGORY);
// Find the max cat_order. The new forum category is added at the end => max cat_order + & // Find the max cat_order. The new forum category is added at the end => max cat_order + &
@ -531,7 +536,7 @@ function store_forumcategory($values)
Database::query($sql); Database::query($sql);
api_item_property_update( api_item_property_update(
api_get_course_info(), $courseInfo,
TOOL_FORUM_CATEGORY, TOOL_FORUM_CATEGORY,
$values['forum_category_id'], $values['forum_category_id'],
'ForumCategoryUpdated', 'ForumCategoryUpdated',
@ -549,32 +554,44 @@ function store_forumcategory($values)
if ($last_id > 0) { if ($last_id > 0) {
api_item_property_update( api_item_property_update(
api_get_course_info(), $courseInfo,
TOOL_FORUM_CATEGORY, TOOL_FORUM_CATEGORY,
$last_id, $last_id,
'ForumCategoryAdded', 'ForumCategoryAdded',
api_get_user_id() api_get_user_id()
); );
api_set_default_visibility($last_id, TOOL_FORUM_CATEGORY); api_set_default_visibility(
$last_id,
TOOL_FORUM_CATEGORY,
0,
$courseInfo
);
} }
$return_message = get_lang('ForumCategoryAdded'); $return_message = get_lang('ForumCategoryAdded');
} }
if ($showMessage) {
Display:: display_confirmation_message($return_message); Display:: display_confirmation_message($return_message);
} }
return $last_id;
}
/** /**
* This function stores the forum in the database. The new forum is added to the end. * This function stores the forum in the database. The new forum is added to the end.
* *
* @param array * @param array $values
* @param array $courseInfo
* @param bool $returnId
* @return string language variable * @return string language variable
* *
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8 * @version february 2006, dokeos 1.8
*/ */
function store_forum($values) function store_forum($values, $courseInfo = array(), $returnId = false)
{ {
$_course = api_get_course_info(); $courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo;
$course_id = api_get_course_int_id(); $course_id = $courseInfo['real_id'];
$session_id = api_get_session_id(); $session_id = api_get_session_id();
if (isset($values['group_id']) && !empty($values['group_id'])) { if (isset($values['group_id']) && !empty($values['group_id'])) {
@ -617,7 +634,7 @@ function store_forum($values)
if (isset($upload_ok)) { if (isset($upload_ok)) {
if ($has_attachment) { if ($has_attachment) {
$course_dir = $_course['path'].'/upload/forum/images'; $course_dir = $courseInfo['path'].'/upload/forum/images';
$sys_course_path = api_get_path(SYS_COURSE_PATH); $sys_course_path = api_get_path(SYS_COURSE_PATH);
$updir = $sys_course_path.$course_dir; $updir = $sys_course_path.$course_dir;
// Try to add an extension to the file if it hasn't one. // Try to add an extension to the file if it hasn't one.
@ -669,7 +686,7 @@ function store_forum($values)
Database::query($sql); Database::query($sql);
api_item_property_update( api_item_property_update(
$_course, $courseInfo,
TOOL_FORUM, TOOL_FORUM,
Database::escape_string($values['forum_id']), Database::escape_string($values['forum_id']),
'ForumUpdated', 'ForumUpdated',
@ -707,13 +724,31 @@ function store_forum($values)
$last_id = Database::insert_id(); $last_id = Database::insert_id();
if ($last_id > 0) { if ($last_id > 0) {
$sql = "UPDATE $table_forums SET forum_id = $last_id WHERE iid = $last_id"; $sql = "UPDATE $table_forums SET forum_id = $last_id
WHERE iid = $last_id";
Database::query($sql); Database::query($sql);
api_item_property_update($_course, TOOL_FORUM, $last_id, 'ForumAdded', api_get_user_id(), $group_id); api_item_property_update(
api_set_default_visibility($last_id, TOOL_FORUM, $group_id); $courseInfo,
TOOL_FORUM,
$last_id,
'ForumAdded',
api_get_user_id(),
$group_id
);
api_set_default_visibility(
$last_id,
TOOL_FORUM,
$group_id,
$courseInfo
);
} }
$return_message = get_lang('ForumAdded'); $return_message = get_lang('ForumAdded');
if ($returnId) {
return $last_id;
}
} }
return $return_message; return $return_message;
@ -2102,24 +2137,29 @@ function get_thread_users_not_qualify($thread_id)
* *
* @deprecated this functionality is now moved to get_forums($forum_id) * @deprecated this functionality is now moved to get_forums($forum_id)
*/ */
function get_forum_information($forum_id) function get_forum_information($forum_id, $courseId = 0)
{ {
$table_forums = Database :: get_course_table(TABLE_FORUM); $table_forums = Database :: get_course_table(TABLE_FORUM);
$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$courseId = empty($courseId) ? api_get_course_int_id(): intval($courseId);
$forum_id = intval($forum_id);
$sql = "SELECT * FROM ".$table_forums." forums, ".$table_item_property." item_properties $sql = "SELECT *
FROM $table_forums forums
INNER JOIN $table_item_property item_properties
ON (forums.c_id = item_properties.c_id)
WHERE WHERE
item_properties.tool = '".TOOL_FORUM."' AND item_properties.tool = '".TOOL_FORUM."' AND
item_properties.ref = '".Database::escape_string($forum_id)."' AND item_properties.ref = '".$forum_id."' AND
item_properties.c_id = ".api_get_course_int_id()." AND forums.forum_id = '".$forum_id."' AND
forums.forum_id = '".Database::escape_string($forum_id)."' AND forums.c_id = ".$courseId."
forums.c_id = ".api_get_course_int_id()."
"; ";
$result = Database::query($sql); $result = Database::query($sql);
$row = Database::fetch_array($result); $row = Database::fetch_array($result);
$row['approval_direct_post'] = 0; $row['approval_direct_post'] = 0;
// We can't anymore change this option, so it should always be activated. // We can't anymore change this option, so it should always be activated.
return $row; return $row;
} }
@ -2179,24 +2219,26 @@ function count_number_of_forums_in_category($cat_id)
* This function stores a new thread. This is done through an entry in the forum_thread table AND * This function stores a new thread. This is done through an entry in the forum_thread table AND
* in the forum_post table because. The threads are also stored in the item_property table. (forum posts are not (yet)) * in the forum_post table because. The threads are also stored in the item_property table. (forum posts are not (yet))
* *
* @param array * @param array $current_forum
* @param array * @param array $values
* @param array $courseInfo
* @param bool $showMessage
* @return void HTML * @return void HTML
* *
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8 * @version february 2006, dokeos 1.8
*/ */
function store_thread($current_forum, $values) function store_thread($current_forum, $values, $courseInfo = array(), $showMessage = true)
{ {
$_course = api_get_course_info(); $courseInfo = empty($courseInfo) ? api_get_course_info() :$courseInfo ;
$_user = api_get_user_info(); $_user = api_get_user_info();
$course_id = $courseInfo['real_id'];
$courseCode = $courseInfo['code'];
$table_threads = Database :: get_course_table(TABLE_FORUM_THREAD); $table_threads = Database :: get_course_table(TABLE_FORUM_THREAD);
$table_posts = Database :: get_course_table(TABLE_FORUM_POST); $table_posts = Database :: get_course_table(TABLE_FORUM_POST);
$course_id = api_get_course_int_id(); $gradebook = isset($_GET['gradebook']) ? Security::remove_XSS($_GET['gradebook']) : '';
$gradebook = Security::remove_XSS($_GET['gradebook']);
$upload_ok = 1; $upload_ok = 1;
$has_attachment = false; $has_attachment = false;
@ -2238,7 +2280,6 @@ function store_thread($current_forum, $values)
if (isset($values['thread_qualify_gradebook']) && 1 == $values['thread_qualify_gradebook']) { if (isset($values['thread_qualify_gradebook']) && 1 == $values['thread_qualify_gradebook']) {
// Add function gradebook. // Add function gradebook.
$coursecode = api_get_course_id();
$resourcetype = 5; $resourcetype = 5;
$resourceid = $last_thread_id; $resourceid = $last_thread_id;
$resourcename = stripslashes($values['calification_notebook_title']); $resourcename = stripslashes($values['calification_notebook_title']);
@ -2247,7 +2288,7 @@ function store_thread($current_forum, $values)
$resourcedescription = ''; $resourcedescription = '';
GradebookUtils::add_resource_to_course_gradebook( GradebookUtils::add_resource_to_course_gradebook(
$values['category_id'], $values['category_id'],
$coursecode, $courseCode,
$resourcetype, $resourcetype,
$resourceid, $resourceid,
$resourcename, $resourcename,
@ -2261,19 +2302,38 @@ function store_thread($current_forum, $values)
if ($last_thread_id) { if ($last_thread_id) {
$sql = "UPDATE $table_threads SET thread_id = $last_thread_id WHERE iid = $last_thread_id"; $sql = "UPDATE $table_threads SET thread_id = $last_thread_id
WHERE iid = $last_thread_id";
Database::query($sql); Database::query($sql);
api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id, 'ForumThreadAdded', api_get_user_id()); api_item_property_update(
$courseInfo,
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, // 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. // 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 // 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. // to make the thread visible AND the post.
// Default behaviour // Default behaviour
api_set_default_visibility($last_thread_id, TOOL_FORUM_THREAD); api_set_default_visibility(
$last_thread_id,
TOOL_FORUM_THREAD,
0,
$courseInfo
);
if ($visible == 0) { if ($visible == 0) {
api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id, 'invisible', api_get_user_id()); api_item_property_update(
$courseInfo,
TOOL_FORUM_THREAD,
$last_thread_id,
'invisible',
api_get_user_id()
);
$visible = 1; $visible = 1;
} }
} }
@ -2295,20 +2355,31 @@ function store_thread($current_forum, $values)
$last_post_id = Database::insert_id(); $last_post_id = Database::insert_id();
if ($last_post_id) { if ($last_post_id) {
$sql = "UPDATE $table_posts SET post_id = $last_post_id WHERE iid = $last_post_id"; $sql = "UPDATE $table_posts SET post_id = $last_post_id
WHERE iid = $last_post_id";
Database::query($sql); Database::query($sql);
} }
// Update attached files // Update attached files
if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) { if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
foreach ($_POST['file_ids'] as $key => $id) { foreach ($_POST['file_ids'] as $key => $id) {
editAttachedFile(array('comment' => $_POST['file_comments'][$key], 'post_id' => $last_post_id), $id); editAttachedFile(
array(
'comment' => $_POST['file_comments'][$key],
'post_id' => $last_post_id,
),
$id
);
} }
} }
// Now we have to update the thread table to fill the thread_last_post field (so that we know when the thread has been updated for the last time). // Now we have to update the thread table to fill the thread_last_post
$sql = "UPDATE $table_threads SET thread_last_post='".Database::escape_string($last_post_id)."' // field (so that we know when the thread has been updated for the last time).
WHERE c_id = $course_id AND thread_id='".Database::escape_string($last_thread_id)."'"; $sql = "UPDATE $table_threads
SET thread_last_post = '".Database::escape_string($last_post_id)."'
WHERE
c_id = $course_id AND
thread_id='".Database::escape_string($last_thread_id)."'";
$result = Database::query($sql); $result = Database::query($sql);
$message = get_lang('NewThreadStored'); $message = get_lang('NewThreadStored');
// Storing the attachments if any. // Storing the attachments if any.
@ -2318,7 +2389,11 @@ function store_thread($current_forum, $values)
$new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']); $new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']);
if (!filter_extension($new_file_name)) { if (!filter_extension($new_file_name)) {
Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); if ($showMessage) {
Display:: display_error_message(
get_lang('UplUnableToSaveFileFilteredExtension')
);
}
} else { } else {
if ($result) { if ($result) {
add_forum_attachment_file($values['file_comment'], $last_post_id); add_forum_attachment_file($values['file_comment'], $last_post_id);
@ -2349,12 +2424,15 @@ function store_thread($current_forum, $values)
Session::erase('breadcrumbs'); Session::erase('breadcrumbs');
Session::erase('addedresource'); Session::erase('addedresource');
Session::erase('addedresourceid'); Session::erase('addedresourceid');
if ($showMessage) {
Display:: display_confirmation_message($message, false); Display:: display_confirmation_message($message, false);
}
} else { } else {
if ($showMessage) {
Display::display_error_message(get_lang('UplNoFileUploaded')); Display::display_error_message(get_lang('UplNoFileUploaded'));
} }
} }
}
/** /**
* This function displays the form that is used to add a post. This can be a new thread or a reply. * This function displays the form that is used to add a post. This can be a new thread or a reply.
@ -2741,8 +2819,8 @@ function current_qualify_of_thread($thread_id, $session_id)
/** /**
* This function stores a reply in the forum_post table. * This function stores a reply in the forum_post table.
* It also updates the forum_threads table (thread_replies +1 , thread_last_post, thread_date) * It also updates the forum_threads table (thread_replies +1 , thread_last_post, thread_date)
* @param array * @param array $current_forum
* @param array * @param array $values
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8 * @version february 2006, dokeos 1.8
*/ */
@ -2750,7 +2828,6 @@ function store_reply($current_forum, $values)
{ {
$_course = api_get_course_info(); $_course = api_get_course_info();
$table_posts = Database :: get_course_table(TABLE_FORUM_POST); $table_posts = Database :: get_course_table(TABLE_FORUM_POST);
$post_date = api_get_utc_datetime(); $post_date = api_get_utc_datetime();
if ($current_forum['approval_direct_post'] == '1' && !api_is_allowed_to_edit(null, true)) { if ($current_forum['approval_direct_post'] == '1' && !api_is_allowed_to_edit(null, true)) {
@ -3383,7 +3460,13 @@ function send_notification_mails($thread_id, $reply_info)
// 4. the reply is visible (=when there is) // 4. the reply is visible (=when there is)
$current_thread = get_thread_information($thread_id); $current_thread = get_thread_information($thread_id);
$current_forum = get_forum_information($current_thread['forum_id']); $current_forum = get_forum_information($current_thread['forum_id']);
$current_forum_category = get_forumcategory_information($current_forum['forum_category']);
$current_forum_category = null;
if (isset($current_forum['forum_category'])) {
$current_forum_category = get_forumcategory_information(
$current_forum['forum_category']
);
}
if ($current_thread['visibility'] == '1' && if ($current_thread['visibility'] == '1' &&
$current_forum['visibility'] == '1' && $current_forum['visibility'] == '1' &&
@ -3397,26 +3480,30 @@ function send_notification_mails($thread_id, $reply_info)
// The forum category, the forum, the thread and the reply are visible to the user // The forum category, the forum, the thread and the reply are visible to the user
if ($send_mails) { if ($send_mails) {
if (isset($current_thread['forum_id'])) {
send_notifications($current_thread['forum_id'], $thread_id); send_notifications($current_thread['forum_id'], $thread_id);
}
} else { } else {
$table_notification = Database::get_course_table(TABLE_FORUM_NOTIFICATION); $table_notification = Database::get_course_table(TABLE_FORUM_NOTIFICATION);
if (isset($current_forum['forum_id'])) {
$sql = "SELECT * FROM $table_notification $sql = "SELECT * FROM $table_notification
WHERE WHERE
c_id = ".api_get_course_int_id()." AND c_id = ".api_get_course_int_id()." AND
( (
forum_id = '".Database::escape_string($current_forum['forum_id'])."' OR forum_id = '".intval($current_forum['forum_id'])."' OR
thread_id = '".Database::escape_string($thread_id)."' thread_id = '".intval($thread_id)."'
) "; ) ";
$result = Database::query($sql); $result = Database::query($sql);
$user_id = api_get_user_id(); $user_id = api_get_user_id();
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
$sql = "INSERT INTO $table (c_id, thread_id, post_id, user_id) $sql = "INSERT INTO $table (c_id, thread_id, post_id, user_id)
VALUES (".api_get_course_int_id().", '".Database::escape_string($thread_id)."', '".Database::escape_string($reply_info['new_post_id'])."', '$user_id' )"; VALUES (".api_get_course_int_id().", '".intval($thread_id)."', '".intval($reply_info['new_post_id'])."', '$user_id' )";
Database::query($sql); Database::query($sql);
} }
} }
} }
}
/** /**
* This function is called whenever something is made visible because there might * This function is called whenever something is made visible because there might
@ -4329,13 +4416,19 @@ function set_notification($content, $id, $add_only = false)
} }
// First we check if the notification is already set for this. // First we check if the notification is already set for this.
$sql = "SELECT * FROM $table_notification WHERE c_id = $course_id AND $database_field = '".Database::escape_string($id)."' AND user_id = '".Database::escape_string($_user['user_id'])."'"; $sql = "SELECT * FROM $table_notification
WHERE
c_id = $course_id AND
$database_field = '".Database::escape_string($id)."' AND
user_id = '".intval($_user['user_id'])."'";
$result = Database::query($sql); $result = Database::query($sql);
$total = Database::num_rows($result); $total = Database::num_rows($result);
// If the user did not indicate that (s)he wanted to be notified already then we store the notification request (to prevent double notification requests). // If the user did not indicate that (s)he wanted to be notified already
// then we store the notification request (to prevent double notification requests).
if ($total <= 0) { if ($total <= 0) {
$sql = "INSERT INTO $table_notification (c_id, $database_field, user_id) VALUES (".$course_id.", '".Database::escape_string($id)."','".Database::escape_string($_user['user_id'])."')"; $sql = "INSERT INTO $table_notification (c_id, $database_field, user_id)
VALUES (".$course_id.", '".Database::escape_string($id)."','".intval($_user['user_id'])."')";
$result = Database::query($sql); $result = Database::query($sql);
Session::erase('forum_notification'); Session::erase('forum_notification');
get_notifications_of_user(0, true); get_notifications_of_user(0, true);
@ -4344,7 +4437,10 @@ function set_notification($content, $id, $add_only = false)
} else { } else {
if (!$add_only) { if (!$add_only) {
$sql = "DELETE FROM $table_notification $sql = "DELETE FROM $table_notification
WHERE c_id = $course_id AND $database_field = '".Database::escape_string($id)."' AND user_id = '".Database::escape_string($_user['user_id'])."'"; WHERE
c_id = $course_id AND
$database_field = '".Database::escape_string($id)."' AND
user_id = '".intval($_user['user_id'])."'";
Database::query($sql); Database::query($sql);
Session::erase('forum_notification'); Session::erase('forum_notification');
get_notifications_of_user(0, true); get_notifications_of_user(0, true);
@ -4477,10 +4573,14 @@ function get_notifications_of_user($user_id = 0, $force = false)
$user_id = api_get_user_id(); $user_id = api_get_user_id();
} }
if (!isset($_SESSION['forum_notification']) || $_SESSION['forum_notification']['course'] != $course_id || $force = true) { if (!isset($_SESSION['forum_notification']) ||
$_SESSION['forum_notification']['course'] != $course_id ||
$force = true
) {
$_SESSION['forum_notification']['course'] = $course_id; $_SESSION['forum_notification']['course'] = $course_id;
$sql = "SELECT * FROM $table_notification WHERE c_id = $course_id AND user_id='".Database::escape_string($user_id)."'"; $sql = "SELECT * FROM $table_notification
WHERE c_id = $course_id AND user_id='".intval($user_id)."'";
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
if (!is_null($row['forum_id'])) { if (!is_null($row['forum_id'])) {
@ -4507,7 +4607,8 @@ function count_number_of_post_in_thread($thread_id)
if (empty($course_id)) { if (empty($course_id)) {
return 0; return 0;
} }
$sql = "SELECT * FROM $table_posts WHERE c_id = $course_id AND thread_id='".Database::escape_string($thread_id)."' "; $sql = "SELECT * FROM $table_posts
WHERE c_id = $course_id AND thread_id='".intval($thread_id)."' ";
$result = Database::query($sql); $result = Database::query($sql);
return count(Database::store_result($result)); return count(Database::store_result($result));
@ -4548,7 +4649,8 @@ function count_number_of_user_in_course($course_id)
{ {
$table_course_rel_user = Database::get_main_table('course_rel_user'); $table_course_rel_user = Database::get_main_table('course_rel_user');
$sql = "SELECT * FROM $table_course_rel_user WHERE course_code ='".Database::escape_string($course_id)."' "; $sql = "SELECT * FROM $table_course_rel_user
WHERE course_code ='".Database::escape_string($course_id)."' ";
$result = Database::query($sql); $result = Database::query($sql);
return count(Database::store_result($result)); return count(Database::store_result($result));
@ -4638,7 +4740,8 @@ function get_name_thread_by_id($thread_id)
{ {
$t_forum_thread = Database::get_course_table(TABLE_FORUM_THREAD); $t_forum_thread = Database::get_course_table(TABLE_FORUM_THREAD);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$sql = "SELECT thread_title FROM ".$t_forum_thread." WHERE c_id = $course_id AND thread_id = '".intval($thread_id)."' "; $sql = "SELECT thread_title FROM ".$t_forum_thread."
WHERE c_id = $course_id AND thread_id = '".intval($thread_id)."' ";
$result = Database::query($sql); $result = Database::query($sql);
$row = Database::fetch_array($result); $row = Database::fetch_array($result);

@ -52,13 +52,13 @@ if (!empty($courseId)) {
$renderer =& $form->defaultRenderer(); $renderer =& $form->defaultRenderer();
$renderer->setCustomElementTemplate('<div style="width: 80%; margin: 0px auto; padding-bottom: 10px; ">{element}</div>'); $renderer->setCustomElementTemplate('<div style="width: 80%; margin: 0px auto; padding-bottom: 10px; ">{element}</div>');
$toolbar_set = 'IntroductionTool'; $config = array(
$width = '100%'; 'ToolbarSet' => 'IntroductionTool',
$height = '300'; 'Width' => '100%',
'Height' => '300'
$editor_config = array('ToolbarSet' => $toolbar_set, 'Width' => $width, 'Height' => $height); );
$form->addHtmlEditor('intro_content', null, null, false, $editor_config); $form->addHtmlEditor('intro_content', null, null, false, $config);
$form->addButtonSave(get_lang('SaveIntroText'), 'intro_cmdUpdate'); $form->addButtonSave(get_lang('SaveIntroText'), 'intro_cmdUpdate');
/* INTRODUCTION MICRO MODULE - COMMANDS SECTION (IF ALLOWED) */ /* INTRODUCTION MICRO MODULE - COMMANDS SECTION (IF ALLOWED) */
@ -70,6 +70,7 @@ if ($intro_editAllowed) {
if ($form->validate()) { if ($form->validate()) {
$form_values = $form->exportValues(); $form_values = $form->exportValues();
$intro_content = Security::remove_XSS(stripslashes(api_html_entity_decode($form_values['intro_content'])), COURSEMANAGERLOWSECURITY); $intro_content = Security::remove_XSS(stripslashes(api_html_entity_decode($form_values['intro_content'])), COURSEMANAGERLOWSECURITY);
if (!empty($intro_content)) { if (!empty($intro_content)) {
$sql = "REPLACE $TBL_INTRODUCTION $sql = "REPLACE $TBL_INTRODUCTION
SET SET
@ -111,7 +112,10 @@ if ($intro_editAllowed) {
// Getting course intro // Getting course intro
$intro_content = null; $intro_content = null;
$sql = "SELECT intro_text FROM $TBL_INTRODUCTION $sql = "SELECT intro_text FROM $TBL_INTRODUCTION
WHERE c_id = $course_id AND id='".Database::escape_string($moduleId)."' AND session_id = 0"; WHERE
c_id = $course_id AND
id = '".Database::escape_string($moduleId)."' AND
session_id = 0";
$intro_dbQuery = Database::query($sql); $intro_dbQuery = Database::query($sql);
if (Database::num_rows($intro_dbQuery) > 0) { if (Database::num_rows($intro_dbQuery) > 0) {
@ -122,7 +126,10 @@ if (Database::num_rows($intro_dbQuery) > 0) {
// Getting session intro // Getting session intro
if (!empty($session_id)) { if (!empty($session_id)) {
$sql = "SELECT intro_text FROM $TBL_INTRODUCTION $sql = "SELECT intro_text FROM $TBL_INTRODUCTION
WHERE c_id = $course_id AND id='".Database::escape_string($moduleId)."' AND session_id = '".intval($session_id)."'"; WHERE
c_id = $course_id AND
id = '".Database::escape_string($moduleId)."' AND
session_id = '".intval($session_id)."'";
$intro_dbQuery = Database::query($sql); $intro_dbQuery = Database::query($sql);
$introSessionContent = null; $introSessionContent = null;
if (Database::num_rows($intro_dbQuery) > 0) { if (Database::num_rows($intro_dbQuery) > 0) {
@ -198,9 +205,6 @@ if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
} }
if (!empty($thematic_advance_info)) { if (!empty($thematic_advance_info)) {
/*$thematic_advance = get_lang('CourseThematicAdvance').'&nbsp;'.
$thematic->get_total_average_of_thematic_advances().'%';*/
$thematic_advance = get_lang('CourseThematicAdvance'); $thematic_advance = get_lang('CourseThematicAdvance');
$thematicScore = $thematic->get_total_average_of_thematic_advances() . '%'; $thematicScore = $thematic->get_total_average_of_thematic_advances() . '%';
$thematicUrl = api_get_path(WEB_CODE_PATH) . $thematicUrl = api_get_path(WEB_CODE_PATH) .
@ -218,7 +222,6 @@ if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
); );
$userInfo = $_SESSION['_user']; $userInfo = $_SESSION['_user'];
$courseInfo = api_get_course_info(); $courseInfo = api_get_course_info();
//die('<pre>'.print_r($courseInfo,1).'</pre>');
$thematic_description_html = ' $thematic_description_html = '
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div id="panel-thematic" class="panel panel-default"> <div id="panel-thematic" class="panel panel-default">
@ -269,11 +272,7 @@ if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
</div>'; </div>';
} }
$thematic_description_html.='</div>'; $thematic_description_html.='</div>';
$thematic_description_html.='</div></div></div></div></div></div>'; $thematic_description_html.='</div></div></div></div></div></div>';
} }
} }

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */
/** /**
* Class AddCourse * Class AddCourse
@ -378,7 +379,7 @@ class AddCourse
{ {
$pictures = array(); $pictures = array();
foreach ($files as $key => $value) { foreach ($files as $key => $value) {
if ($value[$type] != '') { if (isset($value[$type]) && $value[$type] != '') {
$pictures[][$type] = $value[$type]; $pictures[][$type] = $value[$type];
} }
} }
@ -773,6 +774,7 @@ class AddCourse
array(), array(),
$folder $folder
); );
$sorted_array = self::sort_pictures($files, 'dir'); $sorted_array = self::sort_pictures($files, 'dir');
$sorted_array = array_merge( $sorted_array = array_merge(
$sorted_array, $sorted_array,
@ -981,99 +983,115 @@ class AddCourse
$now $now
); );
$manager = Database::getManager();
/* Introduction text */ /* Introduction text */
$intro_text = '<p style="text-align: center;"> $intro_text = '<p style="text-align: center;">
<img src="' . api_get_path(REL_CODE_PATH) . 'img/mascot.png" alt="Mr. Chamilo" title="Mr. Chamilo" /> <img src="' . api_get_path(REL_CODE_PATH) . 'img/mascot.png" alt="Mr. Chamilo" title="Mr. Chamilo" />
<h2>' . self::lang2db(get_lang('IntroductionText')) . '</h2> <h2>' . self::lang2db(get_lang('IntroductionText')) . '</h2>
</p>'; </p>';
Database::query(
"INSERT INTO $TABLEINTROS VALUES ($course_id, '" . TOOL_COURSE_HOMEPAGE . "','" . $intro_text . "', 0)"
);
Database::query(
"INSERT INTO $TABLEINTROS VALUES ($course_id, '" . TOOL_STUDENTPUBLICATION . "','" . self::lang2db(
get_lang('IntroductionTwo')
) . "', 0)"
);
// Wiki intro $toolIntro = new Chamilo\CourseBundle\Entity\CToolIntro();
$intro_wiki = '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="110" valign="top" align="left"></td><td valign="top" align="left">' . self::lang2db( $toolIntro
get_lang('IntroductionWiki') ->setCId($course_id)
) . '</td></tr></table>'; ->setId(TOOL_COURSE_HOMEPAGE)
Database::query( ->setSessionId(0)
"INSERT INTO $TABLEINTROS VALUES ($course_id, '" . TOOL_WIKI . "','" . $intro_wiki . "', 0)" ->setIntroText($intro_text);
); $manager->persist($toolIntro);
$toolIntro = new Chamilo\CourseBundle\Entity\CToolIntro();
$toolIntro
->setCId($course_id)
->setId(TOOL_STUDENTPUBLICATION)
->setSessionId(0)
->setIntroText(get_lang('IntroductionTwo'));
$manager->persist($toolIntro);
$toolIntro = new Chamilo\CourseBundle\Entity\CToolIntro();
$toolIntro
->setCId($course_id)
->setId(TOOL_WIKI)
->setSessionId(0)
->setIntroText(get_lang('IntroductionWiki'));
$manager->persist($toolIntro);
$manager->flush();
/* Exercise tool */ /* Exercise tool */
$exercise = new Exercise($course_id);
$exercise->exercise = get_lang('ExerciceEx');
$html = '<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="110" valign="top" align="left">
<img src="' . api_get_path(WEB_CODE_PATH) . 'default_course_document/images/mr_dokeos/thinking.jpg">
</td>
<td valign="top" align="left">' . get_lang('Antique') . '</td></tr>
</table>';
$exercise->type = 1;
$exercise->setRandom(0);
$exercise->active = 1;
$exercise->results_disabled = 0;
$exercise->description = $html;
$exercise->save();
$exercise_id = $exercise->id;
$question = new MultipleAnswer();
$question->question = get_lang('SocraticIrony');
$question->description = get_lang('ManyAnswers');
$question->weighting = 10;
$question->position = 1;
$question->course = $courseInfo;
$question->save($exercise_id);
$questionId = $question->id;
$answer = new Answer($questionId, $courseInfo['real_id']);
$answer->createAnswer(get_lang('Ridiculise'), 0, get_lang('NoPsychology'), -5, 1);
$answer->createAnswer(get_lang('AdmitError'), 0, get_lang('NoSeduction'), -5, 2);
$answer->createAnswer(get_lang('Force'), 1, get_lang('Indeed'), 5, 3);
$answer->createAnswer(get_lang('Contradiction'), 1, get_lang('NotFalse'), 5, 4);
$answer->save();
Database::query( /* Forum tool */
"INSERT INTO $TABLEQUIZANSWERSLIST (c_id, id, question_id, answer, correct, comment, ponderation, position) VALUES ($course_id, '1', '1', '" . self::lang2db(
get_lang('Ridiculise')
) . "', '0', '" . self::lang2db(
get_lang('NoPsychology')
) . "', '-5', '1')"
);
Database::query(
"INSERT INTO $TABLEQUIZANSWERSLIST (c_id, id, question_id, answer, correct, comment, ponderation, position) VALUES ($course_id, '2', '1', '" . self::lang2db(
get_lang('AdmitError')
) . "', '0', '" . self::lang2db(
get_lang('NoSeduction')
) . "', '-5', '2')"
);
Database::query(
"INSERT INTO $TABLEQUIZANSWERSLIST (c_id, id, question_id, answer, correct, comment, ponderation, position) VALUES ($course_id, '3', '1', '" . self::lang2db(
get_lang('Force')
) . "', '1', '" . self::lang2db(get_lang('Indeed')) . "', '5', '3')"
);
Database::query(
"INSERT INTO $TABLEQUIZANSWERSLIST (c_id, id, question_id, answer, correct, comment, ponderation, position) VALUES ($course_id, '4', '1', '" . self::lang2db(
get_lang('Contradiction')
) . "', '1', '" . self::lang2db(get_lang('NotFalse')) . "', '5', '4')"
);
$html = Database::escape_string( require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
'<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="110" valign="top" align="left"><img src="' . api_get_path(
WEB_CODE_PATH
) . 'default_course_document/images/mr_dokeos/thinking.jpg"></td><td valign="top" align="left">' . get_lang(
'Antique'
) . '</td></tr></table>'
);
Database::query( $params = [
'INSERT INTO ' . $TABLEQUIZ . 'forum_category_title' => get_lang('ExampleForumCategory'),
' (c_id, title, description, type, random, random_answers, active, results_disabled ) ' . 'forum_category_comment' => ''
' VALUES (' . $course_id . ', "' . self::lang2db( ];
get_lang('ExerciceEx')
) . '",' .
' "' . $html . '", "1", "0", "0", "1", "0")'
);
$exercise_id = Database:: insert_id();
Database::query(
"INSERT INTO $TABLEQUIZQUESTIONLIST (c_id, id, question, description, ponderation, position, type, picture, level)
VALUES ( '.$course_id.', '1', '" . self::lang2db(
get_lang('SocraticIrony')
) . "', '" . self::lang2db(
get_lang('ManyAnswers')
) . "', '10', '1', '2','',1)"
);
Database::query(
"INSERT INTO $TABLEQUIZQUESTION (c_id, question_id, exercice_id, question_order) VALUES ('.$course_id.', 1,1,1)"
);
/* Forum tool */ $forumCategoryId = store_forumcategory($params, $courseInfo, false);
Database::query( $params = [
"INSERT INTO $TABLEFORUMCATEGORIES VALUES ($course_id, 1,'" . self::lang2db( 'forum_category' => $forumCategoryId,
get_lang('ExampleForumCategory') 'forum_title' => get_lang('ExampleForum'),
) . "', '', 1, 0, 0)" 'forum_comment' => '',
); 'default_view_type_group' => ['default_view_type' => 'flat'],
$insert_id = Database:: insert_id(); ];
Database::query(
"INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ($course_id, 'forum_category',1,'$now','$now',$insert_id,'ForumCategoryAdded',1,0,NULL,1)"
);
Database::query( $forumId = store_forum($params, $courseInfo, true);
$forumInfo = get_forum_information($forumId, $courseInfo['real_id']);
$params = [
'post_title' => get_lang('ExampleThread'),
'forum_id' => $forumId,
'post_text' => get_lang('ExampleThreadContent'),
'calification_notebook_title' => '',
'numeric_calification' => '',
'weight_calification' => '',
'forum_category' => $forumCategoryId
];
store_thread($forumInfo, $params, $courseInfo, false);
/*Database::query(
"INSERT INTO $TABLEFORUMS (c_id, forum_title, forum_comment, forum_threads,forum_posts,forum_last_post,forum_category, allow_anonymous, allow_edit,allow_attachments, allow_new_threads,default_view,forum_of_group,forum_group_public_private, forum_order,locked,session_id ) "INSERT INTO $TABLEFORUMS (c_id, forum_title, forum_comment, forum_threads,forum_posts,forum_last_post,forum_category, allow_anonymous, allow_edit,allow_attachments, allow_new_threads,default_view,forum_of_group,forum_group_public_private, forum_order,locked,session_id )
VALUES ($course_id, '" . self::lang2db( VALUES ($course_id, '" . self::lang2db(
get_lang('ExampleForum') get_lang('ExampleForum')
@ -1083,8 +1101,8 @@ class AddCourse
Database::query( Database::query(
"INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ($course_id, '" . TOOL_FORUM . "', 1,'$now','$now',$insert_id,'ForumAdded',1,0,NULL,1)" VALUES ($course_id, '" . TOOL_FORUM . "', 1,'$now','$now',$insert_id,'ForumAdded',1,0,NULL,1)"
); );*/
/*
Database::query( Database::query(
"INSERT INTO $TABLEFORUMTHREADS (c_id, thread_id, thread_title, forum_id, thread_replies, thread_poster_id, thread_poster_name, thread_views, thread_last_post, thread_date, locked, thread_qualify_max, session_id) "INSERT INTO $TABLEFORUMTHREADS (c_id, thread_id, thread_title, forum_id, thread_replies, thread_poster_id, thread_poster_name, thread_views, thread_last_post, thread_date, locked, thread_qualify_max, session_id)
VALUES ($course_id, 1, '" . self::lang2db( VALUES ($course_id, 1, '" . self::lang2db(
@ -1103,21 +1121,24 @@ class AddCourse
) . "', '" . self::lang2db( ) . "', '" . self::lang2db(
get_lang('ExampleThreadContent') get_lang('ExampleThreadContent')
) . "', 1, 1, 1, '', '$now', 0, 0, 1)" ) . "', 1, 1, 1, '', '$now', 0, 0, 1)"
); );*/
/* Gradebook tool */ /* Gradebook tool */
$course_code = $courseInfo['code']; $course_code = $courseInfo['code'];
// father gradebook // father gradebook
Database::query( Database::query(
"INSERT INTO $TABLEGRADEBOOK (name, description, user_id, course_code, parent_id, weight, visible, certif_min_score, session_id, document_id) VALUES ('$course_code','',1,'$course_code',0,100,0,75,NULL,$example_cert_id)" "INSERT INTO $TABLEGRADEBOOK (name, description, user_id, course_code, parent_id, weight, visible, certif_min_score, session_id, document_id)
VALUES ('$course_code','',1,'$course_code',0,100,0,75,NULL,$example_cert_id)"
); );
$gbid = Database:: insert_id(); $gbid = Database:: insert_id();
Database::query( Database::query(
"INSERT INTO $TABLEGRADEBOOK (name, description, user_id, course_code, parent_id, weight, visible, certif_min_score, session_id, document_id) VALUES ('$course_code','',1,'$course_code',$gbid,100,1,75,NULL,$example_cert_id)" "INSERT INTO $TABLEGRADEBOOK (name, description, user_id, course_code, parent_id, weight, visible, certif_min_score, session_id, document_id)
VALUES ('$course_code','',1,'$course_code',$gbid,100,1,75,NULL,$example_cert_id)"
); );
$gbid = Database:: insert_id(); $gbid = Database:: insert_id();
Database::query( Database::query(
"INSERT INTO $TABLEGRADEBOOKLINK (type, ref_id, user_id, course_code, category_id, created_at, weight, visible, locked) VALUES (1,$exercise_id,1,'$course_code',$gbid,'$now',100,1,0)" "INSERT INTO $TABLEGRADEBOOKLINK (type, ref_id, user_id, course_code, category_id, created_at, weight, visible, locked)
VALUES (1,$exercise_id,1,'$course_code',$gbid,'$now',100,1,0)"
); );
} }
@ -1201,13 +1222,11 @@ class AddCourse
$tutor_name = isset($params['tutor_name']) ? $params['tutor_name'] : null; $tutor_name = isset($params['tutor_name']) ? $params['tutor_name'] : null;
//$description = $params['description']; //$description = $params['description'];
$category_code = $params['course_category']; $category_code = isset($params['course_category']) ? $params['course_category'] : '';
$course_language = isset($params['course_language']) && !empty($params['course_language']) ? $params['course_language'] : api_get_setting( $course_language = isset($params['course_language']) && !empty($params['course_language']) ? $params['course_language'] : api_get_setting(
'platformLanguage' 'platformLanguage'
); );
$user_id = empty($params['user_id']) ? api_get_user_id() : intval( $user_id = empty($params['user_id']) ? api_get_user_id() : intval($params['user_id']);
$params['user_id']
);
$department_name = isset($params['department_name']) ? $department_name = isset($params['department_name']) ?
$params['department_name'] : null; $params['department_name'] : null;
$department_url = isset($params['department_url']) ? $department_url = isset($params['department_url']) ?

@ -6754,9 +6754,18 @@ function api_is_global_chat_enabled()
/** /**
* @todo Fix tool_visible_by_default_at_creation labels * @todo Fix tool_visible_by_default_at_creation labels
* @todo Add sessionId parameter to avoid using context * @todo Add sessionId parameter to avoid using context
*
* @param int $item_id
* @param int $tool_id
* @param int $group_id
* @param array $courseInfo
*/ */
function api_set_default_visibility($item_id, $tool_id, $group_id = null) function api_set_default_visibility($item_id, $tool_id, $group_id = 0, $courseInfo = array())
{ {
$courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo;
$courseId = $courseInfo['real_id'];
$courseCode = $courseInfo['code'];
$original_tool_id = $tool_id; $original_tool_id = $tool_id;
switch ($tool_id) { switch ($tool_id) {
@ -6796,11 +6805,11 @@ function api_set_default_visibility($item_id, $tool_id, $group_id = null)
// Read the portal and course default visibility // Read the portal and course default visibility
if ($tool_id == 'documents') { if ($tool_id == 'documents') {
$visibility = DocumentManager::getDocumentDefaultVisibility(api_get_course_id()); $visibility = DocumentManager::getDocumentDefaultVisibility($courseCode);
} }
api_item_property_update( api_item_property_update(
api_get_course_info(), $courseInfo,
$original_tool_id, $original_tool_id,
$item_id, $item_id,
$visibility, $visibility,
@ -6816,7 +6825,7 @@ function api_set_default_visibility($item_id, $tool_id, $group_id = null)
switch ($original_tool_id) { switch ($original_tool_id) {
case TOOL_QUIZ: case TOOL_QUIZ:
$objExerciseTmp = new Exercise(); $objExerciseTmp = new Exercise($courseId);
$objExerciseTmp->read($item_id); $objExerciseTmp->read($item_id);
if ($visibility == 'visible') { if ($visibility == 'visible') {
$objExerciseTmp->enable(); $objExerciseTmp->enable();

@ -5506,7 +5506,7 @@ class CourseManager
* This function separates the users from the groups * This function separates the users from the groups
* users have a value USER:XXX (with XXX the groups id have a value * users have a value USER:XXX (with XXX the groups id have a value
* GROUP:YYY (with YYY the group id) * GROUP:YYY (with YYY the group id)
* @param array Array of strings that define the type and id of each destination * @param array $to Array of strings that define the type and id of each destination
* @return array Array of groups and users (each an array of IDs) * @return array Array of groups and users (each an array of IDs)
*/ */
public static function separateUsersGroups($to) public static function separateUsersGroups($to)
@ -5516,7 +5516,9 @@ class CourseManager
foreach ($to as $to_item) { foreach ($to as $to_item) {
if (!empty($to_item)) { if (!empty($to_item)) {
list($type, $id) = explode(':', $to_item); $parts = explode(':', $to_item);
$type = isset($parts[0]) ? $parts[0] : '';
$id = isset($parts[1]) ? $parts[1] : '';
switch ($type) { switch ($type) {
case 'GROUP': case 'GROUP':

@ -32,7 +32,7 @@ class CToolIntro
/** /**
* @var integer * @var integer
* *
* @ORM\Column(name="id", type="integer", nullable=true) * @ORM\Column(name="id", type="string", nullable=false)
*/ */
private $id; private $id;

@ -23,7 +23,8 @@ function fill_courses()
foreach ($courses as $i => $course) { foreach ($courses as $i => $course) {
//first check that the first item doesn't exist already //first check that the first item doesn't exist already
$output[$i]['line-init'] = $course['title']; $output[$i]['line-init'] = $course['title'];
$output[$i]['line-info'] = ($res = CourseManager::create_course($course)? $res: get_lang('NotInserted')); $res = CourseManager::create_course($course);
$output[$i]['line-info'] = $res ? get_lang('Added') : get_lang('NotInserted');
$i++; $i++;
} }

Loading…
Cancel
Save