mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
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:
parent
16b36d376a
commit
c89d23ee6d
8 changed files with 375 additions and 0 deletions
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue