MDL-41945 mod_assign: Properly check if submission is empty

Previous empty submission checks required the submission to
be saved to the database. This patch adds a new method to
submission plugins that lets them report whether the submission
is empty before it is saved.
This commit is contained in:
Cameron Ball 2016-05-31 14:20:03 +08:00
parent 16b36d376a
commit c89d23ee6d
No known key found for this signature in database
GPG key ID: 305B7F70214D810C
8 changed files with 375 additions and 0 deletions

View file

@ -6371,6 +6371,22 @@ class assign {
return $allempty;
}
/**
* Determine if a new submission is empty or not
*
* @param stdClass $data Submission data
* @return bool
*/
public function new_submission_empty($data) {
foreach ($this->submissionplugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible() && $plugin->allow_submissions() &&
!$plugin->submission_is_empty($data)) {
return false;
}
}
return true;
}
/**
* Save assignment submission for the current user.
*