本文整理汇总了PHP中context_module类的典型用法代码示例。如果您正苦于以下问题:PHP context_module类的具体用法?PHP context_module怎么用?PHP context_module使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了context_module类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Run forum cron.
*/
public function execute()
{
global $DB, $CFG;
$currenttime = time();
$statement = 'SELECT R.* FROM {ratingallocate} AS R
LEFT JOIN {ratingallocate_allocations} AS A
ON R.' . this_db\ratingallocate::ID . '=A.' . this_db\ratingallocate_allocations::RATINGALLOCATEID . '
WHERE A.' . this_db\ratingallocate_allocations::ID . ' IS NULL AND R.' . this_db\ratingallocate::ACCESSTIMESTOP . '<' . $currenttime;
$records = $DB->get_records_sql($statement);
$course = null;
foreach ($records as $record) {
$cm = get_coursemodule_from_instance(this_db\ratingallocate::TABLE, $record->{this_db\ratingallocate::ID});
// Fetch the data for the course, if is has changed
if (!$course || $course->id != $record->{this_db\ratingallocate::COURSE}) {
$course = $DB->get_record('course', array('id' => $record->{this_db\ratingallocate::COURSE}), '*', MUST_EXIST);
}
// Create ratingallocate instance from record
$ratingallocate = new \ratingallocate($record, $course, $cm, \context_module::instance($cm->id));
$currenttime = time();
$timetoterminate = $CFG->ratingallocate_algorithm_timeout + $ratingallocate->ratingallocate->algorithmstarttime;
// If last execution exeeds timeout limit assume failure of algorithm run.
if ($ratingallocate->ratingallocate->algorithmstarttime && $currenttime >= $timetoterminate && $ratingallocate->get_algorithm_status() === \mod_ratingallocate\algorithm_status::running) {
$ratingallocate->set_algorithm_failed();
return true;
}
// Only start the algorithm, if it should be run by the cron and hasn't been started somehow, yet.
if ($ratingallocate->ratingallocate->runalgorithmbycron === "1" && $ratingallocate->get_algorithm_status() === \mod_ratingallocate\algorithm_status::notstarted) {
// Run allocation.
$ratingallocate->distrubute_choices();
}
}
return true;
}
开发者ID:andrewhancox,项目名称:moodle-mod_ratingallocate,代码行数:36,代码来源:cron_task.php
示例2: test_imscp_view
/**
* Test imscp_view
* @return void
*/
public function test_imscp_view()
{
global $CFG;
$CFG->enablecompletion = 1;
$this->resetAfterTest();
$this->setAdminUser();
// Setup test data.
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
$imscp = $this->getDataGenerator()->create_module('imscp', array('course' => $course->id), array('completion' => 2, 'completionview' => 1));
$context = context_module::instance($imscp->cmid);
$cm = get_coursemodule_from_instance('imscp', $imscp->id);
// Trigger and capture the event.
$sink = $this->redirectEvents();
imscp_view($imscp, $course, $cm, $context);
$events = $sink->get_events();
// 2 additional events thanks to completion.
$this->assertCount(3, $events);
$event = array_shift($events);
// Checking that the event contains the expected values.
$this->assertInstanceOf('\\mod_imscp\\event\\course_module_viewed', $event);
$this->assertEquals($context, $event->get_context());
$moodleurl = new \moodle_url('/mod/imscp/view.php', array('id' => $cm->id));
$this->assertEquals($moodleurl, $event->get_url());
$this->assertEventContextNotUsed($event);
$this->assertNotEmpty($event->get_name());
// Check completion status.
$completion = new completion_info($course);
$completiondata = $completion->get_data($cm);
$this->assertEquals(1, $completiondata->completionstate);
}
开发者ID:pzhu2004,项目名称:moodle,代码行数:34,代码来源:lib_test.php
示例3: imscp_htmllize_item
/**
* Internal function - creates htmls structure suitable for YUI tree.
*/
function imscp_htmllize_item($item, $imscp, $cm)
{
global $CFG;
if ($item['href']) {
if (preg_match('|^https?://|', $item['href'])) {
$url = $item['href'];
} else {
$context = context_module::instance($cm->id);
$urlbase = "{$CFG->wwwroot}/pluginfile.php";
$path = '/' . $context->id . '/mod_imscp/content/' . $imscp->revision . '/' . $item['href'];
$url = file_encode_url($urlbase, $path, false);
}
$result = "<li><a href=\"{$url}\">" . $item['title'] . '</a>';
} else {
$result = '<li>' . $item['title'];
}
if ($item['subitems']) {
$result .= '<ul>';
foreach ($item['subitems'] as $subitem) {
$result .= imscp_htmllize_item($subitem, $imscp, $cm);
}
$result .= '</ul>';
}
$result .= '</li>';
return $result;
}
开发者ID:pzhu2004,项目名称:moodle,代码行数:29,代码来源:locallib.php
示例4: test_event_properties_guessing
public function test_event_properties_guessing()
{
global $USER;
$this->resetAfterTest();
$course = $this->getDataGenerator()->create_course();
$forum = $this->getDataGenerator()->create_module('forum', array('course' => $course->id));
$context = context_module::instance($forum->cmid);
$event = \core_tests\event\unittest_executed::create(array('context' => $context, 'objectid' => 5));
// Check guessed course ID, and default properties.
$this->assertSame('\\core_tests\\event\\unittest_executed', $event->eventname);
$this->assertSame('core_tests', $event->component);
$this->assertSame('executed', $event->action);
$this->assertSame('unittest', $event->target);
$this->assertSame(5, $event->objectid);
$this->assertEquals($context, $event->get_context());
$this->assertEquals($course->id, $event->courseid);
$this->assertSame($USER->id, $event->userid);
$this->assertNull($event->relateduserid);
$user = $this->getDataGenerator()->create_user();
$context = context_user::instance($user->id);
$event = \core_tests\event\unittest_executed::create(array('contextid' => $context->id, 'objectid' => 5));
// Check guessing on contextid, and user context level.
$this->assertEquals($context, $event->get_context());
$this->assertEquals($context->id, $event->contextid);
$this->assertEquals($context->contextlevel, $event->contextlevel);
$this->assertSame(0, $event->courseid);
$this->assertSame($USER->id, $event->userid);
$this->assertSame($user->id, $event->relateduserid);
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:29,代码来源:event_test.php
示例5: test_import_chapters_events
public function test_import_chapters_events()
{
$course = $this->getDataGenerator()->create_course();
$book = $this->getDataGenerator()->create_module('book', array('course' => $course->id));
$context = context_module::instance($book->cmid);
$record = new stdClass();
$record->contextid = $context->id;
$record->component = 'phpunit';
$record->filearea = 'test';
$record->itemid = 0;
$record->filepath = '/';
$record->filename = 'chapters.zip';
$fs = get_file_storage();
$file = $fs->create_file_from_pathname($record, __DIR__ . '/fixtures/chapters.zip');
// Importing the chapters.
$sink = $this->redirectEvents();
toolbook_importhtml_import_chapters($file, 2, $book, $context, false);
$events = $sink->get_events();
// Checking the results.
$this->assertCount(5, $events);
foreach ($events as $event) {
$this->assertInstanceOf('\\mod_book\\event\\chapter_created', $event);
$this->assertEquals($context, $event->get_context());
$chapter = $event->get_record_snapshot('book_chapters', $event->objectid);
$this->assertNotEmpty($chapter);
$this->assertEventContextNotUsed($event);
}
}
开发者ID:evltuma,项目名称:moodle,代码行数:28,代码来源:locallib_test.php
示例6: test_book_exported
public function test_book_exported() {
// There is no proper API to call to test the event, so what we are
// doing here is simply making sure that the events returns the right information.
$course = $this->getDataGenerator()->create_course();
$book = $this->getDataGenerator()->create_module('book', array('course' => $course->id));
$params = array(
'context' => context_module::instance($book->cmid),
'objectid' => $book->id
);
$event = \booktool_exportimscp\event\book_exported::create($params);
// Triggering and capturing the event.
$sink = $this->redirectEvents();
$event->trigger();
$events = $sink->get_events();
$this->assertCount(1, $events);
$event = reset($events);
// Checking that the event contains the expected values.
$this->assertInstanceOf('\booktool_exportimscp\event\book_exported', $event);
$this->assertEquals(context_module::instance($book->cmid), $event->get_context());
$this->assertEquals($book->id, $event->objectid);
$expected = array($course->id, 'book', 'exportimscp', 'tool/exportimscp/index.php?id=' . $book->cmid,
$book->id, $book->cmid);
$this->assertEventLegacyLogData($expected, $event);
$this->assertEventContextNotUsed($event);
}
开发者ID:rwijaya,项目名称:moodle,代码行数:29,代码来源:events_test.php
示例7: test_generator
public function test_generator()
{
global $DB;
$this->resetAfterTest(true);
$this->assertEquals(0, $DB->count_records('forum'));
$course = $this->getDataGenerator()->create_course();
/** @var mod_forum_generator $generator */
$generator = $this->getDataGenerator()->get_plugin_generator('mod_forum');
$this->assertInstanceOf('mod_forum_generator', $generator);
$this->assertEquals('forum', $generator->get_modulename());
$generator->create_instance(array('course' => $course->id));
$generator->create_instance(array('course' => $course->id));
$forum = $generator->create_instance(array('course' => $course->id));
$this->assertEquals(3, $DB->count_records('forum'));
$cm = get_coursemodule_from_instance('forum', $forum->id);
$this->assertEquals($forum->id, $cm->instance);
$this->assertEquals('forum', $cm->modname);
$this->assertEquals($course->id, $cm->course);
$context = context_module::instance($cm->id);
$this->assertEquals($forum->cmid, $context->instanceid);
// test gradebook integration using low level DB access - DO NOT USE IN PLUGIN CODE!
$forum = $generator->create_instance(array('course' => $course->id, 'assessed' => 1, 'scale' => 100));
$gitem = $DB->get_record('grade_items', array('courseid' => $course->id, 'itemtype' => 'mod', 'itemmodule' => 'forum', 'iteminstance' => $forum->id));
$this->assertNotEmpty($gitem);
$this->assertEquals(100, $gitem->grademax);
$this->assertEquals(0, $gitem->grademin);
$this->assertEquals(GRADE_TYPE_VALUE, $gitem->gradetype);
}
开发者ID:alanaipe2015,项目名称:moodle,代码行数:28,代码来源:generator_test.php
示例8: __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 = context_block::instance($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 = context_module::instance($this->moduleid)->id;
}
parent::__construct($name, $plan);
}
开发者ID:evltuma,项目名称:moodle,代码行数:32,代码来源:backup_block_task.class.php
示例9: create_content
public function create_content($glossary, $record = array(), $aliases = array())
{
global $DB, $USER, $CFG;
$this->entrycount++;
$now = time();
$record = (array) $record + array('glossaryid' => $glossary->id, 'timecreated' => $now, 'timemodified' => $now, 'userid' => $USER->id, 'concept' => 'Glossary entry ' . $this->entrycount, 'definition' => 'Definition of glossary entry ' . $this->entrycount, 'definitionformat' => FORMAT_MOODLE, 'definitiontrust' => 0, 'usedynalink' => $CFG->glossary_linkentries, 'casesensitive' => $CFG->glossary_casesensitive, 'fullmatch' => $CFG->glossary_fullmatch);
if (!isset($record['teacherentry']) || !isset($record['approved'])) {
$context = context_module::instance($glossary->cmid);
if (!isset($record['teacherentry'])) {
$record['teacherentry'] = has_capability('mod/glossary:manageentries', $context, $record['userid']);
}
if (!isset($record['approved'])) {
$defaultapproval = $glossary->defaultapproval;
$record['approved'] = $defaultapproval || has_capability('mod/glossary:approve', $context);
}
}
$id = $DB->insert_record('glossary_entries', $record);
if ($aliases) {
foreach ($aliases as $alias) {
$ar = new stdClass();
$ar->entryid = $id;
$ar->alias = $alias;
$DB->insert_record('glossary_alias', $ar);
}
}
return $DB->get_record('glossary_entries', array('id' => $id), '*', MUST_EXIST);
}
开发者ID:evltuma,项目名称:moodle,代码行数:27,代码来源:lib.php
示例10: test_generator
public function test_generator()
{
global $DB, $SITE;
$this->resetAfterTest(true);
// Must be a non-guest user to create resources.
$this->setAdminUser();
// There are 0 resources initially.
$this->assertEquals(0, $DB->count_records('resource'));
// Create the generator object and do standard checks.
$generator = $this->getDataGenerator()->get_plugin_generator('mod_resource');
$this->assertInstanceOf('mod_resource_generator', $generator);
$this->assertEquals('resource', $generator->get_modulename());
// Create three instances in the site course.
$generator->create_instance(array('course' => $SITE->id));
$generator->create_instance(array('course' => $SITE->id));
$resource = $generator->create_instance(array('course' => $SITE->id));
$this->assertEquals(3, $DB->count_records('resource'));
// Check the course-module is correct.
$cm = get_coursemodule_from_instance('resource', $resource->id);
$this->assertEquals($resource->id, $cm->instance);
$this->assertEquals('resource', $cm->modname);
$this->assertEquals($SITE->id, $cm->course);
// Check the context is correct.
$context = context_module::instance($cm->id);
$this->assertEquals($resource->cmid, $context->instanceid);
// Check that generated resource module contains a file.
$fs = get_file_storage();
$files = $fs->get_area_files($context->id, 'mod_resource', 'content', false, '', false);
$this->assertEquals(1, count($files));
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:30,代码来源:generator_test.php
示例11: showListOfLinks
function showListOfLinks($id, $resop)
{
global $OUTPUT, $DB;
//need it to check capability
$cm = get_coursemodule_from_id('resop', $id, 0, false, MUST_EXIST);
$context = context_module::instance($cm->id);
echo $OUTPUT->heading(get_string('entries', 'resop'), 4);
echo $OUTPUT->action_link(new moodle_url('view.php', array('id' => $id, 'action' => 'showAll')), get_string('showall', 'resop'));
// Required
//linkliste Klassen/Resources - specific for this resop instance
$text = $resop->type == 'typeexam' ? get_string('resExam', 'resop') : get_string('resFree', 'resop');
echo $OUTPUT->heading($text, 4);
$resources = $DB->get_records_sql('SELECT DISTINCT name FROM {resop_resource_user} ru JOIN {resop_resource} rr ' . " ON ru.resid=rr.id WHERE ru.actid={$resop->id} ORDER BY name");
//ok, should only be the resources which are handled in this resop instance
foreach ($resources as $key => $value) {
echo $OUTPUT->action_link(new moodle_url('view.php', array('id' => $id, 'action' => 'showClass', 'class' => $key)), $key);
// Required
echo " ";
}
//link list owner over all instances of resop modul
if (has_capability('mod/resop:book', $context)) {
echo $OUTPUT->heading(get_string('bookedby_header', 'resop'), 4);
$resources = $DB->get_records_sql('SELECT DISTINCT name FROM {resop_resource_user} ru JOIN {resop_resop_user} rru ' . 'on ru.uid = rru.uid JOIN {resop_user} u on ru.uid=u.id ORDER BY name');
foreach ($resources as $key => $value) {
echo $OUTPUT->action_link(new moodle_url('view.php', array('id' => $id, 'action' => 'showBooker', 'name' => $key)), $key);
echo " ";
}
}
}
开发者ID:Roemke,项目名称:resop,代码行数:29,代码来源:view.php
示例12: create_without_groupid
/**
* Convenience method to create event object from data when grading group without knowledge of the groups id
*
* @param \stdClass $cm course module object
* @param \stdClass $data grading data to log
* @return \mod_grouptool\group_graded event object
*/
public static function create_without_groupid(\stdClass $cm, \stdClass $data)
{
// Trigger overview event.
$data->type = 'users';
$event = self::create(array('objectid' => $cm->instance, 'context' => \context_module::instance($cm->id), 'other' => (array) $data));
return $event;
}
开发者ID:rimacher,项目名称:moodle-mod_grouptool,代码行数:14,代码来源:group_graded.php
示例13: test_create_instance
public function test_create_instance()
{
global $DB;
$this->resetAfterTest(true);
$course = $this->getDataGenerator()->create_course();
$this->assertFalse($DB->record_exists('questionnaire', array('course' => $course->id)));
/** @var mod_questionnaire_generator $generator */
$generator = $this->getDataGenerator()->get_plugin_generator('mod_questionnaire');
$this->assertInstanceOf('mod_questionnaire_generator', $generator);
$this->assertEquals('questionnaire', $generator->get_modulename());
$questionnaire = $generator->create_instance(array('course' => $course->id));
$this->assertEquals(1, $DB->count_records('questionnaire'));
$cm = get_coursemodule_from_instance('questionnaire', $questionnaire->id);
$this->assertEquals($questionnaire->id, $cm->instance);
$this->assertEquals('questionnaire', $cm->modname);
$this->assertEquals($course->id, $cm->course);
$context = context_module::instance($cm->id);
$this->assertEquals($questionnaire->cmid, $context->instanceid);
$survey = $DB->get_record('questionnaire_survey', array('id' => $questionnaire->sid));
$this->assertEquals($survey->id, $questionnaire->sid);
$this->assertEquals($questionnaire->name, $survey->name);
$this->assertEquals($questionnaire->name, $survey->title);
// Should test creating a public questionnaire, template questionnaire and creating one from a template.
// Should test event creation if open dates and close dates are specified?
}
开发者ID:SysBind,项目名称:moodle-mod_questionnaire,代码行数:25,代码来源:generator_test.php
示例14: definition
public function definition()
{
$mform = $this->_form;
$currententry = $this->_customdata['current'];
$publication = $this->_customdata['publication'];
$cm = $this->_customdata['cm'];
$definitionoptions = $this->_customdata['definitionoptions'];
$attachmentoptions = $this->_customdata['attachmentoptions'];
$context = context_module::instance($cm->id);
// Prepare format_string/text options.
$fmtoptions = array('context' => $context);
if ($publication->get_instance()->obtainteacherapproval) {
$text = get_string('published_aftercheck', 'publication');
} else {
$text = get_string('published_immediately', 'publication');
}
$mform->addElement('header', 'myfiles', get_string('myfiles', 'publication'));
$mform->addElement('static', 'guideline', get_string('guideline', 'publication'), $text);
$mform->addElement('filemanager', 'attachment_filemanager', '', null, $attachmentoptions);
// Hidden params.
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'cmid');
$mform->setType('cmid', PARAM_INT);
// Buttons.
$this->add_action_buttons(true, get_string('save_changes', 'publication'));
$this->set_data($currententry);
}
开发者ID:Kathrin84,项目名称:moodle-mod_publication,代码行数:28,代码来源:upload_form.php
示例15: create_instance
function create_instance()
{
// Include module lib
$modlib = '../../mod/' . $this->module_name() . '/lib.php';
if (file_exists($modlib)) {
global $CFG;
require_once $modlib;
} else {
return array(false, 'Module lib not found');
}
$ret = $this->set_module_instance_params();
if (!$ret[0]) {
return $ret;
}
// Add instance and update course_modules DB row
$addinstancefunction = $this->module_name() . '_add_instance';
if ($this->get_num_instance_function_params() == 1) {
$returnfromfunc = $addinstancefunction($this->moduleobj);
} else {
$returnfromfunc = $addinstancefunction($this->moduleobj, true);
}
if (!$returnfromfunc or !is_number($returnfromfunc)) {
// undo everything we can
$modcontext = context_module::instance($this->moduleobj->coursemodule);
$modcontext->delete();
$DB->delete_records('course_modules', array('id' => $this->moduleobj->coursemodule));
if (!is_number($returnfromfunc)) {
return array(false, "{$addinstancefunction} is not a valid function");
} else {
return array(false, 'Cannot add new module');
}
}
$this->moduleobj->instance = $returnfromfunc;
return array(true, '');
}
开发者ID:OBU-OBIS,项目名称:moodle-block_module_add,代码行数:35,代码来源:module_plugin_base.php
示例16: get_document
/**
* Returns the document associated with this activity.
*
* This default implementation for activities sets the activity name to title and the activity intro to
* content. Any activity can overwrite this function if it is interested in setting other fields than the
* default ones, or to fill description optional fields with extra stuff.
*
* @param stdClass $record
* @param array $options
* @return \core_search\document
*/
public function get_document($record, $options = array())
{
try {
$cm = $this->get_cm($this->get_module_name(), $record->id, $record->course);
$context = \context_module::instance($cm->id);
} catch (\dml_missing_record_exception $ex) {
// Notify it as we run here as admin, we should see everything.
debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document, not all required data is available: ' . $ex->getMessage(), DEBUG_DEVELOPER);
return false;
} catch (\dml_exception $ex) {
// Notify it as we run here as admin, we should see everything.
debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document: ' . $ex->getMessage(), DEBUG_DEVELOPER);
return false;
}
// Prepare associative array with data from DB.
$doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
$doc->set('title', content_to_text($record->name, false));
$doc->set('content', content_to_text($record->intro, $record->introformat));
$doc->set('contextid', $context->id);
$doc->set('courseid', $record->course);
$doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
$doc->set('modified', $record->{static::MODIFIED_FIELD_NAME});
// Check if this document should be considered new.
if (isset($options['lastindexedtime'])) {
$createdfield = static::CREATED_FIELD_NAME;
if (!empty($createdfield) && $options['lastindexedtime'] < $record->{$createdfield}) {
// If the document was created after the last index time, it must be new.
$doc->set_is_new(true);
}
}
return $doc;
}
开发者ID:sirromas,项目名称:lms,代码行数:43,代码来源:base_activity.php
示例17: get_submission_status
/**
* Search a list of modules.
*
* @param $modulecode
* @return array [string]
* @throws \invalid_parameter_exception
*/
public static function get_submission_status($submissionid)
{
global $DB, $USER;
$params = self::validate_parameters(self::get_submission_status_parameters(), array('submissionid' => $submissionid));
$submissionid = $params['submissionid'];
$submission = $DB->get_record('turnitintooltwo_submissions', array('id' => $submissionid));
if (!$submission) {
return array('status' => 'error');
}
// Grab more data.
$turnitintooltwo = $DB->get_record('turnitintooltwo', array('id' => $submission->turnitintooltwoid));
list($course, $cm) = get_course_and_cm_from_instance($turnitintooltwo, 'turnitintooltwo');
// Check this is our submission.
if ($USER->id !== $submission->userid && !has_capability('mod/turnitintooltwo:grade', \context_module::instance($cm->id))) {
return array('status' => 'nopermission');
}
// What is the status?
$status = $DB->get_record('turnitintooltwo_sub_status', array('submissionid' => $submissionid));
if (!$status) {
return array('status' => 'queued');
}
// Decode the receipt.
$digitalreceipt = (array) json_decode($status->receipt);
// Woo!
if ($status->status == \mod_turnitintooltwo\task\submit_assignment::STATUS_SUCCESS) {
$turnitintooltwoview = new \turnitintooltwo_view();
$digitalreceipt = $turnitintooltwoview->show_digital_receipt($digitalreceipt);
$digitalreceipt = \html_writer::tag("div", $digitalreceipt, array("id" => "box_receipt"));
return array('status' => 'success', 'message' => $digitalreceipt);
}
return array('status' => 'failed', 'message' => \html_writer::tag("div", $digitalreceipt["message"], array("class" => "alert alert-danger")));
}
开发者ID:SkylarKelty,项目名称:moodle-mod_turnitintooltwo,代码行数:39,代码来源:external.php
示例18: video_header
/**
* Renders the videofile page header.
*
* @param videofile videofile
* @return string
*/
public function video_header($videofile)
{
global $CFG;
$output = '';
$name = format_string($videofile->get_instance()->name, true, $videofile->get_course());
$title = $this->page->course->shortname . ': ' . $name;
$coursemoduleid = $videofile->get_course_module()->id;
$context = context_module::instance($coursemoduleid);
// Add videojs css and js files.
$this->page->requires->css('/mod/videofile/video-js-4.6.3/video-js.min.css');
$this->page->requires->js('/mod/videofile/video-js-4.6.3/video.js', true);
// Set the videojs flash fallback url.
$swfurl = new moodle_url('/mod/videofile/video-js-4.6.3/video-js.swf');
$this->page->requires->js_init_code('videojs.options.flash.swf = "' . $swfurl . '";');
// Yui module handles responsive mode video resizing.
if ($videofile->get_instance()->responsive) {
$config = get_config('videofile');
$this->page->requires->yui_module('moodle-mod_videofile-videojs', 'M.mod_videofile.videojs.init', array($videofile->get_instance()->id, $swfurl, $videofile->get_instance()->width, $videofile->get_instance()->height, (bool) $config->limitdimensions));
}
// Header setup.
$this->page->set_title($title);
$this->page->set_heading($this->page->course->fullname);
$output .= $this->output->header();
$output .= $this->output->heading($name, 3);
if (!empty($videofile->get_instance()->intro)) {
$output .= $this->output->box_start('generalbox boxaligncenter', 'intro');
$output .= format_module_intro('videofile', $videofile->get_instance(), $coursemoduleid);
$output .= $this->output->box_end();
}
return $output;
}
开发者ID:jneubauer,项目名称:moodle-mod_videofile,代码行数:37,代码来源:renderer.php
示例19: xmldb_oublog_install
function xmldb_oublog_install()
{
global $DB, $CFG;
require_once $CFG->dirroot . '/course/lib.php';
// Setup the global blog.
$oublog = new stdClass();
$oublog->course = SITEID;
$oublog->name = 'Personal Blogs';
$oublog->intro = '';
$oublog->introformat = FORMAT_HTML;
$oublog->accesstoken = md5(uniqid(rand(), true));
$oublog->maxvisibility = 300;
// OUBLOG_VISIBILITY_PUBLIC.
$oublog->global = 1;
$oublog->allowcomments = 2;
// OUBLOG_COMMENTS_ALLOWPUBLIC.
if (!($oublog->id = $DB->insert_record('oublog', $oublog))) {
return false;
}
$mod = new stdClass();
$mod->course = SITEID;
$mod->module = $DB->get_field('modules', 'id', array('name' => 'oublog'));
$mod->instance = $oublog->id;
$mod->visible = 1;
$mod->visibleold = 0;
$mod->section = 1;
if (!($cm = add_course_module($mod))) {
return true;
}
set_config('oublogsetup', null);
// For unit tests to work, it's necessary to create context now.
context_module::instance($cm);
return true;
}
开发者ID:eugeneventer,项目名称:moodle-mod_oublog,代码行数:34,代码来源:install.php
示例20: get_glossaries_by_courses
/**
* Returns a list of glossaries in a provided list of courses.
*
* If no list is provided all glossaries that the user can view will be returned.
*
* @param array $courseids the course IDs.
* @return array of glossaries
* @since Moodle 3.1
*/
public static function get_glossaries_by_courses($courseids = array())
{
$params = self::validate_parameters(self::get_glossaries_by_courses_parameters(), array('courseids' => $courseids));
$warnings = array();
$courses = array();
$courseids = $params['courseids'];
if (empty($courseids)) {
$courses = enrol_get_my_courses();
$courseids = array_keys($courses);
}
// Array to store the glossaries to return.
$glossaries = array();
// Ensure there are courseids to loop through.
if (!empty($courseids)) {
list($courses, $warnings) = external_util::validate_courses($courseids, $courses);
// Get the glossaries in these courses, this function checks users visibility permissions.
$glossaries = get_all_instances_in_courses('glossary', $courses);
foreach ($glossaries as $glossary) {
$context = context_module::instance($glossary->coursemodule);
$glossary->name = external_format_string($glossary->name, $context->id);
list($glossary->intro, $glossary->introformat) = external_format_text($glossary->intro, $glossary->introformat, $context->id, 'mod_glossary', 'intro', null);
}
}
$result = array();
$result['glossaries'] = $glossaries;
$result['warnings'] = $warnings;
return $result;
}
开发者ID:pzhu2004,项目名称:moodle,代码行数:37,代码来源:external.php
注:本文中的context_module类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论