Merge branch 'MDL-58179-master-fix' of https://github.com/andrewnicols/moodle
authorJake Dallimore <jake@moodle.com>
Thu, 22 Mar 2018 04:05:29 +0000 (12:05 +0800)
committerJake Dallimore <jake@moodle.com>
Thu, 22 Mar 2018 04:05:29 +0000 (12:05 +0800)
admin/user.php
auth/classes/digital_consent.php
blocks/myprofile/block_myprofile.php
mod/glossary/tests/behat/import_entries.feature
mod/lesson/locallib.php
mod/lesson/tests/behat/lesson_exit_enter_clusters.feature [new file with mode: 0644]
mod/quiz/backup/moodle2/restore_quiz_stepslib.php
mod/quiz/tests/tags_test.php
question/format.php
user/classes/participants_table.php

index ac0f5f9..80e462d 100644 (file)
 
     } else {
 
-        $countries = get_string_manager()->get_list_of_countries(false);
+        $countries = get_string_manager()->get_list_of_countries(true);
         if (empty($mnethosts)) {
             $mnethosts = $DB->get_records('mnet_host', null, 'id', 'id,wwwroot,name');
         }
index e3e7e59..3f7e3af 100644 (file)
@@ -71,7 +71,7 @@ class digital_consent {
     public static function parse_age_digital_consent_map($ageconsentmap) {
 
         $ageconsentmapparsed = array();
-        $countries = get_string_manager()->get_list_of_countries();
+        $countries = get_string_manager()->get_list_of_countries(true);
         $isdefaultvaluepresent = false;
         $lines = preg_split('/\r|\n/', $ageconsentmap, -1, PREG_SPLIT_NO_EMPTY);
         foreach ($lines as $line) {
index fa9c166..b596f15 100644 (file)
@@ -75,7 +75,7 @@ class block_myprofile extends block_base {
         $this->content->text .= '<div class="myprofileitem fullname">'.fullname($USER).'</div>';
 
         if(!isset($this->config->display_country) || $this->config->display_country == 1) {
-            $countries = get_string_manager()->get_list_of_countries();
+            $countries = get_string_manager()->get_list_of_countries(true);
             if (isset($countries[$USER->country])) {
                 $this->content->text .= '<div class="myprofileitem country">';
                 $this->content->text .= get_string('country') . ': ' . $countries[$USER->country];
index eab2c79..c33372c 100644 (file)
@@ -1,4 +1,4 @@
-@mod @mod_glossary
+@mod @mod_glossary @_file_upload
 Feature: Importing glossary entries
   In order to add glossary entries by bulk
   As a teacher
index 61a4f92..767b580 100644 (file)
@@ -2515,6 +2515,11 @@ class lesson extends lesson_base {
                     if (!array_key_exists($exitjump, $lessonpages)) {
                         return LESSON_EOL;
                     }
+                    // Check to see that the return type is not a cluster.
+                    if ($lessonpages[$exitjump]->qtype == LESSON_PAGE_CLUSTER) {
+                        // If the exitjump is a cluster then go through this function again and try to find an unseen question.
+                        $exitjump = $this->cluster_jump($exitjump, $userid);
+                    }
                     return $exitjump;
                 }
             }
diff --git a/mod/lesson/tests/behat/lesson_exit_enter_clusters.feature b/mod/lesson/tests/behat/lesson_exit_enter_clusters.feature
new file mode 100644 (file)
index 0000000..216a95e
--- /dev/null
@@ -0,0 +1,228 @@
+@mod @mod_lesson
+Feature: In a lesson activity, students can exit and re-enter the activity when it consists only of cluster pages
+  As a student
+  I need to exit and re-enter a lesson out and into clusters.
+
+  Background:
+    Given the following "users" exist:
+      | username | firstname | lastname | email |
+      | teacher1 | Teacher | 1 | teacher1@example.com |
+      | student1 | Student | 1 | student1@example.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 am on "Course 1" course homepage with editing mode on
+    And I add a "Lesson" to section "1" and I fill the form with:
+      | Name | Lesson with cluster |
+      | Description | Cluster lesson description |
+    And I follow "Lesson with cluster"
+    And I follow "Add a content page"
+    And I set the following fields to these values:
+      | Page title | First page name |
+      | Page contents | First page contents |
+      | id_answer_editor_0 | Next page |
+      | id_jumpto_0 | Next page |
+    And I press "Save page"
+    And I follow "Expanded"
+    And I click on "Add a cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][2]" "xpath_element"
+    And I follow "Update page: Cluster"
+    And I set the following fields to these values:
+      | Page title | C Cluster |
+      | Page contents | C Cluster |
+      | Jump | Unseen question within a cluster |
+    And I press "Save page"
+    And I click on "Add a cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][2]" "xpath_element"
+    And I follow "Update page: Cluster"
+    And I set the following fields to these values:
+      | Page title | B Cluster |
+      | Page contents | B Cluster |
+      | Jump | Unseen question within a cluster |
+    And I press "Save page"
+    And I click on "Add a cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][2]" "xpath_element"
+    And I follow "Update page: Cluster"
+    And I set the following fields to these values:
+      | Page title | A Cluster |
+      | Page contents | A Cluster |
+      | Jump | Unseen question within a cluster |
+    And I press "Save page"
+    And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][3]" "xpath_element"
+    And I set the field "Select a question type" to "Multichoice"
+    And I press "Add a question page"
+    And I set the following fields to these values:
+      | Page title | Question 1 A Cluster |
+      | Page contents | Question 1 from A cluster |
+      | id_answer_editor_0 | Correct answer |
+      | id_response_editor_0 | Good |
+      | id_jumpto_0 | B Cluster |
+      | id_score_0 | 1 |
+      | id_answer_editor_1 | Incorrect answer |
+      | id_response_editor_1 | Bad |
+      | id_jumpto_1 | Unseen question within a cluster |
+      | id_score_1 | 0 |
+    And I press "Save page"
+    And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][4]" "xpath_element"
+    And I set the field "Select a question type" to "Multichoice"
+    And I press "Add a question page"
+    And I set the following fields to these values:
+      | Page title | Question 2 A Cluster |
+      | Page contents | Question 2 from A cluster |
+      | id_answer_editor_0 | Correct answer |
+      | id_response_editor_0 | Good |
+      | id_jumpto_0 | B Cluster |
+      | id_score_0 | 1 |
+      | id_answer_editor_1 | Incorrect answer |
+      | id_response_editor_1 | Bad |
+      | id_jumpto_1 | Unseen question within a cluster |
+      | id_score_1 | 0 |
+    And I press "Save page"
+    And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][5]" "xpath_element"
+    And I press "Add a question page"
+    And I set the following fields to these values:
+      | Page title | Question 3 A Cluster |
+      | Page contents | Question 3 from A cluster |
+      | id_answer_editor_0 | Correct answer |
+      | id_response_editor_0 | Good |
+      | id_jumpto_0 | B Cluster |
+      | id_score_0 | 1 |
+      | id_answer_editor_1 | Incorrect answer |
+      | id_response_editor_1 | Bad |
+      | id_jumpto_1 | Unseen question within a cluster |
+      | id_score_1 | 0 |
+    And I press "Save page"
+    And I click on "Add an end of cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][6]" "xpath_element"
+    And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][8]" "xpath_element"
+    And I set the field "Select a question type" to "Multichoice"
+    And I press "Add a question page"
+    And I set the following fields to these values:
+      | Page title | Question 1 B Cluster |
+      | Page contents | Question 1 from B cluster |
+      | id_answer_editor_0 | Correct answer |
+      | id_response_editor_0 | Good |
+      | id_jumpto_0 | C Cluster |
+      | id_score_0 | 1 |
+      | id_answer_editor_1 | Incorrect answer |
+      | id_response_editor_1 | Bad |
+      | id_jumpto_1 | Unseen question within a cluster |
+      | id_score_1 | 0 |
+    And I press "Save page"
+    And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][9]" "xpath_element"
+    And I set the field "Select a question type" to "Multichoice"
+    And I press "Add a question page"
+    And I set the following fields to these values:
+      | Page title | Question 2 B Cluster |
+      | Page contents | Question 2 from B cluster |
+      | id_answer_editor_0 | Correct answer |
+      | id_response_editor_0 | Good |
+      | id_jumpto_0 | C Cluster |
+      | id_score_0 | 1 |
+      | id_answer_editor_1 | Incorrect answer |
+      | id_response_editor_1 | Bad |
+      | id_jumpto_1 | Unseen question within a cluster |
+      | id_score_1 | 0 |
+    And I press "Save page"
+    And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][10]" "xpath_element"
+    And I press "Add a question page"
+    And I set the following fields to these values:
+      | Page title | Question 3 B Cluster |
+      | Page contents | Question 3 from B cluster |
+      | id_answer_editor_0 | Correct answer |
+      | id_response_editor_0 | Good |
+      | id_jumpto_0 | C Cluster |
+      | id_score_0 | 1 |
+      | id_answer_editor_1 | Incorrect answer |
+      | id_response_editor_1 | Bad |
+      | id_jumpto_1 | Unseen question within a cluster |
+      | id_score_1 | 0 |
+    And I press "Save page"
+    And I click on "Add an end of cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][11]" "xpath_element"
+    And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][13]" "xpath_element"
+    And I set the field "Select a question type" to "Multichoice"
+    And I press "Add a question page"
+    And I set the following fields to these values:
+      | Page title | Question 1 C Cluster |
+      | Page contents | Question 1 from C cluster |
+      | id_answer_editor_0 | Correct answer |
+      | id_response_editor_0 | Good |
+      | id_jumpto_0 | End of lesson |
+      | id_score_0 | 1 |
+      | id_answer_editor_1 | Incorrect answer |
+      | id_response_editor_1 | Bad |
+      | id_jumpto_1 | Unseen question within a cluster |
+      | id_score_1 | 0 |
+    And I press "Save page"
+    And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][14]" "xpath_element"
+    And I set the field "Select a question type" to "Multichoice"
+    And I press "Add a question page"
+    And I set the following fields to these values:
+      | Page title | Question 2 C Cluster |
+      | Page contents | Question 2 from C cluster |
+      | id_answer_editor_0 | Correct answer |
+      | id_response_editor_0 | Good |
+      | id_jumpto_0 | End of lesson |
+      | id_score_0 | 1 |
+      | id_answer_editor_1 | Incorrect answer |
+      | id_response_editor_1 | Bad |
+      | id_jumpto_1 | Unseen question within a cluster |
+      | id_score_1 | 0 |
+    And I press "Save page"
+    And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][15]" "xpath_element"
+    And I press "Add a question page"
+    And I set the following fields to these values:
+      | Page title | Question 3 C Cluster |
+      | Page contents | Question 3 from C cluster |
+      | id_answer_editor_0 | Correct answer |
+      | id_response_editor_0 | Good |
+      | id_jumpto_0 | End of lesson |
+      | id_score_0 | 1 |
+      | id_answer_editor_1 | Incorrect answer |
+      | id_response_editor_1 | Bad |
+      | id_jumpto_1 | Unseen question within a cluster |
+      | id_score_1 | 0 |
+    And I press "Save page"
+    And I click on "Add an end of cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][16]" "xpath_element"
+    And I log out
+
+  Scenario: Accessing as student to a cluster only lesson
+    Given I log in as "student1"
+    And I am on "Course 1" course homepage
+    And I follow "Lesson with cluster"
+    And I should see "First page contents"
+    And I press "Next page"
+    And I should see "Correct answer"
+    And I set the following fields to these values:
+      | Incorrect answer | 1 |
+    And I press "Submit"
+    And I should see "Bad"
+    And I press "Continue"
+    And I set the following fields to these values:
+      | Incorrect answer | 1 |
+    And I press "Submit"
+    And I should see "Bad"
+    And I press "Continue"
+    And I set the following fields to these values:
+      | Correct answer | 1 |
+    And I press "Submit"
+    And I should see "Good"
+    And I press "Continue"
+    And I should see "Incorrect answer"
+    And I set the following fields to these values:
+      | Incorrect answer | 1 |
+    And I press "Submit"
+    And I am on "Course 1" course homepage
+    And I follow "Lesson with cluster"
+    And I should see "Do you want to start at the last page you saw?"
+    And I click on "No" "link" in the "#page-content" "css_element"
+    And I should see "First page contents"
+    And I press "Next page"
+    And I should see "Correct answer"
+    And I set the following fields to these values:
+      | Correct answer | 1 |
+    And I press "Submit"
+    And I should see "Good"
+    And I press "Continue"
+    Then I should see "Correct answer"
index 5f76fa5..13da05f 100644 (file)
@@ -251,7 +251,7 @@ class restore_quiz_activity_structure_step extends restore_questions_activity_st
     }
 
     protected function process_quiz_question_instance($data) {
-        global $DB;
+        global $CFG, $DB;
 
         $data = (object)$data;
 
@@ -302,6 +302,8 @@ class restore_quiz_activity_structure_step extends restore_questions_activity_st
         }
 
         if (isset($data->tags)) {
+            require_once($CFG->dirroot . '/mod/quiz/locallib.php');
+
             $tags = quiz_extract_random_question_tags($data->tags, $this->task->is_samesite());
             $data->tags = quiz_build_random_question_tag_json($tags);
         }
index c5fbbcd..161e07b 100644 (file)
@@ -23,8 +23,6 @@
  */
 
 defined('MOODLE_INTERNAL') || die();
-global $CFG;
-require_once($CFG->dirroot . '/mod/quiz/locallib.php');
 
 /**
  * Class mod_quiz_tags_testcase
index 6e00169..08689f5 100644 (file)
@@ -445,7 +445,7 @@ class qformat_default {
                                 $importingcontext, $question->tags);
                         }
                     }
-                } else {
+                } else if (!empty($question->tags)) {
                     core_tag_tag::set_item_tags('core_question', 'question', $question->id,
                         $question->context, $question->tags);
                 }
index 09f9246..e05e0fd 100644 (file)
@@ -229,7 +229,7 @@ class participants_table extends \table_sql {
         $this->enrolid = $enrolid;
         $this->status = $status;
         $this->selectall = $selectall;
-        $this->countries = get_string_manager()->get_list_of_countries();
+        $this->countries = get_string_manager()->get_list_of_countries(true);
         $this->extrafields = $extrafields;
         $this->context = $context;
         if ($canseegroups) {