Skip to content

Commit

Permalink
Merge branch 'MDL-73335-tim' of https://github.com/ilyatregubov/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyatregubov committed Feb 24, 2022
2 parents f167418 + 2f9032a commit be7a576
Show file tree
Hide file tree
Showing 99 changed files with 619 additions and 988 deletions.
2 changes: 1 addition & 1 deletion admin/tool/recyclebin/tests/behat/backup_user_data.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 follow "Attempt quiz"
And I press "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"
Expand Down
2 changes: 1 addition & 1 deletion badges/tests/behat/criteria_activity.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 follow "Attempt quiz"
And I press "Re-attempt quiz"
And I set the field "False" to "1"
And I press "Finish attempt ..."
And I press "Submit all and finish"
Expand Down
2 changes: 2 additions & 0 deletions lang/en/question.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@
$string['qtypeveryshort'] = 'T';
$string['questionaffected'] = '<a href="{$a->qurl}">Question "{$a->name}" ({$a->qtype})</a> is in this question category but is also being used in <a href="{$a->qurl}">quiz "{$a->quizname}"</a> in another course "{$a->coursename}".';
$string['questionbank'] = 'Question bank';
$string['questionbanknavigation'] = 'Question bank tertiary navigation';
$string['questioncategories'] = 'Question categories';
$string['questioncategory'] = 'Question category';
$string['questioncatsfor'] = 'Question categories for \'{$a}\'';
$string['questiondoesnotexist'] = 'This question does not exist';
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/attemptlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public function get_context() {
}

/**
* @return bool wether the current user is someone who previews the quiz,
* @return bool whether the current user is someone who previews the quiz,
* rather than attempting it.
*/
public function is_preview_user() {
Expand Down
60 changes: 60 additions & 0 deletions mod/quiz/classes/local/views/secondary.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?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\local\views;

use core\navigation\views\secondary as core_secondary;

/**
* Class secondary_navigation_view.
*
* Custom implementation for a plugin.
*
* @package mod_quiz
* @category navigation
* @copyright 2021 Sujith Haridasan <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class secondary extends core_secondary {
/**
* Define a custom secondary nav order/view.
*
* @return array
*/
protected function get_default_module_mapping(): array {
$defaultmaping = parent::get_default_module_mapping();

$defaultmaping[self::TYPE_SETTING] = array_merge($defaultmaping[self::TYPE_SETTING], [
'mod_quiz_edit' => 3,
'quiz_report' => 4,
'mod_quiz_useroverrides' => 6,
'roleassign' => 7,
'filtermanage' => 8,
'roleoverride' => 9,
'rolecheck' => 9.1,
'logreport' => 10,
'backup' => 11,
'restore' => 12,
'competencybreakdown' => 13,
]);

$defaultmaping[self::TYPE_CONTAINER] = [
'questionbank' => 5,
];

return $defaultmaping;
}
}
3 changes: 3 additions & 0 deletions mod/quiz/classes/output/edit_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public function edit_page(\quiz $quizobj, structure $structure,
\core_question\local\bank\question_edit_contexts $contexts, \moodle_url $pageurl, array $pagevars) {
$output = '';

// Page title.
$output .= $this->heading(get_string('questions', 'quiz'));

// Information at the top.
$output .= $this->quiz_state_warnings($structure);

Expand Down
111 changes: 111 additions & 0 deletions mod/quiz/classes/output/overrides_actions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?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 in the quiz secondary navigation
*
* The user/group overrides are now handled in the secondary navigation.
* This class provides the data for the templates to handle the data for
* overrides tab.
*
* @package mod_quiz
* @copyright 2021 Sujith Haridasan <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class overrides_actions implements renderable, templatable {
/** @var int The course module ID. */
private $cmid;

/** @var string The mode passed for the overrides url. */
private $mode;

/** @var bool Check if the user have capabilities to list overrides. */
private $canedit;

/** @var bool Should the add override button be enabled or disabled. */
private $addenabled;

/**
* overrides_action 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 bool $addenabled Whether the add button should be enabled or disabled.
*/
public function __construct(int $cmid, string $mode, bool $canedit, bool $addenabled) {
$this->cmid = $cmid;
$this->mode = $mode;
$this->canedit = $canedit;
$this->addenabled = $addenabled;
}

/**
* Create the add override button.
*
* @param \renderer_base $output an instance of the quiz renderer.
* @return \single_button the button, ready to reander.
*/
public function create_add_button(\renderer_base $output): \single_button {
$addoverrideurl = new moodle_url('/mod/quiz/overrideedit.php',
['cmid' => $this->cmid, 'action' => 'add' . $this->mode]);

if ($this->mode === 'group') {
$label = get_string('addnewgroupoverride', 'quiz');
} else {
$label = get_string('addnewuseroverride', 'quiz');
}

$addoverridebutton = new \single_button($addoverrideurl, $label, 'get', true);
if (!$this->addenabled) {
$addoverridebutton->disabled = true;
}

return $addoverridebutton;
}

public function export_for_template(renderer_base $output): array {
global $PAGE;
$templatecontext = [];

// Build the navigation drop-down.
$useroverridesurl = new moodle_url('/mod/quiz/overrides.php', ['cmid' => $this->cmid, 'mode' => 'user']);
$groupoverridesurl = new moodle_url('/mod/quiz/overrides.php', ['cmid' => $this->cmid, 'mode' => 'group']);

$menu = [
$useroverridesurl->out(false) => get_string('useroverrides', 'quiz'),
$groupoverridesurl->out(false) => get_string('groupoverrides', 'quiz')
];

$overridesnav = new url_select($menu, $PAGE->url->out(false), null, 'quizoverrides');
$templatecontext['overridesnav'] = $overridesnav->export_for_template($output);

// Build the add button - but only if the user can edit.
if ($this->canedit) {
$templatecontext['addoverridebutton'] = $this->create_add_button($output)->export_for_template($output);
}

return $templatecontext;
}
}
98 changes: 0 additions & 98 deletions mod/quiz/classes/output/overridesaction.php

This file was deleted.

68 changes: 0 additions & 68 deletions mod/quiz/classes/output/overwriteedit.php

This file was deleted.

Loading

0 comments on commit be7a576

Please sign in to comment.