Merge branch 'wip-mdl-46891-fix' of https://github.com/rajeshtaneja/moodle
authorDavid Monllao <davidm@moodle.com>
Mon, 14 Mar 2016 06:35:00 +0000 (14:35 +0800)
committerDavid Monllao <davidm@moodle.com>
Mon, 14 Mar 2016 06:35:00 +0000 (14:35 +0800)
28 files changed:
lib/grade/grade_item.php
lib/moodlelib.php
lib/tests/moodlelib_test.php
mod/forum/lib.php
mod/forum/upgrade.txt
mod/wiki/classes/external.php
mod/wiki/db/services.php
mod/wiki/tests/externallib_test.php
mod/wiki/version.php
question/behaviour/adaptive/tests/walkthrough_test.php
question/behaviour/adaptivenopenalty/tests/walkthrough_test.php
question/behaviour/interactive/renderer.php
question/behaviour/interactive/tests/walkthrough_test.php
question/behaviour/interactivecountback/tests/walkthrough_test.php
question/behaviour/rendererbase.php
question/behaviour/upgrade.txt
question/engine/tests/helpers.php
question/type/calculated/tests/walkthrough_test.php
question/type/calculatedmulti/tests/walkthrough_test.php
question/type/calculatedsimple/tests/walkthrough_test.php
question/type/ddimageortext/tests/walkthrough_test.php
question/type/ddmarker/tests/walkthrough_test.php
question/type/ddwtos/tests/walkthrough_test.php
question/type/gapselect/tests/walkthrough_test.php
question/type/match/tests/walkthrough_test.php
question/type/multianswer/tests/walkthrough_test.php
question/type/numerical/tests/walkthrough_test.php
question/type/randomsamatch/tests/walkthrough_test.php

index 40df5cc..229571e 100644 (file)
@@ -1763,6 +1763,7 @@ class grade_item extends grade_object {
             $grade->feedbackformat = $feedbackformat;
         }
 
+        $gradechanged = false;
         if (empty($grade->id)) {
             $grade->timecreated  = null;   // hack alert - date submitted - no submission yet
             $grade->timemodified = time(); // hack alert - date graded
@@ -1772,12 +1773,23 @@ class grade_item extends grade_object {
             if ($result && !is_null($grade->finalgrade)) {
                 \core\event\user_graded::create_from_grade($grade)->trigger();
             }
-        } else if (grade_floats_different($grade->finalgrade, $oldgrade->finalgrade)
-                or $grade->feedback       !== $oldgrade->feedback
-                or $grade->feedbackformat != $oldgrade->feedbackformat
-                or grade_floats_different($grade->rawgrademin, $oldgrade->rawgrademin)
-                or grade_floats_different($grade->rawgrademax, $oldgrade->rawgrademax)
-                or ($oldgrade->overridden == 0 and $grade->overridden > 0)) {
+            $gradechanged = true;
+        } else {
+            // Existing grade_grades.
+
+            if (grade_floats_different($grade->finalgrade, $oldgrade->finalgrade)
+                    or grade_floats_different($grade->rawgrademin, $oldgrade->rawgrademin)
+                    or grade_floats_different($grade->rawgrademax, $oldgrade->rawgrademax)
+                    or ($oldgrade->overridden == 0 and $grade->overridden > 0)) {
+                $gradechanged = true;
+            }
+
+            if ($grade->feedback === $oldgrade->feedback and $grade->feedbackformat == $oldgrade->feedbackformat and
+                    $gradechanged === false) {
+                // No grade nor feedback changed.
+                return $result;
+            }
+
             $grade->timemodified = time(); // hack alert - date graded
             $result = $grade->update($source);
 
@@ -1785,21 +1797,26 @@ class grade_item extends grade_object {
             if ($result && grade_floats_different($grade->finalgrade, $oldgrade->finalgrade)) {
                 \core\event\user_graded::create_from_grade($grade)->trigger();
             }
-        } else {
-            // no grade change
-            return $result;
         }
 
         if (!$result) {
-            // something went wrong - better force final grade recalculation
+            // Something went wrong - better force final grade recalculation.
             $this->force_regrading();
+            return $result;
+        }
+
+        // If we are not updating grades we don't need to recalculate the whole course.
+        if (!$gradechanged) {
+            return $result;
+        }
 
-        } else if ($this->is_course_item() and !$this->needsupdate) {
+        if ($this->is_course_item() and !$this->needsupdate) {
             if (grade_regrade_final_grades($this->courseid, $userid, $this) !== true) {
                 $this->force_regrading();
             }
 
         } else if (!$this->needsupdate) {
+
             $course_item = grade_item::fetch_course_item($this->courseid);
             if (!$course_item->needsupdate) {
                 if (grade_regrade_final_grades($this->courseid, $userid, $this) !== true) {
@@ -1927,6 +1944,7 @@ class grade_item extends grade_object {
         }
         // end of hack alert
 
+        $gradechanged = false;
         if (empty($grade->id)) {
             $result = (bool)$grade->insert($source);
 
@@ -1934,31 +1952,47 @@ class grade_item extends grade_object {
             if ($result && !is_null($grade->finalgrade)) {
                 \core\event\user_graded::create_from_grade($grade)->trigger();
             }
-        } else if (grade_floats_different($grade->finalgrade,  $oldgrade->finalgrade)
-                or grade_floats_different($grade->rawgrade,    $oldgrade->rawgrade)
-                or grade_floats_different($grade->rawgrademin, $oldgrade->rawgrademin)
-                or grade_floats_different($grade->rawgrademax, $oldgrade->rawgrademax)
-                or $grade->rawscaleid     != $oldgrade->rawscaleid
-                or $grade->feedback       !== $oldgrade->feedback
-                or $grade->feedbackformat != $oldgrade->feedbackformat
-                or $grade->timecreated    != $oldgrade->timecreated  // part of hack above
-                or $grade->timemodified   != $oldgrade->timemodified // part of hack above
-                ) {
+            $gradechanged = true;
+        } else {
+            // Existing grade_grades.
+
+            if (grade_floats_different($grade->finalgrade,  $oldgrade->finalgrade)
+                    or grade_floats_different($grade->rawgrade,    $oldgrade->rawgrade)
+                    or grade_floats_different($grade->rawgrademin, $oldgrade->rawgrademin)
+                    or grade_floats_different($grade->rawgrademax, $oldgrade->rawgrademax)
+                    or $grade->rawscaleid != $oldgrade->rawscaleid) {
+                $gradechanged = true;
+            }
+
+            // The timecreated and timemodified checking is part of the hack above.
+            if ($gradechanged === false and
+                    $grade->feedback === $oldgrade->feedback and
+                    $grade->feedbackformat == $oldgrade->feedbackformat and
+                    $grade->timecreated == $oldgrade->timecreated and
+                    $grade->timemodified == $oldgrade->timemodified) {
+                // No changes.
+                return $result;
+            }
             $result = $grade->update($source);
 
             // If the grade update was successful and the actual grade has changed then trigger a user_graded event.
             if ($result && grade_floats_different($grade->finalgrade, $oldgrade->finalgrade)) {
                 \core\event\user_graded::create_from_grade($grade)->trigger();
             }
-        } else {
-            return $result;
         }
 
         if (!$result) {
-            // something went wrong - better force final grade recalculation
+            // Something went wrong - better force final grade recalculation.
             $this->force_regrading();
+            return $result;
+        }
 
-        } else if (!$this->needsupdate) {
+        // If we are not updating grades we don't need to recalculate the whole course.
+        if (!$gradechanged) {
+            return $result;
+        }
+
+        if (!$this->needsupdate) {
             $course_item = grade_item::fetch_course_item($this->courseid);
             if (!$course_item->needsupdate) {
                 if (grade_regrade_final_grades($this->courseid, $userid, $this) !== true) {
index 4ce2921..3df1368 100644 (file)
@@ -5460,6 +5460,37 @@ function email_should_be_diverted($email) {
     return true;
 }
 
+/**
+ * Generate a unique email Message-ID using the moodle domain and install path
+ *
+ * @param string $localpart An optional unique message id prefix.
+ * @return string The formatted ID ready for appending to the email headers.
+ */
+function generate_email_messageid($localpart = null) {
+    global $CFG;
+
+    $urlinfo = parse_url($CFG->wwwroot);
+    $base = '@' . $urlinfo['host'];
+
+    // If multiple moodles are on the same domain we want to tell them
+    // apart so we add the install path to the local part. This means
+    // that the id local part should never contain a / character so
+    // we can correctly parse the id to reassemble the wwwroot.
+    if (isset($urlinfo['path'])) {
+        $base = $urlinfo['path'] . $base;
+    }
+
+    if (empty($localpart)) {
+        $localpart = uniqid('', true);
+    }
+
+    // Because we may have an option /installpath suffix to the local part
+    // of the id we need to escape any / chars which are in the $localpart.
+    $localpart = str_replace('/', '%2F', $localpart);
+
+    return '<' . $localpart . $base . '>';
+}
+
 /**
  * Send an email to a specified user
  *
@@ -5682,6 +5713,11 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml = '',
     $mail->FromName = $renderer->render_from_template('core/email_fromname', $context);
     $messagetext = $renderer->render_from_template('core/email_text', $context);
 
+    // Autogenerate a MessageID if it's missing.
+    if (empty($mail->MessageID)) {
+        $mail->MessageID = generate_email_messageid();
+    }
+
     if ($messagehtml && !empty($user->mailformat) && $user->mailformat == 1) {
         // Don't ever send HTML to users who don't want it.
         $mail->isHTML(true);
index e337c76..fb9d5ae 100644 (file)
@@ -2644,7 +2644,50 @@ class core_moodlelib_testcase extends advanced_testcase {
         $this->assertEventContextNotUsed($event);
     }
 
+    /**
+     * A data provider for testing email messageid
+     */
+    public function generate_email_messageid_provider() {
+        return array(
+            'nopath' => array(
+                'wwwroot' => 'http://www.example.com',
+                'ids' => array(
+                    'a-custom-id' => '<a-custom-id@www.example.com>',
+                    'an-id-with-/-a-slash' => '<an-id-with-%2F-a-slash@www.example.com>',
+                ),
+            ),
+            'path' => array(
+                'wwwroot' => 'http://www.example.com/path/subdir',
+                'ids' => array(
+                    'a-custom-id' => '<a-custom-id/path/subdir@www.example.com>',
+                    'an-id-with-/-a-slash' => '<an-id-with-%2F-a-slash/path/subdir@www.example.com>',
+                ),
+            ),
+        );
+    }
+
+    /**
+     * Test email message id generation
+     *
+     * @dataProvider generate_email_messageid_provider
+     *
+     * @param string $wwwroot The wwwroot
+     * @param array $msgids An array of msgid local parts and the final result
+     */
+    public function test_generate_email_messageid($wwwroot, $msgids) {
+        global $CFG;
+
+        $this->resetAfterTest();
+        $CFG->wwwroot = $wwwroot;
+
+        foreach ($msgids as $local => $final) {
+            $this->assertEquals($final, generate_email_messageid($local));
+        }
+    }
 
+    /**
+     * A data provider for testing email diversion
+     */
     public function diverted_emails_provider() {
         return array(
             'nodiverts' => array(
@@ -2697,7 +2740,14 @@ class core_moodlelib_testcase extends advanced_testcase {
     }
 
     /**
+     * Test email diversion
+     *
      * @dataProvider diverted_emails_provider
+     *
+     * @param string $divertallemailsto An optional email address
+     * @param string $divertallemailsexcept An optional exclusion list
+     * @param array $addresses An array of test addresses
+     * @param boolean $expected Expected result
      */
     public function test_email_should_be_diverted($divertallemailsto, $divertallemailsexcept, $addresses, $expected) {
         global $CFG;
index 39d976a..a1e9069 100644 (file)
@@ -410,11 +410,10 @@ WHERE
  *
  * @param int $postid The ID of the forum post we are notifying the user about
  * @param int $usertoid The ID of the user being notified
- * @param string $hostname The server's hostname
  * @return string A unique message-id
  */
-function forum_get_email_message_id($postid, $usertoid, $hostname) {
-    return '<'.hash('sha256',$postid.'to'.$usertoid).'@'.$hostname.'>';
+function forum_get_email_message_id($postid, $usertoid) {
+    return generate_email_messageid(hash('sha256', $postid . 'to' . $usertoid));
 }
 
 /**
@@ -596,9 +595,6 @@ function forum_cron() {
 
     if ($users && $posts) {
 
-        $urlinfo = parse_url($CFG->wwwroot);
-        $hostname = $urlinfo['host'];
-
         foreach ($users as $userto) {
             // Terminate if processing of any account takes longer than 2 minutes.
             core_php_time_limit::raise(120);
@@ -751,9 +747,9 @@ function forum_cron() {
 
                 $userfrom->customheaders = array (
                     // Headers to make emails easier to track.
-                    'List-Id: "'        . $cleanforumname . '" <moodleforum' . $forum->id . '@' . $hostname.'>',
+                    'List-Id: "'        . $cleanforumname . '" ' . generate_email_messageid('moodleforum' . $forum->id),
                     'List-Help: '       . $CFG->wwwroot . '/mod/forum/view.php?f=' . $forum->id,
-                    'Message-ID: '      . forum_get_email_message_id($post->id, $userto->id, $hostname),
+                    'Message-ID: '      . forum_get_email_message_id($post->id, $userto->id),
                     'X-Course-Id: '     . $course->id,
                     'X-Course-Name: '   . format_string($course->fullname, true),
 
@@ -810,11 +806,11 @@ function forum_cron() {
                 $a->courseshortname = $data->get_coursename();
                 $postsubject = html_to_text(get_string('postmailsubject', 'forum', $a), 0);
 
-                $rootid = forum_get_email_message_id($discussion->firstpost, $userto->id, $hostname);
+                $rootid = forum_get_email_message_id($discussion->firstpost, $userto->id);
 
                 if ($post->parent) {
                     // This post is a reply, so add reply header (RFC 2822).
-                    $parentid = forum_get_email_message_id($post->parent, $userto->id, $hostname);
+                    $parentid = forum_get_email_message_id($post->parent, $userto->id);
                     $userfrom->customheaders[] = "In-Reply-To: $parentid";
 
                     // If the post is deeply nested we also reference the parent message id and
index 2dc8b89..572ffe5 100644 (file)
@@ -1,6 +1,9 @@
 This files describes API changes in /mod/forum/*,
 information provided here is intended especially for developers.
 
+=== 3.1 ===
+ * The inteface to forum_get_email_message_id() has changed and no longer needs the $host argument.
+
 === 3.0 ===
  * External function get_forums_by_courses now returns and additional field "cancreatediscussions" that indicates if the user
    can create discussions in the forum.
index a6634c5..767a662 100644 (file)
@@ -594,4 +594,109 @@ class mod_wiki_external extends external_api {
         );
     }
 
+    /**
+     * Describes the parameters for get_page_contents.
+     *
+     * @return external_function_parameters
+     * @since Moodle 3.1
+     */
+    public static function get_page_contents_parameters() {
+        return new external_function_parameters (
+            array(
+                'pageid' => new external_value(PARAM_INT, 'Page ID.')
+            )
+        );
+    }
+
+    /**
+     * Get a page contents.
+     *
+     * @param int $pageid The page ID.
+     * @return array of warnings and page data.
+     * @since Moodle 3.1
+     */
+    public static function get_page_contents($pageid) {
+
+        $params = self::validate_parameters(self::get_page_contents_parameters(),
+                                            array(
+                                                'pageid' => $pageid
+                                            )
+            );
+        $warnings = array();
+
+        // Get wiki page.
+        if (!$page = wiki_get_page($params['pageid'])) {
+            throw new moodle_exception('incorrectpageid', 'wiki');
+        }
+
+        // Get wiki instance.
+        if (!$wiki = wiki_get_wiki_from_pageid($params['pageid'])) {
+            throw new moodle_exception('incorrectwikiid', 'wiki');
+        }
+
+        // Permission validation.
+        $cm = get_coursemodule_from_instance('wiki', $wiki->id, $wiki->course);
+        $context = context_module::instance($cm->id);
+        self::validate_context($context);
+
+        // Check if user can view this wiki.
+        if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
+            throw new moodle_exception('incorrectsubwikiid', 'wiki');
+        }
+        if (!wiki_user_can_view($subwiki, $wiki)) {
+            throw new moodle_exception('cannotviewpage', 'wiki');
+        }
+
+        $returnedpage = array();
+        $returnedpage['id'] = $page->id;
+        $returnedpage['wikiid'] = $wiki->id;
+        $returnedpage['subwikiid'] = $page->subwikiid;
+        $returnedpage['groupid'] = $subwiki->groupid;
+        $returnedpage['userid'] = $subwiki->userid;
+        $returnedpage['title'] = $page->title;
+
+        // Refresh page cached content if needed.
+        if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
+            if ($content = wiki_refresh_cachedcontent($page)) {
+                $page = $content['page'];
+            }
+        }
+
+        list($returnedpage['cachedcontent'], $returnedpage['contentformat']) = external_format_text(
+                            $page->cachedcontent, FORMAT_HTML, $context->id, 'mod_wiki', 'attachments', $subwiki->id);
+        $returnedpage['caneditpage'] = wiki_user_can_edit($subwiki);
+
+        $result = array();
+        $result['page'] = $returnedpage;
+        $result['warnings'] = $warnings;
+        return $result;
+    }
+
+    /**
+     * Describes the get_page_contents return value.
+     *
+     * @return external_single_structure
+     * @since Moodle 3.1
+     */
+    public static function get_page_contents_returns() {
+        return new external_single_structure(
+            array(
+                'page' => new external_single_structure(
+                    array(
+                        'id' => new external_value(PARAM_INT, 'Page ID.'),
+                        'wikiid' => new external_value(PARAM_INT, 'Page\'s wiki ID.'),
+                        'subwikiid' => new external_value(PARAM_INT, 'Page\'s subwiki ID.'),
+                        'groupid' => new external_value(PARAM_INT, 'Page\'s group ID.'),
+                        'userid' => new external_value(PARAM_INT, 'Page\'s user ID.'),
+                        'title' => new external_value(PARAM_RAW, 'Page title.'),
+                        'cachedcontent' => new external_value(PARAM_RAW, 'Page contents.'),
+                        'contentformat' => new external_format_value('cachedcontent', VALUE_OPTIONAL),
+                        'caneditpage' => new external_value(PARAM_BOOL, 'True if user can edit the page.')
+                    ), 'Page'
+                ),
+                'warnings' => new external_warnings()
+            )
+        );
+    }
+
 }
index 6894260..396e572 100644 (file)
@@ -69,5 +69,14 @@ $functions = array(
         'type'          => 'read',
         'capabilities'  => 'mod/wiki:viewpage',
         'services'      => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
+    ),
+
+    'mod_wiki_get_page_contents' => array(
+        'classname'     => 'mod_wiki_external',
+        'methodname'    => 'get_page_contents',
+        'description'   => 'Returns the contents of a page.',
+        'type'          => 'read',
+        'capabilities'  => 'mod/wiki:viewpage',
+        'services'      => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
     )
 );
index ec1ddf8..31e24be 100644 (file)
@@ -873,4 +873,138 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase {
         $this->assertEquals($expectedpages, $result['pages']);
     }
 
+    /**
+     * Test get_page_contents using an invalid pageid.
+     */
+    public function test_get_page_contents_invalid_pageid() {
+        $this->setExpectedException('moodle_exception');
+        mod_wiki_external::get_page_contents(0);
+    }
+
+    /**
+     * Test get_page_contents using a user not enrolled in the course.
+     */
+    public function test_get_page_contents_unenrolled_user() {
+        // Create and use the user.
+        $usernotenrolled = self::getDataGenerator()->create_user();
+        $this->setUser($usernotenrolled);
+
+        $this->setExpectedException('require_login_exception');
+        mod_wiki_external::get_page_contents($this->firstpage->id);
+    }
+
+    /**
+     * Test get_page_contents using a hidden wiki as student.
+     */
+    public function test_get_page_contents_hidden_wiki_as_student() {
+        // Create a hidden wiki and try to get a page contents.
+        $hiddenwiki = $this->getDataGenerator()->create_module('wiki',
+                            array('course' => $this->course->id, 'visible' => false));
+        $hiddenpage = $this->getDataGenerator()->get_plugin_generator('mod_wiki')->create_page($hiddenwiki);
+
+        $this->setUser($this->student);
+        $this->setExpectedException('require_login_exception');
+        mod_wiki_external::get_page_contents($hiddenpage->id);
+    }
+
+    /**
+     * Test get_page_contents without the viewpage capability.
+     */
+    public function test_get_page_contents_without_viewpage_capability() {
+        // Prohibit capability = mod/wiki:viewpage on the course for students.
+        $contextcourse = context_course::instance($this->course->id);
+        assign_capability('mod/wiki:viewpage', CAP_PROHIBIT, $this->studentrole->id, $contextcourse->id);
+        accesslib_clear_all_caches_for_unit_testing();
+
+        $this->setUser($this->student);
+        $this->setExpectedException('moodle_exception');
+        mod_wiki_external::get_page_contents($this->firstpage->id);
+    }
+
+    /**
+     * Test get_page_contents, check that a student can't get a page from another group when
+     * using separate groups.
+     */
+    public function test_get_page_contents_separate_groups_student_see_other_group() {
+        // Create testing data.
+        $this->create_individual_wikis_with_groups();
+
+        $this->setUser($this->student);
+        $this->setExpectedException('moodle_exception');
+        mod_wiki_external::get_page_contents($this->fpsepg2indt->id);
+    }
+
+    /**
+     * Test get_page_contents without groups. We won't test all the possible cases because that's already
+     * done in the tests for get_subwiki_pages.
+     */
+    public function test_get_page_contents() {
+
+        // Test user with full capabilities.
+        $this->setUser($this->student);
+
+        // Set expected result: first page.
+        $expectedpage = array(
+            'id' => $this->firstpage->id,
+            'wikiid' => $this->wiki->id,
+            'subwikiid' => $this->firstpage->subwikiid,
+            'groupid' => 0, // No groups.
+            'userid' => 0, // Collaborative.
+            'title' => $this->firstpage->title,
+            'cachedcontent' => $this->firstpage->cachedcontent,
+            'contentformat' => 1,
+            'caneditpage' => true
+        );
+
+        $result = mod_wiki_external::get_page_contents($this->firstpage->id);
+        $result = external_api::clean_returnvalue(mod_wiki_external::get_page_contents_returns(), $result);
+        $this->assertEquals($expectedpage, $result['page']);
+
+        // Add a new page to the wiki and test with it.
+        $newpage = $this->getDataGenerator()->get_plugin_generator('mod_wiki')->create_page($this->wiki);
+
+        $expectedpage['id'] = $newpage->id;
+        $expectedpage['title'] = $newpage->title;
+        $expectedpage['cachedcontent'] = $newpage->cachedcontent;
+
+        $result = mod_wiki_external::get_page_contents($newpage->id);
+        $result = external_api::clean_returnvalue(mod_wiki_external::get_page_contents_returns(), $result);
+        $this->assertEquals($expectedpage, $result['page']);
+    }
+
+    /**
+     * Test get_page_contents with groups. We won't test all the possible cases because that's already
+     * done in the tests for get_subwiki_pages.
+     */
+    public function test_get_page_contents_with_groups() {
+
+        // Create testing data.
+        $this->create_individual_wikis_with_groups();
+
+        // Try to get page from a valid group in separate groups wiki.
+        $this->setUser($this->student);
+
+        $expectedfpsepg1indstu = array(
+            'id' => $this->fpsepg1indstu->id,
+            'wikiid' => $this->wikisepind->id,
+            'subwikiid' => $this->fpsepg1indstu->subwikiid,
+            'groupid' => $this->group1->id,
+            'userid' => $this->student->id,
+            'title' => $this->fpsepg1indstu->title,
+            'cachedcontent' => $this->fpsepg1indstu->cachedcontent,
+            'contentformat' => 1,
+            'caneditpage' => true
+        );
+
+        $result = mod_wiki_external::get_page_contents($this->fpsepg1indstu->id);
+        $result = external_api::clean_returnvalue(mod_wiki_external::get_page_contents_returns(), $result);
+        $this->assertEquals($expectedfpsepg1indstu, $result['page']);
+
+        // Check that teacher can view a group pages without belonging to it.
+        $this->setUser($this->teacher);
+        $result = mod_wiki_external::get_page_contents($this->fpsepg1indstu->id);
+        $result = external_api::clean_returnvalue(mod_wiki_external::get_page_contents_returns(), $result);
+        $this->assertEquals($expectedfpsepg1indstu, $result['page']);
+    }
+
 }
index b7707ef..f0472bd 100644 (file)
@@ -33,7 +33,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2016011102;       // The current module version (Date: YYYYMMDDXX)
+$plugin->version   = 2016011103;       // The current module version (Date: YYYYMMDDXX)
 $plugin->requires  = 2015111000;    // Requires this Moodle version
 $plugin->component = 'mod_wiki';       // Full name of the plugin (used for diagnostics)
 $plugin->cron      = 0;
index adfcebc..eeb3a2e 100644 (file)
@@ -232,7 +232,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b
         $this->check_current_mark(2);
         $this->check_current_output(
                 $this->get_contains_mark_summary(2),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation());
     }
 
@@ -310,7 +310,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b
         $this->check_current_mark(0.8);
         $this->check_current_output(
                 $this->get_contains_mark_summary(0.8),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_does_not_contain_validation_error_expectation());
     }
@@ -393,7 +393,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b
         $this->check_current_mark(4.00);
         $this->check_current_output(
                 $this->get_contains_mark_summary(4.00),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_incorrect_expectation(),
                 $this->get_does_not_contain_validation_error_expectation());
     }
@@ -475,7 +475,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b
         $this->check_current_mark(0.66666667);
         $this->check_current_output(
                 $this->get_contains_mark_summary(0.67),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_incorrect_expectation(),
                 $this->get_does_not_contain_validation_error_expectation());
     }
@@ -532,7 +532,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b
         $this->check_current_mark(1.0);
         $this->check_current_output(
                 $this->get_contains_mark_summary(1.0),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_does_not_contain_validation_error_expectation());
     }
@@ -646,7 +646,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b
         $this->check_current_mark(1);
         $this->check_current_output(
                 $this->get_contains_mark_summary(1),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_incorrect_expectation(),
                 $this->get_does_not_contain_validation_error_expectation());
     }
@@ -749,7 +749,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b
         $this->check_current_mark(0.9);
         $this->check_current_output(
                 $this->get_contains_mark_summary(0.9),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_incorrect_expectation(),
                 $this->get_does_not_contain_validation_error_expectation(),
                 $this->get_does_not_contain_disregarded_info_expectation());
@@ -848,7 +848,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b
         $this->check_output_contains_text_input_with_class('sub1_answer', 'correct');
         $this->check_current_output(
                 $this->get_contains_mark_summary(8.00),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_does_not_contain_validation_error_expectation());
     }
index c8de438..42aef51 100644 (file)
@@ -213,7 +213,7 @@ class qbehaviour_adaptivenopenalty_walkthrough_test extends qbehaviour_walkthrou
         $this->check_current_mark(2);
         $this->check_current_output(
                 $this->get_contains_mark_summary(2),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation());
     }
 
@@ -305,7 +305,7 @@ class qbehaviour_adaptivenopenalty_walkthrough_test extends qbehaviour_walkthrou
         $this->check_current_mark(1.0);
         $this->check_current_output(
                 $this->get_contains_mark_summary(1.0),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_incorrect_expectation(),
                 $this->get_does_not_contain_validation_error_expectation());
     }
index 4bae37a..89c5d9c 100644 (file)
@@ -36,6 +36,9 @@ defined('MOODLE_INTERNAL') || die();
  */
 class qbehaviour_interactive_renderer extends qbehaviour_renderer {
     public function controls(question_attempt $qa, question_display_options $options) {
+        if ($options->readonly === qbehaviour_interactive::READONLY_EXCEPT_TRY_AGAIN) {
+            return '';
+        }
         return $this->submit_button($qa, $options);
     }
 
index 1e2d839..8485e6a 100644 (file)
@@ -95,7 +95,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes
                 $this->get_contains_mc_radio_expectation($wrongindex, false, true),
                 $this->get_contains_mc_radio_expectation(($wrongindex + 1) % 3, false, false),
                 $this->get_contains_mc_radio_expectation(($wrongindex + 1) % 3, false, false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_try_again_button_expectation(true),
                 $this->get_does_not_contain_correctness_expectation(),
                 new question_pattern_expectation('/Tries remaining: 2/'),
@@ -135,7 +135,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes
                 $this->get_contains_mc_radio_expectation($rightindex, false, true),
                 $this->get_contains_mc_radio_expectation(($rightindex + 1) % 3, false, false),
                 $this->get_contains_mc_radio_expectation(($rightindex + 1) % 3, false, false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_no_hint_visible_expectation());
 
@@ -219,7 +219,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes
                 $this->get_contains_mc_radio_expectation($wrongindex, false, true),
                 $this->get_contains_mc_radio_expectation(($wrongindex + 1) % 3, false, false),
                 $this->get_contains_mc_radio_expectation(($wrongindex + 1) % 3, false, false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_try_again_button_expectation(true),
                 $this->get_does_not_contain_correctness_expectation(),
                 new question_pattern_expectation('/Tries remaining: 1/'),
@@ -283,7 +283,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes
         $this->check_current_mark(null);
         $this->check_current_output(
                 $this->get_contains_marked_out_of_summary(),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_does_not_contain_validation_error_expectation(),
                 $this->get_contains_try_again_button_expectation(true),
                 new question_pattern_expectation('/Tries remaining: 2/'),
@@ -327,7 +327,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes
         $this->check_current_mark(0.6666667);
         $this->check_current_output(
                 $this->get_contains_mark_summary(0.6666667),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_does_not_contain_validation_error_expectation(),
                 $this->get_no_hint_visible_expectation());
@@ -380,7 +380,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes
                 $this->get_contains_mc_checkbox_expectation($right[1], false, false),
                 $this->get_contains_mc_checkbox_expectation($wrong[0], false, true),
                 $this->get_contains_mc_checkbox_expectation($wrong[1], false, false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_try_again_button_expectation(true),
                 $this->get_does_not_contain_correctness_expectation(),
                 new question_pattern_expectation('/Tries remaining: 2/'),
index 8c87b3d..0523aa7 100644 (file)
@@ -87,7 +87,7 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth
                 $this->get_contains_select_expectation('sub1', $choices, $orderforchoice[1], false),
                 $this->get_contains_select_expectation('sub2', $choices, $orderforchoice[1], false),
                 $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_try_again_button_expectation(true),
                 $this->get_does_not_contain_correctness_expectation(),
                 new question_pattern_expectation('/Tries remaining: 2/'),
@@ -139,7 +139,7 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth
                 $this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], false),
                 $this->get_contains_select_expectation('sub2', $choices, $orderforchoice[2], false),
                 $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_does_not_contain_try_again_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_contains_standard_correct_combined_feedback_expectation(),
index 41f58b2..cdcb2d2 100644 (file)
@@ -208,6 +208,9 @@ abstract class qbehaviour_renderer extends plugin_renderer_base {
      * @return string HTML fragment.
      */
     protected function submit_button(question_attempt $qa, question_display_options $options) {
+        if (!$qa->get_state()->is_active()) {
+            return '';
+        }
         $attributes = array(
             'type' => 'submit',
             'id' => $qa->get_behaviour_field_name('submit'),
index 5c530cd..235e953 100644 (file)
@@ -1,5 +1,15 @@
 This files describes API changes for question behaviour plugins.
 
+=== 3.1 ===
+
+1) The standard behaviours that use a 'Check' button have all been changed so
+   that they only show the button when the question is active. Your behaviour
+   may interit this behaviour, because the change was made in the base class,
+   and this is probably good for consistency. However, if your question behaviour
+   uses the Check button, your probably want to test it carefully, and you will
+   probably have to update your unit tests. See MDL-53304 for more details.
+
+
 === 2.9 ===
 
 1) There are new methods question_behaviour::can_finish_during_attempt and
index c472e1e..8a89633 100644 (file)
@@ -1103,11 +1103,27 @@ abstract class qbehaviour_walkthrough_test_base extends question_testcase {
         return new question_contains_tag_with_attributes('input', $expectedattributes, $forbiddenattributes);
     }
 
+    /**
+     * Returns an epectation that a string contains the HTML of a button with
+     * name {question-attempt prefix}-submit, and eiter enabled or not.
+     * @param bool $enabled if not null, check the enabled/disabled state of the button. True = enabled.
+     * @return question_contains_tag_with_attributes an expectation for use with check_current_output.
+     */
     protected function get_contains_submit_button_expectation($enabled = null) {
         return $this->get_contains_button_expectation(
             $this->quba->get_field_prefix($this->slot) . '-submit', null, $enabled);
     }
 
+    /**
+     * Returns an epectation that a string does not contain the HTML of a button with
+     * name {question-attempt prefix}-submit.
+     * @return question_contains_tag_with_attributes an expectation for use with check_current_output.
+     */
+    protected function get_does_not_contain_submit_button_expectation() {
+        return new question_no_pattern_expectation('/name="' .
+                $this->quba->get_field_prefix($this->slot) . '-submit"/');
+    }
+
     protected function get_tries_remaining_expectation($n) {
         return new question_pattern_expectation('/' .
             preg_quote(get_string('triesremaining', 'qbehaviour_interactive', $n), '/') . '/');
index 11b7ebc..89013c5 100644 (file)
@@ -98,7 +98,7 @@ class qtype_calculated_walkthrough_test extends qbehaviour_walkthrough_test_base
         $this->check_current_mark(3);
         $this->check_current_output(
                 $this->get_contains_mark_summary(3),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_does_not_contain_validation_error_expectation(),
                 $this->get_no_hint_visible_expectation());
index de31a58..00fddca 100644 (file)
@@ -98,7 +98,7 @@ class qtype_calculatedmulti_walkthrough_test extends qbehaviour_walkthrough_test
         $this->check_current_mark(3);
         $this->check_current_output(
                 $this->get_contains_mark_summary(3),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_does_not_contain_validation_error_expectation(),
                 $this->get_no_hint_visible_expectation());
index 63e639f..46af97e 100644 (file)
@@ -97,7 +97,7 @@ class qtype_calculatedsimple_walkthrough_test extends qbehaviour_walkthrough_tes
         $this->check_current_mark(3);
         $this->check_current_output(
                 $this->get_contains_mark_summary(3),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_does_not_contain_validation_error_expectation(),
                 $this->get_no_hint_visible_expectation());
index 71e3eef..932ac1b 100644 (file)
@@ -180,7 +180,7 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
                 $this->quba->get_field_prefix($this->slot) . 'p3', '1'),
             $this->get_contains_hidden_expectation(
                 $this->quba->get_field_prefix($this->slot) . 'p4', '2'),
-            $this->get_contains_submit_button_expectation(false),
+            $this->get_does_not_contain_submit_button_expectation(),
             $this->get_contains_correct_expectation(),
             $this->get_no_hint_visible_expectation());
 
@@ -469,7 +469,7 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
             $this->get_contains_drag_image_home_expectation(2, 2, 1),
             $this->get_contains_drag_image_home_expectation(3, 1, 2),
             $this->get_contains_drag_image_home_expectation(4, 2, 2),
-            $this->get_contains_submit_button_expectation(false),
+            $this->get_does_not_contain_submit_button_expectation(),
             $this->get_contains_try_again_button_expectation(true),
             $this->get_does_not_contain_correctness_expectation(),
             $this->get_contains_hint_expectation('This is the first hint'),
@@ -530,7 +530,7 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
             $this->get_contains_drag_image_home_expectation(2, 2, 1),
             $this->get_contains_drag_image_home_expectation(3, 1, 2),
             $this->get_contains_drag_image_home_expectation(4, 2, 2),
-            $this->get_contains_submit_button_expectation(false),
+            $this->get_does_not_contain_submit_button_expectation(),
             $this->get_contains_try_again_button_expectation(true),
             $this->get_does_not_contain_correctness_expectation(),
             $this->get_contains_hint_expectation('This is the second hint'),
@@ -592,7 +592,7 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
                 $this->quba->get_field_prefix($this->slot) . 'p3', 1),
             $this->get_contains_hidden_expectation(
                 $this->quba->get_field_prefix($this->slot) . 'p4', 2),
-            $this->get_contains_submit_button_expectation(false),
+            $this->get_does_not_contain_submit_button_expectation(),
             $this->get_does_not_contain_try_again_button_expectation(),
             $this->get_contains_correct_expectation(),
             $this->get_no_hint_visible_expectation(),
@@ -648,7 +648,7 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
             $this->get_contains_drag_image_home_expectation(2, 2, 1),
             $this->get_contains_drag_image_home_expectation(3, 1, 2),
             $this->get_contains_drag_image_home_expectation(4, 2, 2),
-            $this->get_contains_submit_button_expectation(false),
+            $this->get_does_not_contain_submit_button_expectation(),
             $this->get_contains_correct_expectation(),
             $this->get_no_hint_visible_expectation());
 
@@ -710,7 +710,7 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
             $this->get_contains_drag_image_home_expectation(2, 2, 1),
             $this->get_contains_drag_image_home_expectation(3, 1, 2),
             $this->get_contains_drag_image_home_expectation(4, 2, 2),
-            $this->get_contains_submit_button_expectation(false),
+            $this->get_does_not_contain_submit_button_expectation(),
             $this->get_contains_partcorrect_expectation(),
             $this->get_no_hint_visible_expectation());
 
@@ -769,7 +769,7 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
             $this->get_contains_drag_image_home_expectation(2, 2, 1),
             $this->get_contains_drag_image_home_expectation(3, 1, 2),
             $this->get_contains_drag_image_home_expectation(4, 2, 2),
-            $this->get_contains_submit_button_expectation(false),
+            $this->get_does_not_contain_submit_button_expectation(),
             $this->get_contains_hint_expectation('This is the first hint'));
 
         // Do try again.
index ae2a734..afaf4a6 100644 (file)
@@ -168,7 +168,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_hidden_expectation(1, '50,50'),
                 $this->get_contains_hidden_expectation(2, '150,50'),
                 $this->get_contains_hidden_expectation(3, '100,150'),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_no_hint_visible_expectation());
 
@@ -399,7 +399,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_draggable_marker_home_expectation(1, false),
                 $this->get_contains_draggable_marker_home_expectation(2, false),
                 $this->get_contains_draggable_marker_home_expectation(3, false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_try_again_button_expectation(true),
                 $this->get_does_not_contain_correctness_expectation(),
                 $this->get_contains_hint_expectation('This is the first hint'),
@@ -448,7 +448,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_draggable_marker_home_expectation(1, false),
                 $this->get_contains_draggable_marker_home_expectation(2, false),
                 $this->get_contains_draggable_marker_home_expectation(3, false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_try_again_button_expectation(true),
                 $this->get_does_not_contain_correctness_expectation(),
                 $this->get_contains_hint_expectation('This is the second hint'),
@@ -493,7 +493,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_hidden_expectation(1, '50,50'),
                 $this->get_contains_hidden_expectation(2, '150,50'),
                 $this->get_contains_hidden_expectation(3, '100,150'),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_does_not_contain_try_again_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_no_hint_visible_expectation(),
@@ -542,7 +542,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_draggable_marker_home_expectation(1, false),
                 $this->get_contains_draggable_marker_home_expectation(2, false),
                 $this->get_contains_draggable_marker_home_expectation(3, false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_no_hint_visible_expectation());
 
@@ -597,7 +597,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_draggable_marker_home_expectation(1, false),
                 $this->get_contains_draggable_marker_home_expectation(2, false),
                 $this->get_contains_draggable_marker_home_expectation(3, false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_partcorrect_expectation(),
                 $this->get_no_hint_visible_expectation());
 
@@ -651,7 +651,7 @@ class qtype_ddmarker_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_draggable_marker_home_expectation(1, false),
                 $this->get_contains_draggable_marker_home_expectation(2, false),
                 $this->get_contains_draggable_marker_home_expectation(3, false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_hint_expectation('This is the first hint'));
 
         // Do try again.
index f56bae9..a50db1b 100644 (file)
@@ -114,7 +114,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_drop_box_expectation('1', 1, true),
                 $this->get_contains_drop_box_expectation('2', 2, true),
                 $this->get_contains_drop_box_expectation('3', 3, true),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_try_again_button_expectation(true),
                 $this->get_does_not_contain_correctness_expectation(),
                 $this->get_contains_hint_expectation('This is the first hint'));
@@ -151,7 +151,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_drop_box_expectation('1', 1, true, 'correct'),
                 $this->get_contains_drop_box_expectation('2', 2, true, 'correct'),
                 $this->get_contains_drop_box_expectation('3', 3, true, 'correct'),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_no_hint_visible_expectation());
 
@@ -401,7 +401,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_drop_box_expectation('1', 1, true),
                 $this->get_contains_drop_box_expectation('2', 2, true),
                 $this->get_contains_drop_box_expectation('3', 3, true),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_try_again_button_expectation(true),
                 $this->get_does_not_contain_correctness_expectation(),
                 $this->get_contains_hint_expectation('This is the first hint'),
@@ -453,7 +453,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_drop_box_expectation('1', 1, true),
                 $this->get_contains_drop_box_expectation('2', 2, true),
                 $this->get_contains_drop_box_expectation('3', 3, true),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_try_again_button_expectation(true),
                 $this->get_does_not_contain_correctness_expectation(),
                 $this->get_contains_hint_expectation('This is the second hint'),
@@ -499,7 +499,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_drop_box_expectation('1', 1, true, 'correct'),
                 $this->get_contains_drop_box_expectation('2', 2, true, 'correct'),
                 $this->get_contains_drop_box_expectation('3', 3, true, 'correct'),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_does_not_contain_try_again_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_no_hint_visible_expectation(),
@@ -557,7 +557,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_drop_box_expectation('1', 1, true, 'correct'),
                 $this->get_contains_drop_box_expectation('2', 2, true, 'correct'),
                 $this->get_contains_drop_box_expectation('3', 3, true, 'correct'),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_no_hint_visible_expectation());
 
@@ -613,7 +613,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_drop_box_expectation('1', 1, true, 'correct'),
                 $this->get_contains_drop_box_expectation('2', 2, true, 'incorrect'),
                 $this->get_contains_drop_box_expectation('3', 3, true, 'incorrect'),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_partcorrect_expectation(),
                 $this->get_no_hint_visible_expectation());
 
@@ -666,7 +666,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_drop_box_expectation('1', 1, true),
                 $this->get_contains_drop_box_expectation('2', 2, true),
                 $this->get_contains_drop_box_expectation('3', 3, true),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_hint_expectation('This is the first hint'));
 
         // Do try again.
index 521d386..b51b439 100644 (file)
@@ -95,7 +95,7 @@ class qtype_gapselect_walkthrough_test extends qbehaviour_walkthrough_test_base
                                 array('' => get_string('choosedots'), '1' => 'fox', '2' => 'dog'), 2, false),
                 $this->get_contains_select_expectation('p3',
                                 array('' => get_string('choosedots'), '1' => 'lazy', '2' => 'assiduous'), 2, false),
-                        $this->get_contains_submit_button_expectation(false),
+                        $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_try_again_button_expectation(true),
                 $this->get_does_not_contain_correctness_expectation(),
                 $this->get_contains_hint_expectation('This is the first hint'));
@@ -132,7 +132,7 @@ class qtype_gapselect_walkthrough_test extends qbehaviour_walkthrough_test_base
                                 array('' => get_string('choosedots'), '1' => 'fox', '2' => 'dog'), 1, false),
                 $this->get_contains_select_expectation('p3',
                                 array('' => get_string('choosedots'), '1' => 'lazy', '2' => 'assiduous'), 1, false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_no_hint_visible_expectation());
 
index a67a942..403d8d3 100644 (file)
@@ -194,7 +194,7 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], false),
                 $this->get_contains_select_expectation('sub2', $choices, $orderforchoice[2], false),
                 $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_no_hint_visible_expectation());
     }
@@ -246,7 +246,7 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], false),
                 $this->get_contains_select_expectation('sub2', $choices, $orderforchoice[1], false),
                 $this->get_contains_select_expectation('sub3', $choices, null, false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_partcorrect_expectation(),
                 $this->get_no_hint_visible_expectation());
     }
@@ -313,7 +313,7 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
                 $this->get_contains_select_expectation('sub1', $choices, $orderforchoice[2], false),
                 $this->get_contains_select_expectation('sub2', $choices, $orderforchoice[2], false),
                 $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_no_hint_visible_expectation());
     }
@@ -422,7 +422,7 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
                         $this->quba->get_field_prefix($this->slot) . 'sub2', '0'),
                 $this->get_contains_hidden_expectation(
                         $this->quba->get_field_prefix($this->slot) . 'sub3', '0'),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_hint_expectation('This is the first hint.'));
 
         // Try again.
@@ -464,7 +464,7 @@ class qtype_match_walkthrough_test extends qbehaviour_walkthrough_test_base {
                         $this->quba->get_field_prefix($this->slot) . 'sub2', $orderforchoice[2]),
                 $this->get_contains_hidden_expectation(
                         $this->quba->get_field_prefix($this->slot) . 'sub3', $orderforchoice[1]),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_hint_expectation('This is the second hint.'));
 
         // Try again.
index cb07b3f..a7b7e84 100644 (file)
@@ -250,7 +250,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
                         $this->quba->get_field_prefix($this->slot) . 'sub3_answer', ''),
                 $this->get_contains_hidden_expectation(
                         $this->quba->get_field_prefix($this->slot) . 'sub4_answer', ''),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_try_again_button_expectation(true),
                 $this->get_does_not_contain_correctness_expectation(),
                 $this->get_contains_hint_expectation('This is the first hint.'));
@@ -300,7 +300,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
                         $this->quba->get_field_prefix($this->slot) . 'sub3_answer', ''),
                 $this->get_contains_hidden_expectation(
                         $this->quba->get_field_prefix($this->slot) . 'sub4_answer', '1'),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_hint_expectation('This is the second hint.'));
 
         // Try again.
@@ -419,7 +419,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
                 $this->get_contains_select_expectation('sub2_answer', $choices, 1, false),
                 $this->get_contains_select_expectation('sub3_answer', $choices, 1, false),
                 $this->get_contains_select_expectation('sub4_answer', $choices, 1, false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_try_again_button_expectation(true),
                 $this->get_does_not_contain_correctness_expectation(),
                 new question_pattern_expectation('/Tries remaining: 2/'),
@@ -460,7 +460,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
                 $this->get_contains_select_expectation('sub2_answer', $choices, '1', false),
                 $this->get_contains_select_expectation('sub3_answer', $choices, '0', false),
                 $this->get_contains_select_expectation('sub4_answer', $choices, '1', false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_does_not_contain_try_again_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 new question_no_pattern_expectation('/class="control\b[^"]*\bpartiallycorrect"/'));
index db73550..0d95cc0 100644 (file)
@@ -97,7 +97,7 @@ class qtype_numerical_walkthrough_test extends qbehaviour_walkthrough_test_base
         $this->check_current_mark(3);
         $this->check_current_output(
                 $this->get_contains_mark_summary(3),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_does_not_contain_validation_error_expectation(),
                 $this->get_no_hint_visible_expectation());
index 07c2643..dfaa54b 100644 (file)
@@ -193,7 +193,7 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
                 $this->get_contains_select_expectation('sub1', $choices, $orderforchoice[16], false),
                 $this->get_contains_select_expectation('sub2', $choices, $orderforchoice[16], false),
                 $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[13], false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_no_hint_visible_expectation());
     }
@@ -245,7 +245,7 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
                 $this->get_contains_select_expectation('sub1', $choices, $orderforchoice[16], false),
                 $this->get_contains_select_expectation('sub2', $choices, $orderforchoice[13], false),
                 $this->get_contains_select_expectation('sub3', $choices, null, false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_partcorrect_expectation(),
                 $this->get_no_hint_visible_expectation());
     }
@@ -312,7 +312,7 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
                 $this->get_contains_select_expectation('sub1', $choices, $orderforchoice[16], false),
                 $this->get_contains_select_expectation('sub2', $choices, $orderforchoice[16], false),
                 $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[13], false),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_correct_expectation(),
                 $this->get_no_hint_visible_expectation());
     }
@@ -369,7 +369,7 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
                         $this->quba->get_field_prefix($this->slot) . 'sub2', '0'),
                 $this->get_contains_hidden_expectation(
                         $this->quba->get_field_prefix($this->slot) . 'sub3', '0'),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_hint_expectation('This is the first hint.'));
 
         // Try again.
@@ -411,7 +411,7 @@ class qtype_randomsamatch_walkthrough_test extends qbehaviour_walkthrough_test_b
                         $this->quba->get_field_prefix($this->slot) . 'sub2', $orderforchoice[16]),
                 $this->get_contains_hidden_expectation(
                         $this->quba->get_field_prefix($this->slot) . 'sub3', $orderforchoice[13]),
-                $this->get_contains_submit_button_expectation(false),
+                $this->get_does_not_contain_submit_button_expectation(),
                 $this->get_contains_hint_expectation('This is the second hint.'));
 
         // Try again.