Skip to content

Commit

Permalink
MDL-32932: Add quickgrading support to mod_assign
Browse files Browse the repository at this point in the history
  • Loading branch information
Damyon Wiese committed May 15, 2012
1 parent a769a00 commit bf78ebd
Show file tree
Hide file tree
Showing 10 changed files with 437 additions and 58 deletions.
2 changes: 1 addition & 1 deletion mod/assign/gradingbatchoperationsform.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function definition() {
if ($instance['submissiondrafts']) {
$options['reverttodraft'] = get_string('reverttodraft', 'assign');
}
$mform->addElement('select', 'operation', get_string('batchoperationsdescription', 'assign'), $options, array('class'=>'operation'));
$mform->addElement('select', 'operation', get_string('batchoperationsdescription', 'assign'), $options, array('class'=>'operation ignoredirty'));
$mform->addHelpButton('operation', 'batchoperationsdescription', 'assign');
$mform->addElement('hidden', 'action', 'batchgradingoperation');
$mform->addElement('hidden', 'id', $instance['cm']);
Expand Down
12 changes: 9 additions & 3 deletions mod/assign/gradingoptionsform.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,16 @@ function definition() {
$mform->addElement('header', 'general', get_string('gradingoptions', 'assign'));
// visible elements
$options = array(-1=>'All',10=>'10', 20=>'20', 50=>'50', 100=>'100');
$autosubmit = array('onchange'=>'form.submit();');
$mform->addElement('select', 'perpage', get_string('assignmentsperpage', 'assign'), $options, $autosubmit);
$mform->addElement('select', 'perpage', get_string('assignmentsperpage', 'assign'), $options, array('class'=>'ignoredirty'));
$options = array(''=>get_string('filternone', 'assign'), ASSIGN_FILTER_SUBMITTED=>get_string('filtersubmitted', 'assign'), ASSIGN_FILTER_REQUIRE_GRADING=>get_string('filterrequiregrading', 'assign'));
$mform->addElement('select', 'filter', get_string('filter', 'assign'), $options, $autosubmit);
$mform->addElement('select', 'filter', get_string('filter', 'assign'), $options, array('class'=>'ignoredirty'));

// quickgrading
if ($instance['showquickgrading']) {
$mform->addElement('checkbox', 'quickgrading', get_string('quickgrading', 'assign'), '', array('class'=>'ignoredirty'));
$mform->addHelpButton('quickgrading', 'quickgrading', 'assign');
$mform->setDefault('quickgrading', $instance['quickgrading']);
}

// hidden params
$mform->addElement('hidden', 'contextid', $instance['contextid']);
Expand Down
39 changes: 26 additions & 13 deletions mod/assign/gradingtable.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class assign_grading_table extends table_sql implements renderable {
private $gradinginfo = null;
/** @var int $tablemaxrows */
private $tablemaxrows = 10000;
/** @var boolean $quickgrading */
private $quickgrading = false;

/**
* overridden constructor keeps a reference to the assignment class that is displaying this table
Expand All @@ -56,12 +58,14 @@ class assign_grading_table extends table_sql implements renderable {
* @param int $perpage how many per page
* @param string $filter The current filter
* @param int $rowoffset For showing a subsequent page of results
* @param bool $quickgrading Is this table wrapped in a quickgrading form?
*/
function __construct(assign $assignment, $perpage, $filter, $rowoffset=0) {
function __construct(assign $assignment, $perpage, $filter, $rowoffset, $quickgrading) {
global $CFG, $PAGE, $DB;
parent::__construct('mod_assign_grading');
$this->assignment = $assignment;
$this->perpage = $perpage;
$this->quickgrading = $quickgrading;
$this->output = $PAGE->get_renderer('mod_assign');

$this->define_baseurl(new moodle_url($CFG->wwwroot . '/mod/assign/view.php', array('action'=>'grading', 'id'=>$assignment->get_course_module()->id)));
Expand Down Expand Up @@ -115,7 +119,7 @@ function __construct(assign $assignment, $perpage, $filter, $rowoffset=0) {

// Select
$columns[] = 'select';
$headers[] = get_string('select') . '<div class="selectall"><input type="checkbox" name="selectall" title="' . get_string('selectall') . '"/></div>';
$headers[] = get_string('select') . '<div class="selectall"><input type="checkbox" class="ignoredirty" name="selectall" title="' . get_string('selectall') . '"/></div>';

// Edit links
if (!$this->is_downloading()) {
Expand Down Expand Up @@ -224,13 +228,14 @@ function get_rows_per_page() {
* Display a grade with scales etc.
*
* @param string $grade
* @param boolean $editable
* @return string The formatted grade
*/
function display_grade($grade) {
function display_grade($grade, $editable, $userid, $modified) {
if ($this->is_downloading()) {
return $grade;
}
$o = $this->assignment->display_grade($grade);
$o = $this->assignment->display_grade($grade, $editable, $userid, $modified);

return $o;
}
Expand All @@ -247,7 +252,20 @@ function col_outcomes(stdClass $row) {
$options = make_grades_menu(-$outcome->scaleid);

$options[0] = get_string('nooutcome', 'grades');
$outcomes .= $this->output->container($outcome->name . ': ' . $options[$outcome->grades[$row->userid]->grade], 'outcome');
if ($this->quickgrading&& !($outcome->grades[$row->userid]->locked)) {
$select = '<select name="outcome_' . $index . '_' . $row->userid . '" class="quickgrade">';
foreach ($options as $optionindex => $optionvalue) {
$selected = '';
if ($outcome->grades[$row->userid]->grade == $optionindex) {
$selected = 'selected="selected"';
}
$select .= '<option value="' . $optionindex . '"' . $selected . '>' . $optionvalue . '</option>';
}
$select .= '</select>';
$outcomes .= $this->output->container($outcome->name . ': ' . $select, 'outcome');
} else {
$outcomes .= $this->output->container($outcome->name . ': ' . $options[$outcome->grades[$row->userid]->grade], 'outcome');
}
}

return $outcomes;
Expand Down Expand Up @@ -284,7 +302,7 @@ function col_fullname($row) {
* @return string
*/
function col_select(stdClass $row) {
return '<input type="checkbox" name="selectedusers" value="' . $row->userid . '"/>';
return '<input type="checkbox" name="selectedusers" value="' . $row->userid . '" class="ignoredirty"/>';
}

/**
Expand Down Expand Up @@ -322,12 +340,7 @@ function col_grade(stdClass $row) {
$separator = $this->output->spacer(array(), true);
}


if ($row->grade) {
$grade = $this->display_grade($row->grade);
} else {
$grade = '-';
}
$grade = $this->display_grade($row->grade, $this->quickgrading, $row->userid, $row->timemarked);


//return $grade . $separator . $link;
Expand All @@ -345,7 +358,7 @@ function col_finalgrade(stdClass $row) {

$grade = $this->get_gradebook_data_for_user($row->userid);
if ($grade) {
$o = $this->display_grade($grade->grade);
$o = $this->display_grade($grade->grade, false, $row->userid, $row->timemarked);
}

return $o;
Expand Down
7 changes: 7 additions & 0 deletions mod/assign/lang/en/assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
It is <a href="{$a->url}">available on the web site</a>.';
$string['enabled'] = 'Enabled';
$string['errornosubmissions'] = 'There are no submissions to download';
$string['errorquickgradingnotcompatiblewithadvancedgrading'] = 'The grades were not saved because this assignment is currently using advanced grading';
$string['errorrecordmodified'] = 'The grades were not saved because someone has modified one or more records more recently than when you loaded the page.';
$string['feedbackcomments'] = 'Feedback comments';
$string['feedback'] = 'Feedback';
$string['feedbackplugins'] = 'Feedback plugins';
Expand Down Expand Up @@ -168,11 +170,16 @@
$string['preventsubmissions'] = 'Prevent the user from making any more submissions to this assignment.';
$string['preventsubmissionsshort'] = 'Prevent submission changes';
$string['previous'] = 'Previous';
$string['quickgrading'] = 'Quick grading';
$string['quickgradingresult'] = 'Quick grading';
$string['quickgradingchangessaved'] = 'The grade changes were saved';
$string['quickgrading_help'] = 'Quick grading allows you to assign grades (and outcomes) directly in the submissions table. Quick grading is not compatible with advanced grading and is not recommended when there are multiple markers.';
$string['reverttodraftforstudent'] = 'Revert submission to draft for student: (id={$a->id}, fullname={$a->fullname}).';
$string['reverttodraft'] = 'Revert the submission to draft status.';
$string['reverttodraftshort'] = 'Revert the submission to draft';
$string['reviewed'] = 'Reviewed';
$string['savechanges'] = 'Save changes';
$string['saveallchanges'] = 'Save all changes';
$string['savenext'] = 'Save and show next';
$string['sendnotifications'] = 'Send notifications to graders';
$string['sendnotifications_help'] = 'If enabled, graders (usually teachers) receive a message whenever a student submits an assignment, early, on time and late. Message methods are configurable.';
Expand Down
Loading

0 comments on commit bf78ebd

Please sign in to comment.