mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
MDL-55289 workshop: Fix files processing in example submissions
While testing the issue MDL-55289 I realized that attaching files to
workshop example submissions does not work at all and throws an error.
The reason was that in MDL-50794 (996f7e82
), the variables $contentopts
and $attachmentopts were replaced with the result of the methods
submission_content_options() and submission_attachment_options().
But I forgot to perform the full refactoring in exsubmission.php too.
Attached behat test should cover both issues on this branch.
This commit is contained in:
parent
21d49a3f93
commit
87b5c584fb
2 changed files with 46 additions and 5 deletions
|
@ -154,11 +154,13 @@ if ($edit and $canmanage) {
|
|||
throw new moodle_exception('err_examplesubmissionid', 'workshop');
|
||||
}
|
||||
}
|
||||
// save and relink embedded images and save attachments
|
||||
$formdata = file_postupdate_standard_editor($formdata, 'content', $contentopts, $workshop->context,
|
||||
'mod_workshop', 'submission_content', $example->id);
|
||||
$formdata = file_postupdate_standard_filemanager($formdata, 'attachment', $attachmentopts, $workshop->context,
|
||||
'mod_workshop', 'submission_attachment', $example->id);
|
||||
|
||||
// Save and relink embedded images and save attachments.
|
||||
$formdata = file_postupdate_standard_editor($formdata, 'content', $workshop->submission_content_options(),
|
||||
$workshop->context, 'mod_workshop', 'submission_content', $example->id);
|
||||
$formdata = file_postupdate_standard_filemanager($formdata, 'attachment', $workshop->submission_attachment_options(),
|
||||
$workshop->context, 'mod_workshop', 'submission_attachment', $example->id);
|
||||
|
||||
if (empty($formdata->attachment)) {
|
||||
// explicit cast to zero integer
|
||||
$formdata->attachment = 0;
|
||||
|
|
39
mod/workshop/tests/behat/example_submission.feature
Normal file
39
mod/workshop/tests/behat/example_submission.feature
Normal file
|
@ -0,0 +1,39 @@
|
|||
@mod @mod_workshop @_file_upload
|
||||
Feature: Provide example submission
|
||||
In order to let students practise the assessment process in the workshop
|
||||
As a teacher
|
||||
I need to be able to define example submission and its referential assessment
|
||||
|
||||
@javascript
|
||||
Scenario: Add example submission with attachments to a workshop
|
||||
# Prepare the users, course, enrolments and the workshop instance.
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Terry1 | Teacher1 | teacher1@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname |
|
||||
| Course1 | c1 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | c1 | editingteacher |
|
||||
And the following "activities" exist:
|
||||
| activity | name | intro | course | idnumber | useexamples |
|
||||
| workshop | TestWorkshop | Test workshop description | c1 | workshop1 | 1 |
|
||||
# As a teacher, define the assessment form to be used in the workshop.
|
||||
When I log in as "teacher1"
|
||||
And I follow "Course1"
|
||||
And I edit assessment form in workshop "TestWorkshop" as:"
|
||||
| id_description__idx_0_editor | Aspect1 |
|
||||
| id_description__idx_1_editor | Aspect2 |
|
||||
| id_description__idx_2_editor | |
|
||||
# Add an example submission with an attachment.
|
||||
And I press "Add example submission"
|
||||
And I set the following fields to these values:
|
||||
| Title | First example submission |
|
||||
| Submission content | Just an example but hey, it works! |
|
||||
| Attachment | lib/tests/fixtures/empty.txt |
|
||||
And I press "Save changes"
|
||||
# Make sure that the submission was saved.
|
||||
Then I should see "First example submission"
|
||||
And I should see "Just an example but hey, it works!"
|
||||
And "empty.txt" "link" should exist
|
Loading…
Add table
Add a link
Reference in a new issue