Merge branch 'wip_MDL-49184_m29_choice' of https://github.com/skodak/moodle
This commit is contained in:
@@ -73,6 +73,7 @@ class mod_choice_renderer extends plugin_renderer_base {
|
||||
$html .= html_writer::end_tag('ul');
|
||||
$html .= html_writer::tag('div', '', array('class'=>'clearfloat'));
|
||||
$html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
|
||||
$html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'action', 'value'=>'makechoice'));
|
||||
$html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'id', 'value'=>$coursemoduleid));
|
||||
|
||||
if (!empty($options['hascapability']) && ($options['hascapability'])) {
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
@mod @mod_choice
|
||||
Feature: Add choice activity
|
||||
In order to customise choice page
|
||||
As a teacher or admin
|
||||
I need to add remove block from the choice page
|
||||
|
||||
# This tests that the hacky block editing is not borked by legacy forms in choice activity.
|
||||
|
||||
@javascript
|
||||
Scenario: Add a choice activity and complete the activity as a student
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And I log in as "admin"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I add a "Choice" to section "1" and I fill the form with:
|
||||
| Choice name | Choice name 1 |
|
||||
| Description | Choice Description 1 |
|
||||
| option[0] | Option 1 |
|
||||
| option[1] | Option 2 |
|
||||
And I follow "Choice name 1"
|
||||
|
||||
When I add the "Blog menu" block
|
||||
Then I should see "View all entries about this Choice"
|
||||
|
||||
When I configure the "Blog menu" block
|
||||
And I press "Save changes"
|
||||
Then I should see "View all entries about this Choice"
|
||||
|
||||
When I open the "Blog menu" blocks action menu
|
||||
And I click on "Delete" "link" in the "Blog menu" "block"
|
||||
And I press "Yes"
|
||||
Then I should not see "View all entries about this Choice"
|
||||
And I should see "Choice Description 1"
|
||||
|
||||
@javascript
|
||||
Scenario: Add a choice activity and complete the activity as a student
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@asd.com |
|
||||
| student1 | Student | 1 | student1@asd.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I add a "Choice" to section "1" and I fill the form with:
|
||||
| Choice name | Choice name 1 |
|
||||
| Description | Choice Description 1 |
|
||||
| option[0] | Option 1 |
|
||||
| option[1] | Option 2 |
|
||||
And I follow "Choice name 1"
|
||||
|
||||
When I add the "Blog menu" block
|
||||
Then I should see "View all entries about this Choice"
|
||||
|
||||
When I configure the "Blog menu" block
|
||||
And I press "Save changes"
|
||||
Then I should see "View all entries about this Choice"
|
||||
|
||||
When I open the "Blog menu" blocks action menu
|
||||
And I click on "Delete" "link" in the "Blog menu" "block"
|
||||
And I press "Yes"
|
||||
Then I should not see "View all entries about this Choice"
|
||||
And I should see "Choice Description 1"
|
||||
|
||||
@javascript
|
||||
Scenario: Add a choice activity and complete the activity as a student
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@asd.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| teacher1 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I add a "Choice" to section "1" and I fill the form with:
|
||||
| Choice name | Choice name 1 |
|
||||
| Description | Choice Description 1 |
|
||||
| option[0] | Option 1 |
|
||||
| option[1] | Option 2 |
|
||||
And I follow "Choice name 1"
|
||||
|
||||
When I add the "Blog menu" block
|
||||
Then I should see "View all entries about this Choice"
|
||||
|
||||
When I configure the "Blog menu" block
|
||||
And I press "Save changes"
|
||||
Then I should see "View all entries about this Choice"
|
||||
|
||||
When I open the "Blog menu" blocks action menu
|
||||
And I click on "Delete" "link" in the "Blog menu" "block"
|
||||
And I press "Yes"
|
||||
Then I should not see "View all entries about this Choice"
|
||||
And I should see "Choice Description 1"
|
||||
@@ -0,0 +1,6 @@
|
||||
This files describes API changes in /mod/choice/*,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 2.9 ===
|
||||
|
||||
* custom renderers must be updated to include action=makechoice field in display_options()
|
||||
+21
-9
@@ -7,6 +7,7 @@ require_once($CFG->libdir . '/completionlib.php');
|
||||
$id = required_param('id', PARAM_INT); // Course Module ID
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$attemptids = optional_param_array('attemptid', array(), PARAM_INT); // array of attempt ids for delete action
|
||||
$notify = optional_param('notify', '', PARAM_ALPHA);
|
||||
|
||||
$url = new moodle_url('/mod/choice/view.php', array('id'=>$id));
|
||||
if ($action !== '') {
|
||||
@@ -43,6 +44,7 @@ if ($action == 'delchoice' and confirm_sesskey() and is_enrolled($context, NULL,
|
||||
if ($completion->is_enabled($cm) && $choice->completionsubmit) {
|
||||
$completion->update_state($cm, COMPLETION_INCOMPLETE);
|
||||
}
|
||||
redirect("view.php?id=$cm->id");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,25 +64,35 @@ if (data_submitted() && is_enrolled($context, NULL, 'mod/choice:choose') && conf
|
||||
redirect("view.php?id=$cm->id");
|
||||
}
|
||||
|
||||
// Redirection after all POSTs breaks block editing, we need to be more specific!
|
||||
if ($choice->allowmultiple) {
|
||||
$answer = optional_param_array('answer', array(), PARAM_INT);
|
||||
} else {
|
||||
$answer = optional_param('answer', '', PARAM_INT);
|
||||
}
|
||||
|
||||
if (empty($answer)) {
|
||||
redirect("view.php?id=$cm->id", get_string('mustchooseone', 'choice'));
|
||||
} else {
|
||||
if ($answer) {
|
||||
choice_user_submit_response($answer, $choice, $USER->id, $course, $cm);
|
||||
redirect(new moodle_url('/mod/choice/view.php',
|
||||
array('id' => $cm->id, 'notify' => 'choicesaved', 'sesskey' => sesskey())));
|
||||
} else if (empty($answer) and $action === 'makechoice') {
|
||||
// We cannot use the 'makechoice' alone because there might be some legacy renderers without it,
|
||||
// outdated renderers will not get the 'mustchoose' message - bad luck.
|
||||
redirect(new moodle_url('/mod/choice/view.php',
|
||||
array('id' => $cm->id, 'notify' => 'mustchooseone', 'sesskey' => sesskey())));
|
||||
}
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(format_string($choice->name), 2, null);
|
||||
echo $OUTPUT->notification(get_string('choicesaved', 'choice'),'notifysuccess');
|
||||
} else {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(format_string($choice->name), 2, null);
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(format_string($choice->name), 2, null);
|
||||
|
||||
if ($notify and confirm_sesskey()) {
|
||||
if ($notify === 'choicesaved') {
|
||||
echo $OUTPUT->notification(get_string('choicesaved', 'choice'), 'notifysuccess');
|
||||
} else if ($notify === 'mustchooseone') {
|
||||
echo $OUTPUT->notification(get_string('mustchooseone', 'choice'), 'notifyproblem');
|
||||
}
|
||||
}
|
||||
|
||||
/// Display the choice and possibly results
|
||||
$eventdata = array();
|
||||
|
||||
Reference in New Issue
Block a user