From 9fee0258a4e1c091e6aacc7cff6e6f27fd4cb9aa Mon Sep 17 00:00:00 2001 From: Gerwood Stewart Date: Mon, 16 May 2011 11:57:33 +1000 Subject: [PATCH] MDL-27521 Updates the can_finalize and can_unfinalize methods to deal with passing a submission object that isn't one (in this case is a Boolean value). This will result in both methods now returning false. Kick on effect is that it corrects the bug described in MDL-27521 by removing the button if it isn't possible to finalize the submission. --- mod/assignment/type/upload/assignment.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mod/assignment/type/upload/assignment.class.php b/mod/assignment/type/upload/assignment.class.php index 7516b416051..5f454520400 100644 --- a/mod/assignment/type/upload/assignment.class.php +++ b/mod/assignment/type/upload/assignment.class.php @@ -919,9 +919,14 @@ class assignment_upload extends assignment_base { } function can_unfinalize($submission) { + if(is_bool($submission)) { + return false; + } + if (!$this->drafts_tracked()) { return false; } + if (has_capability('mod/assignment:grade', $this->context) and $this->isopen() and $this->is_finalized($submission)) { @@ -933,6 +938,11 @@ class assignment_upload extends assignment_base { function can_finalize($submission) { global $USER; + + if(is_bool($submission)) { + return false; + } + if (!$this->drafts_tracked()) { return false; }