Fix fill course with content.

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

@ -508,8 +508,17 @@ class Answer
* @param string $hotspot_coordinates
* @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);
//$id = $this->getQuestionType() == FILL_IN_BLANKS ? $idAnswer[0] : Database::escape_string($position);
$autoId = intval($autoId);

@ -51,36 +51,36 @@ class Exercise
*
* @author Olivier Brouckaert
*/
public function Exercise($course_id = null)
public function __construct($course_id = null)
{
$this->id = 0;
$this->exercise = '';
$this->description = '';
$this->sound = '';
$this->type = ALL_ON_ONE_PAGE;
$this->random = 0;
$this->random_answers = 0;
$this->active = 1;
$this->questionList = array();
$this->timeLimit = 0;
$this->end_time = '0000-00-00 00:00:00';
$this->start_time = '0000-00-00 00:00:00';
$this->id = 0;
$this->exercise = '';
$this->description = '';
$this->sound = '';
$this->type = ALL_ON_ONE_PAGE;
$this->random = 0;
$this->random_answers = 0;
$this->active = 1;
$this->questionList = array();
$this->timeLimit = 0;
$this->end_time = '0000-00-00 00:00:00';
$this->start_time = '0000-00-00 00:00:00';
$this->results_disabled = 1;
$this->expired_time = '0000-00-00 00:00:00';
$this->propagate_neg = 0;
$this->review_answers = false;
$this->randomByCat = 0; //
$this->expired_time = '0000-00-00 00:00:00';
$this->propagate_neg = 0;
$this->review_answers = false;
$this->randomByCat = 0; //
$this->text_when_finished = ""; //
$this->display_category_name = 0;
$this->pass_percentage = null;
$this->pass_percentage = null;
if (!empty($course_id)) {
$course_info = api_get_course_info_by_id($course_id);
$course_info = api_get_course_info_by_id($course_id);
} else {
$course_info = api_get_course_info();
$course_info = api_get_course_info();
}
$this->course_id = $course_info['real_id'];
$this->course = $course_info;
$this->course_id = $course_info['real_id'];
$this->course = $course_info;
}
/**
@ -106,27 +106,27 @@ class Exercise
// if the exercise has been found
if ($object = Database::fetch_object($result)) {
$this->id = $id;
$this->exercise = $object->title;
$this->name = $object->title;
$this->title = $object->title;
$this->description = $object->description;
$this->sound = $object->sound;
$this->type = $object->type;
$this->id = $id;
$this->exercise = $object->title;
$this->name = $object->title;
$this->title = $object->title;
$this->description = $object->description;
$this->sound = $object->sound;
$this->type = $object->type;
if (empty($this->type)) {
$this->type = ONE_PER_PAGE;
}
$this->random = $object->random;
$this->random_answers = $object->random_answers;
$this->active = $object->active;
$this->results_disabled = $object->results_disabled;
$this->attempts = $object->max_attempt;
$this->feedback_type = $object->feedback_type;
$this->propagate_neg = $object->propagate_neg;
$this->randomByCat = $object->random_by_category;
$this->text_when_finished = $object->text_when_finished;
$this->display_category_name = $object->display_category_name;
$this->pass_percentage = $object->pass_percentage;
$this->random = $object->random;
$this->random_answers = $object->random_answers;
$this->active = $object->active;
$this->results_disabled = $object->results_disabled;
$this->attempts = $object->max_attempt;
$this->feedback_type = $object->feedback_type;
$this->propagate_neg = $object->propagate_neg;
$this->randomByCat = $object->random_by_category;
$this->text_when_finished = $object->text_when_finished;
$this->display_category_name = $object->display_category_name;
$this->pass_percentage = $object->pass_percentage;
$this->sessionId = $object->session_id;
$this->is_gradebook_locked = api_resource_is_locked_by_gradebook($id, LINK_EXERCISE);
@ -428,19 +428,21 @@ class Exercise
{
if ($from_db && !empty($this->id)) {
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$sql = "SELECT DISTINCT e.question_order
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.")
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.")
WHERE e.exercice_id = ".intval($this->id)."";
$result = Database::query($sql);
$count_question_orders = Database::num_rows($result);
$sql = "SELECT e.question_id, e.question_order
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.")
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.")
WHERE e.exercice_id = ".intval($this->id)."
ORDER BY question_order";
$result = Database::query($sql);
@ -462,8 +464,10 @@ class Exercise
$question_list = $temp_question_list;
}
}
return $question_list;
}
return $this->questionList;
}
@ -752,7 +756,7 @@ class Exercise
*/
public function save($type_e = '')
{
$_course = api_get_course_info();
$_course = $this->course;
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$id = $this->id;
@ -771,7 +775,7 @@ class Exercise
$text_when_finished = $this->text_when_finished;
$display_category_name = intval($this->display_category_name);
$pass_percentage = intval($this->pass_percentage);
$session_id = api_get_session_id();
$session_id = $this->sessionId;
//If direct we do not show results
if ($feedback_type == EXERCISE_FEEDBACK_TYPE_DIRECT) {
@ -824,16 +828,24 @@ class Exercise
Database::query($sql);
// 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') {
$this->search_engine_edit();
}
} 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 function, api_set_default_visibility, the Quiz is saved too, with an $id and api_get_utc_datetime() is done.
// 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 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 (!empty($this->start_time) && $this->start_time != '0000-00-00 00:00:00') {
$start_time = Database::escape_string($this->start_time);
@ -888,12 +900,14 @@ class Exercise
// This function save the quiz again, carefull about start_time
// 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(
'search_enabled'
) == 'true' && extension_loaded('xapian')
) {
if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
$this->search_engine_save();
}
}
@ -3090,19 +3104,19 @@ class Exercise
$final_missing = 100;
$final_excess = 100;
} else {
// the final overlap is the percentage of the initial polygon
// the final overlap is the percentage of the initial polygon
// that is overlapped by the user's polygon
$final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100);
if ($debug > 1) {
error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0);
}
// the final missing area is the percentage of the initial polygon
// the final missing area is the percentage of the initial polygon
// that is not overlapped by the user's polygon
$final_missing = 100 - $final_overlap;
if ($debug > 1) {
error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0);
}
// the final excess area is the percentage of the initial polygon's size
// the final excess area is the percentage of the initial polygon's size
// that is covered by the user's polygon outside of the initial polygon
$final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100);
if ($debug > 1) {
@ -4566,7 +4580,7 @@ class Exercise
}
$tabres = $questionList;
} else {
// Problem, random by category has been selected and
// Problem, random by category has been selected and
// we have no $this->isRandom number of question selected
// Should not happened
}

@ -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
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @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);
// 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);
api_item_property_update(
api_get_course_info(),
$courseInfo,
TOOL_FORUM_CATEGORY,
$values['forum_category_id'],
'ForumCategoryUpdated',
@ -549,32 +554,44 @@ function store_forumcategory($values)
if ($last_id > 0) {
api_item_property_update(
api_get_course_info(),
$courseInfo,
TOOL_FORUM_CATEGORY,
$last_id,
'ForumCategoryAdded',
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');
}
Display :: display_confirmation_message($return_message);
if ($showMessage) {
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.
*
* @param array
* @param array $values
* @param array $courseInfo
* @param bool $returnId
* @return string language variable
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function store_forum($values)
function store_forum($values, $courseInfo = array(), $returnId = false)
{
$_course = api_get_course_info();
$course_id = api_get_course_int_id();
$courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo;
$course_id = $courseInfo['real_id'];
$session_id = api_get_session_id();
if (isset($values['group_id']) && !empty($values['group_id'])) {
@ -617,7 +634,7 @@ function store_forum($values)
if (isset($upload_ok)) {
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);
$updir = $sys_course_path.$course_dir;
// Try to add an extension to the file if it hasn't one.
@ -669,7 +686,7 @@ function store_forum($values)
Database::query($sql);
api_item_property_update(
$_course,
$courseInfo,
TOOL_FORUM,
Database::escape_string($values['forum_id']),
'ForumUpdated',
@ -707,13 +724,31 @@ function store_forum($values)
$last_id = Database::insert_id();
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);
api_item_property_update($_course, TOOL_FORUM, $last_id, 'ForumAdded', api_get_user_id(), $group_id);
api_set_default_visibility($last_id, TOOL_FORUM, $group_id);
api_item_property_update(
$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');
if ($returnId) {
return $last_id;
}
}
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)
*/
function get_forum_information($forum_id)
function get_forum_information($forum_id, $courseId = 0)
{
$table_forums = Database :: get_course_table(TABLE_FORUM);
$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
item_properties.tool = '".TOOL_FORUM."' AND
item_properties.ref = '".Database::escape_string($forum_id)."' AND
item_properties.c_id = ".api_get_course_int_id()." AND
forums.forum_id = '".Database::escape_string($forum_id)."' AND
forums.c_id = ".api_get_course_int_id()."
item_properties.tool = '".TOOL_FORUM."' AND
item_properties.ref = '".$forum_id."' AND
forums.forum_id = '".$forum_id."' AND
forums.c_id = ".$courseId."
";
$result = Database::query($sql);
$row = Database::fetch_array($result);
$row['approval_direct_post'] = 0;
// We can't anymore change this option, so it should always be activated.
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
* 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
* @param array $current_forum
* @param array $values
* @param array $courseInfo
* @param bool $showMessage
* @return void HTML
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @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();
$course_id = $courseInfo['real_id'];
$courseCode = $courseInfo['code'];
$table_threads = Database :: get_course_table(TABLE_FORUM_THREAD);
$table_posts = Database :: get_course_table(TABLE_FORUM_POST);
$course_id = api_get_course_int_id();
$gradebook = Security::remove_XSS($_GET['gradebook']);
$gradebook = isset($_GET['gradebook']) ? Security::remove_XSS($_GET['gradebook']) : '';
$upload_ok = 1;
$has_attachment = false;
@ -2238,7 +2280,6 @@ function store_thread($current_forum, $values)
if (isset($values['thread_qualify_gradebook']) && 1 == $values['thread_qualify_gradebook']) {
// Add function gradebook.
$coursecode = api_get_course_id();
$resourcetype = 5;
$resourceid = $last_thread_id;
$resourcename = stripslashes($values['calification_notebook_title']);
@ -2247,7 +2288,7 @@ function store_thread($current_forum, $values)
$resourcedescription = '';
GradebookUtils::add_resource_to_course_gradebook(
$values['category_id'],
$coursecode,
$courseCode,
$resourcetype,
$resourceid,
$resourcename,
@ -2261,19 +2302,38 @@ function store_thread($current_forum, $values)
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);
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,
// 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);
// Default behaviour
api_set_default_visibility(
$last_thread_id,
TOOL_FORUM_THREAD,
0,
$courseInfo
);
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;
}
}
@ -2295,20 +2355,31 @@ function store_thread($current_forum, $values)
$last_post_id = Database::insert_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);
}
// Update attached files
if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
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).
$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)."'";
// 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).
$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);
$message = get_lang('NewThreadStored');
// 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']);
if (!filter_extension($new_file_name)) {
Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
if ($showMessage) {
Display:: display_error_message(
get_lang('UplUnableToSaveFileFilteredExtension')
);
}
} else {
if ($result) {
add_forum_attachment_file($values['file_comment'], $last_post_id);
@ -2349,10 +2424,13 @@ function store_thread($current_forum, $values)
Session::erase('breadcrumbs');
Session::erase('addedresource');
Session::erase('addedresourceid');
Display :: display_confirmation_message($message, false);
if ($showMessage) {
Display:: display_confirmation_message($message, false);
}
} else {
Display::display_error_message(get_lang('UplNoFileUploaded'));
if ($showMessage) {
Display::display_error_message(get_lang('UplNoFileUploaded'));
}
}
}
@ -2741,8 +2819,8 @@ function current_qualify_of_thread($thread_id, $session_id)
/**
* 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)
* @param array
* @param array
* @param array $current_forum
* @param array $values
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
@ -2750,7 +2828,6 @@ function store_reply($current_forum, $values)
{
$_course = api_get_course_info();
$table_posts = Database :: get_course_table(TABLE_FORUM_POST);
$post_date = api_get_utc_datetime();
if ($current_forum['approval_direct_post'] == '1' && !api_is_allowed_to_edit(null, true)) {
@ -2767,16 +2844,16 @@ function store_reply($current_forum, $values)
// We first store an entry in the forum_post table.
$sql = "INSERT INTO $table_posts (c_id, post_title, post_text, thread_id, forum_id, poster_id, post_date, post_notification, post_parent_id, visible)
VALUES (
".api_get_course_int_id().",
'".Database::escape_string($values['post_title'])."',
'".Database::escape_string(isset($values['post_text']) ? ($values['post_text']) : null)."',
'".Database::escape_string($values['thread_id'])."',
'".Database::escape_string($values['forum_id'])."',
'".api_get_user_id()."',
'".$post_date."',
'".Database::escape_string(isset($values['post_notification']) ? $values['post_notification'] : null)."',
'".Database::escape_string(isset($values['post_parent_id']) ? $values['post_parent_id'] : null)."',
'".Database::escape_string($visible)."')";
".api_get_course_int_id().",
'".Database::escape_string($values['post_title'])."',
'".Database::escape_string(isset($values['post_text']) ? ($values['post_text']) : null)."',
'".Database::escape_string($values['thread_id'])."',
'".Database::escape_string($values['forum_id'])."',
'".api_get_user_id()."',
'".$post_date."',
'".Database::escape_string(isset($values['post_notification']) ? $values['post_notification'] : null)."',
'".Database::escape_string(isset($values['post_parent_id']) ? $values['post_parent_id'] : null)."',
'".Database::escape_string($visible)."')";
Database::query($sql);
$new_post_id = Database::insert_id();
$values['new_post_id'] = $new_post_id;
@ -3383,7 +3460,13 @@ function send_notification_mails($thread_id, $reply_info)
// 4. the reply is visible (=when there is)
$current_thread = get_thread_information($thread_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' &&
$current_forum['visibility'] == '1' &&
@ -3397,23 +3480,27 @@ function send_notification_mails($thread_id, $reply_info)
// The forum category, the forum, the thread and the reply are visible to the user
if ($send_mails) {
send_notifications($current_thread['forum_id'], $thread_id);
if (isset($current_thread['forum_id'])) {
send_notifications($current_thread['forum_id'], $thread_id);
}
} else {
$table_notification = Database::get_course_table(TABLE_FORUM_NOTIFICATION);
$sql = "SELECT * FROM $table_notification
WHERE
c_id = ".api_get_course_int_id()." AND
(
forum_id = '".Database::escape_string($current_forum['forum_id'])."' OR
thread_id = '".Database::escape_string($thread_id)."'
) ";
if (isset($current_forum['forum_id'])) {
$sql = "SELECT * FROM $table_notification
WHERE
c_id = ".api_get_course_int_id()." AND
(
forum_id = '".intval($current_forum['forum_id'])."' OR
thread_id = '".intval($thread_id)."'
) ";
$result = Database::query($sql);
$user_id = api_get_user_id();
while ($row = Database::fetch_array($result)) {
$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' )";
Database::query($sql);
$result = Database::query($sql);
$user_id = api_get_user_id();
while ($row = Database::fetch_array($result)) {
$sql = "INSERT INTO $table (c_id, thread_id, post_id, user_id)
VALUES (".api_get_course_int_id().", '".intval($thread_id)."', '".intval($reply_info['new_post_id'])."', '$user_id' )";
Database::query($sql);
}
}
}
}
@ -4329,13 +4416,19 @@ function set_notification($content, $id, $add_only = false)
}
// 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);
$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) {
$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);
Session::erase('forum_notification');
get_notifications_of_user(0, true);
@ -4344,7 +4437,10 @@ function set_notification($content, $id, $add_only = false)
} else {
if (!$add_only) {
$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);
Session::erase('forum_notification');
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();
}
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;
$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);
while ($row = Database::fetch_array($result)) {
if (!is_null($row['forum_id'])) {
@ -4507,7 +4607,8 @@ function count_number_of_post_in_thread($thread_id)
if (empty($course_id)) {
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);
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');
$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);
return count(Database::store_result($result));
@ -4610,13 +4712,13 @@ function get_thread_user_post($course_code, $thread_id, $user_id)
$row['status'] = '1';
$post_list[] = $row;
$sql = "SELECT * FROM $table_posts posts
LEFT JOIN $table_users users
ON posts.poster_id=users.user_id
WHERE
posts.c_id = $course_id AND
posts.thread_id='$thread_id'
AND posts.post_parent_id='".$row['post_id']."'
ORDER BY posts.post_id ASC";
LEFT JOIN $table_users users
ON posts.poster_id=users.user_id
WHERE
posts.c_id = $course_id AND
posts.thread_id='$thread_id'
AND posts.post_parent_id='".$row['post_id']."'
ORDER BY posts.post_id ASC";
$result2 = Database::query($sql);
while ($row2 = Database::fetch_array($result2)) {
$row2['status'] = '0';
@ -4638,7 +4740,8 @@ function get_name_thread_by_id($thread_id)
{
$t_forum_thread = Database::get_course_table(TABLE_FORUM_THREAD);
$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);
$row = Database::fetch_array($result);

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

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class AddCourse
@ -378,7 +379,7 @@ class AddCourse
{
$pictures = array();
foreach ($files as $key => $value) {
if ($value[$type] != '') {
if (isset($value[$type]) && $value[$type] != '') {
$pictures[][$type] = $value[$type];
}
}
@ -773,6 +774,7 @@ class AddCourse
array(),
$folder
);
$sorted_array = self::sort_pictures($files, 'dir');
$sorted_array = array_merge(
$sorted_array,
@ -981,101 +983,117 @@ class AddCourse
$now
);
$manager = Database::getManager();
/* Introduction text */
$intro_text = '<p style="text-align: center;">
<img src="' . api_get_path(REL_CODE_PATH) . 'img/mascot.png" alt="Mr. Chamilo" title="Mr. Chamilo" />
<h2>' . self::lang2db(get_lang('IntroductionText')) . '</h2>
</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
$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(
get_lang('IntroductionWiki')
) . '</td></tr></table>';
Database::query(
"INSERT INTO $TABLEINTROS VALUES ($course_id, '" . TOOL_WIKI . "','" . $intro_wiki . "', 0)"
);
$toolIntro = new Chamilo\CourseBundle\Entity\CToolIntro();
$toolIntro
->setCId($course_id)
->setId(TOOL_COURSE_HOMEPAGE)
->setSessionId(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 = 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(
"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')"
);
/* Forum tool */
$html = Database::escape_string(
'<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>'
);
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
Database::query(
'INSERT INTO ' . $TABLEQUIZ .
' (c_id, title, description, type, random, random_answers, active, results_disabled ) ' .
' 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)"
);
$params = [
'forum_category_title' => get_lang('ExampleForumCategory'),
'forum_category_comment' => ''
];
/* Forum tool */
$forumCategoryId = store_forumcategory($params, $courseInfo, false);
Database::query(
"INSERT INTO $TABLEFORUMCATEGORIES VALUES ($course_id, 1,'" . self::lang2db(
get_lang('ExampleForumCategory')
) . "', '', 1, 0, 0)"
);
$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)"
);
$params = [
'forum_category' => $forumCategoryId,
'forum_title' => get_lang('ExampleForum'),
'forum_comment' => '',
'default_view_type_group' => ['default_view_type' => 'flat'],
];
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 )
VALUES ($course_id, '" . self::lang2db(
VALUES ($course_id, '" . self::lang2db(
get_lang('ExampleForum')
) . "', '', 0, 0, 0, 1, 0, 1, '0', 1, 'flat','0', 'public', 1, 0,0)"
);
@ -1083,8 +1101,8 @@ class AddCourse
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, '" . TOOL_FORUM . "', 1,'$now','$now',$insert_id,'ForumAdded',1,0,NULL,1)"
);
);*/
/*
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)
VALUES ($course_id, 1, '" . self::lang2db(
@ -1103,21 +1121,24 @@ class AddCourse
) . "', '" . self::lang2db(
get_lang('ExampleThreadContent')
) . "', 1, 1, 1, '', '$now', 0, 0, 1)"
);
);*/
/* Gradebook tool */
$course_code = $courseInfo['code'];
// father gradebook
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();
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();
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;
//$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(
'platformLanguage'
);
$user_id = empty($params['user_id']) ? api_get_user_id() : intval(
$params['user_id']
);
$user_id = empty($params['user_id']) ? api_get_user_id() : intval($params['user_id']);
$department_name = isset($params['department_name']) ?
$params['department_name'] : null;
$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 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;
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
if ($tool_id == 'documents') {
$visibility = DocumentManager::getDocumentDefaultVisibility(api_get_course_id());
$visibility = DocumentManager::getDocumentDefaultVisibility($courseCode);
}
api_item_property_update(
api_get_course_info(),
$courseInfo,
$original_tool_id,
$item_id,
$visibility,
@ -6812,11 +6821,11 @@ function api_set_default_visibility($item_id, $tool_id, $group_id = null)
api_get_session_id()
);
//Fixes default visibility for tests
// Fixes default visibility for tests
switch ($original_tool_id) {
case TOOL_QUIZ:
$objExerciseTmp = new Exercise();
$objExerciseTmp = new Exercise($courseId);
$objExerciseTmp->read($item_id);
if ($visibility == 'visible') {
$objExerciseTmp->enable();

@ -5506,8 +5506,8 @@ class CourseManager
* This function separates the users from the groups
* users have a value USER:XXX (with XXX the groups id have a value
* GROUP:YYY (with YYY the group id)
* @param array Array of strings that define the type and id of each destination
* @return array Array of groups and users (each an array of IDs)
* @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)
*/
public static function separateUsersGroups($to)
{
@ -5516,7 +5516,9 @@ class CourseManager
foreach ($to as $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) {
case 'GROUP':

@ -381,7 +381,7 @@ class Database
return false;
}
$filtred_attributes = array();
foreach($attributes as $key => $value) {
foreach ($attributes as $key => $value) {
$filtred_attributes[$key] = "'".self::escape_string($value)."'";
}
//@todo check if the field exists in the table we should use a describe of that table

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

@ -23,7 +23,8 @@ function fill_courses()
foreach ($courses as $i => $course) {
//first check that the first item doesn't exist already
$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++;
}

Loading…
Cancel
Save