Skip to content

Commit

Permalink
MDL-37806 Add new workshop class method to return pending assessments
Browse files Browse the repository at this point in the history
This is a simple wrapper around workshop::get_assessments_by_reviewer()
that filters assigned assessments and returns just those that were not
graded by the reviewer yet.
  • Loading branch information
mudrd8mz committed Jan 31, 2013
1 parent 1918a24 commit 0001eea
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions mod/workshop/locallib.php
Expand Up @@ -1169,6 +1169,37 @@ public function get_assessments_by_reviewer($reviewerid) {
return $DB->get_records_sql($sql, $params);
}

/**
* Get allocated assessments not graded yet by the given reviewer
*
* @see self::get_assessments_by_reviewer()
* @param int $reviewerid the reviewer id
* @param null|int|array $exclude optional assessment id (or list of them) to be excluded
* @return array
*/
public function get_pending_assessments_by_reviewer($reviewerid, $exclude = null) {

$assessments = $this->get_assessments_by_reviewer($reviewerid);

foreach ($assessments as $id => $assessment) {
if (!is_null($assessment->grade)) {
unset($assessments[$id]);
continue;
}
if (!empty($exclude)) {
if (is_array($exclude) and in_array($id, $exclude)) {
unset($assessments[$id]);
continue;
} else if ($id == $exclude) {
unset($assessments[$id]);
continue;
}
}
}

return $assessments;
}

/**
* Allocate a submission to a user for review
*
Expand Down

0 comments on commit 0001eea

Please sign in to comment.