@ -36,7 +36,8 @@ class CourseBuilder
/** Course */
public $course;
/* With this array you can filter the tools you want to be parsed by default all tools are included*/
/* With this array you can filter the tools you want to be parsed by
default all tools are included */
public $tools_to_build = array(
'announcements',
'attendance',
@ -58,7 +59,8 @@ class CourseBuilder
'works'
);
/* With this array you can filter wich elements of the tools are going to be added in the course obj (only works with LPs) */
/* With this array you can filter wich elements of the tools are going
to be added in the course obj (only works with LPs) */
public $specific_id_list = array();
/**
@ -85,18 +87,18 @@ class CourseBuilder
/**
*
* @param type $array
* @param array $array
*/
function set_tools_to_build($array)
public function set_tools_to_build($array)
{
$this->tools_to_build = $array;
}
/**
*
* @param type $array
* @param array $array
*/
function set_tools_specific_id_list($array)
public function set_tools_specific_id_list($array)
{
$this->specific_id_list = $array;
}
@ -105,7 +107,7 @@ class CourseBuilder
* Get the created course
* @return course The course
*/
function get_course()
public function get_course()
{
return $this->course;
}
@ -118,37 +120,50 @@ class CourseBuilder
* @param bool true if you want to get the elements that exists in the course and
* in the session, (session_id = 0 or session_id = X)
*/
function build($session_id = 0, $course_code = '', $with_base_content = false)
public function build($session_id = 0, $course_code = '', $with_base_content = false)
{
$table_link = Database :: get_course_table(TABLE_LINKED_RESOURCES);
$table_properties = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id'];
foreach ($this->tools_to_build as $tool) {
$function_build = 'build_'.$tool;
$specificIdList = isset($this->specific_id_list[$tool]) ? $this->specific_id_list[$tool] : null;
$this->$function_build($session_id, $course_code, $with_base_content, $specificIdList);
$this->$function_build(
$session_id,
$course_code,
$with_base_content,
$specificIdList
);
}
//TABLE_LINKED_RESOURCES is the "resource" course table, which is deprecated, apparently
foreach ($this->course->resources as $type => $resources) {
foreach ($resources as $id => $resource) {
$sql = "SELECT * FROM ".$table_link." WHERE c_id = $course_id AND source_type = '".$resource->get_type()."' AND source_id = '".$resource->get_id()."'";
$sql = "SELECT * FROM $table_link
WHERE
c_id = $course_id AND
source_type = '".$resource->get_type()."' AND
source_id = '".$resource->get_id()."'";
$res = Database::query($sql);
while ($link = Database::fetch_object($res)) {
$this->course->resources[$type][$id]->add_linked_resource($link->resource_type, $link->resource_id);
}
}
}
// Once we've built the resouces array a bit more, try to get items
// from the item_propry table and order them in the "resources" array
// Once we've built the resour ces array a bit more, try to get items
// from the item_prope rt y table and order them in the "resources" array
foreach ($this->course->resources as $type => $resources) {
foreach ($resources as $id => $resource) {
$tool = $resource->get_tool();
if ($tool != null) {
$sql = "SELECT * FROM $table_properties WHERE c_id = $course_id AND TOOL = '".$tool."' AND ref='".$resource->get_id()."'";
$sql = "SELECT * FROM $table_properties
WHERE
c_id = $course_id AND
tool = '".$tool."' AND
ref='".$resource->get_id()."'";
$res = Database::query($sql);
$all_properties = array ();
while ($item_property = Database::fetch_array($res)) {
@ -164,9 +179,8 @@ class CourseBuilder
/**
* Build the documents
*/
function build_documents($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
public function build_documents($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
{
$course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id'];
@ -187,24 +201,28 @@ class CourseBuilder
}
if (!empty($this->course->type) & & $this->course->type=='partial') {
$sql = "SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size FROM $table_doc d, $table_prop p
WHERE d.c_id = $course_id AND
p.c_id = $course_id AND
tool = '".TOOL_DOCUMENT."' AND
p.ref = d.id AND
p.visibility != 2 AND
path NOT LIKE '/images/gallery%' AND
$avoid_paths
$session_condition
$sql = "SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
FROM $table_doc d, $table_prop p
WHERE
d.c_id = $course_id AND
p.c_id = $course_id AND
tool = '".TOOL_DOCUMENT."' AND
p.ref = d.id AND
p.visibility != 2 AND
path NOT LIKE '/images/gallery%' AND
$avoid_paths
$session_condition
ORDER BY path";
} else {
$sql = "SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size FROM $table_doc d, $table_prop p
WHERE d.c_id = $course_id AND
p.c_id = $course_id AND
tool = '".TOOL_DOCUMENT."' AND
$avoid_paths AND
p.ref = d.id AND
p.visibility != 2 $session_condition
$sql = "SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
FROM $table_doc d, $table_prop p
WHERE
d.c_id = $course_id AND
p.c_id = $course_id AND
tool = '".TOOL_DOCUMENT."' AND
$avoid_paths AND
p.ref = d.id AND
p.visibility != 2 $session_condition
ORDER BY path";
}
@ -217,31 +235,36 @@ class CourseBuilder
} else {
if (!empty($this->course->type) & & $this->course->type=='partial')
$sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size FROM '.$table_doc.' d, '.$table_prop.' p
WHERE d.c_id = '.$course_id.' AND
p.c_id = '.$course_id.' AND
tool = \''.TOOL_DOCUMENT.'\' AND
p.ref = d.id AND
p.visibility != 2 AND
path NOT LIKE \'/images/gallery%\' AND
'.$avoid_paths.'AND
d.session_id = 0
$sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
FROM '.$table_doc.' d, '.$table_prop.' p
WHERE
d.c_id = '.$course_id.' AND
p.c_id = '.$course_id.' AND
tool = \''.TOOL_DOCUMENT.'\' AND
p.ref = d.id AND
p.visibility != 2 AND
path NOT LIKE \'/images/gallery%\' AND
'.$avoid_paths.'AND
d.session_id = 0
ORDER BY path';
else
$sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
FROM '.$table_doc.' d, '.$table_prop.' p
WHERE d.c_id = '.$course_id.' AND
p.c_id = '.$course_id.' AND
tool = \''.TOOL_DOCUMENT.'\' AND
p.ref = d.id AND
p.visibility != 2 AND
'.$avoid_paths.' AND
d.session_id = 0
WHERE
d.c_id = '.$course_id.' AND
p.c_id = '.$course_id.' AND
tool = \''.TOOL_DOCUMENT.'\' AND
p.ref = d.id AND
p.visibility != 2 AND
'.$avoid_paths.' AND
d.session_id = 0
ORDER BY path';
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result)) {
$doc = new Document($obj->id, $obj->path, $obj->comment, $obj->title, $obj->filetype, $obj->size);
$doc = new Document(
$obj->id, $obj->path, $obj->comment, $obj->title, $obj->filetype, $obj->size
);
$this->course->add_resource($doc);
}
}
@ -250,7 +273,7 @@ class CourseBuilder
/**
* Build the forums
*/
function build_forums($session_id = 0, $course_code = null, $with_base_content = false, $id_list = array())
public function build_forums($session_id = 0, $course_code = null, $with_base_content = false, $id_list = array())
{
$course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id'];
@ -269,7 +292,7 @@ class CourseBuilder
/**
* Build a forum-category
*/
function build_forum_category($session_id = 0, $course_code = null, $with_base_content = false, $id_list = array())
public function build_forum_category($session_id = 0, $course_code = null, $with_base_content = false, $id_list = array())
{
$table = Database :: get_course_table(TABLE_FORUM_CATEGORY);
$course_info = api_get_course_info($course_code);
@ -286,7 +309,7 @@ class CourseBuilder
/**
* Build the forum-topics
*/
function build_forum_topics($session_id = 0, $course_code = null, $with_base_content = false, $id_list = array())
public function build_forum_topics($session_id = 0, $course_code = null, $with_base_content = false, $id_list = array())
{
$table = Database :: get_course_table(TABLE_FORUM_THREAD);
$course_info = api_get_course_info($course_code);
@ -305,7 +328,7 @@ class CourseBuilder
* Build the forum-posts
* TODO: All tree structure of posts should be built, attachments for example.
*/
function build_forum_posts($thread_id = null, $forum_id = null, $only_first_post = false)
public function build_forum_posts($thread_id = null, $forum_id = null, $only_first_post = false)
{
$table = Database :: get_course_table(TABLE_FORUM_POST);
$course_id = api_get_course_int_id();
@ -326,7 +349,7 @@ class CourseBuilder
/**
* Build the links
*/
function build_links($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
public function build_links($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
{
$course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id'];
@ -372,7 +395,7 @@ class CourseBuilder
/**
* Build tool intro
*/
function build_tool_intro($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
public function build_tool_intro($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
{
$table = Database :: get_course_table(TABLE_TOOL_INTRO);
$course_id = api_get_course_int_id();
@ -387,7 +410,7 @@ class CourseBuilder
/**
* Build a link category
*/
function build_link_category($id, $course_code = '')
public function build_link_category($id, $course_code = '')
{
$course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id'];
@ -407,7 +430,7 @@ class CourseBuilder
/**
* Build the Quizzes
*/
function build_quizzes($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
public function build_quizzes($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
{
$course_info = api_get_course_info($course_code);
$table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
@ -423,9 +446,11 @@ class CourseBuilder
} else {
$session_condition = api_get_session_condition($session_id, true);
}
$sql = "SELECT * FROM $table_qui WHERE c_id = $course_id AND active >=0 $session_condition"; //select only quizzes with active = 0 or 1 (not -1 which is for deleted quizzes)
$sql = "SELECT * FROM $table_qui WHERE c_id = $course_id AND active >=0 $session_condition";
//select only quizzes with active = 0 or 1 (not -1 which is for deleted quizzes)
} else {
$sql = "SELECT * FROM $table_qui WHERE c_id = $course_id AND active >=0 AND session_id = 0"; //select only quizzes with active = 0 or 1 (not -1 which is for deleted quizzes)
$sql = "SELECT * FROM $table_qui WHERE c_id = $course_id AND active >=0 AND session_id = 0";
//select only quizzes with active = 0 or 1 (not -1 which is for deleted quizzes)
}
$db_result = Database::query($sql);
@ -456,7 +481,7 @@ class CourseBuilder
/**
* Build the Quiz-Questions
*/
function build_quiz_questions($course_code = null)
public function build_quiz_questions($course_code = null)
{
$course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id'];
@ -474,13 +499,33 @@ class CourseBuilder
// find the question category
// @todo : need to be adapted for multi category questions in 1.10
$question_category_id = Testcategory::getCategoryForQuestion($obj->id, $course_id);
// build the backup ressource question object
$question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture, $obj->level, $obj->extra, $question_category_id);
// build the backup resource question object
$question = new QuizQuestion(
$obj->id,
$obj->question,
$obj->description,
$obj->ponderation,
$obj->type,
$obj->position,
$obj->picture,
$obj->level,
$obj->extra,
$question_category_id
);
$sql = 'SELECT * FROM '.$table_ans.' WHERE c_id = '.$course_id.' AND question_id = '.$obj->id;
$db_result2 = Database::query($sql);
while ($obj2 = Database::fetch_object($db_result2)) {
$question->add_answer($obj2->id, $obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type);
$question->add_answer(
$obj2->id,
$obj2->answer,
$obj2->correct,
$obj2->comment,
$obj2->ponderation,
$obj2->position,
$obj2->hotspot_coordinates,
$obj2->hotspot_type
);
if ($obj->type == MULTIPLE_ANSWER_TRUE_FALSE) {
$table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
$sql = 'SELECT * FROM '.$table_options.' WHERE c_id = '.$course_id.' AND question_id = '.$obj->id;
@ -495,7 +540,8 @@ class CourseBuilder
}
// Building a fictional test for collecting orphan questions.
$build_orphan_questions = !empty($_POST['recycle_option']); // When a course is emptied this option should be activated (true).
// When a course is emptied this option should be activated (true).
$build_orphan_questions = !empty($_POST['recycle_option']);
// 1st union gets the orphan questions from deleted exercises
// 2nd union gets the orphan questions from question that were deleted in a exercise.
@ -539,12 +585,32 @@ class CourseBuilder
// find the question category
// @todo : need to be adapted for multi category questions in 1.10
$question_category_id = Testcategory::getCategoryForQuestion($obj->id, $course_id);
$question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture,$obj->level, $obj->extra, $question_category_id);
$question = new QuizQuestion(
$obj->id,
$obj->question,
$obj->description,
$obj->ponderation,
$obj->type,
$obj->position,
$obj->picture,
$obj->level,
$obj->extra,
$question_category_id
);
$sql = "SELECT * FROM $table_ans WHERE c_id = $course_id AND question_id = ".$obj->id;
$db_result2 = Database::query($sql);
if (Database::num_rows($db_result2)) {
while ($obj2 = Database::fetch_object($db_result2)) {
$question->add_answer($obj2->id, $obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type);
$question->add_answer(
$obj2->id,
$obj2->answer,
$obj2->correct,
$obj2->comment,
$obj2->ponderation,
$obj2->position,
$obj2->hotspot_coordinates,
$obj2->hotspot_type
);
}
$orphanQuestionIds[] = $obj->id;
}
@ -573,7 +639,7 @@ class CourseBuilder
/**
* Build the orphan questions
*/
function build_quiz_orphan_questions()
public function build_quiz_orphan_questions()
{
$table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
$table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
@ -595,14 +661,35 @@ class CourseBuilder
exercises.active = -1)';
$db_result = Database::query($sql);
if (Database::num_rows($db_result) > 0) {
$orphan_questions = new Quiz(-1, get_lang('OrphanQuestions', ''), '', 0, 0, 1, '', 0); // Tjis is the fictional test for collecting orphan questions.
// This is the fictional test for collecting orphan questions.
$orphan_questions = new Quiz(-1, get_lang('OrphanQuestions', ''), '', 0, 0, 1, '', 0);
$this->course->add_resource($orphan_questions);
while ($obj = Database::fetch_object($db_result)) {
$question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture,$obj->level,$obj->extra);
$question = new QuizQuestion(
$obj->id,
$obj->question,
$obj->description,
$obj->ponderation,
$obj->type,
$obj->position,
$obj->picture,
$obj->level,
$obj->extra
);
$sql = 'SELECT * FROM '.$table_ans.' WHERE question_id = '.$obj->id;
$db_result2 = Database::query($sql);
while ($obj2 = Database::fetch_object($db_result2)) {
$question->add_answer($obj2->id, $obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type);
$question->add_answer(
$obj2->id,
$obj2->answer,
$obj2->correct,
$obj2->comment,
$obj2->ponderation,
$obj2->position,
$obj2->hotspot_coordinates,
$obj2->hotspot_type
);
}
$this->course->add_resource($question);
}
@ -614,7 +701,7 @@ class CourseBuilder
* $session_id, $course_code, $with_base_content, $this->specific_id_list[$tool]
* @todo add course session
*/
function build_test_category($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
public function build_test_category($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
{
$course_id = api_get_course_int_id();
@ -631,7 +718,7 @@ class CourseBuilder
/**
* Build the Surveys
*/
function build_surveys($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
public function build_surveys($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
{
$table_survey = Database :: get_course_table(TABLE_SURVEY);
$table_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
@ -655,10 +742,11 @@ class CourseBuilder
}
$this->build_survey_questions();
}
/**
* Build the Survey Questions
*/
function build_survey_questions() {
public function build_survey_questions() {
$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
$table_opt = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
@ -667,10 +755,17 @@ class CourseBuilder
$sql = 'SELECT * FROM '.$table_que.' WHERE c_id = '.$course_id.' ';
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result)){
$question = new SurveyQuestion($obj->question_id, $obj->survey_id,
$obj->survey_question, $obj->survey_question_comment,
$obj->type, $obj->display, $obj->sort,
$obj->shared_question_id, $obj->max_value);
$question = new SurveyQuestion(
$obj->question_id,
$obj->survey_id,
$obj->survey_question,
$obj->survey_question_comment,
$obj->type,
$obj->display,
$obj->sort,
$obj->shared_question_id,
$obj->max_value
);
$sql = 'SELECT * FROM '.$table_opt.' WHERE c_id = '.$course_id.' AND question_id = '.$obj->question_id;
$db_result2 = Database::query($sql);
while ($obj2 = Database::fetch_object($db_result2)) {
@ -683,7 +778,7 @@ class CourseBuilder
/**
* Build the announcements
*/
function build_announcements($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) {
public function build_announcements($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) {
$table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
$course_id = api_get_course_int_id();
@ -701,15 +796,28 @@ class CourseBuilder
$att_size = $attachment_obj->size;
$atth_comment = $attachment_obj->comment;
}
$announcement = new Announcement($obj->id, $obj->title, $obj->content, $obj->end_date,$obj->display_order,$obj->email_sent, $att_path, $att_filename, $att_size, $atth_comment);
$announcement = new Announcement(
$obj->id,
$obj->title,
$obj->content,
$obj->end_date,
$obj->display_order,
$obj->email_sent,
$att_path,
$att_filename,
$att_size,
$atth_comment
);
$this->course->add_resource($announcement);
}
}
/**
* Build the events
*/
function build_events($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) {
public function build_events($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
{
$table = Database :: get_course_table(TABLE_AGENDA);
$course_id = api_get_course_int_id();
@ -731,12 +839,13 @@ class CourseBuilder
$event = new Event($obj->id, $obj->title, $obj->content, $obj->start_date, $obj->end_date, $att_path, $att_filename, $att_size, $atth_comment, $obj->all_day);
$this->course->add_resource($event);
}
}
/**
* Build the course-descriptions
*/
function build_course_descriptions($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) {
public function build_course_descriptions($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
{
$course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id'];
@ -761,11 +870,12 @@ class CourseBuilder
$this->course->add_resource($cd);
}
}
/**
* Build the learnpaths
*/
function build_learnpaths($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) {
public function build_learnpaths($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
{
$course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id'];
$table_main = Database::get_course_table(TABLE_LP_MAIN);
@ -817,9 +927,10 @@ class CourseBuilder
}
$sql_tool = "SELECT id FROM $table_tool
WHERE c_id = $course_id AND
(link LIKE '%lp_controller.php%lp_id=".$obj->id."%' AND image='scormbuilder.gif') AND
visibility = '1' ";
WHERE
c_id = $course_id AND
(link LIKE '%lp_controller.php%lp_id=".$obj->id."%' AND image='scormbuilder.gif') AND
visibility = '1' ";
$db_tool = Database::query($sql_tool);
if (Database::num_rows($db_tool)) {
@ -829,33 +940,34 @@ class CourseBuilder
}
$lp = new CourseCopyLearnpath(
$obj->id,
$obj->lp_type,
$obj->name,
$obj->path,
$obj->ref,
$obj->description,
$obj->content_local,
$obj->default_encoding,
$obj->default_view_mod,
$obj->prevent_reinit,
$obj->force_commit,
$obj->content_maker,
$obj->display_order,
$obj->js_lib,
$obj->content_license,
$obj->debug,
$visibility,
$obj->author,
$obj->preview_image,
$obj->use_max_score,
$obj->autolunch,
$obj->created_on,
$obj->modified_on,
$obj->publicated_on,
$obj->expired_on,
$obj->session_id,
$items);
$obj->id,
$obj->lp_type,
$obj->name,
$obj->path,
$obj->ref,
$obj->description,
$obj->content_local,
$obj->default_encoding,
$obj->default_view_mod,
$obj->prevent_reinit,
$obj->force_commit,
$obj->content_maker,
$obj->display_order,
$obj->js_lib,
$obj->content_license,
$obj->debug,
$visibility,
$obj->author,
$obj->preview_image,
$obj->use_max_score,
$obj->autolunch,
$obj->created_on,
$obj->modified_on,
$obj->publicated_on,
$obj->expired_on,
$obj->session_id,
$items
);
$this->course->add_resource($lp);
}
@ -875,7 +987,8 @@ class CourseBuilder
/**
* Build the glossarys
*/
function build_glossary($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) {
public function build_glossary($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
{
$course_info = api_get_course_info($course_code);
$table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
$course_id = $course_info['real_id'];
@ -912,7 +1025,8 @@ class CourseBuilder
/*
* build session course by jhon
* */
function build_session_course(){
public function build_session_course()
{
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$list_course = Database::get_course_list();
@ -938,7 +1052,14 @@ class CourseBuilder
return $list;
}
function build_wiki($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) {
/**
* @param int $session_id
* @param string $course_code
* @param bool $with_base_content
* @param array $id_list
*/
public function build_wiki($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
{
$course_info = api_get_course_info($course_code);
$tbl_wiki = Database::get_course_table(TABLE_WIKI);
@ -966,7 +1087,8 @@ class CourseBuilder
/**
* Build the Surveys
*/
function build_thematic($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) {
public function build_thematic($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
{
$table_thematic = Database :: get_course_table(TABLE_THEMATIC);
$table_thematic_advance = Database :: get_course_table(TABLE_THEMATIC_ADVANCE);
$table_thematic_plan = Database :: get_course_table(TABLE_THEMATIC_PLAN);
@ -1006,11 +1128,11 @@ class CourseBuilder
$sql = "SELECT tp.*
FROM $table_thematic_plan tp
INNER JOIN $table_thematic t ON (t.id=tp.thematic_id)
WHERE t.c_id = $course_id AND
tp .c_id = $course_id AND
thematic_id = {$row['id']} AND
tp.id IN (".implode(', ', $thematic_plan_id_list).") ";
WHERE
t.c_id = $course_id AND
tp.c_id = $course_id AND
thematic_id = {$row['id']} AND
tp.id IN (".implode(', ', $thematic_plan_id_list).") ";
$result = Database::query($sql);
while ($sub_row = Database::fetch_array($result,'ASSOC')) {
@ -1024,7 +1146,8 @@ class CourseBuilder
/**
* Build the attendances
*/
function build_attendance($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) {
public function build_attendance($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
{
$table_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
$table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR);
@ -1043,16 +1166,24 @@ class CourseBuilder
$this->course->add_resource($obj);
}
}
/**
* Build the works (or "student publications", or "assignments")
*/
function build_works($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) {
$table_work = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
public function build_works($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
{
$table_work = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
//$table_work_assignment = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$course_id = api_get_course_int_id();
$sql = 'SELECT * FROM '.$table_work.' WHERE c_id = '.$course_id.' AND session_id = 0 AND filetype = \'folder\' AND parent_id = 0 AND active = 1';
$sql = 'SELECT * FROM '.$table_work.'
WHERE
c_id = '.$course_id.' AND
session_id = 0 AND
filetype = \'folder\' AND
parent_id = 0 AND
active = 1';
$db_result = Database::query($sql);
while ($row = Database::fetch_array($db_result,'ASSOC')) {
$obj = new Work($row);