Activity module handler get_moduleid() replaced with get_cminfo()

This commit is contained in:
David Mudrak 2011-05-24 15:24:21 +02:00
parent 6357693c8b
commit 8bcefb3254
4 changed files with 23 additions and 8 deletions

View File

@ -1094,18 +1094,30 @@ abstract class moodle1_plugin_handler extends moodle1_xml_handler {
abstract class moodle1_mod_handler extends moodle1_plugin_handler {
/**
* Returns course module id for the given instance id
* Returns the name of the module, eg. 'forum'
*
* The mapping from instance id to course module id has been stashed by
* @return string
*/
public function get_modname() {
return $this->pluginname;
}
/**
* Returns course module information for the given instance id
*
* The information for this instance id has been stashed by
* {@link moodle1_course_outline_handler::process_course_module()}
*
* @param int $instance the module instance id
* @param string $modname the module type, defaults to $this->pluginname
* @return int
*/
protected function get_moduleid($instance) {
protected function get_cminfo($instance, $modname = null) {
$stashed = $this->converter->get_stash('cminfo_'.$this->pluginname, $instance);
return $stashed['id'];
if (is_null($modname)) {
$modname = $this->pluginname;
}
return $this->converter->get_stash('cminfo_'.$modname, $instance);
}
}

View File

@ -68,7 +68,8 @@ class moodle1_mod_assignment_handler extends moodle1_mod_handler {
public function process_assignment($data) {
// get the course module id and context id
$instanceid = $data['id'];
$moduleid = $this->get_moduleid($instanceid);
$cminfo = $this->get_cminfo($instanceid);
$moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $moduleid);
// we now have all information needed to start writing into the file

View File

@ -73,7 +73,8 @@ class moodle1_mod_choice_handler extends moodle1_mod_handler {
// get the course module id and context id
$instanceid = $data['id'];
$moduleid = $this->get_moduleid($instanceid);
$cminfo = $this->get_cminfo($instanceid);
$moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $moduleid);
// we now have all information needed to start writing into the file

View File

@ -69,7 +69,8 @@ class moodle1_mod_forum_handler extends moodle1_mod_handler {
public function process_forum($data) {
// get the course module id and context id
$instanceid = $data['id'];
$moduleid = $this->get_moduleid($instanceid);
$cminfo = $this->get_cminfo($instanceid);
$moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $moduleid);
// we now have all information needed to start writing into the file