Merge branch 'MDL-40472-master' of git://github.com/damyon/moodle
authorMarina Glancy <marina@moodle.com>
Tue, 9 Jul 2013 11:34:49 +0000 (21:34 +1000)
committerMarina Glancy <marina@moodle.com>
Tue, 9 Jul 2013 11:34:49 +0000 (21:34 +1000)
14 files changed:
mod/assign/backup/moodle2/backup_assign_stepslib.php
mod/assign/batchsetmarkingworkflowstateform.php
mod/assign/db/upgrade.php
mod/assign/feedback/comments/db/upgrade.php
mod/assign/feedback/file/db/upgrade.php
mod/assign/gradingoptionsform.php
mod/assign/gradingtable.php
mod/assign/locallib.php
mod/assign/settings.php
mod/assign/submission/comments/db/upgrade.php
mod/assign/submission/file/db/upgrade.php
mod/assign/submission/onlinetext/db/upgrade.php
mod/assign/tests/externallib_test.php
mod/assign/tests/locallib_test.php

index fdbe03f..0373e33 100644 (file)
@@ -68,7 +68,6 @@ class backup_assign_activity_structure_step extends backup_activity_structure_st
                                                   'markingworkflow',
                                                   'markingallocation'));
 
-
         $userflags = new backup_nested_element('userflags');
 
         $userflag = new backup_nested_element('userflag', array('id'),
index 419cab7..690cae6 100644 (file)
@@ -41,8 +41,9 @@ class mod_assign_batch_set_marking_workflow_state_form extends moodleform {
     public function definition() {
         $mform = $this->_form;
         $params = $this->_customdata;
+        $formheader = get_string('batchsetmarkingworkflowstateforusers', 'assign', count($params['users']));
 
-        $mform->addElement('header', 'general', get_string('batchsetmarkingworkflowstateforusers', 'assign', count($params['users'])));
+        $mform->addElement('header', 'general', $formheader);
         $mform->addElement('static', 'userslist', get_string('selectedusers', 'assign'), $params['usershtml']);
 
         $options = $params['markingworkflowstates'];
index 5990ad1..1b6d1df 100644 (file)
@@ -221,7 +221,8 @@ function xmldb_assign_upgrade($oldversion) {
         if (!$dbman->field_exists($table, $field)) {
             // OK safe to cleanup duplicates here.
 
-            $sql = 'SELECT assignment, userid, groupid from {assign_submission} GROUP BY assignment, userid, groupid HAVING (count(id) > 1)';
+            $sql = 'SELECT assignment, userid, groupid from {assign_submission} ' .
+                   'GROUP BY assignment, userid, groupid HAVING (count(id) > 1)';
             $badrecords = $DB->get_recordset_sql($sql);
 
             foreach ($badrecords as $badrecord) {
@@ -425,11 +426,11 @@ function xmldb_assign_upgrade($oldversion) {
     // Put any upgrade step following this.
 
     if ($oldversion < 2013061101) {
-        // Define field markingworkflow to be added to assign
+        // Define field markingworkflow to be added to assign.
         $table = new xmldb_table('assign');
         $field = new xmldb_field('markingworkflow', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'maxattempts');
 
-        // Conditionally launch add field markingworkflow
+        // Conditionally launch add field markingworkflow.
         if (!$dbman->field_exists($table, $field)) {
             $dbman->add_field($table, $field);
         }
@@ -440,18 +441,18 @@ function xmldb_assign_upgrade($oldversion) {
             $dbman->add_field($table, $field);
         }
 
-        // Define field workflowstate to be added to assign_grades
+        // Define field workflowstate to be added to assign_grades.
         $table = new xmldb_table('assign_user_flags');
         $field = new xmldb_field('workflowstate', XMLDB_TYPE_CHAR, '20', null, null, null, null, 'extensionduedate');
 
-        // Conditionally launch add field workflowstate
+        // Conditionally launch add field workflowstate.
         if (!$dbman->field_exists($table, $field)) {
             $dbman->add_field($table, $field);
         }
 
         // Define field allocatedmarker to be added to assign_grades.
         $field = new xmldb_field('allocatedmarker', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'workflowstate');
-        // Conditionally launch add field workflowstate
+        // Conditionally launch add field workflowstate.
         if (!$dbman->field_exists($table, $field)) {
             $dbman->add_field($table, $field);
         }
index baae3fb..bf168d3 100644 (file)
@@ -38,8 +38,5 @@ function xmldb_assignfeedback_comments_upgrade($oldversion) {
     // Moodle v2.5.0 release upgrade line.
     // Put any upgrade step following this.
 
-
     return true;
 }
-
-
index 4f5f0b9..ea28a66 100644 (file)
@@ -38,8 +38,5 @@ function xmldb_assignfeedback_file_upgrade($oldversion) {
     // Moodle v2.5.0 release upgrade line.
     // Put any upgrade step following this.
 
-
     return true;
 }
-
-
index 8596aa7..e417f08 100644 (file)
@@ -55,10 +55,12 @@ class mod_assign_grading_options_form extends moodleform {
             $mform->addElement('select', 'filter', get_string('filter', 'assign'), $options, $dirtyclass);
         }
         if (!empty($instance['markingallocationopt'])) {
-            $mform->addElement('select', 'markerfilter', get_string('markerfilter', 'assign'), $instance['markingallocationopt'], $dirtyclass);
+            $markingfilter = get_string('markerfilter', 'assign');
+            $mform->addElement('select', 'markerfilter', $markingfilter, $instance['markingallocationopt'], $dirtyclass);
         }
         if (!empty($instance['markingworkflowopt'])) {
-            $mform->addElement('select', 'workflowfilter', get_string('workflowfilter', 'assign'), $instance['markingworkflowopt'], $dirtyclass);
+            $workflowfilter = get_string('workflowfilter', 'assign');
+            $mform->addElement('select', 'workflowfilter', $workflowfilter, $instance['markingworkflowopt'], $dirtyclass);
         }
         // Quickgrading.
         if ($instance['showquickgrading']) {
index 6703422..ed7974d 100644 (file)
@@ -187,7 +187,7 @@ class assign_grading_table extends table_sql implements renderable {
 
         if ($this->assignment->get_instance()->markingallocation) {
             if (has_capability('mod/assign:manageallocations', $this->assignment->get_context())) {
-                //Check to see if marker filter is set
+                // Check to see if marker filter is set.
                 $markerfilter = (int)get_user_preferences('assign_markerfilter', '');
                 if (!empty($markerfilter)) {
                     $where .= ' AND uf.allocatedmarker = :markerid';
@@ -203,15 +203,13 @@ class assign_grading_table extends table_sql implements renderable {
             $workflowstates = $this->assignment->get_marking_workflow_states_for_current_user();
             if (!empty($workflowstates)) {
                 $workflowfilter = get_user_preferences('assign_workflowfilter', '');
-                if (array_key_exists($workflowfilter, $workflowstates) || $workflowfilter == ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED) {
-                    if ($workflowfilter == ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED) {
-                        $where .= ' AND (uf.workflowstate = :workflowstate OR uf.workflowstate IS NULL OR '.
-                            $DB->sql_isempty('assign_user_flags', 'workflowstate', true, true).')';
-                        $params['workflowstate'] = $workflowfilter;
-                    } else {
-                        $where .= ' AND uf.workflowstate = :workflowstate';
-                        $params['workflowstate'] = $workflowfilter;
-                    }
+                if ($workflowfilter == ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED) {
+                    $where .= ' AND (uf.workflowstate = :workflowstate OR uf.workflowstate IS NULL OR '.
+                        $DB->sql_isempty('assign_user_flags', 'workflowstate', true, true).')';
+                    $params['workflowstate'] = $workflowfilter;
+                } else if (array_key_exists($workflowfilter, $workflowstates)) {
+                    $where .= ' AND uf.workflowstate = :workflowstate';
+                    $params['workflowstate'] = $workflowfilter;
                 }
             }
         }
@@ -274,7 +272,7 @@ class assign_grading_table extends table_sql implements renderable {
             $columns[] = 'teamstatus';
             $headers[] = get_string('teamsubmissionstatus', 'assign');
         }
-        //allocated marker
+        // Allocated marker.
         if ($this->assignment->get_instance()->markingallocation &&
             has_capability('mod/assign:manageallocations', $this->assignment->get_context())) {
             // Add a column for the allocated marker.
@@ -482,8 +480,9 @@ class assign_grading_table extends table_sql implements renderable {
                 $workflowstate = ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED;
             }
             if ($this->quickgrading && !$gradingdisabled) {
+                $notmarked = get_string('markingworkflowstatenotmarked', 'assign');
                 $name = 'quickgrade_' . $row->id . '_workflowstate';
-                $o .= html_writer::select($workflowstates, $name, $workflowstate, array('' => get_string('markingworkflowstatenotmarked', 'assign')));
+                $o .= html_writer::select($workflowstates, $name, $workflowstate, array('' => $notmarked));
                 // Check if this user is a marker that can't manage allocations and doesn't have the marker column added.
                 if ($this->assignment->get_instance()->markingallocation &&
                     !has_capability('mod/assign:manageallocations', $this->assignment->get_context())) {
@@ -519,7 +518,7 @@ class assign_grading_table extends table_sql implements renderable {
      * @param stdClass $row - The row of data
      * @return id the user->id of the marker.
      */
-    function col_allocatedmarker(stdClass $row) {
+    public function col_allocatedmarker(stdClass $row) {
         static $markers = null;
         static $markerlist = array();
         if ($markers === null) {
index efddb10..3d722a6 100644 (file)
@@ -2921,8 +2921,9 @@ class assign {
         // Get marking states to show in form.
         $markingworkflowoptions = array();
         if ($markingworkflow) {
+            $notmarked = get_string('markingworkflowstatenotmarked', 'assign');
             $markingworkflowoptions[''] = get_string('filternone', 'assign');
-            $markingworkflowoptions[ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED] = get_string('markingworkflowstatenotmarked', 'assign');
+            $markingworkflowoptions[ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED] = $notmarked;
             $markingworkflowoptions = array_merge($markingworkflowoptions, $this->get_marking_workflow_states_for_current_user());
         }
 
@@ -4817,8 +4818,9 @@ class assign {
         // Get marking states to show in form.
         $markingworkflowoptions = array();
         if ($this->get_instance()->markingworkflow) {
+            $notmarked = get_string('markingworkflowstatenotmarked', 'assign');
             $markingworkflowoptions[''] = get_string('filternone', 'assign');
-            $markingworkflowoptions[ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED] = get_string('markingworkflowstatenotmarked', 'assign');
+            $markingworkflowoptions[ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED] = $notmarked
             $markingworkflowoptions = array_merge($markingworkflowoptions, $this->get_marking_workflow_states_for_current_user());
         }
 
@@ -5299,7 +5301,8 @@ class assign {
         }
 
         if ($this->get_instance()->markingworkflow) {
-            $options = array('' => get_string('markingworkflowstatenotmarked', 'assign')) + $this->get_marking_workflow_states_for_current_user();
+            $states = $this->get_marking_workflow_states_for_current_user();
+            $options = array('' => get_string('markingworkflowstatenotmarked', 'assign')) + $states;
             $mform->addElement('select', 'workflowstate', get_string('markingworkflowstate', 'assign'), $options);
             $mform->addHelpButton('workflowstate', 'markingworkflowstate', 'assign');
         }
@@ -5648,8 +5651,6 @@ class assign {
                 $this->add_to_log('set marking workflow state', $message);
             }
         }
-
-
     }
 
     /**
@@ -5692,8 +5693,6 @@ class assign {
                 $this->add_to_log('set marking allocation', $message);
             }
         }
-
-
     }
 
 
index 135fc90..bc8c1c3 100644 (file)
@@ -35,7 +35,6 @@ $ADMIN->add('assignmentplugins', new admin_category('assignfeedbackplugins',
                 new lang_string('feedbackplugins', 'assign'), $module->is_enabled() === false));
 $ADMIN->add('assignfeedbackplugins', new assign_admin_page_manage_assign_plugins('assignfeedback'));
 
-
 assign_plugin_manager::add_admin_assign_plugin_settings('assignsubmission', $ADMIN, $settings, $module);
 assign_plugin_manager::add_admin_assign_plugin_settings('assignfeedback', $ADMIN, $settings, $module);
 
@@ -143,7 +142,7 @@ if ($ADMIN->fulltree) {
     $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
     $settings->add($setting);
 
-    // Constants from locallib.php
+    // Constants from "locallib.php".
     $options = array(
         'none' => get_string('attemptreopenmethod_none', 'mod_assign'),
         'manual' => get_string('attemptreopenmethod_manual', 'mod_assign'),
@@ -160,7 +159,7 @@ if ($ADMIN->fulltree) {
     $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
     $settings->add($setting);
 
-    // Constants from locallib.php
+    // Constants from "locallib.php".
     $options = array(-1 => get_string('unlimitedattempts', 'mod_assign'));
     $options += array_combine(range(1, 30), range(1, 30));
     $name = new lang_string('maxattempts', 'mod_assign');
index b6c05c0..0d2eeac 100644 (file)
@@ -37,7 +37,6 @@ function xmldb_assignsubmission_comments_upgrade($oldversion) {
     // Moodle v2.5.0 release upgrade line.
     // Put any upgrade step following this.
 
-
     return true;
 }
 
index e5c8f26..214b68e 100644 (file)
@@ -35,7 +35,6 @@ function xmldb_assignsubmission_file_upgrade($oldversion) {
     // Moodle v2.5.0 release upgrade line.
     // Put any upgrade step following this.
 
-
     return true;
 }
 
index c63d5d7..5a301c2 100644 (file)
@@ -37,7 +37,6 @@ function xmldb_assignsubmission_onlinetext_upgrade($oldversion) {
     // Moodle v2.5.0 release upgrade line.
     // Put any upgrade step following this.
 
-
     return true;
 }
 
index 7ffeceb..df21515 100644 (file)
@@ -111,7 +111,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
         $this->assertEquals(1, count($assignment['grades']));
         $grade = $assignment['grades'][0];
         $this->assertEquals($student->id, $grade['userid']);
-        // Should be the last grade (not the first)
+        // Should be the last grade (not the first).
         $this->assertEquals(75, $grade['grade']);
     }
 
index c29178f..6fae770 100644 (file)
@@ -755,7 +755,6 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
         $grades = $assign->get_user_grades_for_gradebook($this->students[0]->id);
         $this->assertEquals(50, (int)$grades[$this->students[0]->id]->rawgrade);
 
-
     }
 
     public function test_markingworkflow() {
@@ -765,7 +764,7 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
         $assign = $this->create_instance(array('markingworkflow'=>1));
         $PAGE->set_url(new moodle_url('/mod/assign/view.php', array('id' => $assign->get_course_module()->id)));
 
-        // Mark the submission and set to notmarked
+        // Mark the submission and set to notmarked.
         $this->setUser($this->teachers[0]);
         $data = new stdClass();
         $data->grade = '50.0';
@@ -777,7 +776,7 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
         $output = $assign->view_student_summary($this->students[0], true);
         $this->assertEquals(false, strpos($output, '50.0'));
 
-        // Mark the submission and set to inmarking
+        // Mark the submission and set to inmarking.
         $this->setUser($this->teachers[0]);
         $data = new stdClass();
         $data->grade = '50.0';
@@ -789,7 +788,7 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
         $output = $assign->view_student_summary($this->students[0], true);
         $this->assertEquals(false, strpos($output, '50.0'));
 
-        // Mark the submission and set to readyforreview
+        // Mark the submission and set to readyforreview.
         $this->setUser($this->teachers[0]);
         $data = new stdClass();
         $data->grade = '50.0';
@@ -801,7 +800,7 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
         $output = $assign->view_student_summary($this->students[0], true);
         $this->assertEquals(false, strpos($output, '50.0'));
 
-        // Mark the submission and set to inreview
+        // Mark the submission and set to inreview.
         $this->setUser($this->teachers[0]);
         $data = new stdClass();
         $data->grade = '50.0';
@@ -813,7 +812,7 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
         $output = $assign->view_student_summary($this->students[0], true);
         $this->assertEquals(false, strpos($output, '50.0'));
 
-        // Mark the submission and set to readyforrelease
+        // Mark the submission and set to readyforrelease.
         $this->setUser($this->teachers[0]);
         $data = new stdClass();
         $data->grade = '50.0';
@@ -825,7 +824,7 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
         $output = $assign->view_student_summary($this->students[0], true);
         $this->assertEquals(false, strpos($output, '50.0'));
 
-        // Mark the submission and set to released
+        // Mark the submission and set to released.
         $this->setUser($this->teachers[0]);
         $data = new stdClass();
         $data->grade = '50.0';
@@ -842,21 +841,21 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
         global $PAGE;
 
         $this->setUser($this->editingteachers[0]);
-        $assign = $this->create_instance(array('markingworkflow'=>1,'markingallocation'=>1));
+        $assign = $this->create_instance(array('markingworkflow'=>1, 'markingallocation'=>1));
         $PAGE->set_url(new moodle_url('/mod/assign/view.php', array('id' => $assign->get_course_module()->id)));
 
-        // Allocate marker to submission
+        // Allocate marker to submission.
         $data = new stdClass();
         $data->allocatedmarker = $this->teachers[0]->id;
         $assign->testable_apply_grade_to_user($data, $this->students[0]->id, 0);
 
-        // Check the allocated marker can view the submission
+        // Check the allocated marker can view the submission.
         $this->setUser($this->teachers[0]);
         $gradingtable = new assign_grading_table($assign, 100, '', 0, true);
         $output = $assign->get_renderer()->render($gradingtable);
         $this->assertEquals(true, strpos($output, $this->students[0]->lastname));
 
-        // Check that other teachers can't view this submission
+        // Check that other teachers can't view this submission.
         $this->setUser($this->teachers[1]);
         $gradingtable = new assign_grading_table($assign, 100, '', 0, true);
         $output = $assign->get_renderer()->render($gradingtable);