|
|
|
@ -360,12 +360,14 @@ class CourseBuilder |
|
|
|
|
$with_base_content |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$sql = "SELECT * FROM $table WHERE c_id = $courseId $sessionCondition ORDER BY cat_title"; |
|
|
|
|
$sql = "SELECT * FROM $table |
|
|
|
|
WHERE c_id = $courseId $sessionCondition |
|
|
|
|
ORDER BY cat_title"; |
|
|
|
|
|
|
|
|
|
$db_result = Database::query($sql); |
|
|
|
|
while ($obj = Database::fetch_object($db_result)) { |
|
|
|
|
$forum_category = new ForumCategory($obj); |
|
|
|
|
$this->course->add_resource($forum_category); |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
while ($obj = Database::fetch_object($result)) { |
|
|
|
|
$forumCategory = new ForumCategory($obj); |
|
|
|
|
$this->course->add_resource($forumCategory); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -553,7 +555,8 @@ class CourseBuilder |
|
|
|
|
{ |
|
|
|
|
$link_cat_table = Database :: get_course_table(TABLE_LINK_CATEGORY); |
|
|
|
|
|
|
|
|
|
$sql = "SELECT * FROM $link_cat_table WHERE c_id = $courseId AND id = $id"; |
|
|
|
|
$sql = "SELECT * FROM $link_cat_table |
|
|
|
|
WHERE c_id = $courseId AND id = $id"; |
|
|
|
|
$db_result = Database::query($sql); |
|
|
|
|
while ($obj = Database::fetch_object($db_result)) { |
|
|
|
|
$link_category = new LinkCategory( |
|
|
|
@ -601,24 +604,28 @@ class CourseBuilder |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
$sql = "SELECT * FROM $table_qui WHERE c_id = $courseId AND active >=0 $session_condition"; |
|
|
|
|
$sql = "SELECT * FROM $table_qui |
|
|
|
|
WHERE c_id = $courseId 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 = $courseId AND active >=0 AND session_id = 0"; |
|
|
|
|
$sql = "SELECT * FROM $table_qui |
|
|
|
|
WHERE c_id = $courseId 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); |
|
|
|
|
while ($obj = Database::fetch_object($db_result)) { |
|
|
|
|
if (strlen($obj->sound) > 0) { |
|
|
|
|
$sql = "SELECT id FROM $table_doc WHERE c_id = $courseId AND path = '/audio/".$obj->sound."'"; |
|
|
|
|
$sql = "SELECT id FROM $table_doc |
|
|
|
|
WHERE c_id = $courseId AND path = '/audio/".$obj->sound."'"; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
$doc = Database::fetch_object($res); |
|
|
|
|
$obj->sound = $doc->id; |
|
|
|
|
} |
|
|
|
|
$quiz = new Quiz($obj); |
|
|
|
|
|
|
|
|
|
$sql = 'SELECT * FROM '.$table_rel.' WHERE c_id = '.$courseId.' AND exercice_id = '.$obj->id; |
|
|
|
|
$sql = 'SELECT * FROM '.$table_rel.' |
|
|
|
|
WHERE c_id = '.$courseId.' AND exercice_id = '.$obj->id; |
|
|
|
|
$db_result2 = Database::query($sql); |
|
|
|
|
while ($obj2 = Database::fetch_object($db_result2)) { |
|
|
|
|
$quiz->add_question($obj2->question_id, $obj2->question_order); |
|
|
|
@ -645,7 +652,8 @@ class CourseBuilder |
|
|
|
|
$table_ans = Database :: get_course_table(TABLE_QUIZ_ANSWER); |
|
|
|
|
|
|
|
|
|
// Building normal tests. |
|
|
|
|
$sql = "SELECT * FROM $table_que WHERE c_id = $courseId "; |
|
|
|
|
$sql = "SELECT * FROM $table_que |
|
|
|
|
WHERE c_id = $courseId "; |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
|
|
|
|
|
while ($obj = Database::fetch_object($result)) { |
|
|
|
@ -690,7 +698,8 @@ class CourseBuilder |
|
|
|
|
$table_options = Database::get_course_table( |
|
|
|
|
TABLE_QUIZ_QUESTION_OPTION |
|
|
|
|
); |
|
|
|
|
$sql = 'SELECT * FROM '.$table_options.' WHERE c_id = '.$courseId.' AND question_id = '.$obj->id; |
|
|
|
|
$sql = 'SELECT * FROM '.$table_options.' |
|
|
|
|
WHERE c_id = '.$courseId.' AND question_id = '.$obj->id; |
|
|
|
|
$db_result3 = Database::query($sql); |
|
|
|
|
while ($obj3 = Database::fetch_object($db_result3)) { |
|
|
|
|
$question_option = new QuizQuestionOption($obj3); |
|
|
|
@ -762,7 +771,8 @@ class CourseBuilder |
|
|
|
|
$obj->extra, |
|
|
|
|
$question_category_id |
|
|
|
|
); |
|
|
|
|
$sql = "SELECT * FROM $table_ans WHERE c_id = $courseId AND question_id = ".$obj->id; |
|
|
|
|
$sql = "SELECT * FROM $table_ans |
|
|
|
|
WHERE c_id = $courseId AND question_id = ".$obj->id; |
|
|
|
|
$db_result2 = Database::query($sql); |
|
|
|
|
if (Database::num_rows($db_result2)) { |
|
|
|
|
while ($obj2 = Database::fetch_object($db_result2)) { |
|
|
|
@ -819,11 +829,12 @@ class CourseBuilder |
|
|
|
|
ON questions.id=quizz_questions.question_id |
|
|
|
|
LEFT JOIN '.$table_qui.' as exercises |
|
|
|
|
ON quizz_questions.exercice_id = exercises.id |
|
|
|
|
WHERE questions.c_id = quizz_questions.c_id AND |
|
|
|
|
questions.c_id = exercises.c_id AND |
|
|
|
|
exercises.c_id = '.$courseId.' AND |
|
|
|
|
(quizz_questions.exercice_id IS NULL OR |
|
|
|
|
exercises.active = -1)'; |
|
|
|
|
WHERE |
|
|
|
|
questions.c_id = quizz_questions.c_id AND |
|
|
|
|
questions.c_id = exercises.c_id AND |
|
|
|
|
exercises.c_id = '.$courseId.' AND |
|
|
|
|
(quizz_questions.exercice_id IS NULL OR |
|
|
|
|
exercises.active = -1)'; |
|
|
|
|
$db_result = Database::query($sql); |
|
|
|
|
if (Database::num_rows($db_result) > 0) { |
|
|
|
|
// This is the fictional test for collecting orphan questions. |
|
|
|
@ -933,7 +944,8 @@ class CourseBuilder |
|
|
|
|
$obj->creation_date, $obj->invited, $obj->answered, |
|
|
|
|
$obj->invite_mail, $obj->reminder_mail |
|
|
|
|
); |
|
|
|
|
$sql = 'SELECT * FROM '.$table_question.' WHERE c_id = '.$courseId.' AND survey_id = '.$obj->survey_id; |
|
|
|
|
$sql = 'SELECT * FROM '.$table_question.' |
|
|
|
|
WHERE c_id = '.$courseId.' AND survey_id = '.$obj->survey_id; |
|
|
|
|
$db_result2 = Database::query($sql); |
|
|
|
|
while ($obj2 = Database::fetch_object($db_result2)) { |
|
|
|
|
$survey->add_question($obj2->question_id); |
|
|
|
@ -965,7 +977,8 @@ class CourseBuilder |
|
|
|
|
$obj->shared_question_id, |
|
|
|
|
$obj->max_value |
|
|
|
|
); |
|
|
|
|
$sql = 'SELECT * FROM '.$table_opt.' WHERE c_id = '.$courseId.' AND question_id = '.$obj->question_id; |
|
|
|
|
$sql = 'SELECT * FROM '.$table_opt.' |
|
|
|
|
WHERE c_id = '.$courseId.' AND question_id = '.$obj->question_id; |
|
|
|
|
$db_result2 = Database::query($sql); |
|
|
|
|
while ($obj2 = Database::fetch_object($db_result2)) { |
|
|
|
|
$question->add_answer($obj2->option_text, $obj2->sort); |
|
|
|
@ -995,13 +1008,16 @@ class CourseBuilder |
|
|
|
|
$with_base_content |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$sql = 'SELECT * FROM '.$table.' WHERE c_id = '.$courseId.' '.$sessionCondition; |
|
|
|
|
$sql = 'SELECT * FROM '.$table.' |
|
|
|
|
WHERE c_id = '.$courseId.' '.$sessionCondition; |
|
|
|
|
$db_result = Database::query($sql); |
|
|
|
|
$table_attachment = Database:: get_course_table( |
|
|
|
|
TABLE_ANNOUNCEMENT_ATTACHMENT |
|
|
|
|
); |
|
|
|
|
while ($obj = Database::fetch_object($db_result)) { |
|
|
|
|
|
|
|
|
|
if (empty($obj->id)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
$sql = 'SELECT path, comment, filename, size |
|
|
|
|
FROM '.$table_attachment.' |
|
|
|
|
WHERE c_id = '.$courseId.' AND announcement_id = '.$obj->id.''; |
|
|
|
@ -1053,13 +1069,16 @@ class CourseBuilder |
|
|
|
|
$with_base_content |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$sql = 'SELECT * FROM '.$table.' WHERE c_id = '.$courseId.' '.$sessionCondition; |
|
|
|
|
$sql = 'SELECT * FROM '.$table.' |
|
|
|
|
WHERE c_id = '.$courseId.' '.$sessionCondition; |
|
|
|
|
$db_result = Database::query($sql); |
|
|
|
|
while ($obj = Database::fetch_object($db_result)) { |
|
|
|
|
$table_attachment = Database:: get_course_table( |
|
|
|
|
TABLE_AGENDA_ATTACHMENT |
|
|
|
|
); |
|
|
|
|
$sql = 'SELECT path, comment, filename, size FROM '.$table_attachment.' WHERE c_id = '.$courseId.' AND agenda_id = '.$obj->id.''; |
|
|
|
|
$sql = 'SELECT path, comment, filename, size |
|
|
|
|
FROM '.$table_attachment.' |
|
|
|
|
WHERE c_id = '.$courseId.' AND agenda_id = '.$obj->id.''; |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
|
|
|
|
|
$attachment_obj = Database::fetch_object($result); |
|
|
|
@ -1115,10 +1134,12 @@ class CourseBuilder |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
$sql = 'SELECT * FROM '.$table.' WHERE c_id = '.$courseId.' '.$session_condition; |
|
|
|
|
$sql = 'SELECT * FROM '.$table.' |
|
|
|
|
WHERE c_id = '.$courseId.' '.$session_condition; |
|
|
|
|
} else { |
|
|
|
|
$table = Database:: get_course_table(TABLE_COURSE_DESCRIPTION); |
|
|
|
|
$sql = 'SELECT * FROM '.$table.' WHERE c_id = '.$courseId.' AND session_id = 0'; |
|
|
|
|
$sql = 'SELECT * FROM '.$table.' |
|
|
|
|
WHERE c_id = '.$courseId.' AND session_id = 0'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$db_result = Database::query($sql); |
|
|
|
@ -1164,9 +1185,11 @@ class CourseBuilder |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
$sql = 'SELECT * FROM '.$table_main.' WHERE c_id = '.$courseId.' '.$session_condition; |
|
|
|
|
$sql = 'SELECT * FROM '.$table_main.' |
|
|
|
|
WHERE c_id = '.$courseId.' '.$session_condition; |
|
|
|
|
} else { |
|
|
|
|
$sql = 'SELECT * FROM '.$table_main.' WHERE c_id = '.$courseId.' AND session_id = 0'; |
|
|
|
|
$sql = 'SELECT * FROM '.$table_main.' |
|
|
|
|
WHERE c_id = '.$courseId.' AND session_id = 0'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($id_list)) { |
|
|
|
@ -1301,9 +1324,11 @@ class CourseBuilder |
|
|
|
|
$table_glossary = Database:: get_course_table(TABLE_GLOSSARY); |
|
|
|
|
//@todo check this queries are the same ... ayayay |
|
|
|
|
if (!empty($this->course->type) && $this->course->type == 'partial') { |
|
|
|
|
$sql = 'SELECT * FROM '.$table_glossary.' g WHERE g.c_id = '.$courseId.' AND session_id = 0'; |
|
|
|
|
$sql = 'SELECT * FROM '.$table_glossary.' g |
|
|
|
|
WHERE g.c_id = '.$courseId.' AND session_id = 0'; |
|
|
|
|
} else { |
|
|
|
|
$sql = 'SELECT * FROM '.$table_glossary.' g WHERE g.c_id = '.$courseId.' AND session_id = 0'; |
|
|
|
|
$sql = 'SELECT * FROM '.$table_glossary.' g |
|
|
|
|
WHERE g.c_id = '.$courseId.' AND session_id = 0'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$db_result = Database::query($sql); |
|
|
|
@ -1333,14 +1358,9 @@ class CourseBuilder |
|
|
|
|
$this->course = new Course(); |
|
|
|
|
$this->course->code = $_course['code']; |
|
|
|
|
$this->course->type = 'partial'; |
|
|
|
|
$this->course->path = api_get_path( |
|
|
|
|
SYS_COURSE_PATH |
|
|
|
|
).$_course['directory'].'/'; |
|
|
|
|
$this->course->backup_path = api_get_path( |
|
|
|
|
SYS_COURSE_PATH |
|
|
|
|
).$_course['directory']; |
|
|
|
|
$this->course->encoding = api_get_system_encoding( |
|
|
|
|
); //current platform encoding |
|
|
|
|
$this->course->path = api_get_path(SYS_COURSE_PATH).$_course['directory'].'/'; |
|
|
|
|
$this->course->backup_path = api_get_path(SYS_COURSE_PATH).$_course['directory']; |
|
|
|
|
$this->course->encoding = api_get_system_encoding(); //current platform encoding |
|
|
|
|
$code_course = $_course['code']; |
|
|
|
|
$courseId = $_course['real_id']; |
|
|
|
|
$sql_session = "SELECT s.id, name, c_id |
|
|
|
@ -1390,10 +1410,12 @@ class CourseBuilder |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
$sql = 'SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$courseId.' '.$session_condition; |
|
|
|
|
$sql = 'SELECT * FROM '.$tbl_wiki.' |
|
|
|
|
WHERE c_id = '.$courseId.' '.$session_condition; |
|
|
|
|
} else { |
|
|
|
|
$tbl_wiki = Database::get_course_table(TABLE_WIKI); |
|
|
|
|
$sql = 'SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$courseId.' AND session_id = 0'; |
|
|
|
|
$sql = 'SELECT * FROM '.$tbl_wiki.' |
|
|
|
|
WHERE c_id = '.$courseId.' AND session_id = 0'; |
|
|
|
|
} |
|
|
|
|
$db_result = Database::query($sql); |
|
|
|
|
while ($obj = Database::fetch_object($db_result)) { |
|
|
|
@ -1426,9 +1448,9 @@ class CourseBuilder |
|
|
|
|
$with_base_content = false, |
|
|
|
|
$id_list = array() |
|
|
|
|
) { |
|
|
|
|
$table_thematic = Database :: get_course_table(TABLE_THEMATIC); |
|
|
|
|
$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_plan = Database :: get_course_table(TABLE_THEMATIC_PLAN); |
|
|
|
|
|
|
|
|
|
$session_id = intval($session_id); |
|
|
|
|
if ($with_base_content) { |
|
|
|
@ -1441,11 +1463,13 @@ class CourseBuilder |
|
|
|
|
$session_condition = api_get_session_condition($session_id, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$sql = "SELECT * FROM $table_thematic WHERE c_id = $courseId $session_condition "; |
|
|
|
|
$sql = "SELECT * FROM $table_thematic |
|
|
|
|
WHERE c_id = $courseId $session_condition "; |
|
|
|
|
$db_result = Database::query($sql); |
|
|
|
|
while ($row = Database::fetch_array($db_result, 'ASSOC')) { |
|
|
|
|
$thematic = new Thematic($row); |
|
|
|
|
$sql = 'SELECT * FROM '.$table_thematic_advance.' WHERE c_id = '.$courseId.' AND thematic_id = '.$row['id']; |
|
|
|
|
$sql = 'SELECT * FROM '.$table_thematic_advance.' |
|
|
|
|
WHERE c_id = '.$courseId.' AND thematic_id = '.$row['id']; |
|
|
|
|
|
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
while ($sub_row = Database::fetch_array($result, 'ASSOC')) { |
|
|
|
@ -1457,7 +1481,6 @@ class CourseBuilder |
|
|
|
|
api_get_course_id(), |
|
|
|
|
$session_id |
|
|
|
|
); |
|
|
|
|
//$items_from_session = api_get_item_property_by_tool('thematic_plan', api_get_course_id(), api_get_session_id()); |
|
|
|
|
|
|
|
|
|
$thematic_plan_id_list = array(); |
|
|
|
|
if (!empty($items)) { |
|
|
|
@ -1501,7 +1524,7 @@ class CourseBuilder |
|
|
|
|
$with_base_content = false, |
|
|
|
|
$id_list = array() |
|
|
|
|
) { |
|
|
|
|
$table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
|
|
|
$table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
|
|
|
$table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
|
|
|
|
|
|
|
|
$sessionCondition = api_get_session_condition($session_id, true, $with_base_content); |
|
|
|
|