本文整理汇总了PHP中assign_reset_gradebook函数的典型用法代码示例。如果您正苦于以下问题:PHP assign_reset_gradebook函数的具体用法?PHP assign_reset_gradebook怎么用?PHP assign_reset_gradebook使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assign_reset_gradebook函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reset_userdata
/**
* Actual implementation of the reset course functionality, delete all the
* assignment submissions for course $data->courseid.
*
* @param stdClass $data the data submitted from the reset course.
* @return array status array
*/
public function reset_userdata($data)
{
global $CFG, $DB;
$componentstr = get_string('modulenameplural', 'assign');
$status = array();
$fs = get_file_storage();
if (!empty($data->reset_assign_submissions)) {
// Delete files associated with this assignment.
foreach ($this->submissionplugins as $plugin) {
$fileareas = array();
$plugincomponent = $plugin->get_subtype() . '_' . $plugin->get_type();
$fileareas = $plugin->get_file_areas();
foreach ($fileareas as $filearea) {
$fs->delete_area_files($this->context->id, $plugincomponent, $filearea);
}
if (!$plugin->delete_instance()) {
$status[] = array('component' => $componentstr, 'item' => get_string('deleteallsubmissions', 'assign'), 'error' => $plugin->get_error());
}
}
foreach ($this->feedbackplugins as $plugin) {
$fileareas = array();
$plugincomponent = $plugin->get_subtype() . '_' . $plugin->get_type();
$fileareas = $plugin->get_file_areas();
foreach ($fileareas as $filearea) {
$fs->delete_area_files($this->context->id, $plugincomponent, $filearea);
}
if (!$plugin->delete_instance()) {
$status[] = array('component' => $componentstr, 'item' => get_string('deleteallsubmissions', 'assign'), 'error' => $plugin->get_error());
}
}
$assignssql = 'SELECT a.id
FROM {assign} a
WHERE a.course=:course';
$params = array('course' => $data->courseid);
$DB->delete_records_select('assign_submission', "assignment IN ({$assignssql})", $params);
$status[] = array('component' => $componentstr, 'item' => get_string('deleteallsubmissions', 'assign'), 'error' => false);
if (!empty($data->reset_gradebook_grades)) {
$DB->delete_records_select('assign_grades', "assignment IN ({$assignssql})", $params);
// Remove all grades from gradebook.
require_once $CFG->dirroot . '/mod/assign/lib.php';
assign_reset_gradebook($data->courseid);
}
}
// Updating dates - shift may be negative too.
if ($data->timeshift) {
shift_course_mod_dates('assign', array('duedate', 'allowsubmissionsfromdate', 'cutoffdate'), $data->timeshift, $data->courseid, $this->get_instance()->id);
$status[] = array('component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false);
}
return $status;
}
示例2: reset_userdata
/**
* Actual implementation of the reset course functionality, delete all the
* assignment submissions for course $data->courseid.
*
* @param stdClass $data the data submitted from the reset course.
* @return array status array
*/
public function reset_userdata($data)
{
global $CFG, $DB;
$componentstr = get_string('modulenameplural', 'assign');
$status = array();
$fs = get_file_storage();
if (!empty($data->reset_assign_submissions)) {
// Delete files associated with this assignment.
foreach ($this->submissionplugins as $plugin) {
$fileareas = array();
$plugincomponent = $plugin->get_subtype() . '_' . $plugin->get_type();
$fileareas = $plugin->get_file_areas();
foreach ($fileareas as $filearea => $notused) {
$fs->delete_area_files($this->context->id, $plugincomponent, $filearea);
}
if (!$plugin->delete_instance()) {
$status[] = array('component' => $componentstr, 'item' => get_string('deleteallsubmissions', 'assign'), 'error' => $plugin->get_error());
}
}
foreach ($this->feedbackplugins as $plugin) {
$fileareas = array();
$plugincomponent = $plugin->get_subtype() . '_' . $plugin->get_type();
$fileareas = $plugin->get_file_areas();
foreach ($fileareas as $filearea => $notused) {
$fs->delete_area_files($this->context->id, $plugincomponent, $filearea);
}
if (!$plugin->delete_instance()) {
$status[] = array('component' => $componentstr, 'item' => get_string('deleteallsubmissions', 'assign'), 'error' => $plugin->get_error());
}
}
$assignids = $DB->get_records('assign', array('course' => $data->courseid), '', 'id');
list($sql, $params) = $DB->get_in_or_equal(array_keys($assignids));
$DB->delete_records_select('assign_submission', "assignment {$sql}", $params);
$DB->delete_records_select('assign_user_flags', "assignment {$sql}", $params);
$status[] = array('component' => $componentstr, 'item' => get_string('deleteallsubmissions', 'assign'), 'error' => false);
if (!empty($data->reset_gradebook_grades)) {
$DB->delete_records_select('assign_grades', "assignment {$sql}", $params);
// Remove all grades from gradebook.
require_once $CFG->dirroot . '/mod/assign/lib.php';
assign_reset_gradebook($data->courseid);
// Reset revealidentities if both submissions and grades have been reset.
if ($this->get_instance()->blindmarking && $this->get_instance()->revealidentities) {
$DB->set_field('assign', 'revealidentities', 0, array('id' => $this->get_instance()->id));
}
}
}
// Updating dates - shift may be negative too.
if ($data->timeshift) {
shift_course_mod_dates('assign', array('duedate', 'allowsubmissionsfromdate', 'cutoffdate'), $data->timeshift, $data->courseid, $this->get_instance()->id);
$status[] = array('component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false);
}
return $status;
}