-
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.
#13: Added toggleable course homepage link
- Loading branch information
Showing
7 changed files
with
164 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Renders course section navigation | ||
* | ||
* @package format_cards | ||
* @copyright 2024 University of Essex | ||
* @author John Maydew <jdmayd@essex.ac.uk> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace format_cards\output\courseformat\content; | ||
|
||
use core_courseformat\output\local\content\sectionnavigation as sectionnavigation_base; | ||
use renderer_base; | ||
use stdClass; | ||
|
||
/** | ||
* Renders course section navigation | ||
* | ||
* @package format_cards | ||
* @copyright 2024 University of Essex | ||
* @author John Maydew <jdmayd@essex.ac.uk> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class sectionnavigation extends sectionnavigation_base { | ||
|
||
/** | ||
* Get the template path | ||
* | ||
* @param renderer_base $renderer | ||
* @return string | ||
*/ | ||
public function get_template_name(renderer_base $renderer): string { | ||
return 'format_cards/local/content/sectionnavigation'; | ||
} | ||
|
||
/** | ||
* Export this data so it can be used as the context for a mustache template. | ||
* | ||
* @param renderer_base $output typically, the renderer that's calling this function | ||
* @return stdClass data context for a mustache template | ||
*/ | ||
public function export_for_template(renderer_base $output): stdClass { | ||
|
||
$data = parent::export_for_template($output); | ||
|
||
// Inject courseurl into the template data if we don't already have it. | ||
if (!object_property_exists($data, 'courseurl')) { | ||
$format = $this->format; | ||
$course = $format->get_course(); | ||
|
||
$displayoption = $this->format->get_format_option('sectionnavigationhome'); | ||
$data->showcoursehome = $displayoption == FORMAT_CARDS_SECTIONNAVIGATIONHOME_SHOW; | ||
|
||
$data->courseurl = course_get_url($course, null, [ 'navigation' => true ])->out(); | ||
} | ||
|
||
return $data; | ||
} | ||
} |
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,54 @@ | ||
{{! | ||
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 core_courseformat/local/content/sectionnavigation | ||
Displays the course section navigation. | ||
Example context (json): | ||
{ | ||
"hasprevious": true, | ||
"previousurl": "#", | ||
"larrow": "◄", | ||
"previousname": "Section 3", | ||
"hasnext": true, | ||
"rarrow": "►", | ||
"nexturl": "#", | ||
"nextname": "Section 5" | ||
} | ||
}} | ||
<div class="section-navigation navigationtitle d-flex justify-content-between"> | ||
<div class="prevsection"> | ||
{{#hasprevious}} | ||
<a href="{{{previousurl}}}" class="{{#previoushidden}} dimmed_text {{/previoushidden}} mr-2"> | ||
<span class="larrow">{{{larrow}}}</span>{{{previousname}}} | ||
</a> | ||
{{/hasprevious}} | ||
{{#showcoursehome}} | ||
<a href="{{{courseurl}}}"> | ||
{{#pix}} i/home, core, {{#str}} course {{/str}} {{/pix}}{{#str}} course {{/str}} | ||
</a> | ||
{{/showcoursehome}} | ||
</div> | ||
<div class="nextsection"> | ||
{{#hasnext}} | ||
<a href="{{{nexturl}}}" class="{{#nexthidden}} dimmed_text {{/nexthidden}}"> | ||
<span class="rarrow">{{{rarrow}}}</span>{{{nextname}}} | ||
</a> | ||
{{/hasnext}} | ||
</div> | ||
</div> |
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