Merge branch 'MDL-55289-master-exsubmission' of git://github.com/mudrd8mz/moodle

This commit is contained in:
Andrew Nicols
2016-08-01 08:46:54 +08:00
4 changed files with 57 additions and 6 deletions
+7 -5
View File
@@ -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;
+11
View File
@@ -2486,6 +2486,9 @@ class workshop {
* @return array
*/
public function submission_content_options() {
global $CFG;
require_once($CFG->dirroot.'/repository/lib.php');
return array(
'trusttext' => true,
'subdirs' => false,
@@ -2502,6 +2505,8 @@ class workshop {
* @return array
*/
public function submission_attachment_options() {
global $CFG;
require_once($CFG->dirroot.'/repository/lib.php');
$options = array(
'subdirs' => true,
@@ -2523,12 +2528,16 @@ class workshop {
* @return array
*/
public function overall_feedback_content_options() {
global $CFG;
require_once($CFG->dirroot.'/repository/lib.php');
return array(
'subdirs' => 0,
'maxbytes' => $this->overallfeedbackmaxbytes,
'maxfiles' => $this->overallfeedbackfiles,
'changeformat' => 1,
'context' => $this->context,
'return_types' => FILE_INTERNAL,
);
}
@@ -2538,6 +2547,8 @@ class workshop {
* @return array
*/
public function overall_feedback_attachment_options() {
global $CFG;
require_once($CFG->dirroot.'/repository/lib.php');
$options = array(
'subdirs' => 1,
-1
View File
@@ -25,7 +25,6 @@
require(__DIR__.'/../../config.php');
require_once(__DIR__.'/locallib.php');
require_once($CFG->dirroot . '/repository/lib.php');
$cmid = required_param('cmid', PARAM_INT); // Course module id.
$id = optional_param('id', 0, PARAM_INT); // Submission id.
@@ -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