Skip to content
Browse files

MDL-37806 Add new workshop class method to return pending assessments

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...
1 parent 1918a24 commit 0001eea6dd1b3faa5a76d3d96e06d746c6ac6320 @mudrd8mz mudrd8mz committed Jan 31, 2013
Showing with 31 additions and 0 deletions.
  1. +31 −0 mod/workshop/locallib.php
View
31 mod/workshop/locallib.php
@@ -1170,6 +1170,37 @@ public function get_assessments_by_reviewer($reviewerid) {
}
/**
+ * 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
*
* @param stdClass $submission Submission object with at least id property

0 comments on commit 0001eea

Please sign in to comment.
Something went wrong with that request. Please try again.