Skip to content

Commit

Permalink
Merge branch 'MDL-57766-32' of git://github.com/damyon/moodle into MO…
Browse files Browse the repository at this point in the history
…ODLE_32_STABLE
  • Loading branch information
dmonllao committed Feb 13, 2017
2 parents dfefe26 + 54a20ea commit 21cf201
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
6 changes: 0 additions & 6 deletions mod/assign/gradingtable.php
Expand Up @@ -302,14 +302,8 @@ public function __construct(assign $assignment,
if (!empty($markerfilter)) {
if ($markerfilter == ASSIGN_MARKER_FILTER_NO_MARKER) {
$where .= ' AND (uf.allocatedmarker IS NULL OR uf.allocatedmarker = 0)';
} else {
$where .= ' AND uf.allocatedmarker = :markerid';
$params['markerid'] = $markerfilter;
}
}
} else { // Only show users allocated to this marker.
$where .= ' AND uf.allocatedmarker = :markerid';
$params['markerid'] = $USER->id;
}
}

Expand Down
18 changes: 17 additions & 1 deletion mod/assign/locallib.php
Expand Up @@ -1783,7 +1783,7 @@ public function list_participants_with_filter_status_and_group($currentgroup) {
* @return array List of user records
*/
public function list_participants($currentgroup, $idsonly) {
global $DB;
global $DB, $USER;

if (empty($currentgroup)) {
$currentgroup = 0;
Expand All @@ -1797,6 +1797,7 @@ public function list_participants($currentgroup, $idsonly) {
$fields = 'u.*';
$orderby = 'u.lastname, u.firstname, u.id';
$additionaljoins = '';
$additionalfilters = '';
$instance = $this->get_instance();
if (!empty($instance->blindmarking)) {
$additionaljoins .= " LEFT JOIN {assign_user_mapping} um
Expand All @@ -1818,11 +1819,26 @@ public function list_participants($currentgroup, $idsonly) {
$orderby = "COALESCE(s.timecreated, " . time() . ") ASC, COALESCE(s.id, " . PHP_INT_MAX . ") ASC, um.id ASC";
}

if ($instance->markingworkflow &&
$instance->markingallocation &&
!has_capability('mod/assign:manageallocations', $this->get_context())) {

$additionaljoins .= ' LEFT JOIN {assign_user_flags} uf
ON u.id = uf.userid
AND uf.assignment = :assignmentid3';

$params['assignmentid3'] = (int) $instance->id;

$additionalfilters .= ' AND uf.allocatedmarker = :markerid';
$params['markerid'] = $USER->id;
}

$sql = "SELECT $fields
FROM {user} u
JOIN ($esql) je ON je.id = u.id
$additionaljoins
WHERE u.deleted = 0
$additionalfilters
ORDER BY $orderby";

$users = $DB->get_records_sql($sql, $params);
Expand Down
15 changes: 9 additions & 6 deletions mod/assign/tests/locallib_test.php
Expand Up @@ -2174,15 +2174,18 @@ public function test_markerallocation() {

// 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));

$users = $assign->list_participants(0, true);
$user = reset($users);
$this->assertEquals($this->students[0]->id, $user->id);

$cm = get_coursemodule_from_instance('assign', $assign->get_instance()->id);
$context = context_module::instance($cm->id);
$assign = new testable_assign($context, $cm, $this->course);
// 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);
$this->assertNotEquals(true, strpos($output, $this->students[0]->lastname));
$users = $assign->list_participants(0, true);
$this->assertEquals(0, count($users));
}

/**
Expand Down

0 comments on commit 21cf201

Please sign in to comment.