Skip to content

Commit

Permalink
Merge branch 'MDL-60708-master' of git://github.com/jleyva/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
snake committed Nov 20, 2017
2 parents 087b330 + d995cd4 commit 4a9268b
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 64 deletions.
13 changes: 9 additions & 4 deletions mod/workshop/classes/external.php
Expand Up @@ -746,12 +746,17 @@ protected static function prepare_submission_for_external($submission, workshop
$submission->authorid = 0;
}

$isworkshopclosed = $workshop->phase == workshop::PHASE_CLOSED;
$canviewsubmissiondetail = $ownsubmission || $canviewallsubmissions;
// If the workshop is not closed or the user can't see the submission detail: remove grading or feedback information.
if (!$isworkshopclosed || !$canviewsubmissiondetail) {
// Remove grade, gradeover, gradeoverby, feedbackauthor and timegraded for non-teachers or invalid phase.
// WS mod_workshop_external::get_grades should be used for retrieving grades by students.
if ($workshop->phase < workshop::PHASE_EVALUATION || !$canviewallsubmissions) {
$properties = submission_exporter::properties_definition();
foreach ($properties as $attribute => $settings) {
// Special case, the feedbackauthor (and who did it) should be returned if the workshop is closed and
// the user can view it.
if (($attribute == 'feedbackauthor' || $attribute == 'gradeoverby') &&
$workshop->phase == workshop::PHASE_CLOSED && $ownsubmission) {
continue;
}
if (!empty($settings['optional'])) {
unset($submission->{$attribute});
}
Expand Down

0 comments on commit 4a9268b

Please sign in to comment.