mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
Merge branch 'MDL-78378-master' of https://github.com/sarjona/moodle
This commit is contained in:
commit
58e76214e4
30
mod/survey/tests/behat/survey_description.feature
Normal file
30
mod/survey/tests/behat/survey_description.feature
Normal file
@ -0,0 +1,30 @@
|
||||
@mod @mod_survey
|
||||
Feature: The default introduction is displayed when the activity description is empty
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | format |
|
||||
| Course 1 | C1 | topics |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And the following "activities" exist:
|
||||
| activity | name | course | idnumber | template |
|
||||
| survey | Test survey name | C1 | survey1 | 1 |
|
||||
|
||||
Scenario: Display the default survey introduction when activity description is empty
|
||||
Given I am on the "Test survey name" "survey activity" page logged in as "teacher1"
|
||||
And I should see "Test survey 1"
|
||||
When I am on the "Test survey name" "survey activity editing" page
|
||||
And I set the following fields to these values:
|
||||
| Description | |
|
||||
And I press "Save and display"
|
||||
Then I should see "The purpose of this survey is to help us understand"
|
||||
And I am on the "Test survey name" "survey activity editing" page
|
||||
And I set the following fields to these values:
|
||||
| Survey type | ATTLS (20 item version) |
|
||||
And I press "Save and display"
|
||||
And I should see "The purpose of this questionnaire is to help us evaluate"
|
@ -46,11 +46,6 @@ require_capability('mod/survey:participate', $context);
|
||||
if (! $survey = $DB->get_record("survey", array("id" => $cm->instance))) {
|
||||
throw new \moodle_exception('invalidsurveyid', 'survey');
|
||||
}
|
||||
$trimmedintro = trim($survey->intro);
|
||||
if (empty($trimmedintro)) {
|
||||
$tempo = $DB->get_field("survey", "intro", array("id" => $survey->template));
|
||||
$survey->intro = get_string($tempo, "survey");
|
||||
}
|
||||
|
||||
if (! $template = $DB->get_record("survey", array("id" => $survey->template))) {
|
||||
throw new \moodle_exception('invalidtmptid', 'survey');
|
||||
@ -73,6 +68,13 @@ $PAGE->set_heading($course->fullname);
|
||||
// No need to show the description if the survey is done and a graph page is to be shown.
|
||||
if ($surveyalreadydone && $showscales) {
|
||||
$PAGE->activityheader->set_description('');
|
||||
} else {
|
||||
// If the survey has empty description, display the default one.
|
||||
$trimmedintro = trim($survey->intro);
|
||||
if (empty($trimmedintro)) {
|
||||
$tempo = $DB->get_field("survey", "intro", array("id" => $survey->template));
|
||||
$PAGE->activityheader->set_description(get_string($tempo, "survey"));
|
||||
}
|
||||
}
|
||||
$PAGE->add_body_class('limitedwidth');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user