Source for file CourseBuilder.class.php
Documentation is available at CourseBuilder.class.php
<?php // $Id: CourseBuilder.class.php 13309 2007-09-27 07:29:58Z yannoo $
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004 Dokeos S.A.
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) Bart Mollet (bart.mollet@hogent.be)
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
==============================================================================
require_once ('Course.class.php');
require_once ('Event.class.php');
require_once ('Link.class.php');
require_once ('ToolIntro.class.php');
require_once ('Document.class.php');
require_once ('ScormDocument.class.php');
require_once ('LinkCategory.class.php');
require_once ('CourseDescription.class.php');
require_once ('ForumPost.class.php');
require_once ('ForumTopic.class.php');
require_once ('Forum.class.php');
require_once ('ForumCategory.class.php');
require_once ('Quiz.class.php');
require_once ('QuizQuestion.class.php');
require_once ('Learnpath.class.php');
require_once ('Survey.class.php');
require_once ('SurveyQuestion.class.php');
* Class which can build a course-object from a Dokeos-course.
* @author Bart Mollet <bart.mollet@hogent.be>
* Create a new CourseBuilder
$this->course->code = $_course['official_code'];
* @return course The course
* Build the course-object
//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. " WHERE source_type = '". $resource->get_type(). "' AND source_id = '". $resource->get_id(). "'";
$this->course->resources[$type][$id]->add_linked_resource($link->resource_type, $link->resource_id);
foreach ($this->course->resources as $type => $resources)
foreach ($resources as $id => $resource)
$tool = $resource->get_tool();
$sql = "SELECT * FROM $table WHERE TOOL = '". $tool. "' AND ref='". $resource->get_id(). "'";
$all_properties = array ();
$all_properties[] = $item_property;
$this->course->resources[$type][$id]->item_properties = $all_properties;
$sql = 'SELECT * FROM '. $table_doc. ' d, '. $table_prop. ' p WHERE tool = \''. TOOL_DOCUMENT. '\' AND p.ref = d.id AND p.visibility != 2 ORDER BY path';
$doc = new Document($obj->id, $obj->path, $obj->comment, $obj->title, $obj->filetype, $obj->size);
$this->course->add_resource($doc);
$sql = 'SELECT * FROM '. $table;
$forum = new Forum($obj->forum_id, $obj->forum_name, $obj->forum_description, $obj->cat_id, $obj->forum_last_post_id);
$this->course->add_resource($forum);
$sql = 'SELECT * FROM '. $table. ' WHERE cat_id = '. $id;
$forum_category = new ForumCategory($obj->cat_id, $obj->cat_title);
$this->course->add_resource($forum_category);
$sql = 'SELECT * FROM '. $table;
$forum_topic = new ForumTopic($obj->topic_id, $obj->topic_title, $obj->topic_time, $obj->prenom, $obj->nom, $obj->topic_notify, $obj->forum_id, $obj->topic_last_post_id);
$this->course->add_resource($forum_topic);
$sql = 'SELECT * FROM '. $table_post. ' p,'. $table_posttext. ' pt WHERE p.post_id = pt.post_id';
$forum_post = new ForumPost($obj->post_id, $obj->post_title, $obj->post_text, $obj->post_time, $obj->poster_ip, $obj->prenom, $obj->nom, $obj->topic_notify, $obj->parent_id, $obj->topic_id);
$this->course->add_resource($forum_post);
$sql = "SELECT * FROM $table l, $table_prop p WHERE p.ref=l.id AND p.tool = '". TOOL_LINK. "' AND p.visibility != 2 ORDER BY l.display_order";
$link = new Link($obj->id, $obj->title, $obj->url, $obj->description, $obj->category_id, $obj->on_homepage);
$this->course->add_resource($link);
$sql = 'SELECT * FROM '. $table;
$tool_intro = new ToolIntro($obj->id, $obj->intro_text);
$this->course->add_resource($tool_intro);
$sql = 'SELECT * FROM '. $link_cat_table. ' WHERE id = '. $id;
$link_category = new LinkCategory($obj->id, $obj->category_title, $obj->description, $obj->display_order);
$this->course->add_resource($link_category);
$sql = 'SELECT * FROM '. $table_qui. ' WHERE active >=0'; //select only quizzes with active = 0 or 1 (not -1 which is for deleted quizzes)
$quiz = new Quiz($obj->id, $obj->title, $obj->description, $obj->random, $obj->type, $obj->active, $obj->sound);
$sql = 'SELECT * FROM '. $table_rel. ' WHERE exercice_id = '. $obj->id;
$quiz->add_question($obj2->question_id);
$this->course->add_resource($quiz);
* Build the Quiz-Questions
$sql = 'SELECT * FROM '. $table_que;
$question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture);
$sql = 'SELECT * FROM '. $table_ans. ' WHERE question_id = '. $obj->id;
$question->add_answer($obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type);
$this->course->add_resource($question);
$sql = 'SELECT * FROM '. $table_survey;
$survey = new Survey($obj->survey_id, $obj->code,$obj->title,
$obj->subtitle, $obj->author, $obj->lang,
$obj->avail_from, $obj->avail_till, $obj->is_shared,
$obj->template, $obj->intro, $obj->surveythanks,
$obj->creation_date, $obj->invited, $obj->answered,
$obj->invite_mail, $obj->reminder_mail);
$sql = 'SELECT * FROM '. $table_question. ' WHERE survey_id = '. $obj->survey_id;
$survey->add_question($obj2->question_id);
$this->course->add_resource($survey);
* Build the Survey Questions
$sql = 'SELECT * FROM '. $table_que;
$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 question_id = '. "'". $obj->question_id. "'";
$question->add_answer($obj2->option_text, $obj2->sort);
$this->course->add_resource($question);
* Build the announcements
$sql = 'SELECT * FROM '. $table;
$announcement = new Announcement($obj->id, $obj->title, $obj->content, $obj->end_date,$obj->display_order,$obj->email_sent);
$this->course->add_resource($announcement);
$sql = 'SELECT * FROM '. $table;
$event = new Event($obj->id, $obj->title, $obj->content, $obj->start_date, $obj->end_date);
$this->course->add_resource($event);
* Build the course-descriptions
$sql = 'SELECT * FROM '. $table;
$this->course->add_resource($cd);
$sql = 'SELECT * FROM '. $table_main;
$sql_items = "SELECT * FROM ". $table_item. " WHERE lp_id = ". $obj->id. "";
$item['id'] = $obj_item->id;
$item['item_type'] = $obj_item->item_type;
$item['ref'] = $obj_item->ref;
$item['title'] = $obj_item->title;
$item['description'] = $obj_item->description;
$item['path'] = $obj_item->path;
$item['min_score'] = $obj_item->min_score;
$item['max_score'] = $obj_item->max_score;
$item['mastery_score'] = $obj_item->mastery_score;
$item['parent_item_id'] = $obj_item->parent_item_id;
$item['previous_item_id'] = $obj_item->previous_item_id;
$item['next_item_id'] = $obj_item->next_item_id;
$item['display_order'] = $obj_item->display_order;
$item['prerequisite'] = $obj_item->prerequisite;
$item['parameters'] = $obj_item->parameters;
$item['launch_data'] = $obj_item->launch_data;
$sql_tool = "SELECT id FROM ". $table_tool. " WHERE (link LIKE '%lp_controller.php%lp_id=". $obj->id. "%' and image='scormbuilder.gif') AND visibility='1'";
$this->course->add_resource($lp);
//save scorm directory (previously build_scorm_documents())
$this->course->add_resource($doc);
|