Permalink
Browse files

MDL-34794 mod_assign: Fixed up style after integration

  • Loading branch information...
1 parent f28896b commit 20b133e7a31dadc4d26bb16bfab86881a15b20f2 Sam Hemelryk committed Sep 10, 2012
Showing with 37 additions and 34 deletions.
  1. +14 −9 mod/assign/lib.php
  2. +23 −25 mod/assign/locallib.php
View
23 mod/assign/lib.php
@@ -56,20 +56,22 @@ function assign_delete_instance($id) {
/**
* This function is used by the reset_course_userdata function in moodlelib.
+ *
* This function will remove all assignment submissions and feedbacks in the database
* and clean up any related data.
- * @param $data the data submitted from the reset course.
+ *
+ * @param stdClass $data the data submitted from the reset course.
* @return array status array
*/
function assign_reset_userdata($data) {
global $CFG, $DB;
require_once($CFG->dirroot . '/mod/assign/locallib.php');
$status = array();
- $params = array('courseid'=>$data->courseid);
- $sql = "SELECT a.id FROM {assign} a WHERE a.course=:courseid";
- $course = $DB->get_record('course', array('id'=> $data->courseid), '*', MUST_EXIST);
- if ($assigns = $DB->get_records_sql($sql,$params)) {
+ $params = array('courseid' => $data->courseid);
+ $sql = "SELECT a.id FROM {assign} a WHERE a.course = :courseid";
+ $course = $DB->get_record('course', array('id' => $data->courseid), '*', MUST_EXIST);
+ if ($assigns = $DB->get_records_sql($sql, $params)) {
foreach ($assigns as $assign) {
$cm = get_coursemodule_from_instance('assign', $assign->id, $data->courseid, false, MUST_EXIST);
$context = context_module::instance($cm->id);
@@ -87,12 +89,15 @@ function assign_reset_userdata($data) {
* @param string $type Optional type of assignment to limit the reset to a particular assignment type
*/
function assign_reset_gradebook($courseid, $type='') {
- global $CFG, $DB;
+ global $DB;
$params = array('moduletype'=>'assign','courseid'=>$courseid);
$sql = 'SELECT a.*, cm.idnumber as cmidnumber, a.course as courseid
- FROM {assign} a, {course_modules} cm, {modules} m
- WHERE m.name=:moduletype AND m.id=cm.module AND cm.instance=a.id AND a.course=:courseid';
+ FROM {assign} a, {course_modules} cm, {modules} m
+ WHERE m.name = :moduletype
+ AND m.id = cm.module
+ AND cm.instance = a.id
+ AND a.course = :courseid';
if ($assignments = $DB->get_records_sql($sql,$params)) {
foreach ($assignments as $assignment) {
@@ -104,7 +109,7 @@ function assign_reset_gradebook($courseid, $type='') {
/**
* Implementation of the function for printing the form elements that control
* whether the course reset functionality affects the assignment.
- * @param $mform form passed by reference
+ * @param moodleform $mform form passed by reference
*/
function assign_reset_course_form_definition(&$mform) {
$mform->addElement('header', 'assignheader', get_string('modulenameplural', 'assign'));
View
48 mod/assign/locallib.php
@@ -549,12 +549,12 @@ public function delete_instance() {
}
/**
- * Actual implementation of the reset course functionality, delete all the
- * assignment submissions for course $data->courseid.
- *
- * @param $data the data submitted from the reset course.
- * @return array status array
- */
+ * 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;
@@ -565,42 +565,40 @@ public function reset_userdata($data) {
if (!empty($data->reset_assign_submissions)) {
// Delete files associated with this assignment.
foreach ($this->submissionplugins as $plugin) {
- $fileareas = array();
$fileareas = $plugin->get_file_areas();
foreach ($fileareas as $filearea) {
- $fs->delete_area_files($this->context->id,'mod_assign', $filearea);
+ $fs->delete_area_files($this->context->id, 'mod_assign', $filearea);
}
if (!$plugin->delete_instance()) {
- $status[] = array('component'=>$componentstr,
- 'item'=>get_string('deleteallsubmissions','assign'),
- 'error'=>$plugin->get_error());
+ $status[] = array('component' => $componentstr,
+ 'item' => get_string('deleteallsubmissions', 'assign'),
+ 'error' => $plugin->get_error());
}
}
foreach ($this->feedbackplugins as $plugin) {
- $fileareas = array();
$fileareas = $plugin->get_file_areas();
foreach ($fileareas as $filearea) {
- $fs->delete_area_files($this->context->id,'mod_assign', $filearea);
+ $fs->delete_area_files($this->context->id, 'mod_assign', $filearea);
}
if (!$plugin->delete_instance()) {
- $status[] = array('component'=>$componentstr,
- 'item'=>get_string('deleteallsubmissions','assign'),
- 'error'=>$plugin->get_error());
+ $status[] = array('component' => $componentstr,
+ 'item' => get_string('deleteallsubmissions', 'assign'),
+ 'error' => $plugin->get_error());
}
}
$assignssql = "SELECT a.id
FROM {assign} a
- WHERE a.course=:course";
+ 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);
+ $status[] = array('component' => $componentstr,
+ 'item' => get_string('deleteallsubmissions', 'assign'),
+ 'error' => false);
if (empty($data->reset_gradebook_grades)) {
// Remove all grades from gradebook.
@@ -610,10 +608,10 @@ public function reset_userdata($data) {
}
// Updating dates - shift may be negative too.
if ($data->timeshift) {
- shift_course_mod_dates('assign', array('duedate', 'allowsubmissionsfromdate','cutoffdate'), $data->timeshift, $data->courseid);
- $status[] = array('component'=>$componentstr,
- 'item'=>get_string('datechanged'),
- 'error'=>false);
+ shift_course_mod_dates('assign', array('duedate', 'allowsubmissionsfromdate', 'cutoffdate'), $data->timeshift, $data->courseid);
+ $status[] = array('component' => $componentstr,
+ 'item' => get_string('datechanged'),
+ 'error' => false);
}
return $status;
@@ -3940,7 +3938,7 @@ public function add_submission_form_elements(MoodleQuickForm $mform, stdClass $d
* @return void
*/
private function process_revert_to_draft($userid = 0) {
- global $DB;
+ global $DB, $USER;
// Need grade permission
require_capability('mod/assign:grade', $this->context);

0 comments on commit 20b133e

Please sign in to comment.