mirror of
https://github.com/moodle/moodle.git
synced 2025-04-12 20:12:15 +02:00
Merge branch 'MDL-55957-master-workshopfiles' of git://github.com/mudrd8mz/moodle
This commit is contained in:
commit
03b2e3a04d
@ -265,7 +265,7 @@ echo $output->render($workshop->prepare_submission($submission, has_capability('
|
||||
// for evaluating the assessment
|
||||
if (trim($workshop->instructreviewers)) {
|
||||
$instructions = file_rewrite_pluginfile_urls($workshop->instructreviewers, 'pluginfile.php', $PAGE->context->id,
|
||||
'mod_workshop', 'instructreviewers', 0, workshop::instruction_editors_options($PAGE->context));
|
||||
'mod_workshop', 'instructreviewers', null, workshop::instruction_editors_options($PAGE->context));
|
||||
print_collapsible_region_start('', 'workshop-viewlet-instructreviewers', get_string('instructreviewers', 'workshop'));
|
||||
echo $output->box(format_text($instructions, $workshop->instructreviewersformat, array('overflowdiv'=>true)), array('generalbox', 'instructions'));
|
||||
print_collapsible_region_end();
|
||||
|
@ -143,7 +143,7 @@ echo $output->render($workshop->prepare_example_submission(($example)));
|
||||
// for evaluating the assessment
|
||||
if (trim($workshop->instructreviewers)) {
|
||||
$instructions = file_rewrite_pluginfile_urls($workshop->instructreviewers, 'pluginfile.php', $PAGE->context->id,
|
||||
'mod_workshop', 'instructreviewers', 0, workshop::instruction_editors_options($PAGE->context));
|
||||
'mod_workshop', 'instructreviewers', null, workshop::instruction_editors_options($PAGE->context));
|
||||
print_collapsible_region_start('', 'workshop-viewlet-instructreviewers', get_string('instructreviewers', 'workshop'));
|
||||
echo $output->box(format_text($instructions, $workshop->instructreviewersformat, array('overflowdiv'=>true)), array('generalbox', 'instructions'));
|
||||
print_collapsible_region_end();
|
||||
|
@ -179,7 +179,7 @@ echo $output->heading(format_string($workshop->name), 2);
|
||||
// while reading the submitted answer
|
||||
if (trim($workshop->instructauthors)) {
|
||||
$instructions = file_rewrite_pluginfile_urls($workshop->instructauthors, 'pluginfile.php', $PAGE->context->id,
|
||||
'mod_workshop', 'instructauthors', 0, workshop::instruction_editors_options($PAGE->context));
|
||||
'mod_workshop', 'instructauthors', null, workshop::instruction_editors_options($PAGE->context));
|
||||
print_collapsible_region_start('', 'workshop-viewlet-instructauthors', get_string('instructauthors', 'workshop'));
|
||||
echo $output->box(format_text($instructions, $workshop->instructauthorsformat, array('overflowdiv'=>true)), array('generalbox', 'instructions'));
|
||||
print_collapsible_region_end();
|
||||
|
@ -1318,8 +1318,8 @@ function workshop_pluginfile($course, $cm, $context, $filearea, array $args, $fo
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
if ($filearea === 'instructauthors') {
|
||||
array_shift($args); // itemid is ignored here
|
||||
if ($filearea === 'instructauthors' or $filearea === 'instructreviewers' or $filearea === 'conclusion') {
|
||||
// The $args are supposed to contain just the path, not the item id.
|
||||
$relativepath = implode('/', $args);
|
||||
$fullpath = "/$context->id/mod_workshop/$filearea/0/$relativepath";
|
||||
|
||||
@ -1327,34 +1327,6 @@ function workshop_pluginfile($course, $cm, $context, $filearea, array $args, $fo
|
||||
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
|
||||
send_file_not_found();
|
||||
}
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, null, 0, $forcedownload, $options);
|
||||
|
||||
} else if ($filearea === 'instructreviewers') {
|
||||
array_shift($args); // itemid is ignored here
|
||||
$relativepath = implode('/', $args);
|
||||
$fullpath = "/$context->id/mod_workshop/$filearea/0/$relativepath";
|
||||
|
||||
$fs = get_file_storage();
|
||||
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
|
||||
send_file_not_found();
|
||||
}
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, null, 0, $forcedownload, $options);
|
||||
|
||||
} else if ($filearea === 'conclusion') {
|
||||
array_shift($args); // itemid is ignored here
|
||||
$relativepath = implode('/', $args);
|
||||
$fullpath = "/$context->id/mod_workshop/$filearea/0/$relativepath";
|
||||
|
||||
$fs = get_file_storage();
|
||||
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
|
||||
send_file_not_found();
|
||||
}
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, null, 0, $forcedownload, $options);
|
||||
|
||||
} else if ($filearea === 'submission_content' or $filearea === 'submission_attachment') {
|
||||
|
@ -321,7 +321,7 @@ echo $output->heading(get_string('mysubmission', 'workshop'), 3);
|
||||
// while reading the submitted answer
|
||||
if (trim($workshop->instructauthors)) {
|
||||
$instructions = file_rewrite_pluginfile_urls($workshop->instructauthors, 'pluginfile.php', $PAGE->context->id,
|
||||
'mod_workshop', 'instructauthors', 0, workshop::instruction_editors_options($PAGE->context));
|
||||
'mod_workshop', 'instructauthors', null, workshop::instruction_editors_options($PAGE->context));
|
||||
print_collapsible_region_start('', 'workshop-viewlet-instructauthors', get_string('instructauthors', 'workshop'));
|
||||
echo $output->box(format_text($instructions, $workshop->instructauthorsformat, array('overflowdiv'=>true)), array('generalbox', 'instructions'));
|
||||
print_collapsible_region_end();
|
||||
|
71
mod/workshop/tests/behat/embedded_images.feature
Normal file
71
mod/workshop/tests/behat/embedded_images.feature
Normal file
@ -0,0 +1,71 @@
|
||||
@mod @mod_workshop @javascript @_file_upload
|
||||
Feature: Teachers can embed images into instructions and conclusion fields
|
||||
In order to display images as a part of instructions or conclusions in the workshop
|
||||
As a teacher
|
||||
I need to be able to embed images into the fields and they should display correctly
|
||||
|
||||
Scenario: Embedding the image into the instructions and conclusions fields
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | One | teacher1@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname |
|
||||
| Course 1 | C1 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And I log in as "teacher1"
|
||||
# Upload an image into the private files.
|
||||
And I follow "Manage private files"
|
||||
And I upload "mod/workshop/tests/fixtures/moodlelogo.png" file to "Files" filemanager
|
||||
And I click on "Save changes" "button"
|
||||
And I am on homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
# Create and edit the workshop.
|
||||
When I add a "Workshop" to section "1" and I fill the form with:
|
||||
| Workshop name | Workshop with embedded images |
|
||||
And I follow "Workshop with embedded images"
|
||||
# Embed the image into Instructions for submission.
|
||||
And I navigate to "Edit settings" node in "Workshop administration"
|
||||
And I expand all fieldsets
|
||||
And I select the text in the "Instructions for submission" Atto editor
|
||||
And I click on "Image" "button" in the "#fitem_id_instructauthorseditor" "css_element"
|
||||
And I click on "Browse repositories..." "button"
|
||||
And I click on "Private files" "link"
|
||||
And I click on "moodlelogo.png" "link"
|
||||
And I click on "Select this file" "button"
|
||||
And I set the field "Describe this image for someone who cannot see it" to "How to submit"
|
||||
And I click on "Save image" "button"
|
||||
And I press "Save and display"
|
||||
# Embed the image into Instructions for assessment.
|
||||
And I navigate to "Edit settings" node in "Workshop administration"
|
||||
And I expand all fieldsets
|
||||
And I select the text in the "Instructions for assessment" Atto editor
|
||||
And I click on "Image" "button" in the "#fitem_id_instructreviewerseditor" "css_element"
|
||||
And I click on "Browse repositories..." "button"
|
||||
And I click on "Private files" "link"
|
||||
And I click on "moodlelogo.png" "link"
|
||||
And I click on "Select this file" "button"
|
||||
And I set the field "Describe this image for someone who cannot see it" to "How to assess"
|
||||
And I click on "Save image" "button"
|
||||
And I press "Save and display"
|
||||
# Embed the image into Conclusion.
|
||||
And I navigate to "Edit settings" node in "Workshop administration"
|
||||
And I expand all fieldsets
|
||||
And I select the text in the "Conclusion" Atto editor
|
||||
And I click on "Image" "button" in the "#fitem_id_conclusioneditor" "css_element"
|
||||
And I click on "Browse repositories..." "button"
|
||||
And I click on "Private files" "link"
|
||||
And I click on "moodlelogo.png" "link"
|
||||
And I click on "Select this file" "button"
|
||||
And I set the field "Describe this image for someone who cannot see it" to "Well done"
|
||||
And I click on "Save image" "button"
|
||||
And I press "Save and display"
|
||||
# Save the form and check the images are displayed in appropriate phases.
|
||||
And I change phase in workshop "Workshop with embedded images" to "Submission phase"
|
||||
Then "//*[contains(@class, 'instructions')]//img[contains(@src, 'pluginfile.php') and contains(@src, '/mod_workshop/instructauthors/moodlelogo.png') and @alt='How to submit']" "xpath_element" should exist
|
||||
And I change phase in workshop "Workshop with embedded images" to "Assessment phase"
|
||||
And "//*[contains(@class, 'instructions')]//img[contains(@src, 'pluginfile.php') and contains(@src, '/mod_workshop/instructreviewers/moodlelogo.png') and @alt='How to assess']" "xpath_element" should exist
|
||||
And I change phase in workshop "Workshop with embedded images" to "Closed"
|
||||
And "//*[contains(@class, 'conclusion')]//img[contains(@src, 'pluginfile.php') and contains(@src, '/mod_workshop/conclusion/moodlelogo.png') and @alt='Well done']" "xpath_element" should exist
|
BIN
mod/workshop/tests/fixtures/moodlelogo.png
vendored
Normal file
BIN
mod/workshop/tests/fixtures/moodlelogo.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
@ -148,7 +148,7 @@ case workshop::PHASE_SETUP:
|
||||
case workshop::PHASE_SUBMISSION:
|
||||
if (trim($workshop->instructauthors)) {
|
||||
$instructions = file_rewrite_pluginfile_urls($workshop->instructauthors, 'pluginfile.php', $PAGE->context->id,
|
||||
'mod_workshop', 'instructauthors', 0, workshop::instruction_editors_options($PAGE->context));
|
||||
'mod_workshop', 'instructauthors', null, workshop::instruction_editors_options($PAGE->context));
|
||||
print_collapsible_region_start('', 'workshop-viewlet-instructauthors', get_string('instructauthors', 'workshop'));
|
||||
echo $output->box(format_text($instructions, $workshop->instructauthorsformat, array('overflowdiv'=>true)), array('generalbox', 'instructions'));
|
||||
print_collapsible_region_end();
|
||||
@ -333,7 +333,7 @@ case workshop::PHASE_ASSESSMENT:
|
||||
}
|
||||
if (trim($workshop->instructreviewers)) {
|
||||
$instructions = file_rewrite_pluginfile_urls($workshop->instructreviewers, 'pluginfile.php', $PAGE->context->id,
|
||||
'mod_workshop', 'instructreviewers', 0, workshop::instruction_editors_options($PAGE->context));
|
||||
'mod_workshop', 'instructreviewers', null, workshop::instruction_editors_options($PAGE->context));
|
||||
print_collapsible_region_start('', 'workshop-viewlet-instructreviewers', get_string('instructreviewers', 'workshop'));
|
||||
echo $output->box(format_text($instructions, $workshop->instructreviewersformat, array('overflowdiv'=>true)), array('generalbox', 'instructions'));
|
||||
print_collapsible_region_end();
|
||||
@ -554,7 +554,7 @@ case workshop::PHASE_EVALUATION:
|
||||
case workshop::PHASE_CLOSED:
|
||||
if (trim($workshop->conclusion)) {
|
||||
$conclusion = file_rewrite_pluginfile_urls($workshop->conclusion, 'pluginfile.php', $workshop->context->id,
|
||||
'mod_workshop', 'conclusion', 0, workshop::instruction_editors_options($workshop->context));
|
||||
'mod_workshop', 'conclusion', null, workshop::instruction_editors_options($workshop->context));
|
||||
print_collapsible_region_start('', 'workshop-viewlet-conclusion', get_string('conclusion', 'workshop'));
|
||||
echo $output->box(format_text($conclusion, $workshop->conclusionformat, array('overflowdiv'=>true)), array('generalbox', 'conclusion'));
|
||||
print_collapsible_region_end();
|
||||
|
Loading…
x
Reference in New Issue
Block a user