• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_coursemodule_from_id函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_coursemodule_from_id函数的典型用法代码示例。如果您正苦于以下问题:PHP get_coursemodule_from_id函数的具体用法?PHP get_coursemodule_from_id怎么用?PHP get_coursemodule_from_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_coursemodule_from_id函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct(\mod_mediagallery\collection $collection, array $galleries)
 {
     global $CFG, $DB;
     $this->collection = $collection;
     $this->galleries = $galleries;
     if ($collection->user_can_add_children()) {
         $this->maxreached = false;
     }
     if ($this->isassessable = $collection->is_assessable()) {
         $this->hassubmitted = $collection->has_submitted();
         if ($this->linkedassigncmid = $collection->get_linked_assignid()) {
             require_once $CFG->dirroot . '/mod/assign/locallib.php';
             $context = \context_module::instance($this->linkedassigncmid);
             $cm = get_coursemodule_from_id('assign', $this->linkedassigncmid, 0, false, MUST_EXIST);
             $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
             $assign = new \assign($context, $cm, $course);
             $this->submissionsopen = $assign->submissions_open();
         }
     }
     $this->readonly = $collection->is_read_only();
     $this->tags = $collection->get_tags();
     $mygalleries = $collection->get_my_galleries();
     $this->userorgrouphasgallery = !empty($mygalleries);
     foreach (array('id', 'mode', 'thumbnailsperrow', 'thumbnailsperpage') as $opt) {
         if (isset($collection->{$opt})) {
             $this->{$opt} = $collection->{$opt};
         }
     }
 }
开发者ID:eSrem,项目名称:moodle-mod_mediagallery,代码行数:29,代码来源:renderable.php


示例2: resource_base

 /**
 * 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
 */
 function resource_base($cmid = 0)
 {
     global $CFG, $COURSE;
     if ($cmid) {
         if (!($this->cm = get_coursemodule_from_id('resource', $cmid))) {
             error("Course Module ID was incorrect");
         }
         if (!($this->course = get_record("course", "id", $this->cm->course))) {
             error("Course is misconfigured");
         }
         if (!($this->resource = get_record("resource", "id", $this->cm->instance))) {
             error("Resource ID was incorrect");
         }
         $this->strresource = get_string("modulename", "resource");
         $this->strresources = get_string("modulenameplural", "resource");
         if ($this->course->id != SITEID) {
             $this->navigation = "<a {$CFG->frametarget} onclick=\"this.target='{$CFG->framename}'\" href=\"{$CFG->wwwroot}/course/view.php?id={$this->course->id}\">{$this->course->shortname}</a> -> " . "<a {$CFG->frametarget} onclick=\"this.target='{$CFG->framename}'\" href=\"index.php?id={$this->course->id}\">{$this->strresources}</a> ->";
         } else {
             $this->navigation = "<a {$CFG->frametarget} onclick=\"this.target='{$CFG->framename}'\" href=\"index.php?id={$this->course->id}\">{$this->strresources}</a> ->";
         }
         if (!$this->cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $this->cm->id))) {
             $pagetitle = strip_tags($this->course->shortname . ': ' . $this->strresource);
             print_header($pagetitle, $this->course->fullname, "{$this->navigation} {$this->strresource}", "", "", true, '', navmenu($this->course, $this->cm));
             notice(get_string("activityiscurrentlyhidden"), "{$CFG->wwwroot}/course/view.php?id={$this->course->id}");
         }
     } else {
         $this->course = $COURSE;
     }
 }
开发者ID:veritech,项目名称:pare-project,代码行数:38,代码来源:lib.php


示例3: load

 /**
  * Loads data from the database.
  * Note: even if the function fails, it may still have overwritten some or all existing data in the object.
  * @param mixed $id The site-wide unique identifier for all modules. Type depends on VLE. On Moodle, it is an integer course module identifier ('id' field of 'course_modules' table)
  * @return bool True if successful, or false otherwise
  */
 function load($id)
 {
     // Make sure the ID is valid
     $id = (int) $id;
     if ($id <= 0) {
         return false;
     }
     // Fetch the course module data
     if (!($this->cm = get_coursemodule_from_id('sloodle', $id))) {
         sloodle_debug("Failed to load controler course module.<br>");
         return false;
     }
     // Load from the primary table: Sloodle instance
     if (!($this->sloodle_module_instance = get_record('sloodle', 'id', $this->cm->instance))) {
         sloodle_debug("Failed to load controller Sloodle module instance.<br>");
         return false;
     }
     // Check that it is the correct type
     if ($this->sloodle_module_instance->type != SLOODLE_TYPE_CTRL) {
         sloodle_debug("Loaded Sloodle module instance is not a controller.<br>");
         return false;
     }
     // Load from the secondary table: Controller instance
     if (!($this->sloodle_controller_instance = get_record('sloodle_controller', 'sloodleid', $this->cm->instance))) {
         sloodle_debug("Failed to load controller secondary data table.<br>");
         return false;
     }
     return true;
 }
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:35,代码来源:controller.php


示例4: pagemenu_get_basics

/**
 * Returns course module, course and module instance.
 *
 * @param int $cmid Course module ID
 * @param int $pagemenuid pagemenu module ID
 * @return array of objects
 **/
function pagemenu_get_basics($cmid = 0, $pagemenuid = 0)
{
    if ($cmid) {
        if (!($cm = get_coursemodule_from_id('pagemenu', $cmid))) {
            error('Course Module ID was incorrect');
        }
        if (!($course = get_record('course', 'id', $cm->course))) {
            error('Course is misconfigured');
        }
        if (!($pagemenu = get_record('pagemenu', 'id', $cm->instance))) {
            error('Course module is incorrect');
        }
    } else {
        if ($pagemenuid) {
            if (!($pagemenu = get_record('pagemenu', 'id', $pagemenuid))) {
                error('Course module is incorrect');
            }
            if (!($course = get_record('course', 'id', $pagemenu->course))) {
                error('Course is misconfigured');
            }
            if (!($cm = get_coursemodule_from_instance('pagemenu', $pagemenu->id, $course->id))) {
                error('Course Module ID was incorrect');
            }
        } else {
            error('No course module ID or pagemenu ID were passed');
        }
    }
    return array($cm, $course, $pagemenu);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:36,代码来源:locallib.php


示例5: __ScormUpdate

 public static function __ScormUpdate($uid, $request)
 {
     $courseid = $request->courseid;
     $cmid = $request->modid;
     if (!($cm = get_coursemodule_from_id('scorm', $cmid, $courseid))) {
         print_error('invalidcoursemodule');
     }
     $data = self::scorm_data_array($cmid, $courseid);
     $reqdata = $uid . $courseid . $cmid;
     // $uid.$courseid.$cmid userid + courseid + modid
     $data_submitted = $request->data[0]->organizations->Turnaround_Revitalizing_Resource_ORG->cmi->{$reqdata};
     $result = true;
     $attempts = $data_submitted->attempts->value;
     $starttime = $data_submitted->starttime->value;
     self::scorm_start_time($uid, $data['scormid'], $data['scoid'], $attempts, $starttime);
     foreach ($data_submitted as $element => $value) {
         $element = str_replace('__', '.', $element);
         if (substr($element, 0, 3) == 'cmi') {
             $netelement = preg_replace('/\\.N(\\d+)\\./', "\\.\$1\\.", $element);
             if ($value->setbysco === true) {
                 $result = scorm_insert_track($uid, $data['scormid'], $data['scoid'], $attempts, $element, $value->value, true) && $result;
                 //$scormid, $scoid
             }
         }
     }
     $response = new CliniqueServiceResponce();
     if (!empty($result)) {
         $response->response(false, 'Recorded inserted successfully');
     } else {
         $response->response(true, 'Invalid ID');
     }
     die;
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:33,代码来源:scorm_update.php


示例6: set_properties

 /**
  * Set class properties from params.
  *
  * @throws \coding_exception
  * @throws \moodle_exception
  */
 protected function set_properties()
 {
     global $DB;
     // Set class properties from params.
     $id = optional_param('id', 0, PARAM_INT);
     // Course_module ID, or
     $n = optional_param('n', 0, PARAM_INT);
     // collaborate instance ID.
     if ($id) {
         $cm = get_coursemodule_from_id('collaborate', $id, 0, false, MUST_EXIST);
         $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
         $collaborate = $DB->get_record('collaborate', array('id' => $cm->instance), '*', MUST_EXIST);
     } else {
         if ($n) {
             $collaborate = $DB->get_record('collaborate', array('id' => $n), '*', MUST_EXIST);
             $course = $DB->get_record('course', array('id' => $collaborate->course), '*', MUST_EXIST);
             $cm = get_coursemodule_from_instance('collaborate', $collaborate->id, $course->id, false, MUST_EXIST);
         } else {
             print_error('error:invalidmoduleid', 'mod_collaborate');
         }
     }
     $this->cm = $cm;
     $this->course = $course;
     $this->collaborate = $collaborate;
 }
开发者ID:mpetrowi,项目名称:moodle-mod_collaborate,代码行数:31,代码来源:view_controller.php


示例7: setup

 /**
  * Controller setup
  *
  * Get $cm and $instance and perform
  * proper call to require_login()
  *
  * @return void
  * @see $cm, $instance
  * @throws coding_exception
  */
 public function setup()
 {
     global $DB, $COURSE, $PAGE;
     // Course module ID or module instance ID
     $id = optional_param('id', 0, PARAM_INT);
     $a = optional_param('a', 0, PARAM_INT);
     // Get required course module record
     if ($id) {
         $this->cm = get_coursemodule_from_id($this->component, $id, 0, false, MUST_EXIST);
     } else {
         if ($a) {
             $this->cm = get_coursemodule_from_instance($this->component, $a, 0, false, MUST_EXIST);
         } else {
             throw new coding_exception('No Course Module or Instance ID was passed');
         }
     }
     // Get the module instance
     $this->instance = $DB->get_record($this->component, array('id' => $this->cm->instance), '*', MUST_EXIST);
     require_login($this->cm->course, true, $this->cm);
     $PAGE->set_title(format_string($this->instance->name));
     $PAGE->set_heading(format_string($COURSE->fullname));
     $PAGE->set_activity_record($this->instance);
     $PAGE->set_context($this->get_context());
     $PAGE->set_url($this->new_url(array('action' => $this->action)));
     $this->heading->text = format_string($this->instance->name);
 }
开发者ID:bgao-ca,项目名称:moodle-local_mr,代码行数:36,代码来源:mod.php


示例8: zoom_get_instance_setup

/**
 * Get course/cm/zoom objects from url parameters, and check for login/permissions.
 *
 * @return array Array of ($course, $cm, $zoom)
 */
function zoom_get_instance_setup()
{
    global $DB;
    $id = optional_param('id', 0, PARAM_INT);
    // Course_module ID, or
    $n = optional_param('n', 0, PARAM_INT);
    // ... zoom instance ID - it should be named as the first character of the module.
    if ($id) {
        $cm = get_coursemodule_from_id('zoom', $id, 0, false, MUST_EXIST);
        $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
        $zoom = $DB->get_record('zoom', array('id' => $cm->instance), '*', MUST_EXIST);
    } else {
        if ($n) {
            $zoom = $DB->get_record('zoom', array('id' => $n), '*', MUST_EXIST);
            $course = $DB->get_record('course', array('id' => $zoom->course), '*', MUST_EXIST);
            $cm = get_coursemodule_from_instance('zoom', $zoom->id, $course->id, false, MUST_EXIST);
        } else {
            print_error('You must specify a course_module ID or an instance ID');
        }
    }
    require_login($course, true, $cm);
    $context = context_module::instance($cm->id);
    require_capability('mod/zoom:view', $context);
    return array($course, $cm, $zoom);
}
开发者ID:uofr,项目名称:moodle-mod_zoom,代码行数:30,代码来源:locallib.php


示例9: definition

 function definition()
 {
     global $DB, $PAGE, $OUTPUT;
     $id = required_param('id', PARAM_INT);
     // course module
     if (!($cm = get_coursemodule_from_id('blended', $id))) {
         error("Course Module ID was incorrect");
     }
     if (!($course = get_course($cm->course))) {
         error("Course is misconfigured");
     }
     if (!($blended = $DB->get_record('blended', array('id' => $cm->instance)))) {
         error("Course module is incorrect");
     }
     $form =& $this->_form;
     $calificables = new grade_tree($course->id);
     $items = $calificables->items;
     $ins = array();
     $assignmentname = array();
     // Obtenemos las referencias a toda la informaci�n sobre los modulos dentro del curso
     $modinfo = get_fast_modinfo($course->id);
     foreach ($modinfo->instances as $abc) {
         foreach ($abc as $cmd) {
             foreach ($items as $r => $ite) {
                 $ins[$r] = $ite->iteminstance;
                 if ($cmd->instance == $ins[$r]) {
                     $assignmentname[$r] = $cmd->name;
                 }
             }
         }
     }
     $form->addElement('select', 'activities', 'Selecciona la Tarea', $assignmentname);
 }
开发者ID:juacas,项目名称:moodle-mod_blended,代码行数:33,代码来源:select_activity_form.php


示例10: load

 /**
  * Loads data from the database.
  * Note: even if the function fails, it may still have overwritten some or all existing data in the object.
  * @param mixed $id The site-wide unique identifier for all modules. Type depends on VLE. On Moodle, it is an integer course module identifier ('id' field of 'course_modules' table)
  * @return bool True if successful, or false otherwise
  */
 function load($id)
 {
     // Make sure the ID is valid
     $id = (int) $id;
     if ($id <= 0) {
         return false;
     }
     // Fetch the course module data
     if (!($this->cm = get_coursemodule_from_id('sloodle', $id))) {
         sloodle_debug("Failed to load course module instance #{$id}.<br/>");
         return false;
     }
     // Make sure the module is visible
     if ($this->cm->visible == 0) {
         sloodle_debug("Error: course module instance #{$id} not visible.<br/>");
         return false;
     }
     // Load from the primary table: sloodle instance
     if (!($this->sloodle_instance = get_record('sloodle', 'id', $this->cm->instance))) {
         sloodle_debug("Failed to load Sloodle module with instance ID #{$cm->instance}.<br/>");
         return false;
     }
     // Load from the secondary table: sloodle_presenter
     if (!($this->presenter = get_record('sloodle_presenter', 'sloodleid', $this->cm->instance))) {
         sloodle_debug("Failed to load secondary module table with instance ID #{$this->cm->instance}.<br/>");
         return false;
     }
     return true;
 }
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:35,代码来源:module_presenter.php


示例11: __construct

 /**
  * Constructor - instantiates one object of this class
  */
 public function __construct($name, $blockid, $moduleid = null, $plan = null)
 {
     global $DB;
     // Check blockid exists
     if (!($block = $DB->get_record('block_instances', array('id' => $blockid)))) {
         throw new backup_task_exception('block_task_block_instance_not_found', $blockid);
     }
     $this->blockid = $blockid;
     $this->blockname = $block->blockname;
     $this->contextid = get_context_instance(CONTEXT_BLOCK, $this->blockid)->id;
     $this->moduleid = $moduleid;
     $this->modulename = null;
     $this->parentcontextid = null;
     // If moduleid passed, check exists, supports moodle2 format and save info
     // Check moduleid exists
     if (!empty($moduleid)) {
         if (!($coursemodule = get_coursemodule_from_id(false, $moduleid))) {
             throw new backup_task_exception('block_task_coursemodule_not_found', $moduleid);
         }
         // Check activity supports this moodle2 backup format
         if (!plugin_supports('mod', $coursemodule->modname, FEATURE_BACKUP_MOODLE2)) {
             throw new backup_task_exception('block_task_activity_lacks_moodle2_backup_support', $coursemodule->modname);
         }
         $this->moduleid = $moduleid;
         $this->modulename = $coursemodule->modname;
         $this->parentcontextid = get_context_instance(CONTEXT_MODULE, $this->moduleid)->id;
     }
     parent::__construct($name, $plan);
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:32,代码来源:backup_block_task.class.php


示例12: test_update_activity_completion_status_manually

 /**
  * Test update_activity_completion_status_manually
  */
 public function test_update_activity_completion_status_manually()
 {
     global $DB, $CFG;
     $this->resetAfterTest(true);
     $CFG->enablecompletion = true;
     $user = $this->getDataGenerator()->create_user();
     $course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
     $data = $this->getDataGenerator()->create_module('data', array('course' => $course->id), array('completion' => 1));
     $cm = get_coursemodule_from_id('data', $data->cmid);
     $studentrole = $DB->get_record('role', array('shortname' => 'student'));
     $this->getDataGenerator()->enrol_user($user->id, $course->id, $studentrole->id);
     $this->setUser($user);
     $result = core_completion_external::update_activity_completion_status_manually($data->cmid, true);
     // We need to execute the return values cleaning process to simulate the web service server.
     $result = external_api::clean_returnvalue(core_completion_external::update_activity_completion_status_manually_returns(), $result);
     // Check in DB.
     $this->assertEquals(1, $DB->get_field('course_modules_completion', 'completionstate', array('coursemoduleid' => $data->cmid)));
     // Check using the API.
     $completion = new completion_info($course);
     $completiondata = $completion->get_data($cm);
     $this->assertEquals(1, $completiondata->completionstate);
     $this->assertTrue($result['status']);
     $result = core_completion_external::update_activity_completion_status_manually($data->cmid, false);
     // We need to execute the return values cleaning process to simulate the web service server.
     $result = external_api::clean_returnvalue(core_completion_external::update_activity_completion_status_manually_returns(), $result);
     $this->assertEquals(0, $DB->get_field('course_modules_completion', 'completionstate', array('coursemoduleid' => $data->cmid)));
     $completiondata = $completion->get_data($cm);
     $this->assertEquals(0, $completiondata->completionstate);
     $this->assertTrue($result['status']);
 }
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:33,代码来源:externallib_test.php


示例13: load

 /**
  * Loads data from the database.
  * Note: even if the function fails, it may still have overwritten some or all existing data in the object.
  * @param mixed $id The site-wide unique identifier for all modules. Type depends on VLE. On Moodle, it is an integer course module identifier ('id' field of 'course_modules' table)
  * @return bool True if successful, or false otherwise
  */
 function load($id)
 {
     // Make sure the ID is valid
     if (!is_int($id) || $id <= 0) {
         echo "<hr><pre>ID = ";
         print_r($id);
         echo "</pre><hr>";
         return false;
     }
     // Fetch the course module data
     if (!($this->cm = get_coursemodule_from_id('sloodle', $id))) {
         return false;
     }
     // Load from the primary table: Sloodle instance
     if (!($this->sloodle_module_instance = get_record('sloodle', 'id', $this->cm->instance))) {
         return false;
     }
     // Check that it is the correct type
     if ($this->sloodle_module_instance->type != SLOODLE_TYPE_CTRL) {
         return false;
     }
     // Load from the secondary table: Distributor instance
     if (!($this->sloodle_controller_instance = get_record('sloodle_controller', 'sloodleid', $this->cm->instance))) {
         return false;
     }
     return true;
 }
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:33,代码来源:module_controller.php


示例14: get_owning_activity

 /**
  * If this block belongs to a activity context, then return that activity's id.
  * Otherwise, return 0.
  * @return stdclass the activity record.
  */
 public function get_owning_activity()
 {
     global $DB;
     // Set some defaults.
     $result = new stdClass();
     $result->id = 0;
     if (empty($this->instance->parentcontextid)) {
         return $result;
     }
     $parentcontext = context::instance_by_id($this->instance->parentcontextid);
     if ($parentcontext->contextlevel != CONTEXT_MODULE) {
         return $result;
     }
     $cm = get_coursemodule_from_id($this->page->cm->modname, $parentcontext->instanceid);
     if (!$cm) {
         return $result;
     }
     // Get the grade_items id.
     $rec = $DB->get_record('grade_items', array('iteminstance' => $cm->instance, 'itemmodule' => $this->page->cm->modname));
     if (!$rec) {
         return $result;
     }
     // See if it is a gradable activity.
     if ($rec->gradetype != GRADE_TYPE_VALUE && $rec->gradetype != GRADE_TYPE_SCALE) {
         return $result;
     }
     return $rec;
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:33,代码来源:block_activity_results.php


示例15: delete

 private static function delete($modulename, $course, $title, $section)
 {
     global $DB, $CFG;
     $sql = 'SELECT cm.id FROM {course_sections} AS cs JOIN {course_modules} AS cm ON cm.section = cs.id JOIN {modules} AS ms ON ms.id = cm.module JOIN {' . $modulename . '} AS m ON m.id = cm.instance WHERE cs.course = ? AND cs.section = ? AND m.name = ? AND ms.name = ?';
     $instances = $DB->get_records_sql($sql, array($course->id, $section, $title, $modulename));
     foreach ($instances as $instance) {
         $cm = get_coursemodule_from_id('', $instance->id);
         $modlib = "{$CFG->dirroot}/mod/{$cm->modname}/lib.php";
         if (file_exists($modlib)) {
             require_once $modlib;
         } else {
             return false;
         }
         $deleteinstancefunction = $cm->modname . "_delete_instance";
         if (!$deleteinstancefunction($cm->instance)) {
             return false;
         }
         if (!delete_course_module($cm->id)) {
             return false;
         }
         if (!delete_mod_from_section($cm->id, $cm->section)) {
             return false;
         }
         // Trigger a mod_deleted event with information about this module.
         $eventdata = new stdClass();
         $eventdata->modulename = $cm->modname;
         $eventdata->cmid = $cm->id;
         $eventdata->courseid = $course->id;
         $eventdata->userid = 0;
         events_trigger('mod_deleted', $eventdata);
     }
     return true;
 }
开发者ID:OBU-OBIS,项目名称:moodle-block_module_add,代码行数:33,代码来源:course_mod_add.php


示例16: test_export_contents

 public function test_export_contents()
 {
     global $DB;
     $this->resetAfterTest(true);
     $user = $this->getDataGenerator()->create_user();
     $course = $this->getDataGenerator()->create_course(array('enablecomment' => 1));
     $studentrole = $DB->get_record('role', array('shortname' => 'student'));
     $this->getDataGenerator()->enrol_user($user->id, $course->id, $studentrole->id);
     // Test book with 3 chapters.
     $book = $this->getDataGenerator()->create_module('book', array('course' => $course->id));
     $cm = get_coursemodule_from_id('book', $book->cmid);
     $bookgenerator = $this->getDataGenerator()->get_plugin_generator('mod_book');
     $chapter1 = $bookgenerator->create_chapter(array('bookid' => $book->id, "pagenum" => 1));
     $chapter2 = $bookgenerator->create_chapter(array('bookid' => $book->id, "pagenum" => 2));
     $subchapter = $bookgenerator->create_chapter(array('bookid' => $book->id, "pagenum" => 3, "subchapter" => 1));
     $chapter3 = $bookgenerator->create_chapter(array('bookid' => $book->id, "pagenum" => 4, "hidden" => 1));
     $this->setUser($user);
     $contents = book_export_contents($cm, '');
     // The hidden chapter must not be included, and additional page with the structure must be included.
     $this->assertCount(4, $contents);
     $this->assertEquals('structure', $contents[0]['filename']);
     $this->assertEquals('index.html', $contents[1]['filename']);
     $this->assertEquals('Chapter 1', $contents[1]['content']);
     $this->assertEquals('index.html', $contents[2]['filename']);
     $this->assertEquals('Chapter 2', $contents[2]['content']);
     $this->assertEquals('index.html', $contents[3]['filename']);
     $this->assertEquals('Chapter 3', $contents[3]['content']);
     // Test empty book.
     $emptybook = $this->getDataGenerator()->create_module('book', array('course' => $course->id));
     $cm = get_coursemodule_from_id('book', $emptybook->cmid);
     $contents = book_export_contents($cm, '');
     $this->assertCount(1, $contents);
     $this->assertEquals('structure', $contents[0]['filename']);
     $this->assertEquals(json_encode(array()), $contents[0]['content']);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:35,代码来源:lib_test.php


示例17: __construct

    /**
     * Explicit constructor to set the properties declared by the parent class.
     *
     * Firstly we call the parent's constructor to set the $this->id property
     * from the passed argument. Then we populate the $this->cm so that the
     * default parent class methods work well.
     *
     * @param array $callbackargs
     */
    public function __construct($callbackargs) {

        // Let the parent class set the $this->id property.
        parent::__construct($callbackargs);
        // Populate the $this->cm property.
        $this->cm = get_coursemodule_from_id('workshop', $this->id, 0, false, MUST_EXIST);
    }
开发者ID:rezaies,项目名称:moodle,代码行数:16,代码来源:portfolio_caller.php


示例18: load_data

 /**
  * Load data needed for the portfolio export
  *
  * If the assignment type implements portfolio_load_data(), the processing is delegated
  * to it. Otherwise, the caller must provide either fileid (to export single file) or
  * submissionid (to export all data attached to the given submission) via callback arguments.
  */
 public function load_data()
 {
     global $DB, $CFG;
     if (!($this->cm = get_coursemodule_from_id('assignment', $this->id))) {
         throw new portfolio_caller_exception('invalidcoursemodule');
     }
     if (!($assignment = $DB->get_record("assignment", array("id" => $this->cm->instance)))) {
         throw new portfolio_caller_exception('invalidid', 'assignment');
     }
     $this->assignmentfile = '/mod/assignment/type/' . $assignment->assignmenttype . '/assignment.class.php';
     require_once $CFG->dirroot . $this->assignmentfile;
     $assignmentclass = "assignment_{$assignment->assignmenttype}";
     $this->assignment = new $assignmentclass($this->cm->id, $assignment, $this->cm);
     if (!$this->assignment->portfolio_exportable()) {
         throw new portfolio_caller_exception('notexportable', 'portfolio', $this->get_return_url());
     }
     if (is_callable(array($this->assignment, 'portfolio_load_data'))) {
         return $this->assignment->portfolio_load_data($this);
     }
     if (empty($this->fileid)) {
         if (empty($this->submissionid)) {
             throw new portfolio_caller_exception('invalidfileandsubmissionid', 'mod_assignment');
         }
         if (!($submission = $DB->get_record('assignment_submissions', array('assignment' => $assignment->id, 'id' => $this->submissionid)))) {
             throw new portfolio_caller_exception('invalidsubmissionid', 'mod_assignment');
         }
         $submissionid = $submission->id;
     } else {
         // once we know the file id, we do not need the submission
         $submissionid = null;
     }
     $this->set_file_and_format_data($this->fileid, $this->assignment->context->id, 'mod_assignment', 'submission', $submissionid, 'timemodified', false);
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:40,代码来源:locallib.php


示例19: setup_page

 /**
  * Sets up the edit page
  *
  * @param string $baseurl the base url of the
  *
  * @return array Array of variables that the page is set up with
  */
 public function setup_page($baseurl)
 {
     global $PAGE, $CFG, $DB;
     $this->pagevars = array();
     $pageurl = new \moodle_url($baseurl);
     $pageurl->remove_all_params();
     $id = optional_param('cmid', false, PARAM_INT);
     $quizid = optional_param('quizid', false, PARAM_INT);
     // get necessary records from the DB
     if ($id) {
         $cm = get_coursemodule_from_id('activequiz', $id, 0, false, MUST_EXIST);
         $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
         $quiz = $DB->get_record('activequiz', array('id' => $cm->instance), '*', MUST_EXIST);
     } else {
         $quiz = $DB->get_record('activequiz', array('id' => $quizid), '*', MUST_EXIST);
         $course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
         $cm = get_coursemodule_from_instance('activequiz', $quiz->id, $course->id, false, MUST_EXIST);
     }
     $this->get_parameters();
     // get the rest of the parameters and set them in the class
     if ($CFG->version < 2011120100) {
         $this->context = get_context_instance(CONTEXT_MODULE, $cm->id);
     } else {
         $this->context = \context_module::instance($cm->id);
     }
     // set up question lib
     list($this->pageurl, $this->contexts, $cmid, $cm, $quiz, $this->pagevars) = question_edit_setup('editq', '/mod/activequiz/edit.php', true);
     $PAGE->set_url($this->pageurl);
     $this->pagevars['pageurl'] = $this->pageurl;
     $PAGE->set_title(strip_tags($course->shortname . ': ' . get_string("modulename", "activequiz") . ': ' . format_string($quiz->name, true)));
     $PAGE->set_heading($course->fullname);
     // setup classes needed for the edit page
     $this->RTQ = new \mod_activequiz\activequiz($cm, $course, $quiz, $this->pagevars);
     $this->RTQ->get_renderer()->init($this->RTQ, $this->pageurl, $this->pagevars);
 }
开发者ID:agarnav,项目名称:moodle-mod_activequiz,代码行数:42,代码来源:edit.php


示例20: resource_base

 /**
  * 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
  */
 function resource_base($cmid = 0)
 {
     global $CFG, $COURSE;
     $this->navlinks = array();
     if ($cmid) {
         if (!($this->cm = get_coursemodule_from_id('resource', $cmid))) {
             error("Course Module ID was incorrect");
         }
         if (!($this->course = get_record("course", "id", $this->cm->course))) {
             error("Course is misconfigured");
         }
         if (!($this->resource = get_record("resource", "id", $this->cm->instance))) {
             error("Resource ID was incorrect");
         }
         $this->strresource = get_string("modulename", "resource");
         $this->strresources = get_string("modulenameplural", "resource");
         if (!$this->cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $this->cm->id))) {
             $pagetitle = strip_tags($this->course->shortname . ': ' . $this->strresource);
             $navigation = build_navigation($this->navlinks, $this->cm);
             print_header($pagetitle, $this->course->fullname, $navigation, "", "", true, '', navmenu($this->course, $this->cm));
             notice(get_string("activityiscurrentlyhidden"), "{$CFG->wwwroot}/course/view.php?id={$this->course->id}");
         }
     } else {
         $this->course = $COURSE;
     }
 }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:35,代码来源:lib.php



注:本文中的get_coursemodule_from_id函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_coursemodule_from_instance函数代码示例发布时间:2022-05-15
下一篇:
PHP get_courseid_from_context函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap