Merge branch 'MDL-57602-master' of https://github.com/lucisgit/moodle

This commit is contained in:
David Monllao 2017-02-21 08:43:16 +01:00
commit b98b37c670
14 changed files with 59 additions and 9 deletions

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
define(["core/ajax","jquery","core/templates"],function(a,b,c){return{processResults:function(a,b){return b},transport:function(d,e,f,g){var h=b(d).attr("data-assignmentid"),i=b(d).attr("data-groupid"),j=b('[data-region="configure-filters"] input[type="checkbox"]'),k=[];j.each(function(a,c){k[b(c).attr("name")]=b(c).prop("checked")}),a.call([{methodname:"mod_assign_list_participants",args:{assignid:h,groupid:i,filter:e,limit:30,includeenrolments:!1}}])[0].then(function(a){var d=[],e=b("[data-showuseridentity]").data("showuseridentity").split(",");return b.each(a,function(a,f){var g=f,h=[],i=!0;k.filter_submitted&&!f.submitted&&(i=!1),k.filter_notsubmitted&&f.submitted&&(i=!1),k.filter_requiregrading&&!f.requiregrading&&(i=!1),i&&(b.each(e,function(a,b){"undefined"!=typeof f[b]&&""!==f[b]&&(g.hasidentity=!0,h.push(f[b]))}),g.identity=h.join(", "),d.push(c.render("mod_assign/list_participant_user_summary",g).then(function(a){return{value:f.id,label:a}})))}),b.when.apply(b,d)}).then(function(){var a=[];arguments[0]&&(a=Array.prototype.slice.call(arguments)),f(a)})["catch"](g)}}});
define(["core/ajax","jquery","core/templates"],function(a,b,c){return{processResults:function(a,b){return b},transport:function(d,e,f,g){var h=b(d).attr("data-assignmentid"),i=b(d).attr("data-groupid"),j=b('[data-region="configure-filters"] input[type="checkbox"]'),k=[];j.each(function(a,c){k[b(c).attr("name")]=b(c).prop("checked")}),a.call([{methodname:"mod_assign_list_participants",args:{assignid:h,groupid:i,filter:e,limit:30,includeenrolments:!1}}])[0].then(function(a){var d=[],e=b("[data-showuseridentity]").data("showuseridentity").split(",");return b.each(a,function(a,f){var g=f,h=[],i=!0;k.filter_submitted&&!f.submitted&&(i=!1),k.filter_notsubmitted&&f.submitted&&(i=!1),k.filter_requiregrading&&!f.requiregrading&&(i=!1),k.filter_grantedextension&&!f.grantedextension&&(i=!1),i&&(b.each(e,function(a,b){"undefined"!=typeof f[b]&&""!==f[b]&&(g.hasidentity=!0,h.push(f[b]))}),g.identity=h.join(", "),d.push(c.render("mod_assign/list_participant_user_summary",g).then(function(a){return{value:f.id,label:a}})))}),b.when.apply(b,d)}).then(function(){var a=[];arguments[0]&&(a=Array.prototype.slice.call(arguments)),f(a)})["catch"](g)}}});

View File

@ -212,6 +212,10 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
if (user.requiregrading == "0") {
show = false;
}
} else if (filter == "grantedextension") {
if (user.grantedextension == "0") {
show = false;
}
}
});

View File

@ -79,6 +79,9 @@ define(['core/ajax', 'jquery', 'core/templates'], function(ajax, $, templates) {
if (filterstrings.filter_requiregrading && !user.requiregrading) {
show = false;
}
if (filterstrings.filter_grantedextension && !user.grantedextension) {
show = false;
}
if (show) {
$.each(identityfields, function(i, k) {
if (typeof user[k] !== 'undefined' && user[k] !== '') {

View File

@ -97,6 +97,7 @@ class grading_app implements templatable, renderable {
$user->id = $record->id;
$user->fullname = fullname($record);
$user->requiregrading = $record->requiregrading;
$user->grantedextension = $record->grantedextension;
$user->submitted = $record->submitted;
if (!empty($record->groupid)) {
$user->groupid = $record->groupid;

View File

@ -2617,6 +2617,7 @@ class mod_assign_external extends external_api {
$userdetails['fullname'] = $fullname;
$userdetails['submitted'] = $record->submitted;
$userdetails['requiregrading'] = $record->requiregrading;
$userdetails['grantedextension'] = $record->grantedextension;
if (!empty($record->groupid)) {
$userdetails['groupid'] = $record->groupid;
}
@ -2687,6 +2688,7 @@ class mod_assign_external extends external_api {
),
'submitted' => new external_value(PARAM_BOOL, 'have they submitted their assignment'),
'requiregrading' => new external_value(PARAM_BOOL, 'is their submission waiting for grading'),
'grantedextension' => new external_value(PARAM_BOOL, 'have they been granted an extension'),
'groupid' => new external_value(PARAM_INT, 'for group assignments this is the group id', VALUE_OPTIONAL),
'groupname' => new external_value(PARAM_NOTAGS, 'for group assignments this is the group name', VALUE_OPTIONAL),
];
@ -2752,6 +2754,7 @@ class mod_assign_external extends external_api {
'fullname' => $participant->fullname,
'submitted' => $participant->submitted,
'requiregrading' => $participant->requiregrading,
'grantedextension' => $participant->grantedextension,
'blindmarking' => $assign->is_blind_marking(),
'allowsubmissionsfromdate' => $assign->get_instance()->allowsubmissionsfromdate,
'duedate' => $assign->get_instance()->duedate,
@ -2791,6 +2794,7 @@ class mod_assign_external extends external_api {
'fullname' => new external_value(PARAM_NOTAGS, 'The fullname of the user'),
'submitted' => new external_value(PARAM_BOOL, 'have they submitted their assignment'),
'requiregrading' => new external_value(PARAM_BOOL, 'is their submission waiting for grading'),
'grantedextension' => new external_value(PARAM_BOOL, 'have they been granted an extension'),
'blindmarking' => new external_value(PARAM_BOOL, 'is blind marking enabled for this assignment'),
'allowsubmissionsfromdate' => new external_value(PARAM_INT, 'allowsubmissionsfromdate for the user'),
'duedate' => new external_value(PARAM_INT, 'duedate for the user'),

View File

@ -60,7 +60,8 @@ class mod_assign_grading_options_form extends moodleform {
$options = array('' => get_string('filternone', 'assign'),
ASSIGN_FILTER_NOT_SUBMITTED => get_string('filternotsubmitted', 'assign'),
ASSIGN_FILTER_SUBMITTED => get_string('filtersubmitted', 'assign'),
ASSIGN_FILTER_REQUIRE_GRADING => get_string('filterrequiregrading', 'assign'));
ASSIGN_FILTER_REQUIRE_GRADING => get_string('filterrequiregrading', 'assign'),
ASSIGN_FILTER_GRANTED_EXTENSION => get_string('filtergrantedextension', 'assign'));
if ($instance['submissionsenabled']) {
$mform->addElement('select', 'filter', get_string('filter', 'assign'), $options, $dirtyclass);
}

View File

@ -287,6 +287,9 @@ class assign_grading_table extends table_sql implements renderable {
$where .= '))';
$params['submitted'] = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
} else if ($filter == ASSIGN_FILTER_GRANTED_EXTENSION) {
$where .= ' AND uf.extensionduedate > 0 ';
} else if (strpos($filter, ASSIGN_FILTER_SINGLE_USER) === 0) {
$userfilter = (int) array_pop(explode('=', $filter));
$where .= ' AND (u.id = :userid)';

View File

@ -232,6 +232,7 @@ $string['feedbacksettings'] = 'Feedback settings';
$string['feedbacktypes'] = 'Feedback types';
$string['filesubmissions'] = 'File submissions';
$string['filter'] = 'Filter';
$string['filtergrantedextension'] = 'Granted extension';
$string['filternone'] = 'No filter';
$string['filternotsubmitted'] = 'Not submitted';
$string['filterrequiregrading'] = 'Requires grading';

View File

@ -37,6 +37,7 @@ define('ASSIGN_FILTER_SUBMITTED', 'submitted');
define('ASSIGN_FILTER_NOT_SUBMITTED', 'notsubmitted');
define('ASSIGN_FILTER_SINGLE_USER', 'singleuser');
define('ASSIGN_FILTER_REQUIRE_GRADING', 'require_grading');
define('ASSIGN_FILTER_GRANTED_EXTENSION', 'granted_extension');
// Marker filter for grading page.
define('ASSIGN_MARKER_FILTER_NO_MARKER', -1);
@ -1668,7 +1669,7 @@ class assign {
* Get the submission status/grading status for all submissions in this assignment for the
* given paticipants.
*
* These statuses match the available filters (requiregrading, submitted, notsubmitted).
* These statuses match the available filters (requiregrading, submitted, notsubmitted, grantedextension).
* If this is a group assignment, group info is also returned.
*
* @param array $participants an associative array where the key is the participant id and
@ -1688,8 +1689,9 @@ class assign {
$assignid = $this->get_instance()->id;
$params['assignmentid1'] = $assignid;
$params['assignmentid2'] = $assignid;
$params['assignmentid3'] = $assignid;
$fields = 'SELECT u.id, s.status, s.timemodified AS stime, g.timemodified AS gtime, g.grade';
$fields = 'SELECT u.id, s.status, s.timemodified AS stime, g.timemodified AS gtime, g.grade, uf.extensionduedate';
$from = ' FROM {user} u
LEFT JOIN {assign_submission} s
ON u.id = s.userid
@ -1699,14 +1701,17 @@ class assign {
ON u.id = g.userid
AND g.assignment = :assignmentid2
AND g.attemptnumber = s.attemptnumber
LEFT JOIN {assign_user_flags} uf
ON u.id = uf.userid
AND uf.assignment = :assignmentid3
';
$where = ' WHERE u.id ' . $insql;
if (!empty($this->get_instance()->blindmarking)) {
$from .= 'LEFT JOIN {assign_user_mapping} um
ON u.id = um.userid
AND um.assignment = :assignmentid3 ';
$params['assignmentid3'] = $assignid;
AND um.assignment = :assignmentid4 ';
$params['assignmentid4'] = $assignid;
$fields .= ', um.id as recordid ';
}
@ -1726,12 +1731,14 @@ class assign {
$participants[$userid]->fullname = $this->fullname($participant);
$participants[$userid]->submitted = false;
$participants[$userid]->requiregrading = false;
$participants[$userid]->grantedextension = false;
}
foreach ($records as $userid => $submissioninfo) {
// These filters are 100% the same as the ones in the grading table SQL.
$submitted = false;
$requiregrading = false;
$grantedextension = false;
if (!empty($submissioninfo->stime) && $submissioninfo->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
$submitted = true;
@ -1743,8 +1750,13 @@ class assign {
$requiregrading = true;
}
if (!empty($submissioninfo->extensionduedate)) {
$grantedextension = true;
}
$participants[$userid]->submitted = $submitted;
$participants[$userid]->requiregrading = $requiregrading;
$participants[$userid]->grantedextension = $grantedextension;
if ($this->get_instance()->teamsubmission) {
$group = $this->get_submission_group($userid);
if ($group) {
@ -1758,11 +1770,12 @@ class assign {
/**
* Get the submission status/grading status for all submissions in this assignment.
* These statuses match the available filters (requiregrading, submitted, notsubmitted).
* These statuses match the available filters (requiregrading, submitted, notsubmitted, grantedextension).
* If this is a group assignment, group info is also returned.
*
* @param int $currentgroup
* @return array List of user records with extra fields 'submitted', 'notsubmitted', 'requiregrading', 'groupid', 'groupname'
* @return array List of user records with extra fields 'submitted', 'notsubmitted', 'requiregrading', 'grantedextension',
* 'groupid', 'groupname'
*/
public function list_participants_with_filter_status_and_group($currentgroup) {
$participants = $this->list_participants($currentgroup, false);

View File

@ -50,6 +50,7 @@
<label><input type="checkbox" name="filter_submitted">{{#str}}filtersubmitted, mod_assign{{/str}}</label>
<label><input type="checkbox" name="filter_notsubmitted">{{#str}}filternotsubmitted, mod_assign{{/str}}</label>
<label><input type="checkbox" name="filter_requiregrading">{{#str}}filterrequiregrading, mod_assign{{/str}}</label>
<label><input type="checkbox" name="filter_grantedextension">{{#str}}filtergrantedextension, mod_assign{{/str}}</label>
</form>
</span>

View File

@ -2228,6 +2228,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
$this->assertFalse(fullname($student) == $result['fullname']);
$this->assertFalse($result['submitted']);
$this->assertFalse($result['requiregrading']);
$this->assertFalse($result['grantedextension']);
$this->assertTrue($result['blindmarking']);
// Make sure we don't get any additional info.
$this->assertTrue(empty($result['user']));
@ -2280,6 +2281,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
$this->assertEquals(fullname($student), $result['fullname']);
$this->assertTrue($result['submitted']);
$this->assertTrue($result['requiregrading']);
$this->assertFalse($result['grantedextension']);
$this->assertFalse($result['blindmarking']);
// Make sure we don't get any additional info.
$this->assertTrue(empty($result['user']));

View File

@ -799,6 +799,20 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
$this->assertEquals($student->id, $participant->id);
$this->assertFalse($participant->submitted);
$this->assertFalse($participant->requiregrading);
$this->assertFalse($participant->grantedextension);
}
public function test_get_participant_granted_extension() {
$assign = $this->create_instance(array('grade' => 100));
$student = $this->students[0];
$this->setUser($this->editingteachers[0]);
$assign->save_user_extension($student->id, time());
$participant = $assign->get_participant($student->id);
$this->assertEquals($student->id, $participant->id);
$this->assertFalse($participant->submitted);
$this->assertFalse($participant->requiregrading);
$this->assertTrue($participant->grantedextension);
}
public function test_get_participant_with_ungraded_submission() {
@ -828,6 +842,7 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
$this->assertEquals($student->id, $participant->id);
$this->assertTrue($participant->submitted);
$this->assertTrue($participant->requiregrading);
$this->assertFalse($participant->grantedextension);
}
public function test_get_participant_with_graded_submission() {
@ -867,6 +882,7 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
$this->assertEquals($student->id, $participant->id);
$this->assertTrue($participant->submitted);
$this->assertFalse($participant->requiregrading);
$this->assertFalse($participant->grantedextension);
}
public function test_count_teams() {

View File

@ -49,6 +49,7 @@
<label><input type="checkbox" name="filter_submitted">{{#str}}filtersubmitted, mod_assign{{/str}}</label>
<label><input type="checkbox" name="filter_notsubmitted">{{#str}}filternotsubmitted, mod_assign{{/str}}</label>
<label><input type="checkbox" name="filter_requiregrading">{{#str}}filterrequiregrading, mod_assign{{/str}}</label>
<label><input type="checkbox" name="filter_grantedextension">{{#str}}filtergrantedextension, mod_assign{{/str}}</label>
</form>
</span>