mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-26969 Assignment module - upload: fixed get_submission() return value to nothing when param is set to false.
This commit is contained in:
parent
3294034b80
commit
75cf84ac25
2 changed files with 12 additions and 6 deletions
|
@ -1820,10 +1820,10 @@ class assignment_base {
|
||||||
*
|
*
|
||||||
* @global object
|
* @global object
|
||||||
* @global object
|
* @global object
|
||||||
* @param $userid int The id of the user whose submission we want or 0 in which case USER->id is used
|
* @param int $userid int The id of the user whose submission we want or 0 in which case USER->id is used
|
||||||
* @param $createnew boolean optional Defaults to false. If set to true a new submission object will be created in the database
|
* @param bool $createnew boolean optional Defaults to false. If set to true a new submission object will be created in the database
|
||||||
* @param bool $teachermodified student submission set if false
|
* @param bool $teachermodified student submission set if false
|
||||||
* @return object The submission
|
* @return object|bool The submission or false if $createnew is false.
|
||||||
*/
|
*/
|
||||||
function get_submission($userid=0, $createnew=false, $teachermodified=false) {
|
function get_submission($userid=0, $createnew=false, $teachermodified=false) {
|
||||||
global $USER, $DB;
|
global $USER, $DB;
|
||||||
|
@ -1834,8 +1834,10 @@ class assignment_base {
|
||||||
|
|
||||||
$submission = $DB->get_record('assignment_submissions', array('assignment'=>$this->assignment->id, 'userid'=>$userid));
|
$submission = $DB->get_record('assignment_submissions', array('assignment'=>$this->assignment->id, 'userid'=>$userid));
|
||||||
|
|
||||||
if ($submission || !$createnew) {
|
if ($submission) {
|
||||||
return $submission;
|
return $submission;
|
||||||
|
} else if(!$createnew) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
$newsubmission = $this->prepare_new_submission($userid, $teachermodified);
|
$newsubmission = $this->prepare_new_submission($userid, $teachermodified);
|
||||||
$DB->insert_record("assignment_submissions", $newsubmission);
|
$DB->insert_record("assignment_submissions", $newsubmission);
|
||||||
|
|
|
@ -59,7 +59,7 @@ $PAGE->set_title($title);
|
||||||
$PAGE->set_heading($title);
|
$PAGE->set_heading($title);
|
||||||
|
|
||||||
$instance = new assignment_upload($cm->id, $assignment, $cm, $course);
|
$instance = new assignment_upload($cm->id, $assignment, $cm, $course);
|
||||||
$submission = $instance->get_submission($formdata->userid, true);
|
$submission = $instance->get_submission($formdata->userid, false);
|
||||||
|
|
||||||
$filemanager_options = array('subdirs'=>1, 'maxbytes'=>$assignment->maxbytes, 'maxfiles'=>$assignment->var1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL);
|
$filemanager_options = array('subdirs'=>1, 'maxbytes'=>$assignment->maxbytes, 'maxfiles'=>$assignment->var1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL);
|
||||||
|
|
||||||
|
@ -77,8 +77,12 @@ echo $OUTPUT->header();
|
||||||
echo $OUTPUT->box_start('generalbox');
|
echo $OUTPUT->box_start('generalbox');
|
||||||
if ($instance->can_upload_file($submission) && ($id==null)) {
|
if ($instance->can_upload_file($submission) && ($id==null)) {
|
||||||
$data = new stdClass();
|
$data = new stdClass();
|
||||||
|
$submissionid = null;
|
||||||
|
if (is_object($submission) && isset($submission->id)) {
|
||||||
|
$submissionid = $submission->id;
|
||||||
|
}
|
||||||
// move submission files to user draft area
|
// move submission files to user draft area
|
||||||
$data = file_prepare_standard_filemanager($data, 'files', $filemanager_options, $context, 'mod_assignment', 'submission', $submission->id);
|
$data = file_prepare_standard_filemanager($data, 'files', $filemanager_options, $context, 'mod_assignment', 'submission', $submissionid);
|
||||||
// set file manager itemid, so it will find the files in draft area
|
// set file manager itemid, so it will find the files in draft area
|
||||||
$mform->set_data($data);
|
$mform->set_data($data);
|
||||||
$mform->display();
|
$mform->display();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue