forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'MDL-73335-tim' of https://github.com/ilyatregubov/moodle
- Loading branch information
Showing
99 changed files
with
619 additions
and
988 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.