diff --git a/mod/feedback/analysis.php b/mod/feedback/analysis.php index e69966fccec0b..6fa61e5934220 100644 --- a/mod/feedback/analysis.php +++ b/mod/feedback/analysis.php @@ -133,7 +133,7 @@ } } -echo '
'; +echo '
'; if ($check_anonymously) { $itemnr = 0; //print the items in an analysed form @@ -160,7 +160,7 @@ 'insufficient_responses', 'feedback', '', '', 3); } -echo '
'; +echo ''; echo $OUTPUT->box_end(); echo $OUTPUT->footer(); diff --git a/mod/feedback/complete.php b/mod/feedback/complete.php index 6ee053efd036c..0731907052765 100644 --- a/mod/feedback/complete.php +++ b/mod/feedback/complete.php @@ -417,7 +417,7 @@ //print the items if (is_array($feedbackitems)) { echo $OUTPUT->box_start('feedback_form'); - echo '
'; + echo ''; echo ''; echo $OUTPUT->box_start('feedback_anonymousinfo'); switch ($feedback->anonymous) { diff --git a/mod/feedback/edit.php b/mod/feedback/edit.php index b06274435788a..00258bee8dfe4 100644 --- a/mod/feedback/edit.php +++ b/mod/feedback/edit.php @@ -140,10 +140,6 @@ $lastposition++; -//The add_item-form -$add_item_form = new feedback_edit_add_question_form('edit_item.php'); -$add_item_form->set_data(array('cmid'=>$id, 'position'=>$lastposition)); - //The use_template-form $use_template_form = new feedback_edit_use_template_form('use_templ.php'); $use_template_form->set_feedbackdata(array('course' => $course)); @@ -237,7 +233,10 @@ /////////////////////////////////////////////////////////////////////////// if ($do_show == 'edit') { - $add_item_form->display(); + $select = new single_select(new moodle_url('/mod/feedback/edit_item.php', array('cmid' => $id, 'position' => $lastposition)), + 'typ', feedback_load_feedback_items_options()); + $select->label = get_string('add_item', 'mod_feedback'); + echo $OUTPUT->render($select); if (is_array($feedbackitems)) { $itemnr = 0; diff --git a/mod/feedback/edit_form.php b/mod/feedback/edit_form.php index 708ca5ae7e177..7de1cba864b08 100644 --- a/mod/feedback/edit_form.php +++ b/mod/feedback/edit_form.php @@ -29,29 +29,6 @@ require_once($CFG->libdir.'/formslib.php'); -class feedback_edit_add_question_form extends moodleform { - public function definition() { - $mform = $this->_form; - - //headline - $mform->addElement('header', 'general', get_string('content')); - // visible elements - $feedback_names_options = feedback_load_feedback_items_options(); - - $attributes = 'onChange="M.core_formchangechecker.set_form_submitted(); this.form.submit()"'; - $mform->addElement('select', 'typ', '', $feedback_names_options, $attributes); - - // hidden elements - $mform->addElement('hidden', 'cmid'); - $mform->setType('cmid', PARAM_INT); - $mform->addElement('hidden', 'position'); - $mform->setType('position', PARAM_INT); - - // buttons - $mform->addElement('submit', 'add_item', get_string('add_item', 'feedback'), array('class' => 'hiddenifjs')); - } -} - class feedback_edit_use_template_form extends moodleform { private $feedbackdata; diff --git a/mod/feedback/item/label/label_form.php b/mod/feedback/item/label/label_form.php index dd04e53ccc1ab..b015cd155555a 100644 --- a/mod/feedback/item/label/label_form.php +++ b/mod/feedback/item/label/label_form.php @@ -39,7 +39,7 @@ public function definition() { $mform->setType('label', PARAM_ALPHA); $mform->addElement('header', 'general', get_string($this->type, 'feedback')); - $mform->addElement('editor', 'presentation_editor', '', null, $presentationoptions); + $mform->addElement('editor', 'presentation_editor', get_string('labelcontents', 'feedback'), null, $presentationoptions); $mform->setType('presentation_editor', PARAM_RAW); parent::definition(); diff --git a/mod/feedback/item/multichoice/lib.php b/mod/feedback/item/multichoice/lib.php index 6332f6e10fe27..8a5269863df3b 100644 --- a/mod/feedback/item/multichoice/lib.php +++ b/mod/feedback/item/multichoice/lib.php @@ -244,7 +244,7 @@ public function print_analysed($item, $itemnr = '', $groupid = false, $courseid $quotient = number_format(($val->quotient * 100), 2, $sep_dec, $sep_thous); $str_quotient = ''; if ($val->quotient > 0) { - $str_quotient = ' ('. $quotient . ' %)'; + $str_quotient = ' ('. $quotient . ' %)'; } echo ''; echo ' @@ -252,7 +252,7 @@ public function print_analysed($item, $itemnr = '', $groupid = false, $courseid '.$intvalue.' -  '.$val->answercount.$str_quotient.' + '.$val->answercount.$str_quotient.' '; echo ''; } @@ -717,7 +717,7 @@ private function print_item_radio($presentation, $item, $value, $info, $align) { diff --git a/mod/feedback/item/multichoice/multichoice_form.php b/mod/feedback/item/multichoice/multichoice_form.php index 6dd192dd6d95e..b9b8785caede0 100644 --- a/mod/feedback/item/multichoice/multichoice_form.php +++ b/mod/feedback/item/multichoice/multichoice_form.php @@ -64,12 +64,10 @@ public function definition() { 'hidenoselect', get_string('hide_no_select_option', 'feedback')); - $mform->addElement('static', - 'hint', - get_string('multichoice_values', 'feedback'), - get_string('use_one_line_for_each_value', 'feedback')); + $mform->addElement('textarea', 'values', get_string('multichoice_values', 'feedback'), + 'wrap="virtual" rows="10" cols="65"'); - $mform->addElement('textarea', 'values', '', 'wrap="virtual" rows="10" cols="65"'); + $mform->addElement('static', 'hint', '', get_string('use_one_line_for_each_value', 'feedback')); parent::definition(); $this->set_data($item); diff --git a/mod/feedback/item/multichoicerated/lib.php b/mod/feedback/item/multichoicerated/lib.php index a2bc2b2a8fa38..79c2078d42104 100644 --- a/mod/feedback/item/multichoicerated/lib.php +++ b/mod/feedback/item/multichoicerated/lib.php @@ -226,7 +226,7 @@ public function print_analysed($item, $itemnr = '', $groupid = false, $courseid echo ''.$intvalue.''; echo $val->answercount; if ($val->quotient > 0) { - echo ' ('.$quotient.' %)'; + echo ' ('.$quotient.' %)'; } else { echo ''; } diff --git a/mod/feedback/item/multichoicerated/multichoicerated_form.php b/mod/feedback/item/multichoicerated/multichoicerated_form.php index 0c1632a9c8118..365edd73f6f4a 100644 --- a/mod/feedback/item/multichoicerated/multichoicerated_form.php +++ b/mod/feedback/item/multichoicerated/multichoicerated_form.php @@ -63,16 +63,16 @@ public function definition() { 'hidenoselect', get_string('hide_no_select_option', 'feedback')); - $mform->addElement('static', - 'hint', - get_string('multichoice_values', 'feedback'), - get_string('use_one_line_for_each_value', 'feedback')); - $this->values = $mform->addElement('textarea', 'values', - '', + get_string('multichoice_values', 'feedback'), 'wrap="virtual" rows="10" cols="65"'); + $mform->addElement('static', + 'hint', + '', + get_string('use_one_line_for_each_value', 'feedback')); + parent::definition(); $this->set_data($item); diff --git a/mod/feedback/item/textarea/lib.php b/mod/feedback/item/textarea/lib.php index e086e1259a703..66d76ff54b3f5 100644 --- a/mod/feedback/item/textarea/lib.php +++ b/mod/feedback/item/textarea/lib.php @@ -155,10 +155,8 @@ public function print_analysed($item, $itemnr = '', $groupid = false, $courseid echo ''; foreach ($values as $value) { echo ''; - echo ''; + echo ''; echo '-  '; - echo ''; - echo ''; echo str_replace("\n", '
', $value->value); echo ''; echo ''; diff --git a/mod/feedback/lang/en/feedback.php b/mod/feedback/lang/en/feedback.php index a50f1f829cb04..11120fa96f26c 100644 --- a/mod/feedback/lang/en/feedback.php +++ b/mod/feedback/lang/en/feedback.php @@ -22,7 +22,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['add_item'] = 'Add question to activity'; +$string['add_item'] = 'Add question'; $string['add_pagebreak'] = 'Add a page break'; $string['adjustment'] = 'Adjustment'; $string['after_submit'] = 'After submission'; @@ -143,6 +143,7 @@ $string['item_label'] = 'Label'; $string['item_name'] = 'Question'; $string['label'] = 'Label'; +$string['labelcontents'] = 'Contents'; $string['line_values'] = 'Rating'; $string['mapcourseinfo'] = 'This is a site-wide feedback that is available to all courses using the feedback block. You can however limit the courses to which it will appear by mapping them. Search the course and map it to this feedback.'; $string['mapcoursenone'] = 'No courses mapped. Feedback available to all courses'; diff --git a/mod/feedback/lib.php b/mod/feedback/lib.php index 0b20af457badc..1b68cd5168f50 100644 --- a/mod/feedback/lib.php +++ b/mod/feedback/lib.php @@ -1418,7 +1418,6 @@ function feedback_load_feedback_items_options() { $feedback_options[$fn] = get_string($fn, 'feedback'); } asort($feedback_options); - $feedback_options = array_merge( array(' ' => get_string('select')), $feedback_options ); return $feedback_options; } diff --git a/mod/feedback/tests/behat/behat_mod_feedback.php b/mod/feedback/tests/behat/behat_mod_feedback.php new file mode 100644 index 0000000000000..d6c4b528cbbcc --- /dev/null +++ b/mod/feedback/tests/behat/behat_mod_feedback.php @@ -0,0 +1,72 @@ +. + +/** + * Steps definitions related to mod_feedback. + * + * @package mod_feedback + * @category test + * @copyright 2016 Marina Glancy + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. + +require_once(__DIR__ . '/../../../../lib/behat/behat_base.php'); + +use Behat\Behat\Context\Step\Given as Given, + Behat\Gherkin\Node\TableNode as TableNode, + Behat\Mink\Exception\ExpectationException as ExpectationException; + +/** + * Steps definitions related to mod_feedback. + * + * @copyright 2016 Marina Glancy + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class behat_mod_feedback extends behat_base { + + /** + * Adds a question to the existing feedback with filling the form. + * + * The form for creating a question should be on one page. + * + * @When /^I add a "(?P(?:[^"]|\\")*)" question to the feedback with:$/ + * @param string $questiontype + * @param TableNode $questiondata with data for filling the add question form + */ + public function i_add_question_to_the_feedback_with($questiontype, TableNode $questiondata) { + $rv = array(); + $questiontype = $this->escape($questiontype); + $additem = $this->escape(get_string('add_item', 'feedback')); + $rv[] = new Given("I select \"{$questiontype}\" from the \"{$additem}\" singleselect"); + + $newdata = new TableNode(); + $rows = $questiondata->getRows(); + foreach ($rows as $row) { + foreach ($row as $key => $value) { + $row[$key] = preg_replace('|\\\\n|', "\n", $value); + } + $newdata->addRow($row); + } + $rv[] = new Given('I set the following fields to these values:', $newdata); + + $saveitem = $this->escape(get_string('save_item', 'feedback')); + $rv[] = new Given("I press \"{$saveitem}\""); + + return $rv; + } +} diff --git a/mod/feedback/tests/behat/question_types.feature b/mod/feedback/tests/behat/question_types.feature new file mode 100644 index 0000000000000..585e993c791e5 --- /dev/null +++ b/mod/feedback/tests/behat/question_types.feature @@ -0,0 +1,139 @@ +@mod @mod_feedback +Feature: Test creating different types of feedback questions + In order to create feedbacks + As a teacher + I need to be able to add different question types + + Background: + Given the following "users" exist: + | username | firstname | lastname | + | teacher1 | Teacher | 1 | + | student1 | Student | 1 | + | student2 | Student | 2 | + And the following "courses" exist: + | fullname | shortname | + | Course 1 | C1 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + | student2 | C1 | student | + And I log in as "admin" + And I navigate to "Manage activities" node in "Site administration > Plugins > Activity modules" + And I click on "Show" "link" in the "Feedback" "table_row" + And I log out + And the following "activities" exist: + | activity | name | course | idnumber | + | feedback | Learning experience | C1 | feedback0 | + When I log in as "teacher1" + And I follow "Course 1" + And I follow "Learning experience" + And I follow "Edit questions" + And I add a "Information" question to the feedback with: + | Question | this is an information question | + | Label | info | + | Information-Type | Course | + And I add a "Label" question to the feedback with: + | Contents | label text | + And I add a "Longer text answer" question to the feedback with: + | Question | this is a longer text answer | + | Label | longertext | + And I add a "Multiple choice" question to the feedback with: + | Question | this is a multiple choice 1 | + | Label | multichoice1 | + | Multiple choice type | Multiple choice - single answer | + | Multiple choice values | option a\noption b\noption c | + And I add a "Multiple choice" question to the feedback with: + | Question | this is a multiple choice 2 | + | Label | multichoice2 | + | Multiple choice type | Multiple choice - multiple answers | + | Hide the "Not selected" option | Yes | + | Multiple choice values | option d\noption e\noption f | + And I add a "Multiple choice" question to the feedback with: + | Question | this is a multiple choice 3 | + | Label | multichoice3 | + | Multiple choice type | Multiple choice - single answer allowed (dropdownlist) | + | Multiple choice values | option g\noption h\noption i | + And I add a "Multiple choice (rated)" question to the feedback with: + | Question | this is a multiple choice rated | + | Label | multichoice4 | + | Multiple choice type | Multiple choice - single answer | + | Multiple choice values | 0/option k\n1/option l\n5/option m | + And I add a "Numeric answer" question to the feedback with: + | Question | this is a numeric answer | + | Label | numeric | + | Range to | 100 | + And I add a "Short text answer" question to the feedback with: + | Question | this is a short text answer | + | Label | shorttext | + | Maximum characters accepted | 200 | + And I log out + And I log in as "student1" + And I follow "Course 1" + And I follow "Learning experience" + And I follow "Answer the questions..." + And I set the following fields to these values: + | this is a longer text answer | my long answer | + | option b | 1 | + | option d | 1 | + | option f | 1 | + | this is a multiple choice 3 | option h | + | option l | 1 | + | this is a numeric answer (0 - 100) | 35 | + | this is a short text answer | hello | + And I press "Submit your answers" + And I log out + And I log in as "student2" + And I follow "Course 1" + And I follow "Learning experience" + And I follow "Answer the questions..." + And I set the following fields to these values: + | this is a longer text answer | lots of feedbacks | + | option a | 1 | + | option d | 1 | + | option e | 1 | + | this is a multiple choice 3 | option i | + | option m | 1 | + | this is a numeric answer (0 - 100) | 71 | + | this is a short text answer | no way | + And I press "Submit your answers" + And I log out + When I log in as "teacher1" + And I follow "Course 1" + And I follow "Learning experience" + And I follow "Analysis" + And I should see "Submitted answers: 2" + And I should see "Questions: 8" + And I log out + And I log in as "teacher1" + And I follow "Course 1" + And I follow "Learning experience" + And I follow "Analysis" + And I should see "C1" in the "(info)" "table" + And I should see "my long answer" in the "(longertext)" "table" + And I should see "lots of feedbacks" in the "(longertext)" "table" + #And I should see "1 (50.00 %)" in the "option a:" "table_row" // TODO: MDL-46891 + #And I should see "1 (50.00 %)" in the "option b:" "table_row" // TODO: MDL-46891 + And I should see "2 (100.00 %)" in the "option d:" "table_row" + And I should see "1 (50.00 %)" in the "option e:" "table_row" + And I should see "1 (50.00 %)" in the "option f:" "table_row" + And I should see "0" in the "option g:" "table_row" + And I should not see "%" in the "option g:" "table_row" + And I should see "1 (50.00 %)" in the "option h:" "table_row" + And I should see "1 (50.00 %)" in the "option i:" "table_row" + And I should see "0" in the "option k (0):" "table_row" + And I should not see "%" in the "option k (0):" "table_row" + And I should see "1 (50.00 %)" in the "option l (1):" "table_row" + And I should see "1 (50.00 %)" in the "option m (5):" "table_row" + And I should see "Average: 3.00" in the "(multichoice4)" "table" + And I should see "35.00" in the "(numeric)" "table" + And I should see "71.00" in the "(numeric)" "table" + And I should see "Average: 53.00" in the "(numeric)" "table" + And I should see "no way" in the "(shorttext)" "table" + And I should see "hello" in the "(shorttext)" "table" + And I log out + + Scenario: Create different types of questions in feedback with javascript disabled + + @javascript + Scenario: Create different types of questions in feedback with javascript enabled diff --git a/mod/feedback/tests/behat/show_nonrespondents.feature b/mod/feedback/tests/behat/show_nonrespondents.feature index 6de0a2349b7bd..e675f0068c7d0 100644 --- a/mod/feedback/tests/behat/show_nonrespondents.feature +++ b/mod/feedback/tests/behat/show_nonrespondents.feature @@ -51,7 +51,7 @@ Feature: Show users who have not responded to the feedback survey | Access restrictions | Grouping: GX1 | And I follow "Frogs" And I follow "Edit questions" - And I set the field "id_typ" to "Short text answer" + And I set the field "Add question" to "Short text answer" And I set the following fields to these values: | Question | Y/N? | And I press "Save question"