本文整理汇总了PHP中add_moduleinfo函数的典型用法代码示例。如果您正苦于以下问题:PHP add_moduleinfo函数的具体用法?PHP add_moduleinfo怎么用?PHP add_moduleinfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_moduleinfo函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sizeof
} else {
$glossary->usedynalink = $CFG->glossary_linkentries;
}
if (isset($xmlglossary['DEFAULTAPPROVAL'][0]['#'])) {
$glossary->defaultapproval = $xmlglossary['DEFAULTAPPROVAL'][0]['#'];
} else {
$glossary->defaultapproval = $CFG->glossary_defaultapproval;
}
// These fields were not included in export, assume zero.
$glossary->assessed = 0;
$glossary->availability = null;
// New glossary is to be inserted in section 0, it is always visible.
$glossary->section = 0;
$glossary->visible = 1;
// Include new glossary and return the new ID
if (!($glossary = add_moduleinfo($glossary, $course))) {
echo $OUTPUT->notification("Error while trying to create the new glossary.");
glossary_print_tabbed_table_end();
echo $OUTPUT->footer();
exit;
} else {
echo $OUTPUT->box(get_string("newglossarycreated", "glossary"), 'generalbox boxaligncenter boxwidthnormal');
}
} else {
echo $OUTPUT->notification("Error while trying to create the new glossary.");
echo $OUTPUT->footer();
exit;
}
}
$xmlentries = $xml['GLOSSARY']['#']['INFO'][0]['#']['ENTRIES'][0]['#']['ENTRY'];
$sizeofxmlentries = sizeof($xmlentries);
示例2: execute
public function execute()
{
//some variables you may want to use
//$this->cwd - the directory where moosh command was executed
//$this->mooshDir - moosh installation directory
//$this->expandedOptions - commandline provided options, merged with defaults
//$this->topDir - top Moodle directory
global $CFG, $DB, $USER;
require_once $CFG->dirroot . '/course/lib.php';
require_once $CFG->dirroot . '/course/modlib.php';
$length = 64;
if ($this->expandedOptions['include-text']) {
$split = rand(0, $length);
$text = generate_html_page($split) . $this->expandedOptions['include-text'] . generate_html_page($length - $split);
} else {
$text = generate_html_page($length);
}
$moduleinfo = new \stdClass();
$moduleinfo->introeditor = array('text' => $text, 'format' => '1', 'itemid' => NULL);
$moduleinfo->visible = '1';
$moduleinfo->course = $this->arguments[0];
$moduleinfo->coursemodule = 0;
//choose random section from a course
$sections = $DB->get_records('course_sections', array('course' => $this->arguments[0]), '', 'section');
$moduleinfo->section = array_rand($sections);
$moduleinfo->module = 12;
$moduleinfo->modulename = 'label';
$moduleinfo->instance = 0;
$moduleinfo->add = 'label';
$moduleinfo->update = 0;
$moduleinfo->return = 0;
$moduleinfo->sr = 0;
//$moduleinfo->submitbutton2=> 'Save and return to course';
$course = $DB->get_record('course', array('id' => $this->arguments[0]), '*', MUST_EXIST);
add_moduleinfo($moduleinfo, $course);
}
示例3: create_module
/**
* Create a module.
*
* It includes:
* - capability checks and other checks
* - create the module from the module info
*
* @param object $module
* @return object the created module info
* @throws moodle_exception if user is not allowed to perform the action or module is not allowed in this course
*/
function create_module($moduleinfo)
{
global $DB, $CFG;
require_once $CFG->dirroot . '/course/modlib.php';
// Check manadatory attributs.
$mandatoryfields = array('modulename', 'course', 'section', 'visible');
if (plugin_supports('mod', $moduleinfo->modulename, FEATURE_MOD_INTRO, true)) {
$mandatoryfields[] = 'introeditor';
}
foreach ($mandatoryfields as $mandatoryfield) {
if (!isset($moduleinfo->{$mandatoryfield})) {
throw new moodle_exception('createmodulemissingattribut', '', '', $mandatoryfield);
}
}
// Some additional checks (capability / existing instances).
$course = $DB->get_record('course', array('id' => $moduleinfo->course), '*', MUST_EXIST);
list($module, $context, $cw) = can_add_moduleinfo($course, $moduleinfo->modulename, $moduleinfo->section);
// Add the module.
$moduleinfo->module = $module->id;
$moduleinfo = add_moduleinfo($moduleinfo, $course, null);
return $moduleinfo;
}
示例4: facetoface_add_session
/**
* Create a new entry in the facetoface_sessions table
*/
function facetoface_add_session($session, $sessiondates, $fromform) {
global $USER, $DB, $CFG;
//$face2face=$DB->get_record('facetoface',array('id'=>$session->facetoface));
//$actual_sessions=$face2face->actualsessions+1;
//print_object($face2face);exit;
$session->timecreated = time();
$session = cleanup_session_data($session);
$wiziq=new stdClass();
if (empty($sessiondates)) {
// Insert a dummy date record.
$date = new stdClass();
$date->sessionid = $new_session;
$date->timestart = 0;
$date->timefinish = 0;
$date->sessiontimezone = '';
//commented by niranjan for adding session in multiple dates
// $DB->insert_record('facetoface_sessions_dates', $date);
} else {
foreach ($sessiondates as $date) {
//Niranjan added this to add session in date loop
$new_session= $DB->insert_record('facetoface_sessions', $session);
$date->sessionid = $new_session;
$wiziq->wiziq_datetime=$date->timestart;
$wiziq->wiziq_timezone=$date->sessiontimezone;
$wiziq->class_timezone=$date->sessiontimezone;
$DB->insert_record('facetoface_sessions_dates', $date);
if (!facetoface_save_session_room($new_session, $fromform)) {
print_error('error:couldnotsaveroom', 'facetoface');
}
/*If online session is enabled. */
if($session->onlinesession ==1){
require_once($CFG->dirroot.'/mod/wiziq/locallib.php');
require_once($CFG->dirroot . '/course/modlib.php');
$wiziq->name=$DB->get_field('facetoface','name',array('id'=>$session->facetoface));
$wiziq->modulename='wiziq';
$wiziq->course=1;
$wiziq->duration=$session->duration;
$wiziq->timezone=wiziq_timezone();
//$wiziq->wiziq_timezone='Asia/Kolkata';
// $wiziq->class_timezone = 'Asia/Kolkata';
$wiziq->timenow=time();
$wiziq->datetime=time();
$wiziq->recording=1;
$wiziq->groupinid=0;
$wiziq->module=$DB->get_field('modules','id',array('name'=>$wiziq->modulename));;
$wiziq->section=1;
$wiziq->batchid=$session->facetoface;
$wiziq->sessionid=$new_session;
$wiziq->visible=1;
$courseid = $DB->get_record('course', array('id'=>$wiziq->course), '*', MUST_EXIST);
add_moduleinfo($wiziq, $courseid, $mform = null);
//$wiziq= wiziq_add_instance($wiziq, $mform = null);
}
/**
* Add a record to the facetoface submissions table and sends out an
* email confirmation
*
* @param class $session record from the facetoface_sessions table
* @param class $facetoface record from the facetoface table
* @param class $course record from the course table
* @param string $discountcode code entered by the user
* @param integer $notificationtype type of notifications to send to user
* @see {{MDL_F2F_INVITE}}
* @param integer $statuscode Status code to set
* @param integer $userid user to signup
* @param bool $notifyuser whether or not to send an email confirmation
*
* facetoface_user_signup($session, $facetoface, $course, $discountcode,
$notificationtype, $statuscode, $userid = false,
$notifyuser = true) {
$users = facetoface_get_attendees($session->id);
if ($users) {
// No/deleted session dates
if (empty($session->datetimeknown)) {
// Convert any bookings to waitlists
foreach ($users as $user) {
if ($user->statuscode == MDL_F2F_STATUS_BOOKED) {
if (!facetoface_user_signup($session, $facetoface, $course, $user->discountcode, $user->notificationtype, MDL_F2F_STATUS_WAITLISTED, $user->id)) {
// rollback_sql();
return false;
}
}
//.........这里部分代码省略.........
示例5: redirect
$mformclassname = 'mod_' . $module->name . '_mod_form';
$mform = new $mformclassname($data, $cw->section, $cm, $course);
$mform->set_data($data);
if ($mform->is_cancelled()) {
if ($return && !empty($cm->id)) {
redirect("{$CFG->wwwroot}/mod/{$module->name}/view.php?id={$cm->id}");
} else {
redirect(course_get_url($course, $cw->section, array('sr' => $sectionreturn)));
}
} else {
if ($fromform = $mform->get_data()) {
if (!empty($fromform->update)) {
list($cm, $fromform) = update_moduleinfo($cm, $fromform, $course, $mform);
} else {
if (!empty($fromform->add)) {
$fromform = add_moduleinfo($fromform, $course, $mform);
} else {
print_error('invaliddata');
}
}
if (isset($fromform->submitbutton)) {
if (empty($fromform->showgradingmanagement)) {
redirect("{$CFG->wwwroot}/mod/{$module->name}/view.php?id={$fromform->coursemodule}");
} else {
$returnurl = new moodle_url("/mod/{$module->name}/view.php", array('id' => $fromform->coursemodule));
redirect($fromform->gradingman->get_management_url($returnurl));
}
} else {
redirect(course_get_url($course, $cw->section, array('sr' => $sectionreturn)));
}
exit;
示例6: create_mod_url
/**
* If user has attached a url to a post, we must create a module with type url
*
* @param string $url the url string
* @return record the created module of type url.
*/
protected function create_mod_url($url)
{
global $CFG, $COURSE, $DB;
require_once $CFG->dirroot . '/course/modlib.php';
require_once $CFG->dirroot . '/lib/resourcelib.php';
$moduleid = $DB->get_field('modules', 'id', array('name' => 'url'));
$data = new \stdClass();
$data->modulename = 'url';
$data->module = $moduleid;
$data->name = $url;
$data->visible = 1;
$data->section = 1;
$data->externalurl = $url;
$data->display = RESOURCELIB_DISPLAY_POPUP;
$data->popupwidth = 400;
$data->popupheight = 400;
// Create instance of url.
$modinfo = add_moduleinfo($data, $COURSE);
return $modinfo->coursemodule;
}
示例7: create_instance
/**
* Creates an instance of the module for testing purposes.
*
* Module type will be taken from the class name. Each module type may overwrite
* this function to add other default values used by it.
*
* @param array|stdClass $record data for module being generated. Requires 'course' key
* (an id or the full object). Also can have any fields from add module form.
* @param null|array $options general options for course module. Since 2.6 it is
* possible to omit this argument by merging options into $record
* @return stdClass record from module-defined table with additional field
* cmid (corresponding id in course_modules table)
*/
public function create_instance($record = null, array $options = null)
{
global $CFG, $DB;
require_once $CFG->dirroot . '/course/modlib.php';
$this->instancecount++;
// Merge options into record and add default values.
$record = $this->prepare_moduleinfo_record($record, $options);
// Retrieve the course record.
if (!empty($record->course->id)) {
$course = $record->course;
$record->course = $record->course->id;
} else {
$course = get_course($record->course);
}
// Fill the name and intro with default values (if missing).
if (empty($record->name)) {
$record->name = get_string('pluginname', $this->get_modulename()) . ' ' . $this->instancecount;
}
if (empty($record->introeditor) && empty($record->intro)) {
$record->intro = 'Test ' . $this->get_modulename() . ' ' . $this->instancecount;
}
if (empty($record->introeditor) && empty($record->introformat)) {
$record->introformat = FORMAT_MOODLE;
}
// Before Moodle 2.6 it was possible to create a module with completion tracking when
// it is not setup for course and/or site-wide. Display debugging message so it is
// easier to trace an error in unittests.
if ($record->completion && empty($CFG->enablecompletion)) {
debugging('Did you forget to set $CFG->enablecompletion before generating module with completion tracking?', DEBUG_DEVELOPER);
}
if ($record->completion && empty($course->enablecompletion)) {
debugging('Did you forget to enable completion tracking for the course before generating module with completion tracking?', DEBUG_DEVELOPER);
}
// Add the module to the course.
$moduleinfo = add_moduleinfo($record, $course, $mform = null);
// Prepare object to return with additional field cmid.
$instance = $DB->get_record($this->get_modulename(), array('id' => $moduleinfo->instance), '*', MUST_EXIST);
$instance->cmid = $moduleinfo->coursemodule;
return $instance;
}