-<?php // $Id$
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle 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 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * @package mod-resource
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/** Require {@link portfoliolib.php} */
require_once($CFG->libdir.'/portfoliolib.php');
+/** RESOURCE_LOCALPATH = LOCALPATH */
define('RESOURCE_LOCALPATH', 'LOCALPATH');
+/**
+ * @global array $RESOURCE_WINDOW_OPTIONS
+ * @name $RESOURCE_WINDOW_OPTIONS
+ */
global $RESOURCE_WINDOW_OPTIONS; // must be global because it might be included from a function!
$RESOURCE_WINDOW_OPTIONS = array('resizable', 'scrollbars', 'directories', 'location',
'menubar', 'toolbar', 'status', 'width', 'height');
}
/**
-* resource_base is the base class for resource types
-*
-* This class provides all the functionality for a resource
-*/
-
+ * resource_base is the base class for resource types
+ *
+ * This class provides all the functionality for a resource
+ * @package mod-resource
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class resource_base {
var $cm;
var $navlinks;
/**
- * Constructor for the base resource class
- *
- * Constructor for the base resource class.
- * If cmid is set create the cm, course, resource objects.
- * and do some checks to make sure people can be here, and so on.
- *
- * @param cmid integer, the current course module id - not set for new resources
- */
+ * Constructor for the base resource class
+ *
+ * Constructor for the base resource class.
+ * If cmid is set create the cm, course, resource objects.
+ * and do some checks to make sure people can be here, and so on.
+ *
+ * @global stdClass
+ * @global object
+ * @global object
+ * @uses CONTEXT_MODULE
+ * @param int $cmid the current course module id - not set for new resources
+ */
function resource_base($cmid=0) {
global $CFG, $COURSE, $DB;
/**
- * Display the resource with the course blocks.
- */
+ * Display the resource with the course blocks.
+ *
+ * @global stdClass
+ * @uses PAGE_COURSE_VIEW
+ * @uses PARAM_BOOL
+ * @uses BLOCK_POS_LEFT
+ * @uses BLOCK_POS_RIGHT
+ */
function display_course_blocks_start() {
global $CFG, $USER, $THEME;
/**
* Finish displaying the resource with the course blocks
+ *
+ * @global stdClass
+ * @global object
+ * @uses BLOCK_POS_LEFT
+ * @uses BLOCK_POS_RIGHT
*/
function display_course_blocks_end() {
global $CFG, $THEME;
}
-
+ /**
+ * Given an object containing all the necessary data,
+ * (defined by the form in mod_form.php) this function
+ * will create a new instance and return the id number
+ * of the new instance.
+ *
+ * @global object
+ * @param object $resource
+ * @return int|bool
+ */
function add_instance($resource) {
global $DB;
- // Given an object containing all the necessary data,
- // (defined by the form in mod_form.php) this function
- // will create a new instance and return the id number
- // of the new instance.
$resource->timemodified = time();
return $DB->insert_record("resource", $resource);
}
-
+ /**
+ * Given an object containing all the necessary data,
+ * (defined by the form in mod_form.php) this function
+ * will update an existing instance with new data.
+ *
+ * @global object
+ * @param object $resource
+ * @return bool
+ */
function update_instance($resource) {
global $DB;
- // Given an object containing all the necessary data,
- // (defined by the form in mod_form.php) this function
- // will update an existing instance with new data.
$resource->id = $resource->instance;
$resource->timemodified = time();
return $DB->update_record("resource", $resource);
}
-
+ /**
+ * Given an object containing the resource data
+ * this function will permanently delete the instance
+ * and any data that depends on it.
+ *
+ * @global object
+ * @param object $resource
+ * @return bool
+ */
function delete_instance($resource) {
global $DB;
- // Given an object containing the resource data
- // this function will permanently delete the instance
- // and any data that depends on it.
$result = true;
return $result;
}
+ /**
+ *
+ */
function setup_elements(&$mform) {
//override to add your own options
}
+ /**
+ *
+ */
function setup_preprocessing(&$default_values){
//override to add your own options
}
+ /**
+ * @todo penny implement later - see MDL-15758
+ */
function portfolio_prepare_package_uploaded($exporter) {
// @todo penny implement later - see MDL-15758
}
+ /**
+ * @uses FORMAT_MOODLE
+ * @uses FORMAT_HTML
+ * @param object $exporter
+ * @param bool $text
+ * @return int|bool
+ */
function portfolio_prepare_package_online($exporter, $text=false) {
$filename = clean_filename($this->cm->name . '.' . 'html');
$formatoptions = (object)array('noclean' => true);
return $exporter->write_new_file($content, $filename, false);
}
+ /**
+ * @param bool $text
+ * @uses FORMAT_MOODLE
+ * @uses FORMAT_HTML
+ * @return string
+ */
function portfolio_get_sha1_online($text=false) {
$formatoptions = (object)array('noclean' => true);
$format = (($text) ? FORMAT_MOODLE : FORMAT_HTML);
return sha1($content);
}
+ /**
+ * @todo penny implement later.
+ */
function portfolio_get_sha1_uploaded() {
// @todo penny implement later.
}
} /// end of class definition
-
+/**
+ * @global stdClass
+ * @uses PARAM_SAFEDIR
+ * @param object $resource
+ * @return int|bool
+ */
function resource_add_instance($resource) {
global $CFG;
return $res->add_instance($resource);
}
+/**
+ * @global stdClass
+ * @uses PARAM_SAFEDIR
+ * @param object $resource
+ * @return bool
+ */
function resource_update_instance($resource) {
global $CFG;
return $res->update_instance($resource);
}
+/**
+ * @global stdClass
+ * @global object
+ * @uses PARAM_SAFEDIR
+ * @param int $id
+ * @return bool
+ */
function resource_delete_instance($id) {
global $CFG, $DB;
return $res->delete_instance($resource);
}
-
+/**
+ *
+ * @global object
+ * @param object $course
+ * @param object $user
+ * @param object $mod
+ * @param object $resource
+ * @return object|null
+ */
function resource_user_outline($course, $user, $mod, $resource) {
global $DB;
return NULL;
}
-
+/**
+ * @global stdClass
+ * @global object
+ * @param object $course
+ * @param object $user
+ * @param object $mod
+ * @param object $resource
+ */
function resource_user_complete($course, $user, $mod, $resource) {
global $CFG, $DB;
}
}
+/**
+ * Returns the users with data in one resource
+ * (NONE, byt must exists on EVERY mod !!)
+ *
+ * @param int $resourceid
+ * @return bool false
+ */
function resource_get_participants($resourceid) {
-//Returns the users with data in one resource
-//(NONE, byt must exists on EVERY mod !!)
-
return false;
}
+/**
+ * Given a course_module object, this function returns any
+ * "extra" information that may be needed when printing
+ * this activity in a course listing.
+ *
+ * See {@link get_array_of_activities()} in course/lib.php
+ *
+ * @global stdClass
+ * @global object
+ * @param object $coursemodule
+ * @return object info
+ */
function resource_get_coursemodule_info($coursemodule) {
-/// Given a course_module object, this function returns any
-/// "extra" information that may be needed when printing
-/// this activity in a course listing.
-///
-/// See get_array_of_activities() in course/lib.php
-///
global $CFG, $DB;
$info = NULL;
return $info;
}
+/**
+ * @param string $text
+ * @param string $url
+ * @param string $tagtoparse
+ * @param string $keytoparse
+ * @param string $prefix
+ * @return string
+ */
function resource_redirect_tags($text, $url, $tagtoparse, $keytoparse,$prefix = "" ) {
$valid = 1;
if ( strpos($url,"?") == FALSE ) {
return $text;
}
+/**
+ * @param string $path
+ * @return bool
+ */
function resource_is_url($path) {
if (strpos($path, '://')) { // eg http:// https:// ftp:// etc
return true;
return false;
}
+/**
+ * @global stdClass
+ * @uses MOD_CLASS_RESOURCE
+ * @return array
+ */
function resource_get_types() {
global $CFG;
return $types;
}
+/**
+ * @return array
+ */
function resource_get_view_actions() {
return array('view','view all');
}
+/**
+ * @return array
+ */
function resource_get_post_actions() {
return array();
}
+/**
+ * @global stdClass
+ * @global object
+ * @param object $course
+ * @param string $wdir
+ * @param string $oldname
+ * @param string $name
+ */
function resource_renamefiles($course, $wdir, $oldname, $name) {
global $CFG, $DB;
}
}
+/**
+ * @global stdClass
+ * @global object
+ * @param object $course
+ * @param array $files
+ * @return bool
+ */
function resource_delete_warning($course, $files) {
global $CFG, $DB;
/**
* This function is used by the reset_course_userdata function in moodlelib.
+ *
* @param $data the data submitted from the reset course.
* @return array status array
*/
/**
* Returns all other caps used in module
+ *
+ * @return array
*/
function resource_get_extra_capabilities() {
return array('moodle/site:accessallgroups');
}
+/**
+ * @package mod-resource
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class resource_portfolio_caller extends portfolio_module_caller_base {
private $resource;
private $resourcefile;
+ /**
+ * @return array
+ */
public static function expected_callbackargs() {
return array(
'id' => true,
);
}
+ /**
+ * @global stdClass
+ * @global object
+ */
public function load_data() {
global $CFG, $DB;
if (!$this->cm = get_coursemodule_from_instance('resource', $this->id)) {
$this->supportedformats = array(self::type_to_format($this->cm->type));
}
+ /**
+ * @uses PORTFOLIO_FORMAT_FILE
+ * @uses PORTFOLIO_FORMAT_PLAINHTML
+ * @uses PORTFOLIO_FORMAT_TEXT
+ * @param string $type
+ * @return string
+ */
public static function type_to_format($type) {
// this is kind of yuk... but there's just not good enough OO here
$format = PORTFOLIO_FORMAT_FILE;
return $format;
}
+ /**
+ * @global stdClass
+ * @return void
+ */
public function __wakeup() {
global $CFG;
if (empty($CFG)) {
$this->resource = unserialize(serialize($this->resource));
}
+ /**
+ * @todo penny check filesize if the type is uploadey (not implemented yet)
+ * like this: return portfolio_expected_time_file($this->file); or whatever
+ *
+ * @return string
+ */
public function expected_time() {
- // @todo penny check filesize if the type is uploadey (not implemented yet)
- // like this: return portfolio_expected_time_file($this->file); // or whatever
return PORTFOLIO_TIME_LOW;
}
+ /**
+ *
+ */
public function prepare_package() {
return $this->resource->portfolio_prepare_package($this->exporter);
}
+ /**
+ * @uses CONTEXT_MODULE
+ * @return bool
+ */
public function check_permissions() {
return has_capability('mod/resource:exportresource', get_context_instance(CONTEXT_MODULE, $this->cm->id));
}
+ /**
+ * @uses CONTEXT_MODULE
+ * @param object $resource
+ * @param mixed $format
+ * @param bool $return
+ * @return mixed
+ */
public static function add_button($resource, $format=null, $return=false) {
if (!has_capability('mod/resource:exportresource', get_context_instance(CONTEXT_MODULE, $resource->cm->id))) {
return;
$button->render($format);
}
+ /**
+ * @return string
+ */
public function get_sha1() {
return $this->resource->portfolio_get_sha1();
}
+ /**
+ * @return string
+ */
public static function display_name() {
return get_string('modulename', 'resource');
}
}
/**
+ * @uses FEATURE_GROUPS
+ * @uses FEATURE_GROUPINGS
+ * @uses FEATURE_GROUPMEMBERSONLY
+ * @uses FEATURE_MOD_INTRO
+ * @uses FEATURE_COMPLETION_TRACKS_VIEWS
+ * @uses FEATURE_GRADE_HAS_GRADE
+ * @uses FEATURE_GRADE_OUTCOMES
* @param string $feature FEATURE_xx constant for requested feature
- * @return mixed True if module supports feature, null if doesn't know
+ * @return mixed True if module supports feature, false if not, null if doesn't know
*/
function resource_supports($feature) {
switch($feature) {
* level.
*
* @param string $type shortname (or directory name) of the resource type
+ * @return string
*/
function resource_get_name($type) {
$name = get_string("resourcetype$type", "resource_$type");
-<?php // $Id$
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle 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 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * @package mod-scorm
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/** SCORM_TYPE_LOCAL = local */
define('SCORM_TYPE_LOCAL', 'local');
+/** SCORM_TYPE_LOCALSYNC = localsync */
define('SCORM_TYPE_LOCALSYNC', 'localsync');
+/** SCORM_TYPE_EXTERNAL = external */
define('SCORM_TYPE_EXTERNAL', 'external');
+/** SCORM_TYPE_IMSREPOSITORY = imsrepository */
define('SCORM_TYPE_IMSREPOSITORY', 'imsrepository');
/**
-* Given an object containing all the necessary data,
-* (defined by the form in mod_form.php) this function
-* will create a new instance and return the id number
-* of the new instance.
-*
-* @param object $scorm Form data
-* @param object $mform
-* @return int new instance id
-*/
-
+ * Given an object containing all the necessary data,
+ * (defined by the form in mod_form.php) this function
+ * will create a new instance and return the id number
+ * of the new instance.
+ *
+ * @global stdClass
+ * @global object
+ * @uses CONTEXT_MODULE
+ * @uses SCORM_TYPE_LOCAL
+ * @uses SCORM_TYPE_LOCALSYNC
+ * @uses SCORM_TYPE_EXTERNAL
+ * @uses SCORM_TYPE_IMSREPOSITORY
+ * @param object $scorm Form data
+ * @param object $mform
+ * @return int new instance id
+ */
function scorm_add_instance($scorm, $mform=null) {
global $CFG, $DB;
}
/**
-* Given an object containing all the necessary data,
-* (defined by the form in mod_form.php) this function
-* will update an existing instance with new data.
-*
-* @param object $scorm Form data
-* @param object $mform
-* @return bool success
-*/
+ * Given an object containing all the necessary data,
+ * (defined by the form in mod_form.php) this function
+ * will update an existing instance with new data.
+ *
+ * @global stdClass
+ * @global object
+ * @uses CONTEXT_MODULE
+ * @uses SCORM_TYPE_LOCAL
+ * @uses SCORM_TYPE_LOCALSYNC
+ * @uses SCORM_TYPE_EXTERNAL
+ * @uses SCORM_TYPE_IMSREPOSITORY
+ * @param object $scorm Form data
+ * @param object $mform
+ * @return bool
+ */
function scorm_update_instance($scorm, $mform=null) {
global $CFG, $DB;
}
/**
-* Given an ID of an instance of this module,
-* this function will permanently delete the instance
-* and any data that depends on it.
-*
-* @param int $id Scorm instance id
-* @return boolean
-*/
+ * Given an ID of an instance of this module,
+ * this function will permanently delete the instance
+ * and any data that depends on it.
+ *
+ * @global stdClass
+ * @global object
+ * @param int $id Scorm instance id
+ * @return boolean
+ */
function scorm_delete_instance($id) {
global $CFG, $DB;
}
/**
-* Return a small object with summary information about what a
-* user has done with a given particular instance of this module
-* Used for user activity reports.
-*
-* @param int $course Course id
-* @param int $user User id
-* @param int $mod
-* @param int $scorm The scorm id
-* @return mixed
-*/
+ * Return a small object with summary information about what a
+ * user has done with a given particular instance of this module
+ * Used for user activity reports.
+ *
+ * @global stdClass
+ * @param int $course Course id
+ * @param int $user User id
+ * @param int $mod
+ * @param int $scorm The scorm id
+ * @return mixed
+ */
function scorm_user_outline($course, $user, $mod, $scorm) {
global $CFG;
require_once('locallib.php');
}
/**
-* Print a detailed representation of what a user has done with
-* a given particular instance of this module, for user activity reports.
-*
-* @param int $course Course id
-* @param int $user User id
-* @param int $mod
-* @param int $scorm The scorm id
-* @return boolean
-*/
+ * Print a detailed representation of what a user has done with
+ * a given particular instance of this module, for user activity reports.
+ *
+ * @global stdClass
+ * @global object
+ * @param object $course
+ * @param object $user
+ * @param object $mod
+ * @param object $scorm
+ * @return boolean
+ */
function scorm_user_complete($course, $user, $mod, $scorm) {
global $CFG, $DB;
}
/**
-* Function to be run periodically according to the moodle cron
-* This function searches for things that need to be done, such
-* as sending out mail, toggling flags etc ...
-*
-* @return boolean
-*/
+ * Function to be run periodically according to the moodle cron
+ * This function searches for things that need to be done, such
+ * as sending out mail, toggling flags etc ...
+ *
+ * @global stdClass
+ * @global object
+ * @return boolean
+ */
function scorm_cron () {
global $CFG, $DB;
/**
* Return grade for given user or all users.
*
+ * @global stdClass
+ * @global object
* @param int $scormid id of scorm
* @param int $userid optional user id, 0 means all users
* @return array array of grades, false if none
/**
* Update grades in central gradebook
*
+ * @global stdClass
+ * @global object
* @param object $scorm
* @param int $userid specific user only, 0 mean all
+ * @param bool $nullifnone
*/
function scorm_update_grades($scorm, $userid=0, $nullifnone=true) {
global $CFG, $DB;
/**
* Update all grades in gradebook.
+ *
+ * @global object
*/
function scorm_upgrade_grades() {
global $DB;
/**
* Update/create grade item for given scorm
*
+ * @global stdClass
+ * @global object
+ * @uses GRADE_TYPE_VALUE
+ * @uses GRADE_TYPE_NONE
* @param object $scorm object with extra cmidnumber
- * @param mixed optional array/object of grade(s); 'reset' means reset grades in gradebook
+ * @param mixed $grades optional array/object of grade(s); 'reset' means reset grades in gradebook
* @return object grade_item
*/
function scorm_grade_item_update($scorm, $grades=NULL) {
/**
* Delete grade item for given scorm
*
+ * @global stdClass
* @param object $scorm object
* @return object grade_item
*/
return grade_update('mod/scorm', $scorm->course, 'mod', 'scorm', $scorm->id, 0, NULL, array('deleted'=>1));
}
+/**
+ * @return array
+ */
function scorm_get_view_actions() {
return array('pre-view','view','view all','report');
}
+/**
+ * @return array
+ */
function scorm_get_post_actions() {
return array();
}
+/**
+ * @param object $scorm
+ * @return object $scorm
+ */
function scorm_option2text($scorm) {
$scorm_popoup_options = scorm_get_popup_options_array();
/**
* Implementation of the function for printing the form elements that control
* whether the course reset functionality affects the scorm.
- * @param $mform form passed by reference
+ *
+ * @param object $mform form passed by reference
*/
function scorm_reset_course_form_definition(&$mform) {
$mform->addElement('header', 'scormheader', get_string('modulenameplural', 'scorm'));
/**
* Course reset form defaults.
+ *
+ * @return array
*/
function scorm_reset_course_form_defaults($course) {
return array('reset_scorm'=>1);
/**
* Removes all grades from gradebook
+ *
+ * @global stdClass
+ * @global object
* @param int $courseid
* @param string optional type
*/
/**
* Actual implementation of the rest coures functionality, delete all the
* scorm attempts for course $data->courseid.
- * @param $data the data submitted from the reset course.
+ *
+ * @global stdClass
+ * @global object
+ * @param object $data the data submitted from the reset course.
* @return array status array
*/
function scorm_reset_userdata($data) {
/**
* Returns all other caps used in module
+ *
+ * @return array
*/
function scorm_get_extra_capabilities() {
return array('moodle/site:accessallgroups');
/**
* Lists all file areas current user may browse
+ *
+ * @param object $course
+ * @param object $cm
+ * @param object $context
+ * @return array
*/
function scorm_get_file_areas($course, $cm, $context) {
$areas = array();
/**
* File browsing support
+ *
+ * @todo Document this function
*/
function scorm_get_file_info($browser, $areas, $course, $cm, $context, $filearea, $itemid, $filepath, $filename) {
global $CFG;
return null;
}
}
+ /**
+ * @package mod-scorm
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class scorm_package_file_info extends file_info_stored {
public function get_parent() {
if ($this->lf->get_filepath() === '/' and $this->lf->get_filename() === '.') {
/**
* Serves scorm content, introduction images and packages. Implements needed access control ;-)
+ *
+ * @global stdClass
+ * @param object $course
+ * @param object $cminfo
+ * @param object $context
+ * @param string $filearea
+ * @param array $args
+ * @return bool
*/
function scorm_pluginfile($course, $cminfo, $context, $filearea, $args) {
global $CFG;
}
/**
+ * @uses FEATURE_GROUPS
+ * @uses FEATURE_GROUPINGS
+ * @uses FEATURE_GROUPMEMBERSONLY
+ * @uses FEATURE_MOD_INTRO
+ * @uses FEATURE_COMPLETION_TRACKS_VIEWS
+ * @uses FEATURE_GRADE_HAS_GRADE
+ * @uses FEATURE_GRADE_OUTCOMES
* @param string $feature FEATURE_xx constant for requested feature
- * @return mixed True if module supports feature, null if doesn't know
+ * @return mixed True if module supports feature, false if not, null if doesn't know
*/
function scorm_supports($feature) {
switch($feature) {