本文整理汇总了PHP中completion_info::reset_all_state方法的典型用法代码示例。如果您正苦于以下问题:PHP completion_info::reset_all_state方法的具体用法?PHP completion_info::reset_all_state怎么用?PHP completion_info::reset_all_state使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类completion_info
的用法示例。
在下文中一共展示了completion_info::reset_all_state方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_moduleinfo
/**
* Update the module info.
* This function doesn't check the user capabilities. It updates the course module and the module instance.
* Then execute common action to create/update module process (trigger event, rebuild cache, save plagiarism settings...).
*
* @param object $cm course module
* @param object $moduleinfo module info
* @param object $course course of the module
* @param object $mform - the mform is required by some specific module in the function MODULE_update_instance(). This is due to a hack in this function.
* @return array list of course module and module info.
*/
function update_moduleinfo($cm, $moduleinfo, $course, $mform = null)
{
global $DB, $CFG;
// Attempt to include module library before we make any changes to DB.
include_modulelib($moduleinfo->modulename);
$moduleinfo->course = $course->id;
$moduleinfo = set_moduleinfo_defaults($moduleinfo);
if (!empty($course->groupmodeforce) or !isset($moduleinfo->groupmode)) {
$moduleinfo->groupmode = $cm->groupmode;
// Keep original.
}
// Update course module first.
$cm->groupmode = $moduleinfo->groupmode;
if (isset($moduleinfo->groupingid)) {
$cm->groupingid = $moduleinfo->groupingid;
}
$completion = new completion_info($course);
if ($completion->is_enabled() && !empty($moduleinfo->completionunlocked)) {
// Update completion settings.
$cm->completion = $moduleinfo->completion;
$cm->completiongradeitemnumber = $moduleinfo->completiongradeitemnumber;
$cm->completionview = $moduleinfo->completionview;
$cm->completionexpected = $moduleinfo->completionexpected;
}
if (!empty($CFG->enableavailability)) {
// This code is used both when submitting the form, which uses a long
// name to avoid clashes, and by unit test code which uses the real
// name in the table.
if (property_exists($moduleinfo, 'availabilityconditionsjson')) {
if ($moduleinfo->availabilityconditionsjson !== '') {
$cm->availability = $moduleinfo->availabilityconditionsjson;
} else {
$cm->availability = null;
}
} else {
if (property_exists($moduleinfo, 'availability')) {
$cm->availability = $moduleinfo->availability;
}
}
}
if (isset($moduleinfo->showdescription)) {
$cm->showdescription = $moduleinfo->showdescription;
} else {
$cm->showdescription = 0;
}
$DB->update_record('course_modules', $cm);
$modcontext = context_module::instance($moduleinfo->coursemodule);
// Update embedded links and save files.
if (plugin_supports('mod', $moduleinfo->modulename, FEATURE_MOD_INTRO, true)) {
$moduleinfo->intro = file_save_draft_area_files($moduleinfo->introeditor['itemid'], $modcontext->id, 'mod_' . $moduleinfo->modulename, 'intro', 0, array('subdirs' => true), $moduleinfo->introeditor['text']);
$moduleinfo->introformat = $moduleinfo->introeditor['format'];
unset($moduleinfo->introeditor);
}
$updateinstancefunction = $moduleinfo->modulename . "_update_instance";
if (!$updateinstancefunction($moduleinfo, $mform)) {
print_error('cannotupdatemod', '', course_get_url($course, $cw->section), $moduleinfo->modulename);
}
// Make sure visibility is set correctly (in particular in calendar).
if (has_capability('moodle/course:activityvisibility', $modcontext)) {
set_coursemodule_visible($moduleinfo->coursemodule, $moduleinfo->visible);
}
if (isset($moduleinfo->cmidnumber)) {
// Label.
// Set cm idnumber - uniqueness is already verified by form validation.
set_coursemodule_idnumber($moduleinfo->coursemodule, $moduleinfo->cmidnumber);
}
// Now that module is fully updated, also update completion data if required.
// (this will wipe all user completion data and recalculate it)
if ($completion->is_enabled() && !empty($moduleinfo->completionunlocked)) {
$completion->reset_all_state($cm);
}
$cm->name = $moduleinfo->name;
\core\event\course_module_updated::create_from_cm($cm, $modcontext)->trigger();
$moduleinfo = edit_module_post_actions($moduleinfo, $course);
return array($cm, $moduleinfo);
}
示例2: update_moduleinfo
/**
* Update the module info.
* This function doesn't check the user capabilities. It updates the course module and the module instance.
* Then execute common action to create/update module process (trigger event, rebuild cache, save plagiarism settings...).
*
* @param object $cm course module
* @param object $moduleinfo module info
* @param object $course course of the module
* @param object $mform - the mform is required by some specific module in the function MODULE_update_instance(). This is due to a hack in this function.
* @return array list of course module and module info.
*/
function update_moduleinfo($cm, $moduleinfo, $course, $mform = null)
{
global $DB, $CFG;
// Attempt to include module library before we make any changes to DB.
include_modulelib($moduleinfo->modulename);
$moduleinfo->course = $course->id;
$moduleinfo = set_moduleinfo_defaults($moduleinfo);
if (!empty($course->groupmodeforce) or !isset($moduleinfo->groupmode)) {
$moduleinfo->groupmode = $cm->groupmode;
// Keep original.
}
// Update course module first.
$cm->groupmode = $moduleinfo->groupmode;
if (isset($moduleinfo->groupingid)) {
$cm->groupingid = $moduleinfo->groupingid;
}
if (isset($moduleinfo->groupmembersonly)) {
$cm->groupmembersonly = $moduleinfo->groupmembersonly;
}
$completion = new completion_info($course);
if ($completion->is_enabled() && !empty($moduleinfo->completionunlocked)) {
// Update completion settings.
$cm->completion = $moduleinfo->completion;
$cm->completiongradeitemnumber = $moduleinfo->completiongradeitemnumber;
$cm->completionview = $moduleinfo->completionview;
$cm->completionexpected = $moduleinfo->completionexpected;
}
if (!empty($CFG->enableavailability)) {
$cm->availablefrom = $moduleinfo->availablefrom;
$cm->availableuntil = $moduleinfo->availableuntil;
$cm->showavailability = $moduleinfo->showavailability;
condition_info::update_cm_from_form($cm, $moduleinfo, true);
}
if (isset($moduleinfo->showdescription)) {
$cm->showdescription = $moduleinfo->showdescription;
} else {
$cm->showdescription = 0;
}
$DB->update_record('course_modules', $cm);
$modcontext = context_module::instance($moduleinfo->coursemodule);
// Update embedded links and save files.
if (plugin_supports('mod', $moduleinfo->modulename, FEATURE_MOD_INTRO, true)) {
$moduleinfo->intro = file_save_draft_area_files($moduleinfo->introeditor['itemid'], $modcontext->id, 'mod_' . $moduleinfo->modulename, 'intro', 0, array('subdirs' => true), $moduleinfo->introeditor['text']);
$moduleinfo->introformat = $moduleinfo->introeditor['format'];
unset($moduleinfo->introeditor);
}
$updateinstancefunction = $moduleinfo->modulename . "_update_instance";
if (!$updateinstancefunction($moduleinfo, $mform)) {
print_error('cannotupdatemod', '', course_get_url($course, $cw->section), $moduleinfo->modulename);
}
// Make sure visibility is set correctly (in particular in calendar).
if (has_capability('moodle/course:activityvisibility', $modcontext)) {
set_coursemodule_visible($moduleinfo->coursemodule, $moduleinfo->visible);
}
if (isset($moduleinfo->cmidnumber)) {
// Label.
// Set cm idnumber - uniqueness is already verified by form validation.
set_coursemodule_idnumber($moduleinfo->coursemodule, $moduleinfo->cmidnumber);
}
// Now that module is fully updated, also update completion data if required.
// (this will wipe all user completion data and recalculate it)
if ($completion->is_enabled() && !empty($moduleinfo->completionunlocked)) {
$completion->reset_all_state($cm);
}
// Trigger event based on the action we did.
$event = \core\event\course_module_updated::create(array('courseid' => $course->id, 'context' => $modcontext, 'objectid' => $moduleinfo->coursemodule, 'other' => array('modulename' => $moduleinfo->modulename, 'name' => $moduleinfo->name, 'instanceid' => $moduleinfo->instance)));
$event->trigger();
add_to_log($course->id, $moduleinfo->modulename, "update", "view.php?id={$moduleinfo->coursemodule}", "{$moduleinfo->instance}", $moduleinfo->coursemodule);
$moduleinfo = edit_module_post_actions($moduleinfo, $course);
return array($cm, $moduleinfo);
}
示例3: RWSAUQuiz
//.........这里部分代码省略.........
$r_qiz->groupingid = $r_cmod->groupingid;
$r_qiz->groupmembersonly = $r_cmod->groupmembersonly;
$r_qiz->course = $r_cid;
$r_qiz->module = $r_mr->id;
$r_qiz->modulename = $r_mr->name;
$r_qiz->instance = $r_cmod->instance;
if (respondusws_floatcompare($CFG->version, 2011120500.0, 2) >= 0) {
$r_qiz->showdescription = 0;
}
$r_cpl = new completion_info($r_crs);
if ($r_cpl->is_enabled()) {
$r_qiz->completion = $r_cmod->completion;
$r_qiz->completionview = $r_cmod->completionview;
$r_qiz->completionexpected = $r_cmod->completionexpected;
$r_qiz->completionusegrade = is_null($r_cmod->completiongradeitemnumber) ? 0 : 1;
}
if ($CFG->enableavailability) {
$r_qiz->availablefrom = $r_cmod->availablefrom;
$r_qiz->availableuntil = $r_cmod->availableuntil;
if ($r_qiz->availableuntil) {
$r_qiz->availableuntil = strtotime("23:59:59", $r_qiz->availableuntil);
}
$r_qiz->showavailability = $r_cmod->showavailability;
}
$r_its = grade_item::fetch_all(array('itemtype' => 'mod', 'itemmodule' => $r_qiz->modulename, 'iteminstance' => $r_qiz->instance, 'courseid' => $r_cid));
if ($r_its) {
foreach ($r_its as $r_it) {
if (!empty($r_it->outcomeid)) {
$r_qiz->{'outcome_' . $r_it->outcomeid} = 1;
}
}
$r_gc = false;
foreach ($r_its as $r_it) {
if ($r_gc === false) {
$r_gc = $r_it->categoryid;
continue;
}
if ($r_gc != $r_it->categoryid) {
$r_gc = false;
break;
}
}
if ($r_gc !== false) {
$r_qiz->gradecat = $r_gc;
}
}
if ($r_imp) {
RWSIQSet($r_qiz, $r_sn, $r_sd, $r_ecd);
}
$DB->update_record("course_modules", $r_qiz);
if (is_null($r_qiz->quizpassword) && !is_null($r_qiz->password)) {
$r_qiz->quizpassword = $r_qiz->password;
}
$r_res = quiz_update_instance($r_qiz);
if (!$r_res || is_string($r_res)) {
RWSSErr("2081");
}
RWSSLBSet($r_qiz);
set_coursemodule_visible($r_qzmi, $r_qiz->visible);
if (isset($r_qiz->cmidnumber)) {
set_coursemodule_idnumber($r_qzmi, $r_qiz->cmidnumber);
}
RWSUQGrades($r_qiz);
if ($r_cpl->is_enabled() && !empty($r_qiz->completionunlocked)) {
$r_cpl->reset_all_state($r_qiz);
}
if (respondusws_floatcompare($CFG->version, 2014051200, 2) >= 0) {
$r_qiz->modname = $r_qiz->modulename;
$r_qiz->id = $r_qiz->coursemodule;
\core\event\course_module_updated::create_from_cm($r_qiz)->trigger();
} else {
$r_evt = new stdClass();
$r_evt->modulename = $r_qiz->modulename;
$r_evt->name = $r_qiz->name;
$r_evt->cmid = $r_qiz->coursemodule;
$r_evt->courseid = $r_qiz->course;
$r_evt->userid = $RWSUID;
events_trigger("mod_updated", $r_evt);
}
rebuild_course_cache($r_cid);
grade_regrade_final_grades($r_cid);
if ($RWSLB->mex || $RWSLB->bex) {
if ($RWSLB->mok) {
if ($RWSLB->perr) {
RWSSWarn("3003");
}
} else {
if ($RWSLB->bok) {
if ($RWSLB->perr) {
RWSSWarn("3003");
}
} else {
RWSSWarn("3001");
}
}
} else {
RWSSWarn("3000");
}
RWSSStat("1004");
}
示例4: update_moduleinfo
//.........这里部分代码省略.........
$cm->groupmode = $moduleinfo->groupmode;
if (isset($moduleinfo->groupingid)) {
$cm->groupingid = $moduleinfo->groupingid;
}
$completion = new completion_info($course);
if ($completion->is_enabled()) {
// Completion settings that would affect users who have already completed
// the activity may be locked; if so, these should not be updated.
if (!empty($moduleinfo->completionunlocked)) {
$cm->completion = $moduleinfo->completion;
$cm->completiongradeitemnumber = $moduleinfo->completiongradeitemnumber;
$cm->completionview = $moduleinfo->completionview;
}
// The expected date does not affect users who have completed the activity,
// so it is safe to update it regardless of the lock status.
$cm->completionexpected = $moduleinfo->completionexpected;
}
if (!empty($CFG->enableavailability)) {
// This code is used both when submitting the form, which uses a long
// name to avoid clashes, and by unit test code which uses the real
// name in the table.
if (property_exists($moduleinfo, 'availabilityconditionsjson')) {
if ($moduleinfo->availabilityconditionsjson !== '') {
$cm->availability = $moduleinfo->availabilityconditionsjson;
} else {
$cm->availability = null;
}
} else {
if (property_exists($moduleinfo, 'availability')) {
$cm->availability = $moduleinfo->availability;
}
}
// If there is any availability data, verify it.
if ($cm->availability) {
$tree = new \core_availability\tree(json_decode($cm->availability));
// Save time and database space by setting null if the only data
// is an empty tree.
if ($tree->is_empty()) {
$cm->availability = null;
}
}
}
if (isset($moduleinfo->showdescription)) {
$cm->showdescription = $moduleinfo->showdescription;
} else {
$cm->showdescription = 0;
}
$DB->update_record('course_modules', $cm);
$modcontext = context_module::instance($moduleinfo->coursemodule);
// Update embedded links and save files.
if (plugin_supports('mod', $moduleinfo->modulename, FEATURE_MOD_INTRO, true)) {
$moduleinfo->intro = file_save_draft_area_files($moduleinfo->introeditor['itemid'], $modcontext->id, 'mod_' . $moduleinfo->modulename, 'intro', 0, array('subdirs' => true), $moduleinfo->introeditor['text']);
$moduleinfo->introformat = $moduleinfo->introeditor['format'];
unset($moduleinfo->introeditor);
}
// Get the a copy of the grade_item before it is modified incase we need to scale the grades.
$oldgradeitem = null;
$newgradeitem = null;
if (!empty($data->grade_rescalegrades) && $data->grade_rescalegrades == 'yes') {
// Fetch the grade item before it is updated.
$oldgradeitem = grade_item::fetch(array('itemtype' => 'mod', 'itemmodule' => $moduleinfo->modulename, 'iteminstance' => $moduleinfo->instance, 'itemnumber' => 0, 'courseid' => $moduleinfo->course));
}
$updateinstancefunction = $moduleinfo->modulename . "_update_instance";
if (!$updateinstancefunction($moduleinfo, $mform)) {
print_error('cannotupdatemod', '', course_get_url($course, $cm->section), $moduleinfo->modulename);
}
// This needs to happen AFTER the grademin/grademax have already been updated.
if (!empty($data->grade_rescalegrades) && $data->grade_rescalegrades == 'yes') {
// Get the grade_item after the update call the activity to scale the grades.
$newgradeitem = grade_item::fetch(array('itemtype' => 'mod', 'itemmodule' => $moduleinfo->modulename, 'iteminstance' => $moduleinfo->instance, 'itemnumber' => 0, 'courseid' => $moduleinfo->course));
if ($newgradeitem && $oldgradeitem->gradetype == GRADE_TYPE_VALUE && $newgradeitem->gradetype == GRADE_TYPE_VALUE) {
$params = array($course, $cm, $oldgradeitem->grademin, $oldgradeitem->grademax, $newgradeitem->grademin, $newgradeitem->grademax);
if (!component_callback('mod_' . $moduleinfo->modulename, 'rescale_activity_grades', $params)) {
print_error('cannotreprocessgrades', '', course_get_url($course, $cm->section), $moduleinfo->modulename);
}
}
}
// Make sure visibility is set correctly (in particular in calendar).
if (has_capability('moodle/course:activityvisibility', $modcontext)) {
set_coursemodule_visible($moduleinfo->coursemodule, $moduleinfo->visible);
}
if (isset($moduleinfo->cmidnumber)) {
// Label.
// Set cm idnumber - uniqueness is already verified by form validation.
set_coursemodule_idnumber($moduleinfo->coursemodule, $moduleinfo->cmidnumber);
}
// Update module tags.
if (core_tag_tag::is_enabled('core', 'course_modules') && isset($moduleinfo->tags)) {
core_tag_tag::set_item_tags('core', 'course_modules', $moduleinfo->coursemodule, $modcontext, $moduleinfo->tags);
}
// Now that module is fully updated, also update completion data if required.
// (this will wipe all user completion data and recalculate it)
if ($completion->is_enabled() && !empty($moduleinfo->completionunlocked)) {
$completion->reset_all_state($cm);
}
$cm->name = $moduleinfo->name;
\core\event\course_module_updated::create_from_cm($cm, $modcontext)->trigger();
$moduleinfo = edit_module_post_actions($moduleinfo, $course);
return array($cm, $moduleinfo);
}
示例5: unset
unset($fromform->introeditor);
}
if (!$updateinstancefunction($fromform, $mform)) {
print_error('cannotupdatemod', '', "view.php?id={$course->id}#section-{$cw->section}", $fromform->modulename);
}
// make sure visibility is set correctly (in particular in calendar)
set_coursemodule_visible($fromform->coursemodule, $fromform->visible);
if (isset($fromform->cmidnumber)) {
//label
// set cm idnumber - uniqueness is already verified by form validation
set_coursemodule_idnumber($fromform->coursemodule, $fromform->cmidnumber);
}
// Now that module is fully updated, also update completion data if
// required (this will wipe all user completion data and recalculate it)
if ($completion->is_enabled() && !empty($fromform->completionunlocked)) {
$completion->reset_all_state($cm);
}
// Trigger mod_updated event with information about this module.
$eventdata = new stdClass();
$eventdata->modulename = $fromform->modulename;
$eventdata->name = $fromform->name;
$eventdata->cmid = $fromform->coursemodule;
$eventdata->courseid = $course->id;
$eventdata->userid = $USER->id;
events_trigger('mod_updated', $eventdata);
add_to_log($course->id, "course", "update mod", "../mod/{$fromform->modulename}/view.php?id={$fromform->coursemodule}", "{$fromform->modulename} {$fromform->instance}");
add_to_log($course->id, $fromform->modulename, "update", "view.php?id={$fromform->coursemodule}", "{$fromform->instance}", $fromform->coursemodule);
} else {
if (!empty($fromform->add)) {
if (!empty($course->groupmodeforce) or !isset($fromform->groupmode)) {
$fromform->groupmode = 0;
示例6: taskchain_navigation_accesscontrol_form
//.........这里部分代码省略.........
foreach ($names as $name => $disabled) {
$value = $DB->get_field($table, $name, $params);
if (isset($value)) {
$value = intval($value);
}
if ($value !== $disabled) {
$completion = $completiontracking;
}
}
foreach ($completionfields as $field) {
$name = $field->name;
if (property_exists($instance, $name) && $instance->{$name}) {
$completion = $completiontracking;
}
}
}
// force completion to be something sensible
update_course_module_completion('course_modules', $cm->id, 'completion', $completion, $updated, $skipped, $completion_updated);
// get full $cm record
if (method_exists($cm, 'get_course_module_record')) {
// Moodle >= 2.7
$cm = $cm->get_course_module_record(true);
} else {
// Moodle <= 2.6
$cm = get_coursemodule_from_id($cm->modname, $cm->id, $cm->course, true);
}
// prevent "Cannot find grade item" error in "lib/completionlib.php"
$params = array('courseid' => $cm->course, 'itemtype' => 'mod', 'itemmodule' => $cm->modname, 'iteminstance' => $cm->instance);
if (!grade_item::fetch($params)) {
$cm->completiongradeitemnumber = null;
// disable grade completion
}
$completion = new completion_info($course);
$completion->reset_all_state($cm);
$rebuild_course_cache = true;
}
if ($regrade_item_id) {
$regrade_course_grades = true;
$DB->set_field('grade_items', 'needsupdate', 1, array('id' => $regrade_item_id));
$DB->set_field('grade_items', 'needsupdate', 1, array('courseid' => $course->id, 'itemtype' => 'course'));
}
if ($started_list == false) {
$started_list = true;
echo '<table border="0" cellpadding="4" cellspacing="4" class="selectedactivitylist"><tbody>' . "\n";
echo '<tr><th colspan="2">' . get_string('settingsselected', $plugin) . '</th></tr>' . "\n";
foreach ($selected_settings as $setting) {
list($name, $value) = format_setting($setting, ${$setting}, $ratings, $gradecategories, $groupmodes, $groupings, $indentmenu, $sectionmenu, $positionmenu, $uploadlimitmenu, $conditiongradeitemidmenu, $conditioncmidmenu, $conditioncmcompletionmenu, $conditionfieldnamemenu, $conditionfieldoperatormenu, $conditiongroupidmenu, $conditiongroupingidmenu, $conditionactionmenu, $completiontrackingmenu, $completionfields, $competencyrulemenu, $filters, $filtermenu, $filterdefaulton, $filterdefaultoff);
echo '<tr><td class="itemname">' . $name . ':</td><td class="itemvalue">' . $value . '</td></tr>' . "\n";
}
echo '<tr><th colspan="2">' . get_string('activitiesselected', $plugin) . '</th></tr>' . "\n";
}
echo '<tr><td class="itemname">';
if ($updated) {
echo '<span class="updated">' . get_string('updated', 'moodle', $cm->modname) . '</span>';
} else {
if ($skipped) {
echo '<span class="skipped">' . get_string('skipped') . ' ' . $cm->modname . '</span>';
} else {
echo '<span class="failure">' . get_string('fail', 'install') . ' ' . $cm->modname . '</span>';
}
}
echo '</td><td class="itemvalue">';
$url = $PAGE->theme->pix_url('icon', $cm->modname)->out();
echo '<img src="' . $url . '" class="icon" title="' . s(get_string('modulename', $cm->modname)) . '"></img> ';
$name = urldecode($cm->name);
$name = block_taskchain_navigation::filter_text($name);