MDL-37148 assign: codechecker cleanups
authorDamyon Wiese <damyon@moodle.com>
Fri, 13 Sep 2013 03:50:00 +0000 (11:50 +0800)
committerDamyon Wiese <damyon@moodle.com>
Fri, 13 Sep 2013 05:30:02 +0000 (13:30 +0800)
mod/assign/externallib.php
mod/assign/feedback/file/locallib.php
mod/assign/lib.php
mod/assign/locallib.php
mod/assign/submission/file/locallib.php
mod/assign/tests/externallib_test.php

index 09db0b8..18531bd 100644 (file)
@@ -1528,7 +1528,14 @@ class mod_assign_external extends external_api {
      * @return null
      * @since Moodle 2.6
      */
-    public static function save_grade($assignmentid, $userid, $grade, $attemptnumber, $addattempt, $workflowstate, $applytoall, $plugindata) {
+    public static function save_grade($assignmentid,
+                                      $userid,
+                                      $grade,
+                                      $attemptnumber,
+                                      $addattempt,
+                                      $workflowstate,
+                                      $applytoall,
+                                      $plugindata) {
         global $CFG, $USER;
         require_once("$CFG->dirroot/mod/assign/locallib.php");
 
index c537a43..b4db0ae 100644 (file)
@@ -616,7 +616,12 @@ class assign_feedback_file extends assign_feedback_plugin {
      * @return external_description|null
      */
     public function get_external_parameters() {
-        return array('files_filemanager' => new external_value(PARAM_INT, 'The id of a draft area containing files for this feedback.'));
+        return array(
+            'files_filemanager' => new external_value(
+                PARAM_INT,
+                'The id of a draft area containing files for this feedback.'
+            )
+        );
     }
 
 }
index 49a13f1..65e5cc2 100644 (file)
@@ -280,11 +280,11 @@ function assign_get_coursemodule_info($coursemodule) {
  * @param stdClass $currentcontext Current context of block
  */
 function assign_page_type_list($pagetype, $parentcontext, $currentcontext) {
-    $module_pagetype = array(
+    $modulepagetype = array(
         'mod-assign-*' => get_string('page-mod-assign-x', 'assign'),
         'mod-assign-view' => get_string('page-mod-assign-view', 'assign'),
     );
-    return $module_pagetype;
+    return $modulepagetype;
 }
 
 /**
@@ -656,10 +656,10 @@ function assign_get_recent_mod_activity(&$activities,
     }
 
     $groupmode       = groups_get_activity_groupmode($cm, $course);
-    $cm_context      = context_module::instance($cm->id);
-    $grader          = has_capability('moodle/grade:viewall', $cm_context);
-    $accessallgroups = has_capability('moodle/site:accessallgroups', $cm_context);
-    $viewfullnames   = has_capability('moodle/site:viewfullnames', $cm_context);
+    $cmcontext      = context_module::instance($cm->id);
+    $grader          = has_capability('moodle/grade:viewall', $cmcontext);
+    $accessallgroups = has_capability('moodle/site:accessallgroups', $cmcontext);
+    $viewfullnames   = has_capability('moodle/site:viewfullnames', $cmcontext);
 
     if (is_null($modinfo->get_groups())) {
         // Load all my groups and cache it in modinfo.
index f4eb9c5..30bd6dc 100644 (file)
@@ -2003,10 +2003,10 @@ class assign {
                     $submitted = get_string('submissionstatus_', 'assign');
                 }
             }
-            $grading_info = grade_get_grades($course->id, 'mod', 'assign', $cm->instance, $USER->id);
-            if (isset($grading_info->items[0]->grades[$USER->id]) &&
-                    !$grading_info->items[0]->grades[$USER->id]->hidden ) {
-                $grade = $grading_info->items[0]->grades[$USER->id]->str_grade;
+            $gradinginfo = grade_get_grades($course->id, 'mod', 'assign', $cm->instance, $USER->id);
+            if (isset($gradinginfo->items[0]->grades[$USER->id]) &&
+                    !$gradinginfo->items[0]->grades[$USER->id]->hidden ) {
+                $grade = $gradinginfo->items[0]->grades[$USER->id]->str_grade;
             } else {
                 $grade = '-';
             }
@@ -3651,7 +3651,8 @@ class assign {
                 // Only show the grade if it is not hidden in gradebook.
                 if (!empty($gradebookgrade->grade) && ($cangrade || !$gradebookgrade->hidden)) {
                     if ($controller = $gradingmanager->get_active_controller()) {
-                        $controller->set_grade_range(make_grades_menu($this->get_instance()->grade), $this->get_instance()->grade > 0);
+                        $menu = make_grades_menu($this->get_instance()->grade);
+                        $controller->set_grade_range($menu, $this->get_instance()->grade > 0);
                         $gradefordisplay = $controller->render_grade($PAGE,
                                                                      $grade->id,
                                                                      $gradingitem,
@@ -6023,7 +6024,6 @@ class assign {
             }
         }
 
-
         $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
 
         $logmessage = get_string('unlocksubmissionforstudent',
index f981aa3..7b8facb 100644 (file)
@@ -484,6 +484,11 @@ class assign_submission_file extends assign_submission_plugin {
      * @return external_description|null
      */
     public function get_external_parameters() {
-        return array('files_filemanager' => new external_value(PARAM_INT, 'The id of a draft area containing files for this submission.'));
+        return array(
+            'files_filemanager' => new external_value(
+                PARAM_INT,
+                'The id of a draft area containing files for this submission.'
+            )
+        );
     }
 }
index 31a13d3..aeb0cb3 100644 (file)
@@ -481,7 +481,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
         $plugin = $assign->get_submission_plugin_by_type('onlinetext');
         $plugin->save($submission, $data);
 
-        // Ready to test
+        // Ready to test.
         $this->setUser($teacher);
         $students = array($student1->id, $student2->id);
         $result = mod_assign_external::lock_submissions($instance->id, $students);
@@ -545,7 +545,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
         $plugin = $assign->get_submission_plugin_by_type('onlinetext');
         $plugin->save($submission, $data);
 
-        // Ready to test
+        // Ready to test.
         $this->setUser($teacher);
         $students = array($student1->id, $student2->id);
         $result = mod_assign_external::lock_submissions($instance->id, $students);
@@ -786,7 +786,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
         $result = mod_assign_external::submit_for_grading($instance->id);
         $this->assertEquals(0, count($result));
 
-        // Ready to test
+        // Ready to test.
         $this->setUser($teacher);
         $students = array($student1->id, $student2->id);
         $result = mod_assign_external::revert_submissions_to_draft($instance->id, array($student1->id));
@@ -868,7 +868,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
 
         $fs->create_file_from_string($filerecord, 'image contents (not really)');
 
-        // Now try a submission
+        // Now try a submission.
         $submissionpluginparams = array();
         $submissionpluginparams['files_filemanager'] = $draftidfile;
         $onlinetexteditorparams = array('text'=>'Yeeha!',
@@ -936,13 +936,20 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
         $fs = get_file_storage();
         $fs->create_file_from_string($filerecord, 'text contents');
 
-        // Now try a grade
+        // Now try a grade.
         $feedbackpluginparams = array();
         $feedbackpluginparams['files_filemanager'] = $draftidfile;
         $feedbackeditorparams = array('text'=>'Yeeha!',
                                         'format'=>1);
         $feedbackpluginparams['assignfeedbackcomments_editor'] = $feedbackeditorparams;
-        $result = mod_assign_external::save_grade($instance->id, $student1->id, 50.0, -1, true, 'released', false, $feedbackpluginparams);
+        $result = mod_assign_external::save_grade($instance->id,
+                                                  $student1->id,
+                                                  50.0,
+                                                  -1,
+                                                  true,
+                                                  'released',
+                                                  false,
+                                                  $feedbackpluginparams);
 
         // No warnings.
         $this->assertEquals(0, count($result));
@@ -950,7 +957,6 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
         $result = mod_assign_external::get_grades(array($instance->id));
 
         $this->assertEquals($result['assignments'][0]['grades'][0]['grade'], '50.0');
-
     }
 
     /**
@@ -988,7 +994,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
         $this->getDataGenerator()->enrol_user($student1->id,
                                               $course->id,
                                               $studentrole->id);
-        // Now try a submission
+        // Now try a submission.
         $this->setUser($student1);
         $draftidonlinetext = file_get_unused_draft_itemid();
         $submissionpluginparams = array();
@@ -1001,13 +1007,20 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
 
         $this->setUser($teacher);
         // Add a grade and reopen the attempt.
-        // Now try a grade
+        // Now try a grade.
         $feedbackpluginparams = array();
         $feedbackpluginparams['files_filemanager'] = file_get_unused_draft_itemid();
         $feedbackeditorparams = array('text'=>'Yeeha!',
                                         'format'=>1);
         $feedbackpluginparams['assignfeedbackcomments_editor'] = $feedbackeditorparams;
-        $result = mod_assign_external::save_grade($instance->id, $student1->id, 50.0, -1, true, 'released', false, $feedbackpluginparams);
+        $result = mod_assign_external::save_grade($instance->id,
+                                                  $student1->id,
+                                                  50.0,
+                                                  -1,
+                                                  true,
+                                                  'released',
+                                                  false,
+                                                  $feedbackpluginparams);
 
         $this->setUser($student1);
         // Now copy the previous attempt.