本文整理汇总了PHP中assign::update_gradebook方法的典型用法代码示例。如果您正苦于以下问题:PHP assign::update_gradebook方法的具体用法?PHP assign::update_gradebook怎么用?PHP assign::update_gradebook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assign
的用法示例。
在下文中一共展示了assign::update_gradebook方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_dates
public function save_dates(cm_info $cm, array $dates)
{
global $DB, $COURSE;
$update = new stdClass();
$update->id = $cm->instance;
$update->duedate = $dates['duedate'];
$update->allowsubmissionsfromdate = $dates['allowsubmissionsfromdate'];
$update->cutoffdate = $dates['cutoffdate'];
$result = $DB->update_record('assign', $update);
$module = new assign(context_module::instance($cm->id), null, null);
// Update the calendar and grades.
$module->update_calendar($cm->id);
$module->update_gradebook(false, $cm->id);
}
示例2: upgrade_assignment
//.........这里部分代码省略.........
$submission->timecreated = $oldsubmission->timecreated;
$submission->timemodified = $oldsubmission->timemodified;
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
$submission->id = $DB->insert_record('assign_submission', $submission);
if (!$submission->id) {
$log .= get_string('couldnotinsertsubmission', 'mod_assign', $submission->userid);
$rollback = true;
}
foreach ($newassignment->get_submission_plugins() as $plugin) {
if ($plugin->can_upgrade($oldassignment->assignmenttype, $oldversion)) {
if (!$plugin->upgrade($oldcontext, $oldassignment, $oldsubmission, $submission, $log)) {
$rollback = true;
}
}
}
if ($oldsubmission->timemarked) {
// submission has been graded - create a grade record
$grade = new stdClass();
$grade->assignment = $newassignment->get_instance()->id;
$grade->userid = $oldsubmission->userid;
$grade->grader = $oldsubmission->teacher;
$grade->timemodified = $oldsubmission->timemarked;
$grade->timecreated = $oldsubmission->timecreated;
// $grade->locked = $oldsubmission->locked;
$grade->grade = $oldsubmission->grade;
$grade->mailed = $oldsubmission->mailed;
$grade->id = $DB->insert_record('assign_grades', $grade);
if (!$grade->id) {
$log .= get_string('couldnotinsertgrade', 'mod_assign', $grade->userid);
$rollback = true;
}
// copy any grading instances
if ($gradingarea) {
$gradeidmap[$grade->id] = $oldsubmission->id;
foreach ($gradingdefinitions as $definition) {
$DB->set_field('grading_instances', 'itemid', $grade->id, array('definitionid'=>$definition->id, 'itemid'=>$oldsubmission->id));
}
}
foreach ($newassignment->get_feedback_plugins() as $plugin) {
if ($plugin->can_upgrade($oldassignment->assignmenttype, $oldversion)) {
if (!$plugin->upgrade($oldcontext, $oldassignment, $oldsubmission, $grade, $log)) {
$rollback = true;
}
}
}
}
}
$newassignment->update_calendar($newcoursemodule->id);
$newassignment->update_gradebook(false,$newcoursemodule->id);
// copy the grades from the old assignment to the new one
$DB->set_field('grade_items', 'itemmodule', 'assign', array('iteminstance'=>$oldassignment->id));
$DB->set_field('grade_items', 'iteminstance', $newassignment->get_instance()->id, array('iteminstance'=>$oldassignment->id));
$gradesdone = true;
} catch (Exception $exception) {
$rollback = true;
$log .= get_string('conversionexception', 'mod_assign', $exception->error);
}
if ($rollback) {
// roll back the grades changes
if ($gradesdone) {
// copy the grades from the old assignment to the new one
$DB->set_field('grade_items', 'itemmodule', 'assignment', array('iteminstance'=>$newassignment->get_instance()->id));
$DB->set_field('grade_items', 'iteminstance', $oldassignment->id, array('iteminstance'=>$newassignment->get_instance()->id));
}
// roll back the completion changes
if ($completiondone) {
$DB->set_field('course_modules_completion', 'coursemoduleid', $oldcoursemodule->id, array('coursemoduleid'=>$newcoursemodule->id));
$DB->set_field('course_completion_criteria', 'module', 'assignment', array('moduleinstance'=>$newcoursemodule->id));
$DB->set_field('course_completion_criteria', 'moduleinstance', $oldcoursemodule->id, array('moduleinstance'=>$newcoursemodule->id));
}
// roll back the advanced grading update
if ($gradingarea) {
foreach ($gradeidmap as $newgradeid => $oldsubmissionid) {
foreach ($gradingdefinitions as $definition) {
$DB->set_field('grading_instances', 'itemid', $oldsubmissionid, array('definitionid'=>$definition->id, 'itemid'=>$newgradeid));
}
}
$DB->update_record('grading_areas', array('id'=>$gradingarea->id, 'contextid'=>$oldcontext->id, 'component'=>'mod_assignment', 'areaname'=>'submission'));
}
$newassignment->delete_instance();
return false;
}
// all is well,
// delete the old assignment (use object delete)
$cm = get_coursemodule_from_id('', $oldcoursemodule->id, $oldcoursemodule->course);
if ($cm) {
$this->delete_course_module($cm);
}
rebuild_course_cache($oldcoursemodule->course);
return true;
}