Merge branch 'MDL-71915-master-v8' of https://github.com/sharidas/moodle

This commit is contained in:
Jake Dallimore
2021-12-06 13:34:58 +08:00
199 changed files with 2994 additions and 1050 deletions
@@ -22,18 +22,18 @@ Feature: Use core page resolvers for the I am on the page steps
Then I should see "<shouldsee>"
Examples:
| description | identifier | type | shouldsee |
| Course Category idnumber | CAT1 | category | Add a new course |
| Course Category name | "Cat 1" | Category | Add a new course |
| Course Full name | "Economics 101" | course | Fundamentals of Economics |
| Course Short name | ECON101 | COURSE | Fundamentals of Economics |
| Course idnumber | "2021-econ101" | Course | Fundamentals of Economics |
| Forum idnumber | fundamentalsofeconomics | Activity | Add a new discussion |
| Generic activity editing | fundamentalsofeconomics | "Activity editing" | Updating: Forum |
| Forum name | "Fundamentals of Economics" | "Forum activity" | Add a new discussion |
| Forum name editing | "Fundamentals of Economics" | "Forum activity editing" | Updating: Forum |
| Forum name permissions | "Fundamentals of Economics" | "Forum activity permissions" | Permissions in Forum: Fun |
| Forum name roles | "Fundamentals of Economics" | "Forum activity roles" | Assign roles in Forum: Fun |
| description | identifier | type | shouldsee |
| Course Category idnumber | CAT1 | category | Add a new course |
| Course Category name | "Cat 1" | Category | Add a new course |
| Course Full name | "Economics 101" | course | Fundamentals of Economics |
| Course Short name | ECON101 | COURSE | Fundamentals of Economics |
| Course idnumber | "2021-econ101" | Course | Fundamentals of Economics |
| Forum idnumber | fundamentalsofeconomics | Activity | Add discussion topic |
| Generic activity editing | fundamentalsofeconomics | "Activity editing" | Updating: Forum |
| Forum name | "Fundamentals of Economics" | "Forum activity" | Add discussion topic |
| Forum name editing | "Fundamentals of Economics" | "Forum activity editing" | Updating: Forum |
| Forum name permissions | "Fundamentals of Economics" | "Forum activity permissions" | Permissions in Forum: Fun |
| Forum name roles | "Fundamentals of Economics" | "Forum activity roles" | Assign roles in Forum: Fun |
Scenario Outline: When I am on an instance logged in as
Given the following "categories" exist:
@@ -58,9 +58,9 @@ Feature: Use core page resolvers for the I am on the page steps
| Course Full name | "Economics 101" | course | Fundamentals of Economics |
| Course Short name | ECON101 | COURSE | Fundamentals of Economics |
| Course idnumber | "2021-econ101" | Course | Fundamentals of Economics |
| Forum idnumber | fundamentalsofeconomics | Activity | Add a new discussion |
| Forum idnumber | fundamentalsofeconomics | Activity | Add discussion topic |
| Generic activity editing | fundamentalsofeconomics | "Activity editing" | Updating: Forum |
| Forum name | "Fundamentals of Economics" | "Forum activity" | Add a new discussion |
| Forum name | "Fundamentals of Economics" | "Forum activity" | Add discussion topic |
| Forum name editing | "Fundamentals of Economics" | "Forum activity editing" | Updating: Forum |
| Forum name permissions | "Fundamentals of Economics" | "Forum activity permissions" | Permissions in Forum: Fun |
| Forum name roles | "Fundamentals of Economics" | "Forum activity roles" | Assign roles in Forum: Fun |
@@ -43,7 +43,7 @@ Feature: Backup user data
| Feedback for the response 'False'. | So you think it is false |
And I log out
When I am on the "Quiz 1" "quiz activity" page logged in as student1
And I press "Attempt quiz now"
And I follow "Attempt quiz"
And I click on "True" "radio" in the "First question" "question"
And I click on "False" "radio" in the "Second question" "question"
And I press "Finish attempt"
+1 -1
View File
@@ -57,7 +57,7 @@ Feature: Award badges based on activity completion
And the "Receive a passing grade" completion condition of "Test quiz name" is displayed as "failed"
And the "Receive a pass grade or complete all available attempts" completion condition of "Test quiz name" is displayed as "todo"
When I am on the "Test quiz name" "quiz activity" page
And I press "Re-attempt quiz"
And I follow "Attempt quiz"
And I set the field "False" to "1"
And I press "Finish attempt ..."
And I press "Submit all and finish"
@@ -16,7 +16,9 @@ Feature: Change number of discussions displayed
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Add a new discussion topic"
And I turn editing mode on
And I click on "Social forum" "link"
And I follow "Add discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 10 |
| Message | This is forum post ten |
@@ -24,7 +26,8 @@ Feature: Change number of discussions displayed
And I wait to be redirected
And I am on "Course 1" course homepage
And I wait "1" seconds
And I follow "Add a new discussion topic"
And I click on "Social forum" "link"
And I follow "Add discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 9 |
| Message | This is forum post nine |
@@ -32,7 +35,8 @@ Feature: Change number of discussions displayed
And I wait to be redirected
And I am on "Course 1" course homepage
And I wait "1" seconds
And I follow "Add a new discussion topic"
And I click on "Social forum" "link"
And I follow "Add discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 8 |
| Message | This is forum post eight |
@@ -40,7 +44,8 @@ Feature: Change number of discussions displayed
And I wait to be redirected
And I am on "Course 1" course homepage
And I wait "1" seconds
And I follow "Add a new discussion topic"
And I click on "Social forum" "link"
And I follow "Add discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 7 |
| Message | This is forum post seven |
@@ -48,7 +53,8 @@ Feature: Change number of discussions displayed
And I wait to be redirected
And I am on "Course 1" course homepage
And I wait "1" seconds
And I follow "Add a new discussion topic"
And I click on "Social forum" "link"
And I follow "Add discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 6 |
| Message | This is forum post six |
@@ -56,7 +62,8 @@ Feature: Change number of discussions displayed
And I wait to be redirected
And I am on "Course 1" course homepage
And I wait "1" seconds
And I follow "Add a new discussion topic"
And I click on "Social forum" "link"
And I follow "Add discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 5 |
| Message | This is forum post five |
@@ -64,7 +71,8 @@ Feature: Change number of discussions displayed
And I wait to be redirected
And I am on "Course 1" course homepage
And I wait "1" seconds
And I follow "Add a new discussion topic"
And I click on "Social forum" "link"
And I follow "Add discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 4 |
| Message | This is forum post four |
@@ -72,7 +80,8 @@ Feature: Change number of discussions displayed
And I wait to be redirected
And I am on "Course 1" course homepage
And I wait "1" seconds
And I follow "Add a new discussion topic"
And I click on "Social forum" "link"
And I follow "Add discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 3 |
| Message | This is forum post three |
@@ -80,7 +89,8 @@ Feature: Change number of discussions displayed
And I wait to be redirected
And I am on "Course 1" course homepage
And I wait "1" seconds
And I follow "Add a new discussion topic"
And I click on "Social forum" "link"
And I follow "Add discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 2 |
| Message | This is forum post two |
@@ -88,7 +98,8 @@ Feature: Change number of discussions displayed
And I wait to be redirected
And I am on "Course 1" course homepage
And I wait "1" seconds
And I follow "Add a new discussion topic"
And I click on "Social forum" "link"
And I follow "Add discussion topic"
And I set the following fields to these values:
| Subject | Forum Post 1 |
| Message | This is forum post one |
+1 -1
View File
@@ -21,7 +21,7 @@ Feature: Managers can create courses
And I am on "Course 1" course homepage with editing mode on
And I add the "Latest announcements" block
And I am on the Announcements "forum activity" page
And "Add a new topic" "link" should exist
And "Add discussion topic" "link" should exist
And "Subscription mode > Forced subscription" "link" should not exist in current page administration
And "Subscription mode > Forced subscription" "text" should exist in current page administration
And I log out
@@ -118,6 +118,10 @@ Feature: Using the AJAX grading feature of Grader report to update grades and fe
And I set the field "ajaxgrade" to "33"
And I set the field "ajaxfeedback" to "Student 2 VU feedback"
And I press the enter key
And I click on student "Student 2" for grade item "Item SU"
And I set the field "ajaxgrade" to "Very good"
And I set the field "ajaxfeedback" to "Student 2 SU feedback"
And I press the enter key
And I click on student "Student 3" for grade item "Item VL"
And I should not see a grade field for "Student 3" and grade item "Item VL"
And I should not see a feedback field for "Student 3" and grade item "Item VL"
@@ -126,10 +130,6 @@ Feature: Using the AJAX grading feature of Grader report to update grades and fe
And I should see a feedback field for "Student 3" and grade item "Item TU"
And I set the field "ajaxfeedback" to "Student 3 TU feedback"
And I press the enter key
And I click on student "Student 2" for grade item "Item SU"
And I set the field "ajaxgrade" to "Very good"
And I set the field "ajaxfeedback" to "Student 2 SU feedback"
And I press the enter key
# Reload grader report:
And I navigate to "View > User report" in the course gradebook
And I navigate to "View > Grader report" in the course gradebook
@@ -75,7 +75,7 @@ Feature: Using the activity grade form element
| Group mode | No groups |
And I log out
And I am on the "Test forum name" "forum activity" page logged in as student1
And I click on "Add a new discussion topic" "link"
And I click on "Add discussion topic" "link"
And I set the following fields to these values:
| Subject | Discussion subject |
| Message | Discussion message |
@@ -135,7 +135,7 @@ Feature: Using the activity grade form element
And I press "Save and return to course"
And I log out
And I am on the "Test forum name" "forum activity" page logged in as student1
And I click on "Add a new discussion topic" "link"
And I click on "Add discussion topic" "link"
And I set the following fields to these values:
| Subject | Discussion subject |
| Message | Discussion message |
+2 -5
View File
@@ -13,7 +13,7 @@ Feature: Close modals by clicking outside them
| activity | name | intro | course | idnumber |
| quiz | Test quiz name | Test quiz description | C1 | quiz1 |
And I am on the "quiz1" "Activity" page logged in as "admin"
And I click on "Edit quiz" "button"
And I follow "Add question"
And I click on "Add" "link"
And I click on "a new question" "link"
# Cannot use the normal ‘I click on’ here, because the pop-up gets in the way.
@@ -42,8 +42,5 @@ Feature: Close modals by clicking outside them
| activity | name | intro | course | idnumber |
| quiz | Test quiz name | Test quiz description | C1 | quiz1 |
And I am on the "quiz1" "Activity" page logged in as "admin"
And I click on "Edit quiz" "button"
And I click on "Help with Editing quiz" "icon"
And I should see "More help"
And I click on "body" "css_element"
And I follow "Add question"
Then I should not see "More help"
+20 -20
View File
@@ -39,22 +39,22 @@ Feature: Context freezing apply to child contexts
Scenario: Freeze course module module should freeze just that module
Given I am on the "courseaa1" "Course" page logged in as "admin"
And I follow "faa1"
And "Add a new discussion topic" "link" should exist
And "Add discussion topic" "link" should exist
When I follow "Freeze this context"
And I click on "Continue" "button"
Then "Add a new discussion topic" "link" should not exist
Then "Add discussion topic" "link" should not exist
When I am on "courseaa1" course homepage
Then edit mode should be available on the current page
When I follow "faa1b"
Then "Add a new discussion topic" "link" should exist
Then "Add discussion topic" "link" should exist
When I am on "courseaa2" course homepage
Then edit mode should be available on the current page
When I follow "faa2"
Then "Add a new discussion topic" "link" should exist
Then "Add discussion topic" "link" should exist
When I am on "courseb" course homepage
Then edit mode should be available on the current page
When I follow "fb"
Then "Add a new discussion topic" "link" should exist
Then "Add discussion topic" "link" should exist
And I log out
When I am on the "courseaa1" "Course" page logged in as "teacher"
@@ -63,15 +63,15 @@ Feature: Context freezing apply to child contexts
When I am on "courseaa1" course homepage
Then edit mode should be available on the current page
When I follow "faa1b"
Then "Add a new discussion topic" "link" should exist
Then "Add discussion topic" "link" should exist
When I am on "courseaa2" course homepage
Then edit mode should be available on the current page
When I follow "faa2"
Then "Add a new discussion topic" "link" should exist
Then "Add discussion topic" "link" should exist
When I am on "courseb" course homepage
Then edit mode should be available on the current page
When I follow "fb"
And "Add a new discussion topic" "link" should exist
And "Add discussion topic" "link" should exist
And I log out
When I am on the "courseaa1" "Course" page logged in as "student1"
@@ -79,13 +79,13 @@ Feature: Context freezing apply to child contexts
Then "Add a new discussion topic" "link" should not exist
When I am on "courseaa1" course homepage
When I follow "faa1b"
Then "Add a new discussion topic" "link" should exist
Then "Add discussion topic" "link" should exist
When I am on "courseaa2" course homepage
When I follow "faa2"
Then "Add a new discussion topic" "link" should exist
Then "Add discussion topic" "link" should exist
When I am on "courseb" course homepage
When I follow "fb"
Then "Add a new discussion topic" "link" should exist
Then "Add discussion topic" "link" should exist
Scenario: Freeze course should freeze all children
Given I am on the "courseaa1" "Course" page logged in as "admin"
@@ -103,11 +103,11 @@ Feature: Context freezing apply to child contexts
When I am on "courseaa2" course homepage
Then edit mode should be available on the current page
When I follow "faa2"
Then "Add a new discussion topic" "link" should exist
Then "Add discussion topic" "link" should exist
When I am on "courseb" course homepage
Then edit mode should be available on the current page
When I follow "fb"
Then "Add a new discussion topic" "link" should exist
Then "Add discussion topic" "link" should exist
And I log out
When I am on the "courseaa1" "Course" page logged in as "teacher"
@@ -120,11 +120,11 @@ Feature: Context freezing apply to child contexts
When I am on "courseaa2" course homepage
Then edit mode should be available on the current page
When I follow "faa2"
Then "Add a new discussion topic" "link" should exist
Then "Add discussion topic" "link" should exist
When I am on "courseb" course homepage
Then edit mode should be available on the current page
When I follow "fb"
Then "Add a new discussion topic" "link" should exist
Then "Add discussion topic" "link" should exist
And I log out
When I am on the "courseaa1" "Course" page logged in as "student1"
@@ -135,10 +135,10 @@ Feature: Context freezing apply to child contexts
Then "Add a new discussion topic" "link" should not exist
When I am on "courseaa2" course homepage
When I follow "faa2"
Then "Add a new discussion topic" "link" should exist
Then "Add discussion topic" "link" should exist
When I am on "courseb" course homepage
When I follow "fb"
Then "Add a new discussion topic" "link" should exist
Then "Add discussion topic" "link" should exist
Scenario: Freeze course category should freeze all children
Given I log in as "admin"
@@ -162,7 +162,7 @@ Feature: Context freezing apply to child contexts
When I am on "courseb" course homepage
Then edit mode should be available on the current page
When I follow "fb"
Then "Add a new discussion topic" "link" should exist
Then "Add discussion topic" "link" should exist
And I log out
When I am on the "courseaa1" "Course" page logged in as "teacher"
@@ -180,7 +180,7 @@ Feature: Context freezing apply to child contexts
When I am on "courseb" course homepage
Then edit mode should be available on the current page
When I follow "fb"
Then "Add a new discussion topic" "link" should exist
Then "Add discussion topic" "link" should exist
And I log out
When I am on the "courseaa1" "Course" page logged in as "student1"
@@ -194,4 +194,4 @@ Feature: Context freezing apply to child contexts
Then "Add a new discussion topic" "link" should not exist
When I am on "courseb" course homepage
When I follow "fb"
Then "Add a new discussion topic" "link" should exist
Then "Add discussion topic" "link" should exist
@@ -417,7 +417,7 @@ class discussion {
if ($this->capabilitymanager->must_post_before_viewing_discussion($user, $discussion)) {
$notifications[] = (new notification(
get_string('qandanotify', 'forum')
))->set_show_closebutton(true);
))->set_show_closebutton(true)->set_extra_classes(['mt-3']);
}
}
@@ -37,6 +37,7 @@ use mod_forum\local\vaults\discussion_list as discussion_list_vault;
use renderer_base;
use stdClass;
use core\output\notification;
use mod_forum\local\data_mappers\legacy\forum;
use mod_forum\local\factories\builder as builder_factory;
require_once($CFG->dirroot . '/mod/forum/lib.php');
@@ -145,6 +146,7 @@ class discussion_list {
* @param int $pageno The zero-indexed page number to use
* @param int $pagesize The number of discussions to show on the page
* @param int $displaymode The discussion display mode
* @param bool $enablediscussioncreation To show the discussion button.
* @return string The rendered content for display
*/
public function render(
@@ -154,7 +156,8 @@ class discussion_list {
?int $sortorder,
?int $pageno,
?int $pagesize,
int $displaymode = null
int $displaymode = null,
bool $enablediscussioncreation = true
) : string {
global $PAGE;
@@ -209,7 +212,8 @@ class discussion_list {
],
'totaldiscussioncount' => $alldiscussionscount,
'userid' => $user->id,
'visiblediscussioncount' => count($discussions)
'visiblediscussioncount' => count($discussions),
'enablediscussioncreation' => $enablediscussioncreation,
];
if ($forumview['forum']['capabilities']['create']) {
@@ -241,6 +245,27 @@ class discussion_list {
return $this->renderer->render_from_template($this->template, $forumview);
}
/**
* Add new discussion button to the action bar for tertiary nav.
*
* @param stdClass $user The user object.
* @param int|null $groupid The group id.
* @return string rendered HTML string
*/
public function render_new_discussion(stdClass $user, ?int $groupid): string {
$forumexporter = $this->exporterfactory->get_forum_exporter(
$user,
$this->forum,
$groupid
);
$forumview = [
'forum' => (array) $forumexporter->export($this->renderer),
];
return $this->renderer->render_from_template('mod_forum/forum_new_discussion_actionbar', $forumview);
}
/**
* Get the mod_forum_post_form. This is the default boiler plate from mod_forum/post_form.php with the inpage flag caveat
*
@@ -335,7 +360,7 @@ class discussion_list {
* @param int|null $groupid The forum's group id
* @return array
*/
private function get_notifications(stdClass $user, ?int $groupid) : array {
private function get_notifications(stdClass $user, ?int $groupid): array {
$notifications = $this->notifications;
$forum = $this->forum;
$capabilitymanager = $this->capabilitymanager;
@@ -381,7 +406,7 @@ class discussion_list {
$notifications[] = (new notification(
get_string('qandanotify', 'forum'),
notification::NOTIFY_INFO
))->set_show_closebutton();
))->set_show_closebutton()->set_extra_classes(['mt-3']);
}
if ('eachuser' === $forum->get_type()) {
@@ -0,0 +1,135 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_forum\output;
use renderable;
use renderer_base;
use templatable;
use moodle_url;
use help_icon;
use mod_forum\local\entities\forum as forum_entity;
/**
* Render activity page for tertiary nav
*
* Render elements search forum, add new discussion button and subscribe all
* to the page action.
*
* @package mod_forum
* @copyright 2021 Sujith Haridasan <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class forum_actionbar implements renderable, templatable {
/**
* @var forum_entity $forum
*/
private $forum;
/**
* @var \stdClass $course
*/
private $course;
/**
* @var mixed $groupid
*/
private $groupid;
/**
* @var string $search
*/
private $search;
/**
* forum_actionbar constructor.
*
* @param forum_entity $forum The forum object.
* @param \stdClass $course The course object.
* @param int|null $groupid The group id.
* @param string $search The search string.
*/
public function __construct(forum_entity $forum, \stdClass $course, ?int $groupid, string $search) {
$this->forum = $forum;
$this->course = $course;
$this->groupid = $groupid;
$this->search = $search;
}
/**
* Render the new discussion button.
*
* @return string HTML button
*/
private function get_new_discussion_topic_button(): string {
global $USER;
$renderfactory = \mod_forum\local\container::get_renderer_factory();
$discussionrenderer = $renderfactory->get_discussion_list_renderer($this->forum);
return $discussionrenderer->render_new_discussion($USER, $this->groupid);
}
/**
* Data for the template.
*
* @param renderer_base $output The render_base object.
* @return array data for the template
*/
public function export_for_template(renderer_base $output): array {
global $USER;
$actionurl = (new moodle_url('/mod/forum/search.php'))->out(false);
$helpicon = new help_icon('search', 'core');
$hiddenfields = [
(object) ['name' => 'id', 'value' => $this->course->id],
];
$shownewdiscussionbtn = '';
if ($this->forum->get_type() !== 'single') {
$shownewdiscussionbtn = $this->get_new_discussion_topic_button();
}
$data = [
'action' => $actionurl,
'hiddenfields' => $hiddenfields,
'query' => $this->search,
'helpicon' => $helpicon->export_for_template($output),
'inputname' => 'search',
'searchstring' => get_string('searchforums', 'mod_forum'),
'newdiscussionbtn' => $shownewdiscussionbtn,
];
$legacydatamapperfactory = \mod_forum\local\container::get_legacy_data_mapper_factory();
$forumobject = $legacydatamapperfactory->get_forum_data_mapper()->to_legacy_object($this->forum);
$context = $this->forum->get_context();
$activeenrolled = is_enrolled($context, $USER, '', true);
$canmanage = has_capability('mod/forum:managesubscriptions', $context);
$cansubscribe = $activeenrolled && !($this->forum->get_subscription_mode() === FORUM_FORCESUBSCRIBE) &&
(!($this->forum->get_subscription_mode() === FORUM_DISALLOWSUBSCRIBE) || $canmanage);
if ($cansubscribe) {
$returnurl =
(new moodle_url('/mod/forum/view.php', ['id' => $this->forum->get_course_module_record()->id]))->out(false);
if (!\mod_forum\subscriptions::is_subscribed($USER->id, $forumobject, null, $this->forum->get_course_module_record())) {
$data['subscribetoforum'] = (new moodle_url(
'/mod/forum/subscribe.php',
['id' => $forumobject->id, 'sesskey' => sesskey(), 'returnurl' => $returnurl]
))->out(false);
} else {
$data['unsubscribefromforum'] = (new moodle_url(
'/mod/forum/subscribe.php',
['id' => $forumobject->id, 'sesskey' => sesskey(), 'returnurl' => $returnurl]
))->out(false);
}
}
return $data;
}
}
@@ -0,0 +1,143 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_forum\output;
use moodle_url;
use renderer_base;
use url_select;
use renderable;
use templatable;
/**
* Renders the subscribers page for this activity.
*
* @package mod_forum
* @copyright 2021 Sujith Haridasan <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class subscription_actionbar implements renderable, templatable {
/** @var int course id */
private $id;
/** @var moodle_url */
private $currenturl;
/** @var \stdClass */
private $forum;
/**
* subscription_actionbar constructor.
*
* @param int $id The forum id.
* @param moodle_url $currenturl Current URL.
* @param \stdClass $forum The forum object.
*/
public function __construct(int $id, moodle_url $currenturl, \stdClass $forum) {
$this->id = $id;
$this->currenturl = $currenturl;
$this->forum = $forum;
}
/**
* Create url select menu for subscription option
*
* @return url_select the url_select object
*/
private function create_subscription_menu(): url_select {
$sesskey = sesskey();
$modeset = \mod_forum\subscriptions::get_subscription_mode($this->forum);
$optionallink = new moodle_url('/mod/forum/subscribe.php', ['id' => $this->id, 'mode' => 0, 'sesskey' => $sesskey]);
$forcedlink = new moodle_url('/mod/forum/subscribe.php', ['id' => $this->id, 'mode' => 1, 'sesskey' => $sesskey]);
$autolink = new moodle_url('/mod/forum/subscribe.php', ['id' => $this->id, 'mode' => 2, 'sesskey' => $sesskey]);
$disabledlink = new moodle_url('/mod/forum/subscribe.php', ['id' => $this->id, 'mode' => 3, 'sesskey' => $sesskey]);
$menu = [
$optionallink->out(false) => get_string('subscriptionoptional', 'forum'),
$forcedlink->out(false) => get_string('subscriptionforced', 'forum'),
$autolink->out(false) => get_string('subscriptionauto', 'forum'),
$disabledlink->out(false) => get_string('subscriptiondisabled', 'forum'),
];
switch ($modeset) {
case FORUM_CHOOSESUBSCRIBE:
$set = get_string('subscriptionoptional', 'forum');
break;
case FORUM_FORCESUBSCRIBE:
$set = get_string('subscriptionforced', 'forum');
break;
case FORUM_INITIALSUBSCRIBE:
$set = get_string('subscriptionauto', 'forum');
break;
case FORUM_DISALLOWSUBSCRIBE:
$set = get_string('subscriptiondisabled', 'forum');
break;
default:
throw new \moodle_exception(get_string('invalidforcesubscribe', 'forum'));
}
$menu = array_filter($menu, function($key) use ($set) {
if ($key !== $set) {
return true;
}
});
$urlselect = new url_select($menu, $this->currenturl, ['' => $set], 'selectsubscriptionoptions');
$urlselect->set_label(get_string('subscriptions', 'mod_forum'), ['class' => 'accesshide']);
$urlselect->class .= ' float-right';
return $urlselect;
}
/**
* Create view and manage subscribers select menu.
*
* @return url_select get url_select object.
*/
private function create_view_manage_menu(): url_select {
$viewlink = new moodle_url('/mod/forum/subscribers.php', ['id' => $this->id, 'edit' => 'off']);
$managelink = new moodle_url('/mod/forum/subscribers.php', ['id' => $this->id, 'edit' => 'on']);
$menu = [
$viewlink->out(false) => get_string('forum:viewsubscribers', 'forum'),
$managelink->out(false) => get_string('managesubscriptionson', 'forum'),
];
if ($this->currenturl->get_param('edit') === 'off') {
$this->currenturl = $viewlink;
} else {
$this->currenturl = $managelink;
}
$urlselect = new url_select($menu, $this->currenturl->out(false), null, 'selectviewandmanagesubscribers');
$urlselect->set_label(get_string('subscribers', 'forum'), ['class' => 'accesshide']);
return $urlselect;
}
/**
* Data for the template.
*
* @param renderer_base $output The render_base object.
* @return array data for template
*/
public function export_for_template(renderer_base $output): array {
$subscribeoptionselect = $this->create_subscription_menu();
$viewmanageselect = $this->create_view_manage_menu();
$data = [
'subscriptionoptions' => $subscribeoptionselect->export_for_template($output),
'viewandmanageselect' => $viewmanageselect->export_for_template($output),
];
return $data;
}
}
+3 -1
View File
@@ -320,7 +320,9 @@ if ($isnestedv2displaymode) {
echo $OUTPUT->header();
if (!$isnestedv2displaymode) {
echo $OUTPUT->heading(format_string($forum->get_name()), 2);
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($forum->get_name()), 2);
}
echo $OUTPUT->heading(format_string($discussion->get_name()), 3, 'discussionname');
}
+3 -1
View File
@@ -184,7 +184,9 @@ $PAGE->set_pagelayout('admin');
$PAGE->set_heading($pagetitle);
echo $OUTPUT->header();
echo $OUTPUT->heading($pagetitle);
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading($pagetitle);
}
// It is possible that the following fields have been provided in the URL.
$form->set_data(['useridsselected' => $userids, 'discussionids' => $discussionids, 'from' => $from, 'to' => $to]);
+5 -1
View File
@@ -35,6 +35,7 @@ if ($subscribe !== null) {
$url->param('subscribe', $subscribe);
}
$PAGE->set_url($url);
$PAGE->set_secondary_active_tab('coursehome');
if ($id) {
if (!$course = $DB->get_record('course', array('id' => $id))) {
@@ -454,9 +455,12 @@ if ($course->id != SITEID) { // Only real courses have learning forums
$PAGE->navbar->add($strforums);
$PAGE->set_title("$course->shortname: $strforums");
$PAGE->set_heading($course->fullname);
$PAGE->add_header_action($searchform);
echo $OUTPUT->header();
echo html_writer::start_div('input-group mr-5');
echo $searchform;
echo html_writer::end_div();
if (!isguestuser() && isloggedin() && $showsubscriptioncolumns) {
// Show the subscribe all options only to non-guest, enrolled users.
echo $OUTPUT->box_start('subscription');
+3 -3
View File
@@ -27,7 +27,7 @@ $string['activitydate:due'] = 'Due:';
$string['activityoverview'] = 'There are new forum posts';
$string['actionsforgraderinterface'] = 'Actions for the grader interface';
$string['actionsforpost'] = 'Actions for post';
$string['addanewdiscussion'] = 'Add a new discussion topic';
$string['addanewdiscussion'] = 'Add discussion topic';
$string['addanewquestion'] = 'Add a new question';
$string['addanewtopic'] = 'Add a new topic';
$string['addtofavourites'] = 'Star this discussion';
@@ -664,7 +664,7 @@ $string['smallmessage'] = '{$a->user} posted in {$a->forumname}';
$string['smallmessagedigest'] = 'Forum digest containing {$a} messages';
$string['startedby'] = 'Started by';
$string['subject'] = 'Subject';
$string['subscribe'] = 'Subscribe to this forum';
$string['subscribe'] = 'Subscribe to forum';
$string['subscribediscussion'] = 'Subscribe to this discussion';
$string['subscribeall'] = 'Subscribe everyone to this forum';
$string['subscribeenrolledonly'] = 'Sorry, only enrolled users are allowed to subscribe to forum post notifications.';
@@ -722,7 +722,7 @@ $string['unreadpost'] = 'Unread post';
$string['unreadposts'] = 'Unread posts';
$string['unreadpostsnumber'] = '{$a} unread posts';
$string['unreadpostsone'] = '1 unread post';
$string['unsubscribe'] = 'Unsubscribe from this forum';
$string['unsubscribe'] = 'Unsubscribe from forum';
$string['unsubscribelink'] = 'Unsubscribe from this forum: {$a}';
$string['unsubscribediscussion'] = 'Unsubscribe from this discussion';
$string['unsubscribediscussionlink'] = 'Unsubscribe from this discussion: {$a}';
+36 -42
View File
@@ -20,6 +20,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use mod_forum\local\entities\forum as forum_entity;
defined('MOODLE_INTERNAL') || die();
/** Include required files */
@@ -2599,6 +2601,22 @@ function forum_search_form($course, $search='') {
return $output->render($forumsearch);
}
/**
* Retrieve HTML for the page action
*
* @param forum_entity|null $forum The forum entity.
* @param mixed $groupid false if groups not used, int if groups used, 0 means all groups
* @param stdClass $course The course object.
* @param string $search The search string.
* @return string rendered HTML string.
*/
function forum_activity_actionbar(?forum_entity $forum, $groupid, stdClass $course, string $search=''): string {
global $PAGE;
$actionbar = new mod_forum\output\forum_actionbar($forum, $course, $groupid, $search);
$output = $PAGE->get_renderer('mod_forum');
return $output->render($actionbar);
}
/**
* @global object
@@ -5472,22 +5490,6 @@ function forum_extend_settings_navigation(settings_navigation $settingsnav, navi
$discussionid = $params['d'];
}
// Display all forum reports user has access to.
if (isloggedin() && !isguestuser()) {
$reportnames = array_keys(core_component::get_plugin_list('forumreport'));
foreach ($reportnames as $reportname) {
if (has_capability("forumreport/{$reportname}:view", $PAGE->cm->context)) {
$reportlinkparams = [
'courseid' => $forumobject->course,
'forumid' => $forumobject->id,
];
$reportlink = new moodle_url("/mod/forum/report/{$reportname}/index.php", $reportlinkparams);
$forumnode->add(get_string('nodetitle', "forumreport_{$reportname}"), $reportlink, navigation_node::TYPE_CONTAINER);
}
}
}
// For some actions you need to be enrolled, being admin is not enough sometimes here.
$enrolled = is_enrolled($PAGE->cm->context, $USER, '', false);
$activeenrolled = is_enrolled($PAGE->cm->context, $USER, '', true);
@@ -5500,6 +5502,7 @@ function forum_extend_settings_navigation(settings_navigation $settingsnav, navi
if ($canmanage) {
$mode = $forumnode->add(get_string('subscriptionmode', 'forum'), null, navigation_node::TYPE_CONTAINER);
$mode->add_class('subscriptionmode');
$mode->set_show_in_secondary_navigation(false);
// Optional subscription mode.
$allowchoicestring = get_string('subscriptionoptional', 'forum');
@@ -5594,34 +5597,25 @@ function forum_extend_settings_navigation(settings_navigation $settingsnav, navi
}
}
if ($cansubscribe) {
if (\mod_forum\subscriptions::is_subscribed($USER->id, $forumobject, null, $PAGE->cm)) {
$linktext = get_string('unsubscribe', 'forum');
} else {
$linktext = get_string('subscribe', 'forum');
}
$url = new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'sesskey'=>sesskey()));
$forumnode->add($linktext, $url, navigation_node::TYPE_SETTING);
if (isset($discussionid)) {
if (\mod_forum\subscriptions::is_subscribed($USER->id, $forumobject, $discussionid, $PAGE->cm)) {
$linktext = get_string('unsubscribediscussion', 'forum');
} else {
$linktext = get_string('subscribediscussion', 'forum');
}
$url = new moodle_url('/mod/forum/subscribe.php', array(
'id' => $forumobject->id,
'sesskey' => sesskey(),
'd' => $discussionid,
'returnurl' => $PAGE->url->out(),
));
$forumnode->add($linktext, $url, navigation_node::TYPE_SETTING);
}
if (has_capability('mod/forum:viewsubscribers', $PAGE->cm->context)) {
$url = new moodle_url('/mod/forum/subscribers.php', ['id' => $forumobject->id, 'edit' => 'off']);
$forumnode->add(get_string('subscriptions', 'forum'), $url, navigation_node::TYPE_SETTING, null, 'forumsubscriptions');
}
if (has_capability('mod/forum:viewsubscribers', $PAGE->cm->context)){
$url = new moodle_url('/mod/forum/subscribers.php', array('id'=>$forumobject->id));
$forumnode->add(get_string('showsubscribers', 'forum'), $url, navigation_node::TYPE_SETTING);
// Display all forum reports user has access to.
if (isloggedin() && !isguestuser()) {
$reportnames = array_keys(core_component::get_plugin_list('forumreport'));
foreach ($reportnames as $reportname) {
if (has_capability("forumreport/{$reportname}:view", $PAGE->cm->context)) {
$reportlinkparams = [
'courseid' => $forumobject->course,
'forumid' => $forumobject->id,
];
$reportlink = new moodle_url("/mod/forum/report/{$reportname}/index.php", $reportlinkparams);
$forumnode->add(get_string('reports'), $reportlink, navigation_node::TYPE_CONTAINER);
}
}
}
if ($enrolled && forum_tp_can_track_forums($forumobject)) { // keep tracking info for users with suspended enrolments
+13 -4
View File
@@ -464,7 +464,9 @@ if (!empty($forum)) {
}
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($forum->name), 2);
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($forum->name), 2);
}
echo $OUTPUT->confirm(get_string("deletesureplural", "forum", $replycount + 1),
"post.php?delete=$delete&confirm=$delete",
$CFG->wwwroot.'/mod/forum/discuss.php?d='.$post->discussion.'#p'.$post->id);
@@ -487,7 +489,9 @@ if (!empty($forum)) {
echo $postsrenderer->render($USER, [$forumentity], [$discussionentity], $postentities);
} else {
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($forum->name), 2);
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($forum->name), 2);
}
echo $OUTPUT->confirm(get_string("deletesure", "forum", $replycount),
"post.php?delete=$delete&confirm=$delete",
$CFG->wwwroot.'/mod/forum/discuss.php?d='.$post->discussion.'#p'.$post->id);
@@ -634,7 +638,9 @@ if (!empty($forum)) {
$PAGE->set_title(format_string($discussion->name).": ".format_string($post->subject));
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($forum->name), 2);
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($forum->name), 2);
}
echo $OUTPUT->heading(get_string('pruneheading', 'forum'), 3);
$prunemform->display();
@@ -1087,9 +1093,12 @@ if ($edit) {
$PAGE->set_title("{$course->shortname}: {$strdiscussionname}{$titlesubject}");
$PAGE->set_heading($course->fullname);
$PAGE->set_secondary_active_tab("modulepage");
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($forum->name), 2);
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($forum->name), 2);
}
// Checkup.
if (!empty($parententity) && !$capabilitymanager->can_view_post($USER, $discussionentity, $parententity)) {
+27 -2
View File
@@ -234,10 +234,35 @@ class mod_forum_renderer extends plugin_renderer_base {
* Render quick search form.
*
* @param \mod_forum\output\quick_search_form $form The renderable.
* @return string
* @return string rendered HTML string from the template.
*/
public function render_quick_search_form(\mod_forum\output\quick_search_form $form) {
return $this->render_from_template('mod_forum/quick_search_form', $form->export_for_template($this));
if (strpos($this->page->url->get_path(), "index.php")) {
return $this->render_from_template('mod_forum/quick_search_form', $form->export_for_template($this));
}
return $this->render_from_template('mod_forum/forum_new_discussion_actionbar', $form->export_for_template($this));
}
/**
* Render the view action area.
*
* @param \mod_forum\output\forum_actionbar $actionbar forum_actionbar object.
* @return string rendered HTML string
*/
public function render_activity_actionbar(\mod_forum\output\forum_actionbar $actionbar): string {
return $this->render_from_template('mod_forum/forum_actionbar', $actionbar->export_for_template($this));
}
/**
* Render the subscription action area.
*
* @param \mod_forum\output\subscription_actionbar $subscriptionactionbar subscription_actionbar object.
* @return bool|string rendered HTML string.
*/
public function subscription_actionbar(\mod_forum\output\subscription_actionbar $subscriptionactionbar): string {
return $this->render_from_template('mod_forum/forum_subscription_action',
$subscriptionactionbar->export_for_template($this));
}
/**
+4
View File
@@ -109,6 +109,10 @@ $PAGE->set_title($title);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add(get_string('nodetitle', 'forumreport_summary'));
// Activate the secondary nav tab.
navigation_node::override_active_url(new moodle_url('/mod/forum/report/summary/index.php',
['courseid' => $courseid, 'forumid' => $forumid]));
$allowbulkoperations = !$download && !empty($CFG->messaging) && has_capability('moodle/course:bulkmessaging', $context);
$canseeprivatereplies = false;
$hasviewall = false;
@@ -41,7 +41,7 @@ Feature: Message users in the summary report
| user | course | role |
| student3 | C1 | student |
When I am on the forum1 "forum activity" page logged in as teacher1
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
And I click on "Select 'Student 1'" "checkbox"
And I click on "Select 'Student 3'" "checkbox"
And I set the field "With selected users..." to "Send a message"
@@ -61,7 +61,7 @@ Feature: Message users in the summary report
@javascript
Scenario: Message all users
When I am on the forum1 "forum activity" page logged in as teacher1
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
And I click on "Select all" "checkbox"
And I set the field "With selected users..." to "Send a message"
Then I should see "Send message to 3 people"
@@ -71,6 +71,6 @@ Feature: Message users in the summary report
Given the following config values are set as admin:
| messaging | 0 |
When I am on the forum1 "forum activity" page logged in as teacher1
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
Then I should not see "With selected users..."
And I should not see "Select all"
@@ -56,7 +56,7 @@ Feature: Course level forum summary report
Scenario: Course forum summary report can be viewed by teacher and contains accurate data
When I am on the forum2 "forum activity" page logged in as teacher1
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
And I should see "Export posts"
And the following should exist in the "forumreport_summary_table" table:
# | | Discussions | Replies | | |
@@ -91,7 +91,7 @@ Feature: Course level forum summary report
When I log in as "student1"
And I am on "Course 1" course homepage
And I follow "forum1"
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
And the following should exist in the "forumreport_summary_table" table:
# | | Discussions | Replies | | |
| First name / Surname | -2- | -3- | Earliest post | Most recent post |
@@ -47,7 +47,7 @@ Feature: forum report shows post/reply/word counts correctly
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "forum1"
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
Then "Teacher 1" row "Number of attachments" column of "forumreport_summary_table" table should contain "6"
And "Student 1" row "Number of attachments" column of "forumreport_summary_table" table should contain "5"
And "Student 1" row "Word count" column of "forumreport_summary_table" table should contain "4"
@@ -42,7 +42,7 @@ Feature: Include private replies in the summary report
Scenario: Private replies are counted for Teacher
When I am on the forum1 "forum activity" page logged in as teacher2
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
Then "Teacher 1" row "Number of replies posted" column of "forumreport_summary_table" table should contain "3"
Scenario: Private replies are not counted when Teacher has not capability
@@ -50,5 +50,5 @@ Feature: Include private replies in the summary report
| capability | permission | role | contextlevel | reference |
| mod/forum:readprivatereplies | Prevent | editingteacher | Course | C1 |
When I am on the forum1 "forum activity" page logged in as teacher2
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
Then "Teacher 1" row "Number of replies posted" column of "forumreport_summary_table" table should contain "2"
@@ -34,7 +34,7 @@ Feature: Report relevant content availability
@javascript
Scenario: Teachers can access report data about other users by default
Given I am on the "forum1" "forum activity" page logged in as teacher1
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
Then the following should exist in the "forumreport_summary_table" table:
| -2- | -3- | -4- | -5- | -6- | -7- | -8- |
| Student 1 | 1 | 1 | 5 | 0 | 3 | 14 |
@@ -64,7 +64,7 @@ Feature: Report relevant content availability
| capability | permission | role | contextlevel | reference |
| forumreport/summary:view | Allow | student | Course | C1 |
When I am on the "forum1" "forum activity" page logged in as student1
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
Then the following should exist in the "forumreport_summary_table" table:
| -1- | -2- | -3- | -4- | -5- | -6- | -7- |
| Student 1 | 1 | 1 | 5 | 1 | 3 | 14 |
@@ -42,7 +42,7 @@ Feature: Attachments count column data available
| user | forum | name | message | attachments | inlineattachments |
| teacher1 | forum1 | discussion1 | message1 | att1.jpg, att2.txt | |
When I am on the forum1C1 "forum activity" page logged in as teacher1
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
Then "Teacher 1" row "Number of attachments" column of "forumreport_summary_table" table should contain "6"
And "Student 1" row "Number of attachments" column of "forumreport_summary_table" table should contain "5"
And "Student 2" row "Number of attachments" column of "forumreport_summary_table" table should contain "0"
@@ -44,7 +44,7 @@ Feature: Post date columns data available
| teacher1 | forum1 | discussion1 | t1 other course | ##2017-01-01 03:00:00## |
| teacher1 | forum1 | discussion2 | t1 other course | ##2019-09-13 23:59:00## |
When I am on the forum1C1 "forum activity" page logged in as teacher1
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
Then "Teacher 1" row "Earliest post" column of "forumreport_summary_table" table should contain "Tuesday, 2 January 2018, 9:00"
Then "Teacher 1" row "Most recent post" column of "forumreport_summary_table" table should contain "Sunday, 1 September 2019, 7:00"
Then "Student 1" row "Earliest post" column of "forumreport_summary_table" table should contain "Wednesday, 27 March 2019, 4:00"
@@ -63,7 +63,7 @@ Feature: Groups report filter is available if groups exist
@javascript
Scenario: All groups can be selected or cleared together in the groups filter, and are unchecked by default
When I am on the "c1forum1" "forum activity" page logged in as teacher1
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
Then "Groups" "button" should exist
And the following should exist in the "forumreport_summary_table" table:
# | | Discussions | Replies |
@@ -111,7 +111,7 @@ Feature: Groups report filter is available if groups exist
@javascript
Scenario: The summary report can be filtered by a subset of groups, and re-ordering the results retains the filter
When I am on the "c1forum1" "forum activity" page logged in as teacher1
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
Then "Groups" "button" should exist
And the following should exist in the "forumreport_summary_table" table:
# | | Discussions | Replies |
@@ -145,7 +145,7 @@ Feature: Groups report filter is available if groups exist
@javascript
Scenario: The summary report can be filtered as a mixture of groups and no groups
When I am on the "c1forum2" "forum activity" page logged in as teacher1
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
Then "Groups" "button" should exist
And the following should exist in the "forumreport_summary_table" table:
# | | Discussions | Replies |
@@ -169,7 +169,7 @@ Feature: Groups report filter is available if groups exist
@javascript
Scenario: The summary report can be filtered by no groups only
When I am on the "c1forum2" "forum activity" page logged in as teacher1
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
Then the following should exist in the "forumreport_summary_table" table:
# | | Discussions | Replies |
| First name / Surname | -3- | -4- |
@@ -192,7 +192,7 @@ Feature: Groups report filter is available if groups exist
Scenario: Filtering by a group containing no users still allows the page to render
# Log in as admin so Teacher 1 not existing on page can be confirmed.
When I am on the "c1forum1" "forum activity" page logged in as admin
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
Then "Groups" "button" should exist
And the following should exist in the "forumreport_summary_table" table:
# | | Discussions | Replies |
@@ -215,7 +215,7 @@ Feature: Groups report filter is available if groups exist
@javascript
Scenario: Course forum summary report can be filtered by group
When I am on the "c1forum2" "forum activity" page logged in as teacher1
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
And I select "All forums in course" from the "Forum selected" singleselect
And I click on "Groups" "button"
And I click on "Clear" "button" in the "filter-groups-popover" "region"
@@ -50,7 +50,7 @@ Feature: Groups report filter is not available if no groups exist
| teacher1 | forum1 | discussion1 | D1 other course | ## 1 week ago ## |
| teacher1 | forum1 | discussion2 | D2 other course | ## 4 days ago ## |
When I am on the forum1C1 "forum activity" page logged in as teacher1
And I navigate to "Forum summary report" in current page administration
And I navigate to "Reports" in current page administration
Then "Groups" "button" should not exist
And the following should exist in the "forumreport_summary_table" table:
# | | Discussions |
+7 -2
View File
@@ -71,6 +71,7 @@ $starredonly = optional_param('starredonly', false, PARAM_BOOL); // Include only
$PAGE->set_pagelayout('standard');
$PAGE->set_url($FULLME); //TODO: this is very sloppy --skodak
$PAGE->set_secondary_active_tab("coursehome");
if (empty($search)) { // Check the other parameters instead
if (!empty($words)) {
@@ -166,7 +167,9 @@ if (!$posts = forum_search_posts($searchterms, $course->id, $page*$perpage, $per
$PAGE->set_title($strsearchresults);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading($strforums, 2);
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading($strforums, 2);
}
echo $OUTPUT->heading($strsearchresults, 3);
echo $OUTPUT->heading(get_string("noposts", "forum"), 4);
@@ -220,7 +223,9 @@ echo html_writer::link($url, get_string('advancedsearch', 'forum').'...');
echo '</div>';
echo $OUTPUT->heading($strforums, 2);
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading($strforums, 2);
}
echo $OUTPUT->heading("$strsearchresults: $totalcount", 3);
$url = new moodle_url('search.php', array('search' => $search, 'id' => $course->id, 'perpage' => $perpage));
+17 -17
View File
@@ -35,8 +35,11 @@ if ($group !== 0) {
$url->param('group', $group);
}
if ($edit !== 0) {
$url->param('edit', $edit);
$url->param('edit', 'on');
} else {
$url->param('edit', 'off');
}
$PAGE->set_url($url);
$forum = $DB->get_record('forum', array('id'=>$id), '*', MUST_EXIST);
@@ -100,21 +103,20 @@ $strsubscribers = get_string("subscribers", "forum");
$PAGE->navbar->add($strsubscribers, $url);
$PAGE->set_title($strsubscribers);
$PAGE->set_heading($COURSE->fullname);
if (has_capability('mod/forum:managesubscriptions', $context) && \mod_forum\subscriptions::is_forcesubscribed($forum) === false) {
if ($edit != -1) {
$USER->subscriptionsediting = $edit;
}
$updatesubscriptionsbutton = forum_update_subscriptions_button($course->id, $id);
} else {
$updatesubscriptionsbutton = '';
unset($USER->subscriptionsediting);
}
// Activate the secondary nav tab.
$PAGE->set_secondary_active_tab("forumsubscriptions");
// Output starts from here.
$actionbar = new \mod_forum\output\subscription_actionbar($id, $url, $forum);
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('forum', 'forum').' '.$strsubscribers);
if (!empty($updatesubscriptionsbutton)) {
echo \html_writer::div($updatesubscriptionsbutton, 'float-right');
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(get_string('forum', 'forum') . ' ' . $strsubscribers);
}
if (empty($USER->subscriptionsediting)) {
echo $forumoutput->subscription_actionbar($actionbar);
if ($edit === 0) {
$subscribers = \mod_forum\subscriptions::fetch_subscribed_users($forum, $currentgroup, $context);
if (\mod_forum\subscriptions::is_forcesubscribed($forum)) {
$subscribers = mod_forum_filter_hidden_users($cm, $context, $subscribers);
@@ -123,9 +125,7 @@ if (empty($USER->subscriptionsediting)) {
} else {
echo $forumoutput->subscriber_selection_form($existingselector, $subscriberselector);
}
if (!empty($updatesubscriptionsbutton)) {
echo $updatesubscriptionsbutton;
}
echo $OUTPUT->footer();
/**
+7 -5
View File
@@ -52,11 +52,13 @@
<div class="py-3">
{{#forum.capabilities.create}}
<a class="btn btn-primary" data-toggle="collapse" href="#collapseAddForm">
{{$discussion_create_text}}
{{#str}}addanewdiscussion, forum{{/str}}
{{/discussion_create_text}}
</a>
{{#enablediscussioncreation}}
<a class="btn btn-primary" data-toggle="collapse" href="#collapseAddForm">
{{$discussion_create_text}}
{{#str}}addanewdiscussion, forum{{/str}}
{{/discussion_create_text}}
</a>
{{/enablediscussioncreation}}
{{/forum.capabilities.create}}
{{^forum.capabilities.create}}
{{#forum.capabilities.selfenrol}}
@@ -0,0 +1,69 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template mod_forum/forum_actionbar
Simple search input.
Context variables required for this template:
* see mod/forum/classes/output/forum_actionbar.php
Example context (json):
{
"action": "https://moodle.local/mod/forum/search.php",
"inputname": "search",
"searchstring": "Search settings",
"query": "themedesigner",
"hiddenfields": [{
"name": "id",
"value": "11"
}],
"helpicon": {
"heading": "Search",
"text": "<div class='no-overflow'><p>For basic searching .</p></div>",
"alt": "Help with search",
"icon": [{
"attributes": [{
"name": "alt",
"value": "Help with Search"
}, {
"name": "src",
"value": "http://localhost/theme/image.php?theme=boost&component=core&image=help"
}]
}]
},
"newdiscussionbtn": "<a class='btn btn-primary'>Add discussion topic</a>",
"subscribetoforum": "http://localhost/moodle/mod/forum/subscribe.php?id=7&sesskey=abcd&returnurl=http//localhost/moodle/mod/forum/view.php?id=4",
"unsubscribefromforum": "http://localhost/moodle/mod/forum/subscribe.php?id=7&sesskey=abcd&returnurl=http//localhost/moodle/mod/forum/view.php?id=4"
}
}}
<div class="container-fluid mb-4">
<div class="row">
<div class="d-flex">
{{> mod_forum/quick_search_form }}
</div>
<div class="ml-2">
{{{newdiscussionbtn}}}
</div>
<div class="ml-auto d-flex">
{{#subscribetoforum}}
<a class="btn btn-secondary" href="{{ subscribetoforum }}">{{#str}}subscribe, mod_forum {{/str}}</a>
{{/subscribetoforum}}
{{#unsubscribefromforum}}
<a class="btn btn-secondary" href="{{ unsubscribefromforum }}">{{#str}}unsubscribe, mod_forum {{/str}}</a>
{{/unsubscribefromforum}}
</div>
</div>
</div>
@@ -0,0 +1,49 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template mod_forum/forum_new_discussion_actionbar
Add button to create a new discussion in the forum activity.
Classes required for JS:
* none
Data attributes required for JS:
* none
Context variables required for this template:
* see mod/forum/classes/output/activity_actionbar.php
Example context (json):
{
"forum": {
"id": 3,
"name": "Forum test",
"state": [],
"userstate": "",
"capabilities": [{
"viewdiscussions": true,
"create": true,
"selfenrol": false
}],
"urls": [{
"create": "http://localhost/mod/forum/post.php?forum=11"
}]
}
}
}}
{{#forum.capabilities.create}}
<a class="btn btn-primary" data-toggle="collapse" href="#collapseAddForm">
{{#str}}addanewdiscussion, forum{{/str}}
</a>
{{/forum.capabilities.create}}
@@ -0,0 +1,82 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template mod_forum/forum_subscription_action
Actions bar for the subscribers page UI.
Classes required for JS:
* none
Data attributes required for JS:
* data-region
Context variables required for this template:
* see mod/forum/classes/output/subscription_actionbar.php
Example context (json):
{
"subscriptionoptions": {
"formid": "selectsubscriptions",
"classes": "urlselect float-right",
"disabled": false,
"sesskey": "abcdef",
"action": "http://localhost/course/jumpto.php",
"helpicon": false,
"options": [
{
"name": "Subscription disabled",
"value": ""
},
{
"name": "Optional subscrition",
"value": "/mod/forum/subscribe.php?id=3&mode=0&sesskey=abc123"
}
]
},
"viewandmanageselect": {
"formid": "selectviewandmanagesubscribers",
"classes": "urlselect",
"label": "Subscribers",
"disabled": false,
"sesskey": "abcdef",
"action": "http://localhost/course/jumpto.php",
"options": [
{
"name": "View subscribers",
"value": "/mod/forum/subscribers.php?id=3&edit=off",
"selected": true
},
{
"name": "Manage subscribers",
"value": "/mod/forum/subscribers.php?id=3&edit=on",
"selected": false
}
]
}
}
}}
<div class="container-fluid">
<div class="row justify-content-between">
<div class="col-xs-6 float-left">
{{#viewandmanageselect}}
{{>core/url_select}}
{{/viewandmanageselect}}
</div>
<div class="col-sm-6 float-right">
{{#subscriptionoptions}}
{{>core/url_select}}
{{/subscriptionoptions}}
</div>
</div>
</div>
<br>
@@ -30,5 +30,4 @@
{{#helpicon}}
{{>core/help_icon}}
{{/helpicon}}
{{< core/search_input }}
{{/ core/search_input }}
{{>core/search_input}}
+18 -18
View File
@@ -39,20 +39,20 @@ Feature: The forum search allows users to perform advanced searches for forum po
Scenario: Perform an advanced search using any term
Given I am on the "Announcements" "forum activity" page logged in as student1
And I press "Search forums"
And I press "Search"
And I should see "Advanced search"
And I set the field "words" to "subject"
When I press "Search forums"
When I press "Search"
Then I should see "My subject"
And I should see "Your subjective"
Scenario: Perform an advanced search avoiding words
Given I am on the "Announcements" "forum activity" page logged in as student1
And I press "Search forums"
And I press "Search"
And I should see "Advanced search"
And I set the field "words" to "My"
And I set the field "notwords" to "subjective"
When I press "Search forums"
When I press "Search"
Then I should see "My subject"
And I should not see "Your subjective"
@@ -61,19 +61,19 @@ Feature: The forum search allows users to perform advanced searches for forum po
| mysql |
| postgres |
And I am on the "Announcements" "forum activity" page logged in as student1
And I press "Search forums"
And I press "Search"
And I should see "Advanced search"
And I set the field "fullwords" to "subject"
When I press "Search forums"
When I press "Search"
Then I should see "My subject"
And I should not see "Your subjective"
Scenario: Perform an advanced search matching the subject
Given I am on the "Announcements" "forum activity" page logged in as student1
And I press "Search forums"
And I press "Search"
And I should see "Advanced search"
And I set the field "subject" to "subjective"
When I press "Search forums"
When I press "Search"
Then I should not see "My message"
And I should see "Your subjective"
@@ -85,19 +85,19 @@ Feature: The forum search allows users to perform advanced searches for forum po
| Message | My message |
And I log out
When I am on the "Announcements" "forum activity" page logged in as student1
And I press "Search forums"
And I press "Search"
And I should see "Advanced search"
And I set the field "user" to "TWO"
And I press "Search forums"
And I press "Search"
Then I should see "Teacher TWO"
And I should not see "Teacher ONE"
Scenario: Perform an advanced search with multiple words
Given I am on the "Announcements" "forum activity" page logged in as student1
And I press "Search forums"
And I press "Search"
And I should see "Advanced search"
And I set the field "subject" to "your subjective"
When I press "Search forums"
When I press "Search"
Then I should not see "My message"
And I should see "Your subjective"
@@ -111,10 +111,10 @@ Feature: The forum search allows users to perform advanced searches for forum po
And I press "Save changes"
And I log out
And I am on the "Announcements" "forum activity" page logged in as student1
And I press "Search forums"
And I press "Search"
And I should see "Advanced search"
And I set the field "Is tagged with" to "SearchedTag"
When I press "Search forums"
When I press "Search"
Then I should see "My subject"
And I should not see "Your subjective"
@@ -123,10 +123,10 @@ Feature: The forum search allows users to perform advanced searches for forum po
Given I am on the "Announcements" "forum activity" page logged in as student1
And I click on "Your subjective" action menu
And I follow "Star this discussion"
And I press "Search forums"
And I press "Search"
And I should see "Advanced search"
And I set the field "starredonly" to "1"
When I press "Search forums"
When I press "Search"
Then I should not see "My message"
And I should see "Your subjective"
@@ -135,10 +135,10 @@ Feature: The forum search allows users to perform advanced searches for forum po
Given I am on the "Announcements" "forum activity" page logged in as student1
And I click on "Your subjective" action menu
And I follow "Star this discussion"
And I press "Search forums"
And I press "Search"
And I should see "Advanced search"
And I set the field "words" to "message"
And I set the field "starredonly" to "1"
When I press "Search forums"
When I press "Search"
Then I should not see "My message"
And I should see "Your subjective"
+2 -26
View File
@@ -46,7 +46,7 @@ class behat_mod_forum extends behat_base {
* @param TableNode $table
*/
public function i_add_a_new_topic_to_forum_with($forumname, TableNode $table) {
$this->add_new_discussion($forumname, $table, get_string('addanewtopic', 'forum'));
$this->add_new_discussion($forumname, $table, get_string('addanewdiscussion', 'forum'));
}
/**
@@ -57,7 +57,7 @@ class behat_mod_forum extends behat_base {
* @param TableNode $table
*/
public function i_add_a_new_question_to_forum_with($forumname, TableNode $table) {
$this->add_new_discussion($forumname, $table, get_string('addanewquestion', 'forum'));
$this->add_new_discussion($forumname, $table, get_string('addanewdiscussion', 'forum'));
}
/**
@@ -273,15 +273,7 @@ class behat_mod_forum extends behat_base {
* @Given /^I can subscribe to this forum$/
*/
public function i_can_subscribe_to_this_forum() {
if ($this->running_javascript()) {
$this->execute('behat_general::i_click_on', [get_string('actionsmenu'), 'link']);
}
$this->execute('behat_general::assert_page_contains_text', [get_string('subscribe', 'mod_forum')]);
if ($this->running_javascript()) {
$this->execute('behat_general::i_click_on', [get_string('actionsmenu'), 'link']);
}
}
/**
@@ -290,15 +282,7 @@ class behat_mod_forum extends behat_base {
* @Given /^I can unsubscribe from this forum$/
*/
public function i_can_unsubscribe_from_this_forum() {
if ($this->running_javascript()) {
$this->execute('behat_general::i_click_on', [get_string('actionsmenu'), 'link']);
}
$this->execute('behat_general::assert_page_contains_text', [get_string('unsubscribe', 'mod_forum')]);
if ($this->running_javascript()) {
$this->execute('behat_general::i_click_on', [get_string('actionsmenu'), 'link']);
}
}
/**
@@ -307,10 +291,6 @@ class behat_mod_forum extends behat_base {
* @Given /^I subscribe to this forum$/
*/
public function i_subscribe_to_this_forum() {
if ($this->running_javascript()) {
$this->execute('behat_general::i_click_on', [get_string('actionsmenu'), 'link']);
}
$this->execute('behat_general::click_link', [get_string('subscribe', 'mod_forum')]);
}
@@ -320,10 +300,6 @@ class behat_mod_forum extends behat_base {
* @Given /^I unsubscribe from this forum$/
*/
public function i_unsubscribe_from_this_forum() {
if ($this->running_javascript()) {
$this->execute('behat_general::i_click_on', [get_string('actionsmenu'), 'link']);
}
$this->execute('behat_general::click_link', [get_string('unsubscribe', 'mod_forum')]);
}
@@ -50,7 +50,7 @@ Feature: A user can control their own subscription preferences for a discussion
And I can subscribe to this forum
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
And I subscribe to this forum
And I follow "Subscribe to forum"
And I should see "Student One will be notified of new posts in 'Test forum name'"
And I can unsubscribe from this forum
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
@@ -149,50 +149,6 @@ Feature: A user can control their own subscription preferences for a discussion
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
@javascript
Scenario: A user does not lose their preferences when a forum is switch from optional to automatic
Given the following "activity" exists:
| activity | forum |
| course | C1 |
| idnumber | forum1 |
| name | Test forum name |
| intro | Test forum description |
| type | general |
| forcesubscribe | 0 |
And I am on "Course 1" course homepage
And I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject one |
| Message | Test post message one |
And I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject two |
| Message | Test post message two |
And I log out
And I am on the "Test forum name" "forum activity" page logged in as student1
And I can subscribe to this forum
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
And I click on "input[id^=subscription-toggle]" "css_element" in the "Test post subject one" "table_row"
And I can subscribe to this forum
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
And I log out
And I log in as "admin"
And I am on the "Test forum name" "forum activity" page
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| Subscription mode | Auto subscription |
And I press "Save and return to course"
And I log out
And I am on the "Test forum name" "forum activity" page logged in as student1
And I can unsubscribe from this forum
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
When I unsubscribe from this forum
And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
And I can subscribe to this forum
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
Scenario: An optional forum prompts a user to subscribe to a discussion when posting unless they have already chosen not to subscribe
Given the following "activity" exists:
| activity | forum |
@@ -211,7 +167,7 @@ Feature: A user can control their own subscription preferences for a discussion
| Message | Test post message two |
And I log out
When I am on the "Test forum name" "forum activity" page logged in as student1
And I should see "Subscribe to this forum"
And I should see "Subscribe to forum"
And I reply "Test post subject one" post from "Test forum name" forum with:
| Subject | Reply 1 to discussion 1 |
| Message | Discussion contents 1, second message |
@@ -247,17 +203,24 @@ Feature: A user can control their own subscription preferences for a discussion
And I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject two |
| Message | Test post message two |
# added for this scenario
And the following "users" exist:
| username | firstname | lastname | email |
| student2 | Student | Two | student.two@example.com |
And the following "course enrolments" exist:
| user | course | role |
| student2 | C1 | student |
And I log out
When I am on the "Test forum name" "forum activity" page logged in as student1
And I should see "Unsubscribe from this forum"
When I am on the "Test forum name" "forum activity" page logged in as student2
And I should see "Unsubscribe from forum"
And I reply "Test post subject one" post from "Test forum name" forum with:
| Subject | Reply 1 to discussion 1 |
| Message | Discussion contents 1, second message |
| Discussion subscription | 1 |
| Subject | Reply 1 to discussion 1 |
| Message | Discussion contents 1, second message |
| Discussion subscription | 1 |
And I reply "Test post subject two" post from "Test forum name" forum with:
| Subject | Reply 1 to discussion 1 |
| Message | Discussion contents 1, second message |
| Discussion subscription | 0 |
| Subject | Reply 1 to discussion 1 |
| Message | Discussion contents 1, second message |
| Discussion subscription | 0 |
And I am on the "Test forum name" "forum activity" page
Then "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
@@ -276,8 +239,8 @@ Feature: A user can control their own subscription preferences for a discussion
And I am on site homepage
And I turn editing mode on
And I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject one |
| Message | Test post message one |
| Subject | Test post subject one |
| Message | Test post message one |
And I log out
When I log in as "guest"
And I follow "Test forum name"
@@ -294,8 +257,8 @@ Feature: A user can control their own subscription preferences for a discussion
And I am on site homepage
And I turn editing mode on
And I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject one |
| Message | Test post message one |
| Subject | Test post subject one |
| Message | Test post message one |
And I log out
When I follow "Test forum name"
Then "Subscribe to this discussion" "checkbox" should not exist in the "Test post subject one" "table_row"
@@ -319,13 +282,13 @@ Feature: A user can control their own subscription preferences for a discussion
| Message | Test post message one |
And I log out
When I am on the "Test forum name" "forum activity" page logged in as student1
Then "Subscribe to this forum" "link" should exist in current page administration
Then "Subscribe to forum" "link" should exist
And I follow "Test post subject one"
And "You are not subscribed to this discussion. Click to subscribe" "link" should exist
And I follow "Test forum name"
And I navigate to "Subscribe to this forum" in current page administration
And I follow "Subscribe to forum"
And I should see "Student One will be notified of new posts in 'Test forum name'"
And "Unsubscribe from this forum" "link" should exist in current page administration
And "Unsubscribe from forum" "link" should exist
And I follow "Test post subject one"
And "You are subscribed to this discussion. Click to unsubscribe" "link" should exist
And I follow "You are subscribed to this discussion. Click to unsubscribe"
@@ -333,22 +296,22 @@ Feature: A user can control their own subscription preferences for a discussion
And I follow "Test post subject one"
And "You are not subscribed to this discussion. Click to subscribe" "link" should exist
And I follow "Test forum name"
And I navigate to "Unsubscribe from this forum" in current page administration
And I follow "Unsubscribe from forum"
And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
And "Subscribe to this forum" "link" should exist in current page administration
And "Subscribe to forum" "link" should exist
And I follow "Test post subject one"
And "You are not subscribed to this discussion. Click to subscribe" "link" should exist
And I follow "You are not subscribed to this discussion. Click to subscribe"
And I should see "Student One will be notified of new posts in 'Test post subject one' of 'Test forum name'"
And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row"
And I navigate to "Subscribe to this forum" in current page administration
And I follow "Subscribe to forum"
And I should see "Student One will be notified of new posts in 'Test forum name'"
And "Unsubscribe from this forum" "link" should exist in current page administration
And "Unsubscribe from forum" "link" should exist
And I follow "Test post subject one"
And "You are subscribed to this discussion. Click to unsubscribe" "link" should exist
And I follow "Test forum name"
And I navigate to "Unsubscribe from this forum" in current page administration
And I follow "Unsubscribe from forum"
And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
And "Subscribe to this forum" "link" should exist in current page administration
And "Subscribe to forum" "link" should exist
And I follow "Test post subject one"
And "You are not subscribed to this discussion. Click to subscribe" "link" should exist
+1 -1
View File
@@ -48,7 +48,7 @@ Feature: Edited forum posts handle tags correctly
And I press "Continue"
And I log out
And I am on the "Test forum name" "forum activity" page logged in as teacher1
And I click on "Add a new discussion topic" "link"
And I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
And I expand all fieldsets
And I open the autocomplete suggestions list
@@ -92,12 +92,12 @@ Feature: A user can control their own subscription preferences for a forum
When I log in as "student1"
And I am on "Course 1" course homepage
And I follow "Test forum name"
Then I should see "Subscribe to this forum"
And I should not see "Unsubscribe from this forum"
And I follow "Subscribe to this forum"
Then I should see "Subscribe to forum"
And I should not see "Unsubscribe from forum"
And I follow "Subscribe to forum"
And I should see "Student One will be notified of new posts in 'Test forum name'"
And I should see "Unsubscribe from this forum"
And I should not see "Subscribe to this forum"
And I should see "Unsubscribe from forum"
And I should not see "Subscribe to forum"
Scenario: An Automatic forum can be unsubscribed from
Given the following "activity" exists:
@@ -121,9 +121,9 @@ Feature: A user can control their own subscription preferences for a forum
When I log in as "student1"
And I am on "Course 1" course homepage
And I follow "Test forum name"
Then I should see "Unsubscribe from this forum"
And I should not see "Subscribe to this forum"
And I follow "Unsubscribe from this forum"
Then I should see "Unsubscribe from forum"
And I should not see "Subscribe to forum"
And I follow "Unsubscribe from forum"
And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
And I should see "Subscribe to this forum"
And I should not see "Unsubscribe from this forum"
And I should see "Subscribe to forum"
And I should not see "Unsubscribe from forum"
@@ -45,7 +45,7 @@ Feature: As a teacher I need to see an accurate list of subscribed users
| Description | Test forum description |
| Subscription mode | Forced subscription |
And I am on the "Forced Forum 1" "forum activity" page
And I navigate to "Show/edit current subscribers" in current page administration
And I navigate to "Subscriptions" in current page administration
Then I should see "Student 1"
And I should see "Teacher Teacher"
And I should see "Student 2"
@@ -56,7 +56,7 @@ Feature: As a teacher I need to see an accurate list of subscribed users
And I click on "Grouping" "button" in the "Add restriction..." "dialogue"
And I set the field with xpath "//select[@name='id']" to "Grouping 1"
And I press "Save and display"
And I navigate to "Show/edit current subscribers" in current page administration
And I navigate to "Subscriptions" in current page administration
And I should see "Student 1"
And I should see "Teacher Teacher"
And I should not see "Student 2"
@@ -78,12 +78,12 @@ Feature: As a teacher I need to see an accurate list of subscribed users
| Availability | Show on course page |
And I press "Save and return to course"
And I am on the "Forced Forum 2" "forum activity" page
And I navigate to "Show/edit current subscribers" in current page administration
And I navigate to "Subscriptions" in current page administration
Then I should see "Teacher Teacher"
And I should see "Student 1"
And I should see "Student 2"
And I should see "Student 3"
And I should not see "Manage subscribers"
And the "Subscribers" select box should contain "View subscribers"
Scenario: A forced and hidden forum lists only teachers
Given the following "activity" exists:
@@ -101,7 +101,7 @@ Feature: As a teacher I need to see an accurate list of subscribed users
| Availability | Hide from students |
And I press "Save and return to course"
And I am on the "Forced Forum 2" "forum activity" page
And I navigate to "Show/edit current subscribers" in current page administration
And I navigate to "Subscriptions" in current page administration
Then I should see "Teacher Teacher"
And I should not see "Student 1"
And I should not see "Student 2"
@@ -115,7 +115,7 @@ Feature: As a teacher I need to see an accurate list of subscribed users
| Description | Test forum description |
| Subscription mode | Auto subscription |
And I am on the "Forced Forum 1" "forum activity" page
And I navigate to "Show/edit current subscribers" in current page administration
And I navigate to "Subscriptions" in current page administration
Then I should see "Student 1"
And I should see "Teacher Teacher"
And I should see "Student 2"
@@ -127,7 +127,7 @@ Feature: As a teacher I need to see an accurate list of subscribed users
And I click on "Grouping" "button" in the "Add restriction..." "dialogue"
And I set the field with xpath "//select[@name='id']" to "Grouping 1"
And I press "Save and display"
And I navigate to "Show/edit current subscribers" in current page administration
And I navigate to "Subscriptions" in current page administration
And I should see "Student 1"
And I should see "Teacher Teacher"
And I should not see "Student 2"
@@ -27,12 +27,12 @@ Feature: A user can control their default discussion subscription settings
Scenario: Creating a new discussion in an optional forum follows user preferences
Given I am on the "Test forum name" "forum activity" page logged in as student1
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
Then "input[name=discussionsubscribe][checked=checked]" "css_element" should exist
And I log out
And I am on the "Test forum name" "forum activity" page logged in as student2
And I click on "Add a new discussion topic" "link"
And I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
And "input[name=discussionsubscribe]:not([checked=checked])" "css_element" should exist
@@ -59,12 +59,12 @@ Feature: A user can control their default discussion subscription settings
And I press "Save and return to course"
And I log out
And I am on the "Test forum name" "forum activity" page logged in as student1
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
Then "input[name=discussionsubscribe][checked=checked]" "css_element" should exist
And I log out
And I am on the "Test forum name" "forum activity" page logged in as student2
And I click on "Add a new discussion topic" "link"
And I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
And "input[name=discussionsubscribe][checked=checked]" "css_element" should exist
@@ -29,26 +29,12 @@ Feature: A teacher can control the subscription to a forum
When I log in as "teacher"
And I am on "Course 1" course homepage
And I follow "Test forum name"
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| Subscription mode | Auto subscription |
And I press "Save and return to course"
And I follow "Test forum name"
And I follow "Show/edit current subscribers"
Then ".userselector" "css_element" should not exist
And "Manage subscribers" "button" should exist
And I press "Manage subscribers"
And ".userselector" "css_element" should exist
And "Finish managing subscriptions" "button" should exist
And I press "Finish managing subscriptions"
And ".userselector" "css_element" should not exist
And "Manage subscribers" "button" should exist
And I press "Manage subscribers"
And ".userselector" "css_element" should exist
And "Finish managing subscriptions" "button" should exist
And I press "Finish managing subscriptions"
And ".userselector" "css_element" should not exist
And "Manage subscribers" "button" should exist
And I navigate to "Subscriptions" in current page administration
Then I select "Manage subscribers" from the "Subscribers" singleselect
And "Add" "button" should exist
And "Remove" "button" should exist
And I select "View subscribers" from the "Subscribers" singleselect
And the "Subscribers" select box should contain "View subscribers"
@javascript
Scenario Outline: Toggle forum subscription mode via settings navigation
@@ -28,9 +28,10 @@ Feature: Changes to the subscription mode of a forum can change subcribers of a
Scenario: A change from Forced subscription to Auto subcription causes all participants to be subscribed
Given I follow "Test forum name"
And I navigate to "Subscription mode > Auto subscription" in current page administration
When I navigate to "Show/edit current subscribers" in current page administration
And I navigate to "Subscriptions" in current page administration
When I select "Auto subscription" from the "Subscriptions" singleselect
Then I should not see "There are no subscribers yet for this forum"
And I navigate to "Subscriptions" in current page administration
And I should see "Student 1"
And I should see "student.1@example.com"
And I should see "Student 2"
@@ -35,7 +35,7 @@ Feature: Forums in 'No groups' mode allow posting to All participants for all us
And I follow "Standard forum name"
And I should not see "Group A"
And I should not see "Group B"
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
Then I should not see "Post a copy to all groups"
And I should not see "Group" in the "form" "css_element"
And I set the following fields to these values:
@@ -51,7 +51,7 @@ Feature: Forums in 'No groups' mode allow posting to All participants for all us
And I follow "Standard forum name"
And I should not see "Group A"
And I should not see "Group B"
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
Then I should not see "Post a copy to all groups"
And I should not see "Group" in the "form" "css_element"
And I set the following fields to these values:
@@ -80,7 +80,7 @@ Feature: Inline editing H5P content in mod_forum
Given I am on the "C1" "Course" page logged in as "admin"
# Add H5P content to a forum post as admin.
And I am on the "ForumName1" "forum activity" page
And I click on "Add a new discussion topic" "link"
And I click on "Add discussion topic" "link"
And I set the following fields to these values:
| Subject | Forum post by admin |
And I click on "Insert H5P" "button" in the "#fitem_id_message" "css_element"
@@ -23,7 +23,7 @@ Feature: Posting to forums in a course with no groups behaves correctly
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Standard forum"
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
Then I should not see "Post a copy to all groups"
And I set the following fields to these values:
| Subject | Teacher -> All participants |
@@ -36,7 +36,7 @@ Feature: Posting to forums in a course with no groups behaves correctly
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Separate forum"
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
Then I should not see "Post a copy to all groups"
And I set the following fields to these values:
| Subject | Teacher -> All participants |
@@ -49,7 +49,7 @@ Feature: Posting to forums in a course with no groups behaves correctly
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Visible forum"
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
Then I should not see "Post a copy to all groups"
And I set the following fields to these values:
| Subject | Teacher -> All participants |
@@ -62,7 +62,7 @@ Feature: Posting to forums in a course with no groups behaves correctly
Given I log in as "student1"
And I am on "Course 1" course homepage
And I follow "Standard forum"
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
Then I should not see "Post a copy to all groups"
And I set the following fields to these values:
| Subject | Student -> All participants |
@@ -76,11 +76,11 @@ Feature: Posting to forums in a course with no groups behaves correctly
And I am on "Course 1" course homepage
When I follow "Separate forum"
Then I should see "You are not able to create a discussion because you are not a member of any group."
And I should not see "Add a new discussion topic"
And I should not see "Add discussion topic"
Scenario: Students cannot post in forum with visible groups
Given I log in as "student1"
And I am on "Course 1" course homepage
When I follow "Visible forum"
Then I should see "You are not able to create a discussion because you are not a member of any group."
And I should not see "Add a new discussion topic"
And I should not see "Add discussion topic"
@@ -112,7 +112,7 @@ Feature: A user with access to multiple groups should be able to post a copy of
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "No group forum"
And I click on "Add a new discussion topic" "link"
And I click on "Add discussion topic" "link"
Then I should not see "Post a copy to all groups"
Scenario: Posts to all groups that have groupings should only display within the grouping and not to other groups
@@ -56,7 +56,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Standard forum name"
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
Then the "Group" select box should contain "All participants"
And the "Group" select box should contain "Group A"
@@ -69,7 +69,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u
And I am on "Course 1" course homepage
And I follow "Standard forum name"
And I select "Group A" from the "Separate groups" singleselect
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
Then I should see "Post a copy to all groups"
And I set the following fields to these values:
@@ -100,7 +100,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u
And I am on "Course 1" course homepage
And I follow "Standard forum name"
And I select "Group A" from the "Separate groups" singleselect
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
Then I should see "Post a copy to all groups"
And I set the following fields to these values:
@@ -130,7 +130,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Standard forum name"
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
And I set the following fields to these values:
| Subject | Teacher 1 -> Post to all |
@@ -159,7 +159,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u
And I am on "Course 1" course homepage
When I follow "Standard forum name"
Then I should see "Group A"
And I click on "Add a new discussion topic" "link"
And I click on "Add discussion topic" "link"
And I should see "Group A"
And I should not see "Group B"
And I should not see "Group C"
@@ -177,7 +177,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u
And I am on "Course 1" course homepage
When I follow "Standard forum name"
And I select "Group A" from the "Separate groups" singleselect
And I click on "Add a new discussion topic" "link"
And I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
And the "Group" select box should not contain "All participants"
And the "Group" select box should contain "Group A"
@@ -198,7 +198,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u
And I should not see "Student -> B"
# Now try posting in Group A (starting at Group B)
And I select "Group B" from the "Separate groups" singleselect
And I click on "Add a new discussion topic" "link"
And I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
And the "Group" select box should not contain "All participants"
And the "Group" select box should contain "Group A"
@@ -226,7 +226,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u
Given I log in as "noneditor1"
And I am on "Course 1" course homepage
And I follow "Standard forum name"
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
Then the "Group" select box should not contain "All participants"
And the "Group" select box should contain "Group A"
@@ -241,7 +241,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u
Given I log in as "noneditor1"
And I am on "Course 1" course homepage
And I follow "Standard forum name"
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
Then the "Group" select box should not contain "All participants"
And the "Group" select box should contain "Group A"
@@ -88,13 +88,13 @@ Feature: I can grade a students by group with separate groups
And I log out
When I am on the "Test Forum 1" "forum activity" page logged in as student1
And I select "Group A" from the "Separate groups" singleselect
And I click on "Add a new discussion topic" "link"
And I click on "Add discussion topic" "link"
And I set the following fields to these values:
| Subject | Discussion subject A |
| Message | Discussion message A |
And I press "Post to forum"
And I select "Group C" from the "Separate groups" singleselect
And I click on "Add a new discussion topic" "link"
And I click on "Add discussion topic" "link"
And I set the following fields to these values:
| Subject | Discussion subject C |
| Message | Discussion message C |
@@ -47,14 +47,14 @@ Feature: Posting to groups in a separate group discussion when restricted to gro
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Multiple groups forum"
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
Then the "Group" select box should contain "All participants"
And the "Group" select box should contain "G1G1"
And the "Group" select box should contain "G1G2"
And I am on "Course 1" course homepage
And I follow "Single groups forum"
And I click on "Add a new discussion topic" "link"
And I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
And the "Group" select box should contain "All participants"
And the "Group" select box should contain "G2G1"
@@ -64,14 +64,14 @@ Feature: Posting to groups in a separate group discussion when restricted to gro
Given I log in as "teacher2"
And I am on "Course 1" course homepage
And I follow "Multiple groups forum"
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
Then the "Group" select box should not contain "All participants"
And the "Group" select box should contain "G1G1"
And the "Group" select box should contain "G1G2"
And I am on "Course 1" course homepage
And I follow "Single groups forum"
And I click on "Add a new discussion topic" "link"
And I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
And I should see "G2G1"
And "Group" "select" should not exist
@@ -47,7 +47,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Standard forum name"
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
Then the "Group" select box should contain "All participants"
And the "Group" select box should contain "Group A"
@@ -60,7 +60,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us
And I am on "Course 1" course homepage
And I follow "Standard forum name"
And I select "Group A" from the "Visible groups" singleselect
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
Then I should see "Post a copy to all groups"
And I set the following fields to these values:
@@ -91,7 +91,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us
And I am on "Course 1" course homepage
And I follow "Standard forum name"
And I select "Group A" from the "Visible groups" singleselect
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
Then I should see "Post a copy to all groups"
And I set the following fields to these values:
@@ -121,7 +121,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Standard forum name"
When I click on "Add a new discussion topic" "link"
When I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
And I set the following fields to these values:
| Subject | Teacher 1 -> Post to all |
@@ -159,7 +159,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us
And I am on "Course 1" course homepage
When I follow "Standard forum name"
Then I should see "Group A"
And I click on "Add a new discussion topic" "link"
And I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
And I should see "Group A"
And I should not see "Group B"
@@ -178,7 +178,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us
And I am on "Course 1" course homepage
When I follow "Standard forum name"
And I select "Group A" from the "Visible groups" singleselect
And I click on "Add a new discussion topic" "link"
And I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
And the "Group" select box should not contain "All participants"
And the "Group" select box should contain "Group A"
@@ -199,7 +199,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us
And I should not see "Student -> B"
# Now try posting in Group A (starting at Group B)
And I select "Group B" from the "Visible groups" singleselect
And I click on "Add a new discussion topic" "link"
And I click on "Add discussion topic" "link"
And I click on "Advanced" "button"
And the "Group" select box should not contain "All participants"
And the "Group" select box should contain "Group A"
+1 -1
View File
@@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2021101101; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2021101102; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2021052500; // Requires this Moodle version.
$plugin->component = 'mod_forum'; // Full name of the plugin (used for diagnostics)
+13 -6
View File
@@ -158,27 +158,34 @@ if (!empty($CFG->enablerssfeeds) && !empty($CFG->forum_enablerssfeeds) && $forum
rss_add_http_header($forum->get_context(), 'mod_forum', $forumrecord, $rsstitle);
}
// Output starts from here.
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($forum->get_name()), 2);
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($forum->get_name()), 2);
}
// Render the activity information.
$completiondetails = \core_completion\cm_completion_details::get_instance($cm, $USER->id);
$activitydates = \core\activity_dates::get_dates_for_module($cm, $USER->id);
echo $OUTPUT->activity_information($cm, $completiondetails, $activitydates);
// Fetch the current groupid.
$groupid = groups_get_activity_group($cm, true) ?: null;
if (!$istypesingle && !empty($forum->get_intro())) {
echo $OUTPUT->box(format_module_intro('forum', $forumrecord, $cm->id), 'generalbox', 'intro');
}
$rendererfactory = mod_forum\local\container::get_renderer_factory();
// The elements for view action are rendered and added to the page.
echo forum_activity_actionbar($forum, $groupid, $course, $search);
if ($sortorder) {
set_user_preference('forum_discussionlistsortorder', $sortorder);
}
$sortorder = get_user_preferences('forum_discussionlistsortorder', $discussionlistvault::SORTORDER_LASTPOST_DESC);
// Fetch the current groupid.
$groupid = groups_get_activity_group($cm, true) ?: null;
$rendererfactory = mod_forum\local\container::get_renderer_factory();
switch ($forum->get_type()) {
case 'single':
$forumgradeitem = forum_gradeitem::load_from_forum_entity($forum);
@@ -243,7 +250,7 @@ switch ($forum->get_type()) {
$discussionsrenderer = $rendererfactory->get_blog_discussion_list_renderer($forum);
// Blog forums always show discussions newest first.
echo $discussionsrenderer->render($USER, $cm, $groupid, $discussionlistvault::SORTORDER_CREATED_DESC,
$pageno, $pagesize);
$pageno, $pagesize, null, false);
if (!$CFG->forum_usermarksread && forum_tp_is_tracked($forumrecord, $USER)) {
$discussions = mod_forum_get_discussion_summaries($forum, $USER, $groupid, null, $pageno, $pagesize);
@@ -255,7 +262,7 @@ switch ($forum->get_type()) {
break;
default:
$discussionsrenderer = $rendererfactory->get_discussion_list_renderer($forum);
echo $discussionsrenderer->render($USER, $cm, $groupid, $sortorder, $pageno, $pagesize, $displaymode);
echo $discussionsrenderer->render($USER, $cm, $groupid, $sortorder, $pageno, $pagesize, $displaymode, false);
}
echo $OUTPUT->footer();
+2
View File
@@ -47,6 +47,8 @@ $PAGE->set_url($attemptobj->attempt_url(null, $page));
// During quiz attempts, the browser back/forwards buttons should force a reload.
$PAGE->set_cacheable(false);
$PAGE->set_secondary_active_tab("modulepage");
// Check login.
require_login($attemptobj->get_course(), false, $attemptobj->get_cm());
@@ -55,11 +55,6 @@ class edit_renderer extends \plugin_renderer_base {
\question_edit_contexts $contexts, \moodle_url $pageurl, array $pagevars) {
$output = '';
// Page title.
$output .= $this->heading_with_help(get_string('editingquizx', 'quiz',
format_string($quizobj->get_quiz_name())), 'editingquiz', 'quiz', '',
get_string('basicideasofquiz', 'quiz'), 2);
// Information at the top.
$output .= $this->quiz_state_warnings($structure);
@@ -0,0 +1,98 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_quiz\output;
use moodle_url;
use renderable;
use renderer_base;
use templatable;
use url_select;
/**
* Render overrides action
*
* @package mod_quiz
* @copyright 2021 Sujith Haridasan <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class overridesaction implements renderable, templatable {
/** @var int */
private $cmid;
/** @var string */
private $mode;
/** @var bool */
private $canedit;
/** @var array */
private $options;
/**
* overridesaction constructor.
*
* @param int $cmid The course module id.
* @param string $mode The mode passed for the overrides url.
* @param bool $canedit Does the user have capabilities to list overrides.
* @param array $options The options passed to single button.
*/
public function __construct(int $cmid, string $mode, bool $canedit, array $options) {
$this->cmid = $cmid;
$this->mode = $mode;
$this->canedit = $canedit;
$this->options = $options;
}
/**
* Get the data for the template
*
* @param renderer_base $output renderer_base object.
* @return array data for the template.
*/
public function export_for_template(renderer_base $output): array {
global $PAGE;
$useroverride = new moodle_url('/mod/quiz/overrides.php', ['cmid' => $this->cmid, 'mode' => 'user']);
$groupoverride = new moodle_url('/mod/quiz/overrides.php', ['cmid' => $this->cmid, 'mode' => 'group']);
$menu = [
$useroverride->out(false) => get_string('useroverrides', 'quiz'),
$groupoverride->out(false) => get_string('groupoverrides', 'quiz')
];
$urlselect = new url_select($menu, $PAGE->url->out(false), null, 'quizoverrides');
$overridesbuttonurl =
new moodle_url('/mod/quiz/overrideedit.php', ['cmid' => $this->cmid, 'action' => 'add' . $this->mode]);
if ($this->mode === 'group') {
$overridesbutton = new \single_button($overridesbuttonurl, get_string( 'addnewgroupoverride', 'quiz'),
'post', true);
} else {
$overridesbutton = new \single_button($overridesbuttonurl, get_string( 'addnewuseroverride', 'quiz'),
'get', true);
}
if (isset($this->options['disabled'])) {
$overridesbutton->disabled = true;
}
return [
'overrides' => $urlselect->export_for_template($output),
'canedit' => $this->canedit,
'overridesbtn' => $overridesbutton->export_for_template($output),
];
}
}
+68
View File
@@ -0,0 +1,68 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_quiz\output;
use renderable;
use renderer_base;
use templatable;
use moodle_url;
/**
* Render the tertiary elements for the edit page
*
* @package mod_quiz
* @copyright 2021 Sujith Haridasan <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class overwriteedit implements templatable, renderable {
/** @var int */
private $cmid;
/** @var bool */
private $quizhasquestion;
/**
* overwriteedit constructor.
*
* @param int $cmid The course module id.
* @param bool $quizhasquestion Check if quiz has question.
*/
public function __construct(int $cmid, bool $quizhasquestion) {
$this->cmid = $cmid;
$this->quizhasquestion = $quizhasquestion;
}
/**
* Provides the data for the template.
*
* @param renderer_base $output renderer_base object
* @return array data for the template
*/
public function export_for_template(renderer_base $output): array {
$data = [];
$data = [
'back' => (new moodle_url('/mod/quiz/view.php', ['id' => $this->cmid]))->out(false),
];
if ($this->quizhasquestion) {
$data['previewlink'] =
(new moodle_url('/mod/quiz/startattempt.php', ['cmid' => $this->cmid, 'sesskey' => sesskey()]))->out(false);
$data['previewquiz'] = get_string('previewquiz', 'mod_quiz');
}
return $data;
}
}
@@ -0,0 +1,65 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_quiz\output;
use renderable;
use renderer_base;
use templatable;
use moodle_url;
/**
* Output the preview action area of this activity
*
* @package mod_quiz
* @copyright 2021 Sujith Haridasan <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class overwritepreview implements templatable, renderable {
/** @var int */
private $cmid;
/** @var bool */
private $canedit;
/**
* overwritepreview constructor.
*
* @param int $cmid The course module id.
* @param bool $canedit Can edit the quiz.
*/
public function __construct(int $cmid, bool $canedit) {
$this->cmid = $cmid;
$this->canedit = $canedit;
}
/**
* Provide data for the template
*
* @param renderer_base $output
* @return array data for the template
*/
public function export_for_template(renderer_base $output): array {
$data = [
'back' => (new moodle_url('/mod/quiz/view.php', ['id' => $this->cmid]))->out(false),
];
if ($this->canedit) {
$data['editlink'] = (new moodle_url('/mod/quiz/edit.php', ['cmid' => $this->cmid]))->out(false);
}
return $data;
}
}
@@ -0,0 +1,99 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_quiz\output;
use moodle_url;
use renderer_base;
use templatable;
use renderable;
/**
* Render view action with preview and edit buttons
*
* @package mod_quiz
* @copyright 2021 Sujith Haridasan <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class previeweditaction implements templatable, renderable {
/** @var int */
private $cmid;
/** @var bool */
private $canedit;
/** @var bool */
private $canattempt;
/** @var bool */
private $canpreview;
/** @var bool */
private $quizhasquestions;
/** @var int */
private $attempts;
/**
* previeweditaction constructor.
*
* @param int $cmid The course module id.
* @param bool $canedit Can edit the quiz.
* @param bool $canattempt can attempt the quiz.
* @param bool $canpreview Can preview the quiz.
* @param bool $quizhasquestions If quiz has questions.
* @param int $attempts The attempts made.
*/
public function __construct(int $cmid, bool $canedit, bool $canattempt,
bool $canpreview, bool $quizhasquestions, int $attempts) {
$this->cmid = $cmid;
$this->canedit = $canedit;
$this->canattempt = $canattempt;
$this->canpreview = $canpreview;
$this->quizhasquestions = $quizhasquestions;
$this->attempts = $attempts;
}
/**
* Provide data for the template
*
* @param renderer_base $output renderer_base objects.
* @return array data for template
*/
public function export_for_template(renderer_base $output): array {
$data = [];
if ($this->quizhasquestions) {
if ($this->canpreview) {
$data['previewlink'] = (new moodle_url('/mod/quiz/startattempt.php',
['attempt' => $this->attempts, 'cmid' => $this->cmid, 'sesskey' => sesskey()]))->out(false);
$data['previewquiz'] = get_string('previewquiz', 'mod_quiz');
}
if ($this->canedit) {
$data['editlink'] = (new moodle_url('/mod/quiz/edit.php', ['cmid' => $this->cmid]))->out(false);
}
if ($this->canattempt && !$this->canpreview) {
$data['attemptlink'] =
(new moodle_url('/mod/quiz/startattempt.php', ['cmid' => $this->cmid, 'sesskey' => sesskey()]))->out(false);
}
} else {
$data['addquestionlink'] = (new moodle_url('/mod/quiz/edit.php', ['cmid' => $this->cmid]))->out(false);
}
return $data;
}
}
+73
View File
@@ -0,0 +1,73 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_quiz\output;
use templatable;
use renderable;
use renderer_base;
use moodle_url;
use url_select;
/**
* Render results action
*
* @package mod_quiz
* @copyright 2021 Sujith Haridasan <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class resultsaction implements templatable, renderable {
/** @var int */
private $id;
/**
* resultsaction constructor.
*
* @param int $id The course module id.
*/
public function __construct(int $id) {
$this->id = $id;
}
/**
* Provide data for the template
*
* @param renderer_base $output renderer_base object.
* @return array data for template.
*/
public function export_for_template(renderer_base $output): array {
global $PAGE;
$gradeslink = new moodle_url('/mod/quiz/report.php', ['id' => $this->id, 'mode' => 'overview']);
$responseslink = new moodle_url('/mod/quiz/report.php', ['id' => $this->id, 'mode' => 'responses']);
$statisticslink = new moodle_url('/mod/quiz/report.php', ['id' => $this->id, 'mode' => 'statistics']);
$manualgrading = new moodle_url('/mod/quiz/report.php', ['id' => $this->id, 'mode' => 'grading']);
$menu = [
$gradeslink->out(false) => get_string('grades', 'grades'),
$responseslink->out(false) => get_string('responses', 'quiz_responses'),
$statisticslink->out(false) => get_string('statistics', 'quiz_statistics'),
$manualgrading->out(false) => get_string('grading', 'quiz_grading')
];
$urlselect = new url_select($menu, $PAGE->url->out(false), null, 'quizresults');
$data = [
'resultaction' => $urlselect->export_for_template($output)
];
return $data;
}
}
+7
View File
@@ -59,6 +59,7 @@ $defaultcategory = $defaultcategoryobj->id . ',' . $defaultcategoryobj->contexti
$quizhasattempts = quiz_has_attempts($quiz->id);
$PAGE->set_url($thispageurl);
$PAGE->set_secondary_active_tab("modulepage");
// Get the course object and related bits.
$course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
@@ -185,8 +186,14 @@ $node = $PAGE->settingsnav->find('mod_quiz_edit', navigation_node::TYPE_SETTING)
if ($node) {
$node->make_active();
}
$overwriteedit = new \mod_quiz\output\overwriteedit($cmid, quiz_has_questions($quiz->id));
echo $OUTPUT->header();
$renderer = $PAGE->get_renderer('mod_quiz');
echo $renderer->overwrite_edit_action($overwriteedit);
// Initialise the JavaScript.
$quizeditconfig = new stdClass();
$quizeditconfig->url = $thispageurl->out(true, array('qbanktool' => '0'));
+4 -1
View File
@@ -47,7 +47,10 @@ $PAGE->navbar->add($strquizzes);
$PAGE->set_title($strquizzes);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading($strquizzes, 2);
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading($strquizzes, 2);
}
// Get all the appropriate data.
if (!$quizzes = get_all_instances_in_course("quiz", $course)) {
+1
View File
@@ -7,3 +7,4 @@ completionpassdesc,mod_quiz
completionpass_help,mod_quiz
completiondetail:passgrade,mod_quiz
gradetopassnotset,mod_quiz
basicideasofquiz,mod_quiz
+3 -2
View File
@@ -100,6 +100,7 @@ $string['attemptincomplete'] = 'That attempt (by {$a}) is not yet completed.';
$string['attemptlast'] = 'Last attempt';
$string['attemptnumber'] = 'Attempt';
$string['attemptquiznow'] = 'Attempt quiz now';
$string['attemptquiz'] = 'Attempt quiz';
$string['attemptreviewtitle'] = '{$a}: Attempt review';
$string['attemptreviewtitlepaged'] = '{$a->name}: Attempt review (page {$a->currentpage} of {$a->totalpages})';
$string['attempts'] = 'Attempts';
@@ -124,7 +125,6 @@ $string['back'] = 'Back to preview question';
$string['backtocourse'] = 'Back to the course';
$string['backtoquestionlist'] = 'Back to question list';
$string['backtoquiz'] = 'Back to quiz editing';
$string['basicideasofquiz'] = 'The basic ideas of quiz-making';
$string['bestgrade'] = 'Best grade';
$string['bothattempts'] = 'Show students with and without attempts';
$string['browsersecurity'] = 'Browser security';
@@ -673,7 +673,7 @@ $string['popupnotice'] = 'Students will see this quiz in a secure window';
$string['preprocesserror'] = 'Error occurred during pre-processing!';
$string['preview'] = 'Preview';
$string['previewquestion'] = 'Preview question';
$string['previewquiz'] = 'Preview {$a}';
$string['previewquiz'] = 'Preview quiz';
$string['previewquiznow'] = 'Preview quiz now';
$string['previous'] = 'Previous state';
$string['privacy:metadata:core_question'] = 'The quiz activity stores question usage information in the core_question subsystem.';
@@ -1054,3 +1054,4 @@ $string['completionpassdesc'] = 'Student must achieve a passing grade to complet
$string['completionpass_help'] = 'If enabled, this activity is considered complete when the student receives a pass grade (as specified in the Grade section of the quiz settings) or higher.';
$string['completiondetail:passgrade'] = 'Receive a pass grade';
$string['gradetopassnotset'] = 'This quiz does not yet have a grade to pass set. It may be set in the Grade section of the quiz settings.';
$string['basicideasofquiz'] = 'The basic ideas of quiz-making';
+10 -14
View File
@@ -1731,15 +1731,9 @@ function quiz_extend_settings_navigation($settings, $quiznode) {
}
if (has_any_capability(['mod/quiz:manageoverrides', 'mod/quiz:viewoverrides'], $PAGE->cm->context)) {
$url = new moodle_url('/mod/quiz/overrides.php', array('cmid'=>$PAGE->cm->id));
$node = navigation_node::create(get_string('groupoverrides', 'quiz'),
new moodle_url($url, array('mode'=>'group')),
navigation_node::TYPE_SETTING, null, 'mod_quiz_groupoverrides');
$quiznode->add_node($node, $beforekey);
$node = navigation_node::create(get_string('useroverrides', 'quiz'),
new moodle_url($url, array('mode'=>'user')),
navigation_node::TYPE_SETTING, null, 'mod_quiz_useroverrides');
$url = new moodle_url('/mod/quiz/overrides.php', array('cmid' => $PAGE->cm->id));
$node = navigation_node::create(get_string('overrides', 'quiz'),
$url, navigation_node::TYPE_SETTING, null, 'mod_quiz_useroverrides');
$quiznode->add_node($node, $beforekey);
}
@@ -1748,7 +1742,8 @@ function quiz_extend_settings_navigation($settings, $quiznode) {
new moodle_url('/mod/quiz/edit.php', array('cmid'=>$PAGE->cm->id)),
navigation_node::TYPE_SETTING, null, 'mod_quiz_edit',
new pix_icon('t/edit', ''));
$quiznode->add_node($node, $beforekey);
$editquiznode = $quiznode->add_node($node, $beforekey);
$editquiznode->set_show_in_secondary_navigation(false);
}
if (has_capability('mod/quiz:preview', $PAGE->cm->context)) {
@@ -1757,9 +1752,12 @@ function quiz_extend_settings_navigation($settings, $quiznode) {
$node = navigation_node::create(get_string('preview', 'quiz'), $url,
navigation_node::TYPE_SETTING, null, 'mod_quiz_preview',
new pix_icon('i/preview', ''));
$quiznode->add_node($node, $beforekey);
$previewnode = $quiznode->add_node($node, $beforekey);
$previewnode->set_show_in_secondary_navigation(false);
}
question_extend_settings_navigation($quiznode, $PAGE->cm->context)->trim_if_empty();
if (has_any_capability(array('mod/quiz:viewreports', 'mod/quiz:grade'), $PAGE->cm->context)) {
require_once($CFG->dirroot . '/mod/quiz/report/reportlib.php');
$reportlist = quiz_report_list($PAGE->cm->context);
@@ -1768,7 +1766,7 @@ function quiz_extend_settings_navigation($settings, $quiznode) {
array('id' => $PAGE->cm->id, 'mode' => reset($reportlist)));
$reportnode = $quiznode->add_node(navigation_node::create(get_string('results', 'quiz'), $url,
navigation_node::TYPE_SETTING,
null, null, new pix_icon('i/report', '')), $beforekey);
null, null, new pix_icon('i/report', '')));
foreach ($reportlist as $report) {
$url = new moodle_url('/mod/quiz/report.php',
@@ -1778,8 +1776,6 @@ function quiz_extend_settings_navigation($settings, $quiznode) {
null, 'quiz_report_' . $report, new pix_icon('i/item', '')));
}
}
question_extend_settings_navigation($quiznode, $PAGE->cm->context)->trim_if_empty();
}
/**
+3 -1
View File
@@ -89,7 +89,9 @@ $PAGE->set_title($title);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($quiz->name, true, array('context' => $context)));
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($quiz->name, true, array('context' => $context)));
}
if ($override->groupid) {
$group = $DB->get_record('groups', ['id' => $override->groupid], 'id, name');
+6 -1
View File
@@ -66,6 +66,9 @@ if ($overrideid) {
$PAGE->set_url($url);
// Activate the secondary nav tab.
$PAGE->set_secondary_active_tab("mod_quiz_useroverrides");
require_login($course, false, $cm);
$context = context_module::instance($cm->id);
@@ -239,7 +242,9 @@ $PAGE->set_pagelayout('admin');
$PAGE->set_title($pagetitle);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($quiz->name, true, array('context' => $context)));
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($quiz->name, true, array('context' => $context)));
}
$mform->display();
+25 -17
View File
@@ -69,6 +69,9 @@ $PAGE->set_pagelayout('admin');
$PAGE->set_title($title);
$PAGE->set_heading($course->fullname);
// Activate the secondary nav tab.
$PAGE->set_secondary_active_tab("mod_quiz_useroverrides");
// Delete orphaned group overrides.
$sql = 'SELECT o.id
FROM {quiz_overrides} o
@@ -303,32 +306,32 @@ echo $OUTPUT->header();
echo $OUTPUT->heading($title);
// Output the table and button.
echo html_writer::start_tag('div', ['id' => 'quizoverrides']);
$output = '';
$output .= html_writer::start_tag('div', ['id' => 'quizoverrides']);
if (count($table->data)) {
echo html_writer::table($table);
$output .= html_writer::table($table);
} else {
if ($groupmode) {
echo $OUTPUT->notification(get_string('overridesnoneforgroups', 'quiz'), 'info', false);
$output .= $OUTPUT->notification(get_string('overridesnoneforgroups', 'quiz'), 'info', false);
} else {
echo $OUTPUT->notification(get_string('overridesnoneforusers', 'quiz'), 'info', false);
$output .= $OUTPUT->notification(get_string('overridesnoneforusers', 'quiz'), 'info', false);
}
}
if ($hasinactive) {
echo $OUTPUT->notification(get_string('inactiveoverridehelp', 'quiz'), 'info', false);
$output .= $OUTPUT->notification(get_string('inactiveoverridehelp', 'quiz'), 'info', false);
}
$addbutton = '';
$options = [];
if ($canedit) {
echo html_writer::start_tag('div', ['class' => 'buttons']);
$options = [];
$output .= html_writer::start_tag('div', ['class' => 'buttons']);
if ($groupmode) {
if (empty($groups)) {
// There are no groups.
echo $OUTPUT->notification(get_string('groupsnone', 'quiz'), 'error');
$output .= $OUTPUT->notification(get_string('groupsnone', 'quiz'), 'error');
$options['disabled'] = true;
}
echo $OUTPUT->single_button($overrideediturl->out(true,
['action' => 'addgroup', 'cmid' => $cm->id]),
get_string('addnewgroupoverride', 'quiz'), 'post', $options);
} else {
$users = [];
// See if there are any students in the quiz.
@@ -346,17 +349,22 @@ if ($canedit) {
if (empty($users)) {
// There are no students.
echo $OUTPUT->notification($nousermessage, 'error');
$output .= $OUTPUT->notification($nousermessage, 'error');
$options['disabled'] = true;
}
echo $OUTPUT->single_button($overrideediturl->out(true,
['action' => 'adduser', 'cmid' => $cm->id]),
get_string('addnewuseroverride', 'quiz'), 'get', $options);
}
echo html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
}
echo html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
// Outputs overrides action.
$overridesaction = new \mod_quiz\output\overridesaction($cmid, $mode, $canedit, $options);
$renderer = $PAGE->get_renderer('mod_quiz');
echo $renderer->overrides_action($overridesaction);
// Now output what we captured after the overrides action.
echo $output;
// Finish the page.
echo $OUTPUT->footer();
+112 -39
View File
@@ -449,8 +449,17 @@ class mod_quiz_renderer extends plugin_renderer_base {
*/
public function attempt_page($attemptobj, $page, $accessmanager, $messages, $slots, $id,
$nextpage) {
$context = $attemptobj->get_quizobj()->get_context();
$cmid = $attemptobj->get_quizobj()->get_cmid();
$canedit = has_capability('mod/quiz:manage', $context);
$overwritepreview = new \mod_quiz\output\overwritepreview($cmid, $canedit);
$output = '';
$output .= $this->header();
$renderer = $this->page->get_renderer('mod_quiz');
$output .= $renderer->overwrite_preview_action($overwritepreview);
$output .= $this->quiz_notices($messages);
$output .= $this->countdown_timer($attemptobj, time());
$output .= $this->attempt_form($attemptobj, $page, $slots, $id, $nextpage);
@@ -540,7 +549,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
protected function attempt_navigation_buttons($page, $lastpage, $navmethod = 'free') {
$output = '';
$output .= html_writer::start_tag('div', array('class' => 'submitbtns'));
$output .= html_writer::start_tag('div', array('class' => 'submitbtns mb-4'));
if ($page > 0 && $navmethod == 'free') {
$output .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'previous',
'value' => get_string('navigateprevious', 'quiz'), 'class' => 'mod_quiz-prev-nav btn btn-secondary',
@@ -625,7 +634,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
public function access_messages($messages) {
$output = '';
foreach ($messages as $message) {
$output .= html_writer::tag('p', $message) . "\n";
$output .= html_writer::tag('p', $message, ['class' => 'float-left']) . "\n";
}
return $output;
}
@@ -677,21 +686,19 @@ class mod_quiz_renderer extends plugin_renderer_base {
foreach ($slots as $slot) {
// Add a section headings if we need one here.
$heading = $attemptobj->get_heading_before_slot($slot);
if ($heading) {
$heading = format_string($heading);
}
$sections = $attemptobj->get_quizobj()->get_sections();
if (!is_null($heading) && empty($heading) && count($sections) > 1) {
if (!is_null($heading) && empty($heading)) {
$heading = get_string('sectionnoname', 'quiz');
$heading = \html_writer::span($heading, 'dimmed_text');
}
if ($heading) {
$cell = new html_table_cell($heading);
$cell = new html_table_cell(format_string($heading));
$cell->header = true;
$cell->colspan = $tablewidth;
$table->data[] = array($cell);
$table->rowclasses[] = 'quizsummaryheading';
$classes = 'quizsummaryheading';
if ($heading === get_string('sectionnoname', 'quiz')) {
$classes .= ' dimmed_text';
}
$table->rowclasses[] = $classes;
}
// Don't display information items.
@@ -799,10 +806,14 @@ class mod_quiz_renderer extends plugin_renderer_base {
*/
public function view_page($course, $quiz, $cm, $context, $viewobj) {
$output = '';
$output .= $this->view_information($quiz, $cm, $context, $viewobj->infomessages);
$output .= $this->view_information($quiz, $cm, $context, $viewobj->infomessages, $viewobj->quizhasquestions);
$output .= $this->view_table($quiz, $context, $viewobj);
$output .= $this->view_result_info($quiz, $context, $cm, $viewobj);
$output .= $this->box($this->view_page_buttons($viewobj), 'quizattempt');
// Output any access messages.
if ($viewobj->infomessages) {
$output .= $this->box($this->access_messages($viewobj->infomessages), 'quizinfo');
}
return $output;
}
@@ -814,27 +825,11 @@ class mod_quiz_renderer extends plugin_renderer_base {
* @return string HTML to output.
*/
public function view_page_buttons(mod_quiz_view_object $viewobj) {
global $CFG;
$output = '';
if (!$viewobj->quizhasquestions) {
$output .= $this->no_questions_message($viewobj->canedit, $viewobj->editurl);
$output .= $this->generate_no_questions_message();
}
$output .= $this->access_messages($viewobj->preventmessages);
if ($viewobj->buttontext) {
$output .= $this->start_attempt_button($viewobj->buttontext,
$viewobj->startattempturl, $viewobj->preflightcheckform,
$viewobj->popuprequired, $viewobj->popupoptions);
}
if ($viewobj->showbacktocourse) {
$output .= $this->single_button($viewobj->backtocourseurl,
get_string('backtocourse', 'quiz'), 'get',
array('class' => 'continuebutton'));
}
return $output;
}
@@ -890,9 +885,13 @@ class mod_quiz_renderer extends plugin_renderer_base {
* @param object $quiz the quiz settings.
* @param object $cm the course_module object.
* @param object $context the quiz context.
* @deprecated since Moodle 4.0 MDL-71915 - please do not use this function any more.
*
* @return string HTML to output.
*/
public function no_questions_message($canedit, $editurl) {
debugging('no_questions_message() is deprecated, please use generate_no_questions_message() instead.', DEBUG_DEVELOPER);
$output = html_writer::start_tag('div', array('class' => 'card text-center mb-3'));
$output .= html_writer::start_tag('div', array('class' => 'card-body'));
@@ -906,6 +905,21 @@ class mod_quiz_renderer extends plugin_renderer_base {
return $output;
}
/**
* Generate a message saying that this quiz has no questions
*
* @return string HTML to output.
*/
public function generate_no_questions_message() {
$output = html_writer::start_tag('div', array('class' => 'text-left mb-3'));
$output .= $this->notification(get_string('noquestions', 'quiz'), 'warning', false);
$output .= html_writer::end_tag('div');
return $output;
}
/**
* Outputs an error message for any guests accessing the quiz
*
@@ -914,10 +928,11 @@ class mod_quiz_renderer extends plugin_renderer_base {
* @param int $cm Course Module ID
* @param int $context The page contect ID
* @param array $messages Array containing any messages
* @param bool $quizhasquestions If quiz has questions
*/
public function view_page_guest($course, $quiz, $cm, $context, $messages) {
public function view_page_guest($course, $quiz, $cm, $context, $messages, $quizhasquestions = false) {
$output = '';
$output .= $this->view_information($quiz, $cm, $context, $messages);
$output .= $this->view_information($quiz, $cm, $context, $messages, $quizhasquestions);
$guestno = html_writer::tag('p', get_string('guestsno', 'quiz'));
$liketologin = html_writer::tag('p', get_string('liketologin'));
$referer = get_local_referer(false);
@@ -933,11 +948,12 @@ class mod_quiz_renderer extends plugin_renderer_base {
* @param int $cm Course Module ID
* @param int $context The page contect ID
* @param array $messages Array containing any messages
* @param bool $quizhasquestions If quiz has questions
*/
public function view_page_notenrolled($course, $quiz, $cm, $context, $messages) {
public function view_page_notenrolled($course, $quiz, $cm, $context, $messages, $quizhasquestions = false) {
global $CFG;
$output = '';
$output .= $this->view_information($quiz, $cm, $context, $messages);
$output .= $this->view_information($quiz, $cm, $context, $messages, $quizhasquestions);
$youneedtoenrol = html_writer::tag('p', get_string('youneedtoenrol', 'quiz'));
$button = html_writer::tag('p',
$this->continue_button($CFG->wwwroot . '/course/view.php?id=' . $course->id));
@@ -952,15 +968,18 @@ class mod_quiz_renderer extends plugin_renderer_base {
* @param object $cm the course_module object.
* @param context $context the quiz context.
* @param array $messages any access messages that should be described.
* @param bool $quizhasquestions does quiz has questions added.
* @return string HTML to output.
*/
public function view_information($quiz, $cm, $context, $messages) {
public function view_information($quiz, $cm, $context, $messages, bool $quizhasquestions = false) {
global $USER;
$output = '';
// Print quiz name.
$output .= $this->heading(format_string($quiz->name));
if (!$this->page->has_secondary_navigation()) {
$output .= $this->heading(format_string($quiz->name));
}
// Print any activity information (eg completion requirements / dates).
$cminfo = cm_info::create($cm);
@@ -971,10 +990,14 @@ class mod_quiz_renderer extends plugin_renderer_base {
// Print quiz description.
$output .= $this->quiz_intro($quiz, $cm);
// Output any access messages.
if ($messages) {
$output .= $this->box($this->access_messages($messages), 'quizinfo');
}
// Print the preview, quiz buttons for tertiary nav.
$canedit = has_capability('mod/quiz:manage', $context);
$canpreview = has_capability('mod/quiz:preview', $context);
$canattempt = has_capability('mod/quiz:attempt', $context);
$previeweditaction = new \mod_quiz\output\previeweditaction($cm->id, $canedit, $canattempt, $canpreview, $quizhasquestions,
$quiz->attempts);
$renderer = $this->page->get_renderer('mod_quiz');
$output .= $renderer->preview_edit_action($previeweditaction);
// Show number of attempts summary to those who can view reports.
if (has_capability('mod/quiz:viewreports', $context)) {
@@ -1360,6 +1383,56 @@ class mod_quiz_renderer extends plugin_renderer_base {
array('id' => 'connection-error', 'style' => 'display: none;', 'role' => 'alert')) .
html_writer::tag('div', $ok, array('id' => 'connection-ok', 'style' => 'display: none;', 'role' => 'alert'));
}
/**
* Get the rendered HTML for the action area of view.php
*
* @param \mod_quiz\output\previeweditaction $previeweditaction previeweditaction object.
* @return string rendered HTML for the action area of view.php
*/
public function preview_edit_action(\mod_quiz\output\previeweditaction $previeweditaction):string {
return $this->render_from_template('mod_quiz/quiz_preview_edit_action', $previeweditaction->export_for_template($this));
}
/**
* Get the rendered HTML for the action area of preview page
*
* @param \mod_quiz\output\overwritepreview $overwritepreview overwritepreview object.
* @return string rendered HTML for the preview page
*/
public function overwrite_preview_action(\mod_quiz\output\overwritepreview $overwritepreview): string {
return $this->render_from_template('mod_quiz/quiz_preview_action', $overwritepreview->export_for_template($this));
}
/**
* Get the rendered HTML for the action area of the edit page.
*
* @param \mod_quiz\output\overwriteedit $overwriteedit overwriteedit object.
* @return string rendered HTML for the edit page
*/
public function overwrite_edit_action(\mod_quiz\output\overwriteedit $overwriteedit): string {
return $this->render_from_template('mod_quiz/quiz_edit_action', $overwriteedit->export_for_template($this));
}
/**
* Get rendered HTML for the action area of the results page.
*
* @param \mod_quiz\output\resultsaction $resultsaction resultsaction object.
* @return string rendered HTML string from the template.
*/
public function get_results_action(\mod_quiz\output\resultsaction $resultsaction): string {
return $this->render_from_template('mod_quiz/quiz_results_action', $resultsaction->export_for_template($this));
}
/**
* Get rendered HTML for the action area of the overrides page.
*
* @param \mod_quiz\output\overridesaction $overridesaction the overridesaction object.
* @return string rendered HTML string from the template.
*/
public function overrides_action(\mod_quiz\output\overridesaction $overridesaction): string {
return $this->render_from_template('mod_quiz/quiz_overrides', $overridesaction->export_for_template($this));
}
}
+6 -1
View File
@@ -68,7 +68,12 @@ abstract class quiz_default_report {
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
$context = context_module::instance($cm->id);
echo $OUTPUT->heading(format_string($quiz->name, true, array('context' => $context)));
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($quiz->name, true, array('context' => $context)));
}
$resultsaction = new \mod_quiz\output\resultsaction($cm->id);
$renderer = $PAGE->get_renderer('mod_quiz');
echo $renderer->get_results_action($resultsaction);
if (!empty($CFG->enableplagiarism)) {
require_once($CFG->libdir . '/plagiarismlib.php');
echo plagiarism_update_status($course, $cm);
+1
View File
@@ -42,6 +42,7 @@ if ($page !== 0) {
$url->param('showall', $showall);
}
$PAGE->set_url($url);
$PAGE->set_secondary_active_tab("modulepage");
$attemptobj = quiz_create_attempt_handling_errors($attemptid, $cmid);
$attemptobj->preload_all_attempt_step_users();
+1
View File
@@ -32,6 +32,7 @@ $cmid = optional_param('cmid', null, PARAM_INT);
$PAGE->set_url('/mod/quiz/summary.php', array('attempt' => $attemptid));
// During quiz attempts, the browser back/forwards buttons should force a reload.
$PAGE->set_cacheable(false);
$PAGE->set_secondary_active_tab("modulepage");
$attemptobj = quiz_create_attempt_handling_errors($attemptid, $cmid);
@@ -0,0 +1,39 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template mod_quiz/quiz_edit_action
Actions bar at the top of the quiz edit page UI.
Classes required for JS:
* none
Data attributes required for JS:
* none
Context variables required for this template:
* see mod/quiz/classes/output/overwriteedit.php
Example context (json):
{
"back": "http://localhost/mod/quiz/view.php?id=2",
"previewlink": "http://localhost/mod/quiz/startattempt.php?cmid=2&sesskey=G8FPNoJz9r"
}
}}
<div class="container-fluid mb-3">
<div class="row">
<a class="btn btn-secondary" href="{{back}}">{{#str}}back, core {{/str}}</a>
{{#previewlink}}
<a class="btn btn-secondary ml-2" href="{{previewlink}}">{{#str}}previewquiz, quiz{{/str}}</a>
{{/previewlink}}
</div>
</div>
@@ -0,0 +1,75 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template mod_quiz/quiz_overrides
Actions bar at the top of the overrides page UI.
Classes required for JS:
* none
Data attributes required for JS:
* none
Context variables required for this template:
* see mod/quiz/classes/output/overridesaction.php
Example context (json):
{
"overrides": {
"options": [{
"name": "User overrides",
"value": "/mod/quiz/overrides.php?cmid=71&mode=user"
},
{
"name": "Group overrrides",
"value": "/mod/quiz/overrides.php?cmid=71&mode=group"
}
]
},
"canedit": true,
"overridesbtn": {
"id": "single_button1234",
"method": "get",
"url": "http://localhost/moodle/mod/quiz/overrideedit.php",
"lablel": "Add user override",
"classes": "singlebutton",
"disabled": false,
"params": [
{
"name": "cmid",
"value": "73"
},
{
"name": "action",
"value": "adduser"
}
]
}
}
}}
<div class="container-fluid mb-3">
<div class="row">
{{#overrides}}
<div class="col-xs-6">
{{>core/url_select}}
</div>
{{/overrides}}
{{#canedit}}
{{#overridesbtn}}
<div class="ml-2">
{{>core/single_button}}
</div>
{{/overridesbtn}}
{{/canedit}}
</div>
</div>
@@ -0,0 +1,39 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template mod_quiz/quiz_preview_action
Action bar at the top of the quiz attempt page UI.
Classes required for JS:
* none
Data attributes required for JS:
* none
Context variables required for this template:
* see mod/quiz/classes/output/overwritepreview.php
Example context (json):
{
"back": "http://localhost/mod/quiz/view.php?id=2",
"editlink": "http://localhost/mod/quiz/edit.php?cmid=3"
}
}}
<div class="container-fluid mb-3">
<div class="row">
<a class="btn btn-secondary" href="{{back}}">{{#str}}back, core {{/str}}</a>
{{#editlink}}
<a class="btn btn-primary ml-2" href="{{editlink}}">{{#str}}editquiz, quiz{{/str}}</a>
{{/editlink}}
</div>
</div>
@@ -0,0 +1,49 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template mod_quiz/quiz_preview_edit_action
Actions bar at the top of the quiz view page
Classes required for JS:
* none
Data attributes required for JS:
* none
Context variables required for this template:
* see mod/quiz/classes/output/previeweditaction.php
Example context (json):
{
"previewlink": "http://localhost/mod/quiz/startattempt.php?cmid=2&sesskey=G8FPNoJz9r",
"editlink": "http://localhost/mod/quiz/edit.php?cmid=3",
"attemptlink": "http://localhost/mod/quiz/startattempt.php?cmid=5&sesskey=psqFTeG0Hi",
"addquestionlink": "http://localhost/mod/quiz/edit.php?cmid=3"
}
}}
<div class="container-fluid mb-3">
<div class="row">
{{#previewlink}}
<a class="btn btn-secondary mr-2" href="{{previewlink}}">{{#str}}previewquiz, quiz{{/str}}</a>
{{/previewlink}}
{{#editlink}}
<a class="btn btn-primary mr-2" href="{{editlink}}">{{#str}}editquiz, quiz{{/str}}</a>
{{/editlink}}
{{#attemptlink}}
<a class="btn btn-primary" href="{{attemptlink}}">{{#str}}attemptquiz, quiz{{/str}}</a>
{{/attemptlink}}
{{#addquestionlink}}
<a class="btn btn-primary" href="{{addquestionlink}}">{{#str}}addquestion, quiz{{/str}}</a>
{{/addquestionlink}}
</div>
</div>
@@ -0,0 +1,58 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template mod_quiz/quiz_results_action
Actions bar at the top of the report page UI.
Classes required for JS:
* none
Data attributes required for JS:
* none
Context variables required for this template:
* see mod/quiz/classes/output/resultsaction.php
Example context (json):
{
"resultaction": {
"id": "url_select_test",
"options": [{
"name": "Grades",
"value": "/mod/quiz/report.php?id=4&mode=overview"
},
{
"name": "Responses",
"value": "/mod/quiz/report.php?id=4&mode=responses"
},
{
"name": "Statistics",
"value": "/mod/quiz/report.php?id=4&mode=statistics"
},
{
"name": "Manual grading",
"value": "/mod/quiz/report.php?id=4&mode=grading"
}
]
}
}
}}
<div class="container-fluid mb-3">
<div class="row">
<div class="float-left">
{{#resultaction}}
{{>core/url_select}}
{{/resultaction}}
</div>
</div>
</div>
+1 -1
View File
@@ -36,7 +36,7 @@ Feature: Add a quiz
And I log out
And I am on the "Test quiz name" "quiz activity" page logged in as student1
And I press "Attempt quiz now"
And I follow "Attempt quiz"
Then I should see "Question 1"
And I should see "Answer the first question"
And I set the field "True" to "1"
+3 -3
View File
@@ -45,7 +45,7 @@ Feature: Attempt a quiz
And I should see "Grade"
And I should see "25.00 out of 100.00"
And I follow "Finish review"
And I press "Re-attempt quiz"
And I follow "Attempt quiz"
@javascript
Scenario: Attempt a quiz with mulitple sections
@@ -73,7 +73,7 @@ Feature: Attempt a quiz
| Section 3 | 5 | 1 |
When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
And I press "Attempt quiz now"
And I follow "Attempt quiz"
Then I should see "Section 1" in the "Quiz navigation" "block"
And I should see question "1" in section "Section 1" in the quiz navigation
@@ -125,7 +125,7 @@ Feature: Attempt a quiz
| TF1 | 1 |
| TF2 | 2 |
When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
And I press "Attempt quiz now"
And I follow "Attempt quiz"
Then I should see "Text of the first question"
And I should not see "Text of the second question"
And I press "Next page"
+13 -13
View File
@@ -30,7 +30,7 @@ Feature: The various checks that may happen when an attept is started
| question | page |
| TF1 | 1 |
When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
And I press "Attempt quiz now"
And I follow "Attempt quiz"
Then I should see "Text of the first question"
@javascript
@@ -42,11 +42,11 @@ Feature: The various checks that may happen when an attept is started
| question | page |
| TF1 | 1 |
When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
And I press "Attempt quiz now"
Then I should see "To attempt this quiz you need to know the quiz password" in the "Start attempt" "dialogue"
And I should see "Your attempt will have a time limit of 1 hour. When you " in the "Start attempt" "dialogue"
And I follow "Attempt quiz"
Then I should see "To attempt this quiz you need to know the quiz password" in the "region-main" "region"
And I should see "Your attempt will have a time limit of 1 hour. When you " in the "region-main" "region"
And I set the field "Quiz password" to "Frog"
And I click on "Start attempt" "button" in the "Start attempt" "dialogue"
And I click on "Start attempt" "button" in the "region-main" "region"
And I should see "Text of the first question"
@javascript
@@ -58,10 +58,10 @@ Feature: The various checks that may happen when an attept is started
| question | page |
| TF1 | 1 |
When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
And I press "Attempt quiz now"
And I click on "Cancel" "button" in the "Start attempt" "dialogue"
And I follow "Attempt quiz"
And I click on "Cancel" "button" in the "region-main" "region"
Then I should see "Quiz 1 description"
And "Attempt quiz now" "button" should be visible
And "Attempt quiz" "link" should be visible
@javascript
Scenario: Start a quiz with time limit and password, get the password wrong first time
@@ -72,9 +72,9 @@ Feature: The various checks that may happen when an attept is started
| question | page |
| TF1 | 1 |
When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
And I press "Attempt quiz now"
And I follow "Attempt quiz"
And I set the field "Quiz password" to "Toad"
And I click on "Start attempt" "button" in the "Start attempt" "dialogue"
And I click on "Start attempt" "button" in the "region-main" "region"
Then I should see "Quiz 1 description"
And I should see "To attempt this quiz you need to know the quiz password"
And I should see "Your attempt will have a time limit of 1 hour. When you "
@@ -94,9 +94,9 @@ Feature: The various checks that may happen when an attept is started
| question | page |
| TF1 | 1 |
When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
And I press "Attempt quiz now"
And I follow "Attempt quiz"
And I set the field "Quiz password" to "Toad"
And I click on "Start attempt" "button" in the "Start attempt" "dialogue"
And I click on "Start attempt" "button" in the "region-main" "region"
And I should see "Quiz 1 description"
And I should see "To attempt this quiz you need to know the quiz password"
And I should see "Your attempt will have a time limit of 1 hour. When you "
@@ -106,4 +106,4 @@ Feature: The various checks that may happen when an attept is started
And I press tab key in "Quiz password" "field"
And I press "Cancel"
Then I should see "Quiz 1 description"
And "Attempt quiz now" "button" should be visible
And "Attempt quiz" "link" should be visible
@@ -34,7 +34,7 @@ Feature: Allow students to redo questions in a practice quiz, without starting a
@javascript
Scenario: After completing a question, there is a redo question button that restarts the question
Given I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
When I press "Attempt quiz now"
When I follow "Attempt quiz"
And I click on "False" "radio" in the "First question" "question"
And I click on "Check" "button" in the "First question" "question"
And I press "Try another question like this one"
@@ -44,7 +44,7 @@ Feature: Allow students to redo questions in a practice quiz, without starting a
@javascript
Scenario: The redo question button is visible but disabled for teachers
Given I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
When I press "Attempt quiz now"
When I follow "Attempt quiz"
And I click on "False" "radio" in the "First question" "question"
And I click on "Check" "button" in the "First question" "question"
And I log out
@@ -56,7 +56,7 @@ Feature: Allow students to redo questions in a practice quiz, without starting a
@javascript
Scenario: The redo question buttons are no longer visible after the attempt is submitted.
Given I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
When I press "Attempt quiz now"
When I follow "Attempt quiz"
And I click on "False" "radio" in the "First question" "question"
And I click on "Check" "button" in the "First question" "question"
And I press "Finish attempt ..."
@@ -67,7 +67,7 @@ Feature: Allow students to redo questions in a practice quiz, without starting a
@javascript @_switch_window
Scenario: Teachers reviewing can see all the questions attempted in a slot
Given I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
When I press "Attempt quiz now"
When I follow "Attempt quiz"
And I click on "False" "radio" in the "First question" "question"
And I click on "Check" "button" in the "First question" "question"
And I press "Try another question like this one"
@@ -96,7 +96,7 @@ Feature: Allow students to redo questions in a practice quiz, without starting a
@javascript
Scenario: Redoing question 1 should save any changes to question 2 on the same page
Given I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
When I press "Attempt quiz now"
When I follow "Attempt quiz"
And I click on "False" "radio" in the "First question" "question"
And I click on "Check" "button" in the "First question" "question"
And I click on "True" "radio" in the "Second question" "question"
@@ -119,7 +119,7 @@ Feature: Allow students to redo questions in a practice quiz, without starting a
| slot | actualquestion |
| 1 | TF1 |
And I am on the "Quiz 2" "mod_quiz > View" page logged in as "student"
When I press "Continue the last attempt"
When I follow "Attempt quiz"
And I should see "First question"
And I click on "False" "radio"
And I click on "Check" "button"
@@ -35,7 +35,7 @@ Feature: Attempt a quiz where some questions require that the previous question
| TF2 | 1 | 1 |
When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
And I press "Attempt quiz now"
And I follow "Attempt quiz"
Then I should see "First question"
And I should see "This question cannot be attempted until the previous question has been completed."
@@ -63,7 +63,7 @@ Feature: Attempt a quiz where some questions require that the previous question
| TF2 | 1 | 1 |
When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
And I press "Attempt quiz now"
And I follow "Attempt quiz"
And I click on "True" "radio" in the "First question" "question"
And I press "Check"
@@ -88,7 +88,7 @@ Feature: Attempt a quiz where some questions require that the previous question
| TF2 | 1 | 1 |
When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
And I press "Attempt quiz now"
And I follow "Attempt quiz"
And I press "Finish attempt ..."
And I press "Submit all and finish"
And I click on "Submit all and finish" "button" in the "Confirmation" "dialogue"
@@ -111,7 +111,7 @@ Feature: Attempt a quiz where some questions require that the previous question
| TF2 | 1 | 1 |
When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
And I press "Attempt quiz now"
And I follow "Attempt quiz"
Then I should see "First question"
And I should see "Second question"
@@ -135,7 +135,7 @@ Feature: Attempt a quiz where some questions require that the previous question
| Section 1 | 1 | 1 |
When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
And I press "Attempt quiz now"
And I follow "Attempt quiz"
Then I should see "First question"
And I should see "Second question"
@@ -160,7 +160,7 @@ Feature: Attempt a quiz where some questions require that the previous question
| Section 2 | 2 | 0 |
When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
And I press "Attempt quiz now"
And I follow "Attempt quiz"
And I press "Next page"
Then I should see "Second question"
@@ -181,7 +181,7 @@ Feature: Attempt a quiz where some questions require that the previous question
| TF2 | 1 | 1 |
When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
And I press "Attempt quiz now"
And I follow "Attempt quiz"
Then I should see "First question"
And I should see "Second question"
@@ -202,7 +202,7 @@ Feature: Attempt a quiz where some questions require that the previous question
| TF2 | 1 | 1 |
When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
And I press "Attempt quiz now"
And I follow "Attempt quiz"
Then I should see "First question"
And I should see "Second question"
@@ -223,7 +223,7 @@ Feature: Attempt a quiz where some questions require that the previous question
| TF1 | 1 | 1 |
When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student"
And I press "Attempt quiz now"
And I follow "Attempt quiz"
Then I should see "Read me"
And I should see "First question"
@@ -41,7 +41,7 @@ Feature: Set a quiz to be marked complete when the student uses all attempts all
And the "Receive a passing grade" completion condition of "Test quiz name" is displayed as "failed"
And the "Receive a pass grade or complete all available attempts" completion condition of "Test quiz name" is displayed as "todo"
And I follow "Test quiz name"
And I press "Re-attempt quiz"
And I follow "Attempt quiz"
And I set the field "<answer>" to "1"
And I press "Finish attempt ..."
And I press "Submit all and finish"
@@ -43,7 +43,7 @@ Feature: Set a quiz to be marked complete when the student completes a minimum a
And I am on "Course 1" course homepage
And the "Make attempts: 2" completion condition of "Test quiz name" is displayed as "todo"
And I follow "Test quiz name"
And I press "Re-attempt quiz"
And I follow "Attempt quiz"
And I set the field "False" to "1"
And I press "Finish attempt ..."
And I press "Submit all and finish"
+8 -18
View File
@@ -18,7 +18,6 @@ Feature: Edit quiz page - adding things
| activity | name | intro | course | idnumber |
| quiz | Quiz 1 | Quiz 1 for testing the Add menu | C1 | quiz1 |
And I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
And I should see "Editing quiz: Quiz 1"
@javascript
Scenario: Add some new question to the quiz using '+ a new question' options of the 'Add' menu.
@@ -30,7 +29,6 @@ Feature: Edit quiz page - adding things
And I set the field "Question name" to "Essay 01 new"
And I set the field "Question text" to "Please write 200 words about Essay 01"
And I press "id_submitbutton"
Then I should see "Editing quiz: Quiz 1"
And I should see "Essay 01 new" on quiz page "1"
And I open the "Page 1" add to quiz menu
@@ -41,7 +39,6 @@ Feature: Edit quiz page - adding things
And I set the field "Question name" to "Essay 02 new"
And I set the field "Question text" to "Please write 200 words about Essay 02"
And I press "id_submitbutton"
Then I should see "Editing quiz: Quiz 1"
And I should see "Essay 01 new" on quiz page "1"
And I should see "Essay 02 new" on quiz page "1"
@@ -53,7 +50,6 @@ Feature: Edit quiz page - adding things
And I set the field "Question name" to "Essay 03 new"
And I set the field "Question text" to "Please write 300 words about Essay 03"
And I press "id_submitbutton"
Then I should see "Editing quiz: Quiz 1"
And I should see "Essay 01 new" on quiz page "1"
And I should see "Essay 02 new" on quiz page "1"
And I should see "Essay 03 new" on quiz page "1"
@@ -66,7 +62,6 @@ Feature: Edit quiz page - adding things
And I set the field "Question name" to "Essay 04 new"
And I set the field "Question text" to "Please write 300 words about Essay 04"
And I press "id_submitbutton"
Then I should see "Editing quiz: Quiz 1"
And I should see "Essay 01 new" on quiz page "1"
And I should see "Essay 02 new" on quiz page "1"
And I should see "Essay 03 new" on quiz page "1"
@@ -77,7 +72,7 @@ Feature: Edit quiz page - adding things
When I press "Repaginate"
Then I should see "Repaginate with"
And I set the field "menuquestionsperpage" to "2"
When I click on "Go" "button" in the "Repaginate" "dialogue"
And I click on "Go" "button" in the "Repaginate" "dialogue"
And I should see "Essay 01 new" on quiz page "1"
And I should see "Essay 02 new" on quiz page "1"
And I should see "Essay 03 new" on quiz page "2"
@@ -89,10 +84,9 @@ Feature: Edit quiz page - adding things
And I set the field "item_qtype_essay" to "1"
And I press "submitbutton"
Then I should see "Adding an Essay question"
When I set the field "Question name" to "Essay for page 2"
And I set the field "Question name" to "Essay for page 2"
And I set the field "Question text" to "Please write 200 words about Essay for page 2"
And I press "id_submitbutton"
Then I should see "Editing quiz: Quiz 1"
And I should see "Essay 01 new" on quiz page "1"
And I should see "Essay 02 new" on quiz page "1"
And I should see "Essay 03 new" on quiz page "2"
@@ -106,22 +100,23 @@ Feature: Edit quiz page - adding things
# Create a couple of sub categories.
When I am on "Course 1" course homepage
And I navigate to "Question bank > Categories" in current page administration
And I navigate to "Question bank" in current page administration
And I select "Categories" from the "questionbankactionselect" singleselect
Then I should see "Add category"
Then I set the field "Parent category" to "Default for C1"
And I set the field "Name" to "Subcat 1"
And I set the field "Category info" to "This is sub category 1"
Then I press "id_submitbutton"
And I press "id_submitbutton"
And I should see "Subcat 1"
Then I set the field "Parent category" to "Default for C1"
And I set the field "Name" to "Subcat 2"
And I set the field "Category info" to "This is sub category 2"
Then I press "id_submitbutton"
And I press "id_submitbutton"
And I should see "Subcat 2"
And I click on "Questions" "link"
Then I should see "Question bank"
And I select "Questions" from the "questionbankactionselect" singleselect
And I should see "Question bank"
And I should see "Select a category"
# Create the Essay 01 question.
@@ -194,14 +189,12 @@ Feature: Edit quiz page - adding things
And I click on "Essay 03" "checkbox"
Then the "Add selected questions to the quiz" "button" should be enabled
And I click on "Add to quiz" "link" in the "Essay 03" "table_row"
Then I should see "Editing quiz: Quiz 1"
And I should see "Essay 03" on quiz page "1"
# Add Essay 01 from question bank.
And I open the "Page 1" add to quiz menu
And I follow "from question bank"
And I click on "Add to quiz" "link" in the "Essay 01" "table_row"
Then I should see "Editing quiz: Quiz 1"
And I should see "Essay 03" on quiz page "1"
And I should see "Essay 01" on quiz page "1"
@@ -211,7 +204,6 @@ Feature: Edit quiz page - adding things
And I should see "Select a category"
And I set the field "Select a category" to "Subcat 1"
And I click on "Add to quiz" "link" in the "Essay 02" "table_row"
Then I should see "Editing quiz: Quiz 1"
And I should see "Essay 03" on quiz page "1"
And I should see "Essay 01" on quiz page "1"
And I should see "Essay 02" on quiz page "1"
@@ -220,7 +212,6 @@ Feature: Edit quiz page - adding things
And I open the "Page 1" add to quiz menu
And I follow "a random question"
And I press "Add random question"
Then I should see "Editing quiz: Quiz 1"
And I should see "Essay 03" on quiz page "1"
And I should see "Essay 01" on quiz page "1"
And I should see "Essay 02" on quiz page "1"
@@ -246,7 +237,6 @@ Feature: Edit quiz page - adding things
And I set the field "Question name" to "Essay for page 4"
And I set the field "Question text" to "Please write 200 words about Essay for page 4"
And I press "id_submitbutton"
Then I should see "Editing quiz: Quiz 1"
And I should see "Essay 03" on quiz page "1"
And I should see "Essay 01" on quiz page "2"
And I should see "Essay 02" on quiz page "3"
@@ -25,8 +25,6 @@ Feature: Edit quiz page - pagination
Scenario: Repaginate questions with N question(s) per page as well as clicking
on "add page break" or "Remove page break" icons to repaginate in any desired format.
Then I should see "Editing quiz: Quiz 1"
# Add the first Essay question.
And I open the action menu in ".page-add-actions" "css_element"
And I follow "a new question"
@@ -36,8 +34,7 @@ Feature: Edit quiz page - pagination
And I set the field "Question name" to "Essay 01 new"
And I set the field "Question text" to "Please write 100 words about Essay 01"
And I press "id_submitbutton"
Then I should see "Editing quiz: Quiz 1"
And I should see "Essay 01 new" on quiz page "1"
Then I should see "Essay 01 new" on quiz page "1"
# Add the second Essay question.
And I open the action menu in ".page-add-actions" "css_element"
@@ -48,8 +45,7 @@ Feature: Edit quiz page - pagination
And I set the field "Question name" to "Essay 02 new"
And I set the field "Question text" to "Please write 200 words about Essay 02"
And I press "id_submitbutton"
Then I should see "Editing quiz: Quiz 1"
And I should see "Essay 01 new" on quiz page "1"
Then I should see "Essay 01 new" on quiz page "1"
And I should see "Essay 02 new" on quiz page "1"
# Start repaginating.
@@ -73,8 +69,7 @@ Feature: Edit quiz page - pagination
And I set the field "Question name" to "Essay 03 new"
And I set the field "Question text" to "Please write 200 words about Essay 03"
And I press "id_submitbutton"
Then I should see "Editing quiz: Quiz 1"
And I should see "Essay 01 new" on quiz page "1"
Then I should see "Essay 01 new" on quiz page "1"
And I should see "Essay 02 new" on quiz page "1"
And I should see "Essay 03 new" on quiz page "1"
And I should not see "Page 2"
@@ -121,8 +116,7 @@ Feature: Edit quiz page - pagination
When I set the field "Question name" to "Essay 04 new"
And I set the field "Question text" to "Please write 300 words about Essay 04"
And I press "id_submitbutton"
Then I should see "Editing quiz: Quiz 1"
And I should see "Essay 01 new" on quiz page "1"
Then I should see "Essay 01 new" on quiz page "1"
And I should see "Essay 02 new" on quiz page "2"
And I should see "Essay 03 new" on quiz page "3"
And I should see "Essay 04 new" on quiz page "3"
@@ -31,7 +31,7 @@ Feature: Edit quiz marks with attempts
| Default mark | 3.0 |
And I log out
And I am on the "Quiz 1" "mod_quiz > View" page logged in as "student1"
And I press "Attempt quiz now"
And I follow "Attempt quiz"
And I log out
And I log in as "teacher1"
And I am on the "Quiz 1" "mod_quiz > Edit" page
@@ -29,7 +29,7 @@ Feature: Teachers can override the grade for any question
| question | page |
| TF1 | 1 |
And I am on the "Quiz 1" "mod_quiz > View" page logged in as "student1"
And I press "Attempt quiz now"
And I follow "Attempt quiz"
And I follow "Finish attempt ..."
And I press "Submit all and finish"
And I click on "Submit all and finish" "button" in the "Confirmation" "dialogue"
+1 -1
View File
@@ -44,6 +44,6 @@ Feature: Preview a quiz as a teacher
@javascript
Scenario: Preview the quiz
Given I am on the "Quiz 1" "mod_quiz > View" page logged in as "teacher"
When I press "Preview quiz now"
When I follow "Preview quiz"
Then I should see "Question 1"
And "Start a new preview" "button" should exist
@@ -62,7 +62,7 @@ Feature: View activity completion in the quiz activity
And the "Receive a grade" completion condition of "Test quiz name" is displayed as "done"
And the "Receive a passing grade" completion condition of "Test quiz name" is displayed as "failed"
And the "Receive a pass grade or complete all available attempts" completion condition of "Test quiz name" is displayed as "todo"
And I press "Re-attempt quiz"
And I follow "Attempt quiz"
And I set the field "<answer>" to "1"
And I press "Finish attempt ..."
And I press "Submit all and finish"
@@ -33,7 +33,7 @@ Feature: Quiz user override
| quiz | Test quiz | C1 | quiz1 |
And I am on the "Test quiz" "mod_quiz > View" page logged in as "teacher"
And I change window size to "large"
And I navigate to "User overrides" in current page administration
And I navigate to "Overrides" in current page administration
And I press "Add user override"
And I set the following fields to these values:
| Override user | Student One (student1@example.com) |
@@ -147,7 +147,7 @@ Feature: Quiz user override
| Test quiz | student1 | 2 |
| Test quiz | student2 | 2 |
And I am on the "Test quiz" "mod_quiz > View" page logged in as "helper"
When I navigate to "User overrides" in current page administration
When I navigate to "Overrides" in current page administration
Then "Student One" "table_row" should exist
And "Student Two" "table_row" should exist
And "Add user override" "button" should not exist
@@ -52,7 +52,7 @@ Feature: Settings form fields disabled if not required
# And the "id_delay2_enabled" "field" should be enabled
When I press "Save and display"
And I navigate to "User overrides" in current page administration
And I navigate to "Overrides" in current page administration
And I press "Add user override"
And I set the following fields to these values:
| Override user | Student1 |
@@ -67,7 +67,7 @@ Feature: Settings form fields disabled if not required
And the "id_delay2_enabled" "field" should be enabled
When I press "Save and display"
And I navigate to "User overrides" in current page administration
And I navigate to "Overrides" in current page administration
And I click on "Edit" "link" in the "region-main" "region"
And I set the field "Attempts allowed" to "2"
And I press "Save"
@@ -80,7 +80,7 @@ Feature: Settings form fields disabled if not required
And the "id_delay2_enabled" "field" should be disabled
When I press "Save and display"
And I navigate to "User overrides" in current page administration
And I navigate to "Overrides" in current page administration
And I press "Add user override"
And I set the following fields to these values:
| Override user | Student2 |
+5
View File
@@ -8,6 +8,11 @@ This files describes API changes in the quiz code.
- quiz_send_notification_messages() in mod/quiz/locallib.php
* The completionpass criteria has been moved to core as 'completionpassgrade'. Refer to completion/upgrade.txt for
further information.
* New argument quizhasquestions has been added to public methods: view_information, view_page_notenrolled and view_page_guest
in mod/quiz/renderer.php.
* The function no_questions_message() in class mod_quiz_renderer is deprecated. Please use generate_no_questions_message()
in the same class.
=== 3.11 ===
+1 -1
View File
@@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2021101900;
$plugin->version = 2021101901;
$plugin->requires = 2021052500;
$plugin->component = 'mod_quiz';
+2 -2
View File
@@ -250,11 +250,11 @@ echo $OUTPUT->header();
if (isguestuser()) {
// Guests can't do a quiz, so offer them a choice of logging in or going back.
echo $output->view_page_guest($course, $quiz, $cm, $context, $viewobj->infomessages);
echo $output->view_page_guest($course, $quiz, $cm, $context, $viewobj->infomessages, $viewobj->quizhasquestions);
} else if (!isguestuser() && !($canattempt || $canpreview
|| $viewobj->canreviewmine)) {
// If they are not enrolled in this course in a good enough role, tell them to enrol.
echo $output->view_page_notenrolled($course, $quiz, $cm, $context, $viewobj->infomessages);
echo $output->view_page_notenrolled($course, $quiz, $cm, $context, $viewobj->infomessages, $viewobj->quizhasquestions);
} else {
echo $output->view_page($course, $quiz, $cm, $context, $viewobj);
}
+2 -2
View File
@@ -92,8 +92,8 @@ class tracks_viewed extends \core\event\base {
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'scorm', 'userreporttracks', 'report/userreporttracks.php?id=' . $this->contextinstanceid
. '&user=' . $this->relateduserid . '&attempt=' . $this->other['attemptid'] . '&scoid=' . $this->other['scoid'],
$this->other['instanceid'], $this->contextinstanceid);
. '&user=' . $this->relateduserid . '&attempt=' . $this->other['attemptid'] . '&scoid=' . $this->other['scoid']
. '&mode=' . $this->other['mode'], $this->other['instanceid'], $this->contextinstanceid);
}
/**
+120
View File
@@ -0,0 +1,120 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_scorm\output;
use renderable;
use renderer_base;
use templatable;
use moodle_url;
use url_select;
/**
* Render HTML elements for tertiary nav for scorm.
*
* @package mod_scorm
* @copyright 2021 Sujith Haridasan <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class actionbar implements renderable, templatable {
/** @var int */
private $id;
/** @var string */
private $download;
/** @var int */
private $attemptsmode;
/**
* actionbar constructor.
*
* @param int $id The course module id.
* @param bool $download Show download button or not.
* @param int $attemptsmode attempts mode for scorm.
*/
public function __construct(int $id, bool $download = false, int $attemptsmode = 0) {
$this->id = $id;
$this->download = $download;
$this->attemptsmode = $attemptsmode;
}
/**
* Provide data for the template
*
* @param renderer_base $output renderer_base object.
* @return array data for the template
*/
public function export_for_template(renderer_base $output): array {
global $PAGE;
$basicreportlink = new moodle_url('/mod/scorm/report.php', ['id' => $this->id, 'mode' => 'basic']);
$graphreportlink = new moodle_url('/mod/scorm/report.php', ['id' => $this->id, 'mode' => 'graphs']);
$interactionreportlink = new moodle_url('/mod/scorm/report.php', ['id' => $this->id, 'mode' => 'interactions']);
$objectivesreportlink = new moodle_url('/mod/scorm/report.php', ['id' => $this->id, 'mode' => 'objectives']);
$reportmenu = [
$basicreportlink->out(false) => get_string('pluginname', 'scormreport_basic'),
$graphreportlink->out(false) => get_string('pluginname', 'scormreport_graphs'),
$interactionreportlink->out(false) => get_string('pluginname', 'scormreport_interactions'),
$objectivesreportlink->out(false) => get_string('pluginname', 'scormreport_objectives'),
];
$sesskey = sesskey();
if ($this->download) {
$mode = $PAGE->url->get_param('mode');
if ($mode === 'basic') {
$options = [
'id' => $this->id, 'mode' => $mode,
'attemptsmode' => $this->attemptsmode, 'sesskey' => $sesskey
];
} else if ($mode === 'interactions') {
$options = [
'id' => $this->id, 'mode' => $mode, 'qtext' => '0',
'resp' => '1', 'right' => '0', 'result' => '0',
'attemptsmode' => $this->attemptsmode, 'sesskey' => $sesskey
];
} else if ($mode === 'objectives') {
$options = [
'id' => $this->id, 'mode' => $mode,
'attemptsmode' => $this->attemptsmode, 'objectivescore' => '0',
'sesskey' => $sesskey
];
}
$options['download'] = 'ODS';
$downloadodslink = new moodle_url($PAGE->url, $options);
$options['download'] = 'Excel';
$downloadexcellink = new moodle_url($PAGE->url, $options);
$options['download'] = 'CSV';
$downloadtextlink = new moodle_url($PAGE->url, $options);
}
$url = new moodle_url('/mod/scorm/report.php', $PAGE->url->remove_params('attemptsmode'));
$urlselect = new url_select($reportmenu, $url->out(false), null, 'selectscormreports');
$data = [
'scormreports' => $urlselect->export_for_template($output),
'candownload' => $this->download,
'downloadods' => ($this->download) ? $downloadodslink->out(false) : '',
'downloadexcel' => ($this->download) ? $downloadexcellink->out(false) : '',
'downloadtext' => ($this->download) ? $downloadtextlink->out(false) : ''
];
return $data;
}
}

Some files were not shown because too many files have changed in this diff Show More