* @return int The id of this resource in the source course.
*/
function get_id() {
return $this->source_id;
}
/**
* Resturns the type of this resource
* @return constant The type.
*/
function get_type() {
return $this->type;
}
/**
* Get the constant which defines the tool of this resource. This is
* used in the item_properties table.
* @param bool $for_item_property_table (optional) Added by Ivan, 29-AUG-2009: A parameter for resolving differencies between defined TOOL_* constants and hardcoded strings that are stored in the database.
* Example: The constant TOOL_THREAD is defined in the main_api.lib.php with the value 'thread', but the "Forums" tool records in the field 'tool' in the item property table the hardcoded value 'forum_thread'.
* @todo once the RESOURCE_* constants are replaced by the globally
* defined TOOL_* constants, this function will be replaced by get_type()
*/
function get_tool($for_item_property_table = true) {
switch ($this->get_type()) {
case RESOURCE_DOCUMENT:
return TOOL_DOCUMENT;
case RESOURCE_LINK:
return TOOL_LINK;
case RESOURCE_EVENT:
return TOOL_CALENDAR_EVENT;
case RESOURCE_COURSEDESCRIPTION:
return TOOL_COURSE_DESCRIPTION;
case RESOURCE_LEARNPATH:
return TOOL_LEARNPATH;
case RESOURCE_ANNOUNCEMENT:
return TOOL_ANNOUNCEMENT;
case RESOURCE_FORUMCATEGORY:
return 'forum_category'; // Ivan, 29-AUG-2009: A constant like TOOL_FORUM_CATEGORY is missing in main_api.lib.php. Such a constant has been defined in the forum tool for local needs.
case RESOURCE_FORUM:
return TOOL_FORUM;
case RESOURCE_FORUMTOPIC:
if ($for_item_property_table) {
return 'forum_thread'; // Ivan, 29-AUG-2009: A hardcoded value that the "Forums" tool stores in the item property table.
}
return TOOL_THREAD;
case RESOURCE_FORUMPOST:
return TOOL_POST;
case RESOURCE_QUIZ:
return TOOL_QUIZ;
//case RESOURCE_QUIZQUESTION: //no corresponding global constant