|
@@ -122,21 +122,19 @@ class CourseBuilder
|
|
*/
|
|
*/
|
|
public function build(
|
|
public function build(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = '',
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false
|
|
$with_base_content = false
|
|
) {
|
|
) {
|
|
$table_link = Database:: get_course_table(TABLE_LINKED_RESOURCES);
|
|
$table_link = Database:: get_course_table(TABLE_LINKED_RESOURCES);
|
|
$table_properties = Database:: get_course_table(TABLE_ITEM_PROPERTY);
|
|
$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) {
|
|
foreach ($this->tools_to_build as $tool) {
|
|
$function_build = 'build_'.$tool;
|
|
$function_build = 'build_'.$tool;
|
|
$specificIdList = isset($this->specific_id_list[$tool]) ? $this->specific_id_list[$tool] : null;
|
|
$specificIdList = isset($this->specific_id_list[$tool]) ? $this->specific_id_list[$tool] : null;
|
|
|
|
|
|
$this->$function_build(
|
|
$this->$function_build(
|
|
$session_id,
|
|
$session_id,
|
|
- $course_code,
|
|
|
|
|
|
+ $course_id,
|
|
$with_base_content,
|
|
$with_base_content,
|
|
$specificIdList
|
|
$specificIdList
|
|
);
|
|
);
|
|
@@ -151,6 +149,7 @@ class CourseBuilder
|
|
source_type = '".$resource->get_type()."' AND
|
|
source_type = '".$resource->get_type()."' AND
|
|
source_id = '".$resource->get_id()."'";
|
|
source_id = '".$resource->get_id()."'";
|
|
$res = Database::query($sql);
|
|
$res = Database::query($sql);
|
|
|
|
+ error_log($sql);
|
|
while ($link = Database::fetch_object($res)) {
|
|
while ($link = Database::fetch_object($res)) {
|
|
$this->course->resources[$type][$id]->add_linked_resource(
|
|
$this->course->resources[$type][$id]->add_linked_resource(
|
|
$link->resource_type,
|
|
$link->resource_type,
|
|
@@ -186,19 +185,16 @@ class CourseBuilder
|
|
/**
|
|
/**
|
|
* Build the documents
|
|
* Build the documents
|
|
* @param int $session_id
|
|
* @param int $session_id
|
|
- * @param string $course_code
|
|
|
|
|
|
+ * @param int $course_id
|
|
* @param bool $with_base_content
|
|
* @param bool $with_base_content
|
|
* @param array $id_list
|
|
* @param array $id_list
|
|
*/
|
|
*/
|
|
public function build_documents(
|
|
public function build_documents(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = '',
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$id_list = array()
|
|
) {
|
|
) {
|
|
- $course_info = api_get_course_info($course_code);
|
|
|
|
- $course_id = $course_info['real_id'];
|
|
|
|
-
|
|
|
|
$table_doc = Database::get_course_table(TABLE_DOCUMENT);
|
|
$table_doc = Database::get_course_table(TABLE_DOCUMENT);
|
|
$table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY);
|
|
$table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY);
|
|
|
|
|
|
@@ -207,7 +203,7 @@ class CourseBuilder
|
|
path NOT LIKE '/chat_files%' ";
|
|
path NOT LIKE '/chat_files%' ";
|
|
//$avoid_paths = " 1 = 1 ";
|
|
//$avoid_paths = " 1 = 1 ";
|
|
|
|
|
|
- if (!empty($course_code) && !empty($session_id)) {
|
|
|
|
|
|
+ if (!empty($course_id) && !empty($session_id)) {
|
|
$session_id = intval($session_id);
|
|
$session_id = intval($session_id);
|
|
if ($with_base_content) {
|
|
if ($with_base_content) {
|
|
$session_condition = api_get_session_condition(
|
|
$session_condition = api_get_session_condition(
|
|
@@ -308,25 +304,27 @@ class CourseBuilder
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build the forums
|
|
* Build the forums
|
|
|
|
+ * @param int $session_id Internal session ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param bool $with_base_content Whether to include content from the course without session or not
|
|
|
|
+ * @param array $id_list If you want to restrict the structure to only the given IDs
|
|
|
|
+ * @return void
|
|
*/
|
|
*/
|
|
public function build_forums(
|
|
public function build_forums(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = null,
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$id_list = array()
|
|
) {
|
|
) {
|
|
- $course_info = api_get_course_info($course_code);
|
|
|
|
- $course_id = $course_info['real_id'];
|
|
|
|
-
|
|
|
|
$table = Database:: get_course_table(TABLE_FORUM);
|
|
$table = Database:: get_course_table(TABLE_FORUM);
|
|
|
|
|
|
- $sessionCodition = api_get_session_condition(
|
|
|
|
|
|
+ $sessionCondition = api_get_session_condition(
|
|
$session_id,
|
|
$session_id,
|
|
true,
|
|
true,
|
|
$with_base_content
|
|
$with_base_content
|
|
);
|
|
);
|
|
|
|
|
|
- $sql = "SELECT * FROM $table WHERE c_id = $course_id $sessionCodition";
|
|
|
|
|
|
+ $sql = "SELECT * FROM $table WHERE c_id = $course_id $sessionCondition";
|
|
$sql .= " ORDER BY forum_title, forum_category";
|
|
$sql .= " ORDER BY forum_title, forum_category";
|
|
$db_result = Database::query($sql);
|
|
$db_result = Database::query($sql);
|
|
while ($obj = Database::fetch_object($db_result)) {
|
|
while ($obj = Database::fetch_object($db_result)) {
|
|
@@ -337,24 +335,27 @@ class CourseBuilder
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build a forum-category
|
|
* Build a forum-category
|
|
|
|
+ * @param int $session_id Internal session ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param bool $with_base_content Whether to include content from the course without session or not
|
|
|
|
+ * @param array $id_list If you want to restrict the structure to only the given IDs
|
|
|
|
+ * @return void
|
|
*/
|
|
*/
|
|
public function build_forum_category(
|
|
public function build_forum_category(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = null,
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$id_list = array()
|
|
) {
|
|
) {
|
|
$table = Database:: get_course_table(TABLE_FORUM_CATEGORY);
|
|
$table = Database:: get_course_table(TABLE_FORUM_CATEGORY);
|
|
- $course_info = api_get_course_info($course_code);
|
|
|
|
- $course_id = $course_info['real_id'];
|
|
|
|
|
|
|
|
- $sessionCodition = api_get_session_condition(
|
|
|
|
|
|
+ $sessionCondition = api_get_session_condition(
|
|
$session_id,
|
|
$session_id,
|
|
true,
|
|
true,
|
|
$with_base_content
|
|
$with_base_content
|
|
);
|
|
);
|
|
|
|
|
|
- $sql = "SELECT * FROM $table WHERE c_id = $course_id $sessionCodition ORDER BY cat_title";
|
|
|
|
|
|
+ $sql = "SELECT * FROM $table WHERE c_id = $course_id $sessionCondition ORDER BY cat_title";
|
|
|
|
|
|
$db_result = Database::query($sql);
|
|
$db_result = Database::query($sql);
|
|
while ($obj = Database::fetch_object($db_result)) {
|
|
while ($obj = Database::fetch_object($db_result)) {
|
|
@@ -365,45 +366,52 @@ class CourseBuilder
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build the forum-topics
|
|
* Build the forum-topics
|
|
|
|
+ * @param int $session_id Internal session ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param bool $with_base_content Whether to include content from the course without session or not
|
|
|
|
+ * @param array $id_list If you want to restrict the structure to only the given IDs
|
|
|
|
+ * @return void
|
|
*/
|
|
*/
|
|
public function build_forum_topics(
|
|
public function build_forum_topics(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = null,
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$id_list = array()
|
|
) {
|
|
) {
|
|
$table = Database:: get_course_table(TABLE_FORUM_THREAD);
|
|
$table = Database:: get_course_table(TABLE_FORUM_THREAD);
|
|
- $course_info = api_get_course_info($course_code);
|
|
|
|
- $course_id = $course_info['real_id'];
|
|
|
|
|
|
|
|
- $sessionCodition = api_get_session_condition(
|
|
|
|
|
|
+ $sessionCondition = api_get_session_condition(
|
|
$session_id,
|
|
$session_id,
|
|
true,
|
|
true,
|
|
$with_base_content
|
|
$with_base_content
|
|
);
|
|
);
|
|
|
|
|
|
$sql = "SELECT * FROM $table WHERE c_id = $course_id
|
|
$sql = "SELECT * FROM $table WHERE c_id = $course_id
|
|
- $sessionCodition
|
|
|
|
|
|
+ $sessionCondition
|
|
ORDER BY thread_title ";
|
|
ORDER BY thread_title ";
|
|
$db_result = Database::query($sql);
|
|
$db_result = Database::query($sql);
|
|
while ($obj = Database::fetch_object($db_result)) {
|
|
while ($obj = Database::fetch_object($db_result)) {
|
|
$forum_topic = new ForumTopic($obj);
|
|
$forum_topic = new ForumTopic($obj);
|
|
$this->course->add_resource($forum_topic);
|
|
$this->course->add_resource($forum_topic);
|
|
- $this->build_forum_posts($obj->thread_id, $obj->forum_id, true);
|
|
|
|
|
|
+ $this->build_forum_posts($course_id, $obj->thread_id, $obj->forum_id, true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build the forum-posts
|
|
* Build the forum-posts
|
|
* TODO: All tree structure of posts should be built, attachments for example.
|
|
* TODO: All tree structure of posts should be built, attachments for example.
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param int $thread_id Internal thread ID
|
|
|
|
+ * @param int $forum_id Internal forum ID
|
|
|
|
+ * @param bool $only_first_post Whether to only copy the first post or not
|
|
*/
|
|
*/
|
|
public function build_forum_posts(
|
|
public function build_forum_posts(
|
|
|
|
+ $course_id = 0,
|
|
$thread_id = null,
|
|
$thread_id = null,
|
|
$forum_id = null,
|
|
$forum_id = null,
|
|
$only_first_post = false
|
|
$only_first_post = false
|
|
) {
|
|
) {
|
|
- $table = Database:: get_course_table(TABLE_FORUM_POST);
|
|
|
|
- $course_id = api_get_course_int_id();
|
|
|
|
|
|
+ $table = Database :: get_course_table(TABLE_FORUM_POST);
|
|
$sql = "SELECT * FROM $table WHERE c_id = $course_id ";
|
|
$sql = "SELECT * FROM $table WHERE c_id = $course_id ";
|
|
if (!empty($thread_id) && !empty($forum_id)) {
|
|
if (!empty($thread_id) && !empty($forum_id)) {
|
|
$forum_id = intval($forum_id);
|
|
$forum_id = intval($forum_id);
|
|
@@ -420,20 +428,21 @@ class CourseBuilder
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build the links
|
|
* Build the links
|
|
|
|
+ * @param int $session_id Internal session ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param bool $with_base_content Whether to include content from the course without session or not
|
|
|
|
+ * @param array $id_list If you want to restrict the structure to only the given IDs
|
|
*/
|
|
*/
|
|
public function build_links(
|
|
public function build_links(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = '',
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$id_list = array()
|
|
) {
|
|
) {
|
|
- $course_info = api_get_course_info($course_code);
|
|
|
|
- $course_id = $course_info['real_id'];
|
|
|
|
|
|
+ $table = Database :: get_course_table(TABLE_LINK);
|
|
|
|
+ $table_prop = Database :: get_course_table(TABLE_ITEM_PROPERTY);
|
|
|
|
|
|
- $table = Database:: get_course_table(TABLE_LINK);
|
|
|
|
- $table_prop = Database:: get_course_table(TABLE_ITEM_PROPERTY);
|
|
|
|
-
|
|
|
|
- if (!empty($session_id) && !empty($course_code)) {
|
|
|
|
|
|
+ if (!empty($session_id) && !empty($course_id)) {
|
|
$session_id = intval($session_id);
|
|
$session_id = intval($session_id);
|
|
if ($with_base_content) {
|
|
if ($with_base_content) {
|
|
$session_condition = api_get_session_condition(
|
|
$session_condition = api_get_session_condition(
|
|
@@ -484,11 +493,8 @@ class CourseBuilder
|
|
);
|
|
);
|
|
$this->course->add_resource($link);
|
|
$this->course->add_resource($link);
|
|
|
|
|
|
- if (!empty($course_code)) {
|
|
|
|
- $res = $this->build_link_category(
|
|
|
|
- $obj->category_id,
|
|
|
|
- $course_code
|
|
|
|
- );
|
|
|
|
|
|
+ if (!empty($course_id)) {
|
|
|
|
+ $res = $this->build_link_category($obj->category_id, $course_id);
|
|
} else {
|
|
} else {
|
|
$res = $this->build_link_category($obj->category_id);
|
|
$res = $this->build_link_category($obj->category_id);
|
|
}
|
|
}
|
|
@@ -504,23 +510,26 @@ class CourseBuilder
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build tool intro
|
|
* Build tool intro
|
|
|
|
+ * @param int $session_id Internal session ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param bool $with_base_content Whether to include content from the course without session or not
|
|
|
|
+ * @param array $id_list If you want to restrict the structure to only the given IDs
|
|
*/
|
|
*/
|
|
public function build_tool_intro(
|
|
public function build_tool_intro(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = '',
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$id_list = array()
|
|
) {
|
|
) {
|
|
$table = Database:: get_course_table(TABLE_TOOL_INTRO);
|
|
$table = Database:: get_course_table(TABLE_TOOL_INTRO);
|
|
- $course_id = api_get_course_int_id();
|
|
|
|
|
|
|
|
- $sessionCodition = api_get_session_condition(
|
|
|
|
|
|
+ $sessionCondition = api_get_session_condition(
|
|
$session_id,
|
|
$session_id,
|
|
true,
|
|
true,
|
|
$with_base_content
|
|
$with_base_content
|
|
);
|
|
);
|
|
|
|
|
|
- $sql = "SELECT * FROM $table WHERE c_id = $course_id $sessionCodition";
|
|
|
|
|
|
+ $sql = "SELECT * FROM $table WHERE c_id = $course_id $sessionCondition";
|
|
|
|
|
|
$db_result = Database::query($sql);
|
|
$db_result = Database::query($sql);
|
|
while ($obj = Database::fetch_object($db_result)) {
|
|
while ($obj = Database::fetch_object($db_result)) {
|
|
@@ -531,13 +540,12 @@ class CourseBuilder
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build a link category
|
|
* Build a link category
|
|
|
|
+ * @param int $id Internal link ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
*/
|
|
*/
|
|
- public function build_link_category($id, $course_code = '')
|
|
|
|
|
|
+ public function build_link_category($id, $course_id = 0)
|
|
{
|
|
{
|
|
- $course_info = api_get_course_info($course_code);
|
|
|
|
- $course_id = $course_info['real_id'];
|
|
|
|
-
|
|
|
|
- $link_cat_table = Database:: get_course_table(TABLE_LINK_CATEGORY);
|
|
|
|
|
|
+ $link_cat_table = Database :: get_course_table(TABLE_LINK_CATEGORY);
|
|
|
|
|
|
$sql = "SELECT * FROM $link_cat_table WHERE c_id = $course_id AND id = $id";
|
|
$sql = "SELECT * FROM $link_cat_table WHERE c_id = $course_id AND id = $id";
|
|
$db_result = Database::query($sql);
|
|
$db_result = Database::query($sql);
|
|
@@ -558,22 +566,23 @@ class CourseBuilder
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build the Quizzes
|
|
* Build the Quizzes
|
|
|
|
+ * @param int $session_id Internal session ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param bool $with_base_content Whether to include content from the course without session or not
|
|
|
|
+ * @param array $id_list If you want to restrict the structure to only the given IDs
|
|
*/
|
|
*/
|
|
public function build_quizzes(
|
|
public function build_quizzes(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = '',
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$id_list = array()
|
|
) {
|
|
) {
|
|
- $course_info = api_get_course_info($course_code);
|
|
|
|
$table_qui = Database:: get_course_table(TABLE_QUIZ_TEST);
|
|
$table_qui = Database:: get_course_table(TABLE_QUIZ_TEST);
|
|
$table_rel = Database:: get_course_table(TABLE_QUIZ_TEST_QUESTION);
|
|
$table_rel = Database:: get_course_table(TABLE_QUIZ_TEST_QUESTION);
|
|
$table_doc = Database:: get_course_table(TABLE_DOCUMENT);
|
|
$table_doc = Database:: get_course_table(TABLE_DOCUMENT);
|
|
|
|
|
|
- $course_id = $course_info['real_id'];
|
|
|
|
-
|
|
|
|
- if (!empty($course_code) && !empty($session_id)) {
|
|
|
|
- $session_id = intval($session_id);
|
|
|
|
|
|
+ if (!empty($course_id) && !empty($session_id)) {
|
|
|
|
+ $session_id = intval($session_id);
|
|
if ($with_base_content) {
|
|
if ($with_base_content) {
|
|
$session_condition = api_get_session_condition(
|
|
$session_condition = api_get_session_condition(
|
|
$session_id,
|
|
$session_id,
|
|
@@ -611,8 +620,8 @@ class CourseBuilder
|
|
$this->course->add_resource($quiz);
|
|
$this->course->add_resource($quiz);
|
|
}
|
|
}
|
|
|
|
|
|
- if (!empty($course_code)) {
|
|
|
|
- $this->build_quiz_questions($course_code);
|
|
|
|
|
|
+ if (!empty($course_id)) {
|
|
|
|
+ $this->build_quiz_questions($course_id);
|
|
} else {
|
|
} else {
|
|
$this->build_quiz_questions();
|
|
$this->build_quiz_questions();
|
|
}
|
|
}
|
|
@@ -620,16 +629,14 @@ class CourseBuilder
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build the Quiz-Questions
|
|
* Build the Quiz-Questions
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
*/
|
|
*/
|
|
- public function build_quiz_questions($course_code = null)
|
|
|
|
|
|
+ public function build_quiz_questions($course_id = 0)
|
|
{
|
|
{
|
|
- $course_info = api_get_course_info($course_code);
|
|
|
|
- $course_id = $course_info['real_id'];
|
|
|
|
-
|
|
|
|
- $table_qui = Database:: get_course_table(TABLE_QUIZ_TEST);
|
|
|
|
- $table_rel = Database:: get_course_table(TABLE_QUIZ_TEST_QUESTION);
|
|
|
|
- $table_que = Database:: get_course_table(TABLE_QUIZ_QUESTION);
|
|
|
|
- $table_ans = Database:: get_course_table(TABLE_QUIZ_ANSWER);
|
|
|
|
|
|
+ $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
|
|
|
|
+ $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
|
|
|
|
+ $table_que = Database :: get_course_table(TABLE_QUIZ_QUESTION);
|
|
|
|
+ $table_ans = Database :: get_course_table(TABLE_QUIZ_ANSWER);
|
|
|
|
|
|
// Building normal tests.
|
|
// Building normal tests.
|
|
$sql = "SELECT * FROM $table_que WHERE c_id = $course_id ";
|
|
$sql = "SELECT * FROM $table_que WHERE c_id = $course_id ";
|
|
@@ -859,17 +866,18 @@ class CourseBuilder
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build the test category
|
|
* Build the test category
|
|
- * $session_id, $course_code, $with_base_content, $this->specific_id_list[$tool]
|
|
|
|
|
|
+ * @param int $session_id Internal session ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param bool $with_base_content Whether to include content from the course without session or not
|
|
|
|
+ * @param array $id_list If you want to restrict the structure to only the given IDs
|
|
* @todo add course session
|
|
* @todo add course session
|
|
*/
|
|
*/
|
|
public function build_test_category(
|
|
public function build_test_category(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = '',
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$id_list = array()
|
|
) {
|
|
) {
|
|
- $course_id = api_get_course_int_id();
|
|
|
|
-
|
|
|
|
// get all test category in course
|
|
// get all test category in course
|
|
$tab_test_categories_id = TestCategory::getCategoryListInfo(
|
|
$tab_test_categories_id = TestCategory::getCategoryListInfo(
|
|
"id",
|
|
"id",
|
|
@@ -888,16 +896,19 @@ class CourseBuilder
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build the Surveys
|
|
* Build the Surveys
|
|
|
|
+ * @param int $session_id Internal session ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param bool $with_base_content Whether to include content from the course without session or not
|
|
|
|
+ * @param array $id_list If you want to restrict the structure to only the given IDs
|
|
*/
|
|
*/
|
|
public function build_surveys(
|
|
public function build_surveys(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = '',
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$id_list = array()
|
|
) {
|
|
) {
|
|
$table_survey = Database:: get_course_table(TABLE_SURVEY);
|
|
$table_survey = Database:: get_course_table(TABLE_SURVEY);
|
|
$table_question = Database:: get_course_table(TABLE_SURVEY_QUESTION);
|
|
$table_question = Database:: get_course_table(TABLE_SURVEY_QUESTION);
|
|
- $course_id = api_get_course_int_id();
|
|
|
|
|
|
|
|
$sessionCondition = api_get_session_condition(
|
|
$sessionCondition = api_get_session_condition(
|
|
$session_id,
|
|
$session_id,
|
|
@@ -923,18 +934,16 @@ class CourseBuilder
|
|
}
|
|
}
|
|
$this->course->add_resource($survey);
|
|
$this->course->add_resource($survey);
|
|
}
|
|
}
|
|
- $this->build_survey_questions();
|
|
|
|
|
|
+ $this->build_survey_questions($course_id);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build the Survey Questions
|
|
* Build the Survey Questions
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
*/
|
|
*/
|
|
- public function build_survey_questions()
|
|
|
|
- {
|
|
|
|
- $table_que = Database:: get_course_table(TABLE_SURVEY_QUESTION);
|
|
|
|
- $table_opt = Database:: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
|
|
|
|
-
|
|
|
|
- $course_id = api_get_course_int_id();
|
|
|
|
|
|
+ public function build_survey_questions($course_id) {
|
|
|
|
+ $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
|
|
|
|
+ $table_opt = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
|
|
|
|
|
|
$sql = 'SELECT * FROM '.$table_que.' WHERE c_id = '.$course_id.' ';
|
|
$sql = 'SELECT * FROM '.$table_que.' WHERE c_id = '.$course_id.' ';
|
|
$db_result = Database::query($sql);
|
|
$db_result = Database::query($sql);
|
|
@@ -961,15 +970,18 @@ class CourseBuilder
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build the announcements
|
|
* Build the announcements
|
|
|
|
+ * @param int $session_id Internal session ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param bool $with_base_content Whether to include content from the course without session or not
|
|
|
|
+ * @param array $id_list If you want to restrict the structure to only the given IDs
|
|
*/
|
|
*/
|
|
public function build_announcements(
|
|
public function build_announcements(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = '',
|
|
|
|
|
|
+ $courseId = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$id_list = array()
|
|
) {
|
|
) {
|
|
$table = Database:: get_course_table(TABLE_ANNOUNCEMENT);
|
|
$table = Database:: get_course_table(TABLE_ANNOUNCEMENT);
|
|
- $courseId = api_get_course_int_id();
|
|
|
|
|
|
|
|
$sessionCondition = api_get_session_condition(
|
|
$sessionCondition = api_get_session_condition(
|
|
$session_id,
|
|
$session_id,
|
|
@@ -1016,15 +1028,18 @@ class CourseBuilder
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build the events
|
|
* Build the events
|
|
|
|
+ * @param int $session_id Internal session ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param bool $with_base_content Whether to include content from the course without session or not
|
|
|
|
+ * @param array $id_list If you want to restrict the structure to only the given IDs
|
|
*/
|
|
*/
|
|
public function build_events(
|
|
public function build_events(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = '',
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$id_list = array()
|
|
) {
|
|
) {
|
|
$table = Database:: get_course_table(TABLE_AGENDA);
|
|
$table = Database:: get_course_table(TABLE_AGENDA);
|
|
- $course_id = api_get_course_int_id();
|
|
|
|
|
|
|
|
$sessionCondition = api_get_session_condition(
|
|
$sessionCondition = api_get_session_condition(
|
|
$session_id,
|
|
$session_id,
|
|
@@ -1067,19 +1082,20 @@ class CourseBuilder
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build the course-descriptions
|
|
* Build the course-descriptions
|
|
|
|
+ * @param int $session_id Internal session ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param bool $with_base_content Whether to include content from the course without session or not
|
|
|
|
+ * @param array $id_list If you want to restrict the structure to only the given IDs
|
|
*/
|
|
*/
|
|
public function build_course_descriptions(
|
|
public function build_course_descriptions(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = '',
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$id_list = array()
|
|
) {
|
|
) {
|
|
- $course_info = api_get_course_info($course_code);
|
|
|
|
- $course_id = $course_info['real_id'];
|
|
|
|
-
|
|
|
|
$table = Database:: get_course_table(TABLE_COURSE_DESCRIPTION);
|
|
$table = Database:: get_course_table(TABLE_COURSE_DESCRIPTION);
|
|
|
|
|
|
- if (!empty($session_id) && !empty($course_code)) {
|
|
|
|
|
|
+ if (!empty($session_id) && !empty($course_id)) {
|
|
$session_id = intval($session_id);
|
|
$session_id = intval($session_id);
|
|
if ($with_base_content) {
|
|
if ($with_base_content) {
|
|
$session_condition = api_get_session_condition(
|
|
$session_condition = api_get_session_condition(
|
|
@@ -1113,20 +1129,22 @@ class CourseBuilder
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build the learnpaths
|
|
* Build the learnpaths
|
|
|
|
+ * @param int $session_id Internal session ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param bool $with_base_content Whether to include content from the course without session or not
|
|
|
|
+ * @param array $id_list If you want to restrict the structure to only the given IDs
|
|
*/
|
|
*/
|
|
public function build_learnpaths(
|
|
public function build_learnpaths(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = '',
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$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);
|
|
$table_main = Database::get_course_table(TABLE_LP_MAIN);
|
|
$table_item = Database::get_course_table(TABLE_LP_ITEM);
|
|
$table_item = Database::get_course_table(TABLE_LP_ITEM);
|
|
$table_tool = Database::get_course_table(TABLE_TOOL_LIST);
|
|
$table_tool = Database::get_course_table(TABLE_TOOL_LIST);
|
|
|
|
|
|
- if (!empty($session_id) && !empty($course_code)) {
|
|
|
|
|
|
+ if (!empty($session_id) && !empty($course_id)) {
|
|
$session_id = intval($session_id);
|
|
$session_id = intval($session_id);
|
|
if ($with_base_content) {
|
|
if ($with_base_content) {
|
|
$session_condition = api_get_session_condition(
|
|
$session_condition = api_get_session_condition(
|
|
@@ -1239,19 +1257,21 @@ class CourseBuilder
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Build the glossarys
|
|
|
|
|
|
+ * Build the glossaries
|
|
|
|
+ * @param int $session_id Internal session ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param bool $with_base_content Whether to include content from the course without session or not
|
|
|
|
+ * @param array $id_list If you want to restrict the structure to only the given IDs
|
|
*/
|
|
*/
|
|
public function build_glossary(
|
|
public function build_glossary(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = '',
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$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'];
|
|
|
|
|
|
+ $table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
|
|
|
|
|
|
- if (!empty($session_id) && !empty($course_code)) {
|
|
|
|
|
|
+ if (!empty($session_id) && !empty($course_id)) {
|
|
$session_id = intval($session_id);
|
|
$session_id = intval($session_id);
|
|
if ($with_base_content) {
|
|
if ($with_base_content) {
|
|
$session_condition = api_get_session_condition(
|
|
$session_condition = api_get_session_condition(
|
|
@@ -1293,8 +1313,8 @@ class CourseBuilder
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
- * build session course by jhon
|
|
|
|
- * */
|
|
|
|
|
|
+ * Build session course by jhon
|
|
|
|
+ */
|
|
public function build_session_course()
|
|
public function build_session_course()
|
|
{
|
|
{
|
|
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
|
|
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
|
|
@@ -1337,23 +1357,20 @@ class CourseBuilder
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @param int $session_id
|
|
|
|
- * @param string $course_code
|
|
|
|
- * @param bool $with_base_content
|
|
|
|
- * @param array $id_list
|
|
|
|
|
|
+ * @param int $session_id Internal session ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param bool $with_base_content Whether to include content from the course without session or not
|
|
|
|
+ * @param array $id_list If you want to restrict the structure to only the given IDs
|
|
*/
|
|
*/
|
|
public function build_wiki(
|
|
public function build_wiki(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = '',
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$id_list = array()
|
|
) {
|
|
) {
|
|
- $course_info = api_get_course_info($course_code);
|
|
|
|
$tbl_wiki = Database::get_course_table(TABLE_WIKI);
|
|
$tbl_wiki = Database::get_course_table(TABLE_WIKI);
|
|
|
|
|
|
- $course_id = $course_info['real_id'];
|
|
|
|
-
|
|
|
|
- if (!empty($session_id) && !empty($course_code)) {
|
|
|
|
|
|
+ if (!empty($session_id) && !empty($course_id)) {
|
|
$session_id = intval($session_id);
|
|
$session_id = intval($session_id);
|
|
if ($with_base_content) {
|
|
if ($with_base_content) {
|
|
$session_condition = api_get_session_condition(
|
|
$session_condition = api_get_session_condition(
|
|
@@ -1392,18 +1409,20 @@ class CourseBuilder
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build the Surveys
|
|
* Build the Surveys
|
|
|
|
+ * @param int $session_id Internal session ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param bool $with_base_content Whether to include content from the course without session or not
|
|
|
|
+ * @param array $id_list If you want to restrict the structure to only the given IDs
|
|
*/
|
|
*/
|
|
public function build_thematic(
|
|
public function build_thematic(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = '',
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$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);
|
|
|
|
|
|
+ $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);
|
|
|
|
|
|
$session_id = intval($session_id);
|
|
$session_id = intval($session_id);
|
|
if ($with_base_content) {
|
|
if ($with_base_content) {
|
|
@@ -1416,8 +1435,6 @@ class CourseBuilder
|
|
$session_condition = api_get_session_condition($session_id, true);
|
|
$session_condition = api_get_session_condition($session_id, true);
|
|
}
|
|
}
|
|
|
|
|
|
- $course_id = api_get_course_int_id();
|
|
|
|
-
|
|
|
|
$sql = "SELECT * FROM $table_thematic WHERE c_id = $course_id $session_condition ";
|
|
$sql = "SELECT * FROM $table_thematic WHERE c_id = $course_id $session_condition ";
|
|
$db_result = Database::query($sql);
|
|
$db_result = Database::query($sql);
|
|
while ($row = Database::fetch_array($db_result, 'ASSOC')) {
|
|
while ($row = Database::fetch_array($db_result, 'ASSOC')) {
|
|
@@ -1467,25 +1484,21 @@ class CourseBuilder
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build the attendances
|
|
* Build the attendances
|
|
|
|
+ * @param int $session_id Internal session ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param bool $with_base_content Whether to include content from the course without session or not
|
|
|
|
+ * @param array $id_list If you want to restrict the structure to only the given IDs
|
|
*/
|
|
*/
|
|
public function build_attendance(
|
|
public function build_attendance(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = '',
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$id_list = array()
|
|
) {
|
|
) {
|
|
- $table_attendance = Database:: get_course_table(TABLE_ATTENDANCE);
|
|
|
|
- $table_attendance_calendar = Database:: get_course_table(
|
|
|
|
- TABLE_ATTENDANCE_CALENDAR
|
|
|
|
- );
|
|
|
|
|
|
+ $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
|
|
|
|
+ $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR);
|
|
|
|
|
|
- $course_id = api_get_course_int_id();
|
|
|
|
-
|
|
|
|
- $sessionCondition = api_get_session_condition(
|
|
|
|
- $session_id,
|
|
|
|
- true,
|
|
|
|
- $with_base_content
|
|
|
|
- );
|
|
|
|
|
|
+ $sessionCondition = api_get_session_condition($session_id, true, $with_base_content);
|
|
|
|
|
|
$sql = 'SELECT * FROM '.$table_attendance.'
|
|
$sql = 'SELECT * FROM '.$table_attendance.'
|
|
WHERE c_id = '.$course_id.' '.$sessionCondition;
|
|
WHERE c_id = '.$course_id.' '.$sessionCondition;
|
|
@@ -1505,20 +1518,18 @@ class CourseBuilder
|
|
|
|
|
|
/**
|
|
/**
|
|
* Build the works (or "student publications", or "assignments")
|
|
* Build the works (or "student publications", or "assignments")
|
|
- *
|
|
|
|
- * @param int $session_id
|
|
|
|
- * @param string $course_code
|
|
|
|
- * @param bool $with_base_content
|
|
|
|
- * @param array $id_list
|
|
|
|
|
|
+ * @param int $session_id Internal session ID
|
|
|
|
+ * @param int $course_id Internal course ID
|
|
|
|
+ * @param bool $with_base_content Whether to include content from the course without session or not
|
|
|
|
+ * @param array $id_list If you want to restrict the structure to only the given IDs
|
|
*/
|
|
*/
|
|
public function build_works(
|
|
public function build_works(
|
|
$session_id = 0,
|
|
$session_id = 0,
|
|
- $course_code = '',
|
|
|
|
|
|
+ $course_id = 0,
|
|
$with_base_content = false,
|
|
$with_base_content = false,
|
|
$id_list = array()
|
|
$id_list = array()
|
|
) {
|
|
) {
|
|
$table_work = Database:: get_course_table(TABLE_STUDENT_PUBLICATION);
|
|
$table_work = Database:: get_course_table(TABLE_STUDENT_PUBLICATION);
|
|
- $course_id = api_get_course_int_id();
|
|
|
|
$sessionCondition = api_get_session_condition(
|
|
$sessionCondition = api_get_session_condition(
|
|
$session_id,
|
|
$session_id,
|
|
true,
|
|
true,
|