Commit 5d1d4172 authored by Camille Tardy's avatar Camille Tardy
Browse files

Fix for Moodle 3.7 and 3.8 + add a column + css for mod_book + css for new course overview block.

parent 776311b0
...@@ -5,7 +5,7 @@ namespace theme_unige\output\core; ...@@ -5,7 +5,7 @@ namespace theme_unige\output\core;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
use moodle_url; use moodle_url;
use coursecat; use core_course_category;
use coursecat_helper; use coursecat_helper;
use html_writer; use html_writer;
use single_select; use single_select;
...@@ -59,8 +59,8 @@ class course_renderer extends \core_course_renderer { ...@@ -59,8 +59,8 @@ class course_renderer extends \core_course_renderer {
*/ */
public function course_category($category) { public function course_category($category) {
global $CFG; global $CFG;
require_once($CFG->libdir. '/coursecatlib.php'); // require_once($CFG->libdir. '/coursecatlib.php');
$coursecat = coursecat::get(is_object($category) ? $category->id : $category); $coursecat = core_course_category::get(is_object($category) ? $category->id : $category);
$site = get_site(); $site = get_site();
$output = ''; $output = '';
...@@ -117,9 +117,9 @@ class course_renderer extends \core_course_renderer { ...@@ -117,9 +117,9 @@ class course_renderer extends \core_course_renderer {
$output .= $this->course_search_form(); $output .= $this->course_search_form();
if (!$coursecat->id) { if (!$coursecat->id) {
if (coursecat::count_all() == 1) { if (core_course_category::is_simple_site() == 1) {
// There exists only one category in the system, do not display link to it // There exists only one category in the system, do not display link to it
$coursecat = coursecat::get_default(); $coursecat = core_course_category::get_default();
$strfulllistofcourses = get_string('fulllistofcourses'); $strfulllistofcourses = get_string('fulllistofcourses');
$this->page->set_title("$site->shortname: $strfulllistofcourses"); $this->page->set_title("$site->shortname: $strfulllistofcourses");
} else { } else {
...@@ -128,16 +128,16 @@ class course_renderer extends \core_course_renderer { ...@@ -128,16 +128,16 @@ class course_renderer extends \core_course_renderer {
} }
} else { } else {
$title = $site->shortname; $title = $site->shortname;
if (coursecat::count_all() > 1) { if (core_course_category::is_simple_site() > 1) {
$title .= ": ". $coursecat->get_formatted_name(); $title .= ": ". $coursecat->get_formatted_name();
} }
$this->page->set_title($title); $this->page->set_title($title);
// Print the category selector // Print the category selector
if (coursecat::count_all() > 1) { if (core_course_category::is_simple_site() > 1) {
$output .= html_writer::start_tag('div', array('class' => 'categorypicker')); $output .= html_writer::start_tag('div', array('class' => 'categorypicker'));
$select = new single_select(new moodle_url('/course/index.php'), 'categoryid', $select = new single_select(new moodle_url('/course/index.php'), 'categoryid',
coursecat::make_categories_list(), $coursecat->id, null, 'switchcategory'); core_course_category::make_categories_list(), $coursecat->id, null, 'switchcategory');
$select->set_label(get_string('categories').':'); $select->set_label(get_string('categories').':');
$output .= $this->render($select); $output .= $this->render($select);
$output .= html_writer::end_tag('div'); // .categorypicker $output .= html_writer::end_tag('div'); // .categorypicker
...@@ -208,19 +208,11 @@ class course_renderer extends \core_course_renderer { ...@@ -208,19 +208,11 @@ class course_renderer extends \core_course_renderer {
'data-type' => self::COURSECAT_TYPE_CATEGORY, 'data-type' => self::COURSECAT_TYPE_CATEGORY,
)); ));
// category id
$id_category = '0';
if ($this->page->pagetype == "course-index") {
$id_category = $coursecat->id;
} elseif ($this->page->pagetype == "course-index-category") {
$id_category = $_GET['categoryid'];
}
// category name // category name
$categoryname = $coursecat->get_formatted_name(); $categoryname = $coursecat->get_formatted_name();
$categoryname = html_writer::link(new moodle_url('/course/index.php', $categoryname = html_writer::link(new moodle_url('/course/index.php',
array('categoryid' => $coursecat->id)), array('categoryid' => $coursecat->id)),
$categoryname, array('class' => $this->color_fac_category($id_category))); $categoryname, array('class' => $this->color_fac_category($coursecat->id)));
if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_COUNT if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_COUNT
&& ($coursescount = $coursecat->get_courses_count())) { && ($coursescount = $coursecat->get_courses_count())) {
$categoryname .= html_writer::tag('span', ' ('. $coursescount.')', $categoryname .= html_writer::tag('span', ' ('. $coursescount.')',
...@@ -382,7 +374,7 @@ class course_renderer extends \core_course_renderer { ...@@ -382,7 +374,7 @@ class course_renderer extends \core_course_renderer {
* please use {@link core_course_renderer::course_info_box()} * please use {@link core_course_renderer::course_info_box()}
* *
* @param coursecat_helper $chelper various display options * @param coursecat_helper $chelper various display options
* @param course_in_list|stdClass $course * @param core_course_list_element|stdClass $course
* @param string $additionalclasses additional classes to add to the main <div> tag (usually * @param string $additionalclasses additional classes to add to the main <div> tag (usually
* depend on the course position in list - first/last/even/odd) * depend on the course position in list - first/last/even/odd)
* @return string * @return string
...@@ -396,8 +388,8 @@ class course_renderer extends \core_course_renderer { ...@@ -396,8 +388,8 @@ class course_renderer extends \core_course_renderer {
return ''; return '';
} }
if ($course instanceof stdClass) { if ($course instanceof stdClass) {
require_once($CFG->libdir. '/coursecatlib.php'); // require_once($CFG->libdir. '/coursecatlib.php');
$course = new course_in_list($course); $course = new core_course_list_element($course);
} }
$content = ''; $content = '';
$classes = trim('coursebox clearfix '. $additionalclasses); $classes = trim('coursebox clearfix '. $additionalclasses);
......
...@@ -50,7 +50,7 @@ class core_renderer extends \theme_boost\output\core_renderer { ...@@ -50,7 +50,7 @@ class core_renderer extends \theme_boost\output\core_renderer {
$header->courseheader = $this->course_header(); $header->courseheader = $this->course_header();
$header->courseheader .= $this->scroll_header(); $header->courseheader .= $this->scroll_header();
return $this->render_from_template('theme_boost/header', $header); return $this->render_from_template('theme_unige/full_header', $header);
} }
/** /**
......
...@@ -2,6 +2,32 @@ ...@@ -2,6 +2,32 @@
// This line protects the file from being accessed by a URL directly // This line protects the file from being accessed by a URL directly
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$THEME->layouts = [
// Main course page.
'course' => array(
'file' => 'columns2.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
),
'coursecategory' => array(
'file' => 'columns2.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
),
// My dashboard page.
'mydashboard' => array(
'file' => 'columns2.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
),
// Part of course, typical for modules - default page layout if $cm specified in require_login().
'incourse' => array(
'file' => 'columns3.php',
'regions' => array('side-pre', 'side-left'),
'defaultregion' => 'side-pre',
),
];
// Theme name // Theme name
$THEME->name = 'unige'; $THEME->name = 'unige';
......
<?php
defined('MOODLE_INTERNAL') || die();
user_preference_allow_ajax_update('drawer-open-nav', PARAM_ALPHA);
require_once($CFG->libdir . '/behat/lib.php');
if (isloggedin()) {
$navdraweropen = (get_user_preferences('drawer-open-nav', 'true') == 'true');
} else {
$navdraweropen = false;
}
$extraclasses = [];
if ($navdraweropen) {
$extraclasses[] = 'drawer-open-left';
}
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
$blockshtml = $OUTPUT->blocks('side-pre');
$blockstoc = $OUTPUT->blocks('side-left');
$hasblocks = strpos($blockshtml, 'data-block=') !== false;
$hastoc = strpos($blockstoc, 'data-block=') !== false;
$regionmainsettingsmenu = $OUTPUT->region_main_settings_menu();
$templatecontext = [
'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
'output' => $OUTPUT,
'sidepreblocks' => $blockshtml,
'sideleftblock' => $blockstoc,
'hasblocks' => $hasblocks,
'hastoc' => $hastoc,
'bodyattributes' => $bodyattributes,
'navdraweropen' => $navdraweropen,
'regionmainsettingsmenu' => $regionmainsettingsmenu,
'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
'arrow-down' => $OUTPUT->image_url('arrow-down', 'theme'),
'unige-logo' => $OUTPUT->image_url('unige-logo', 'theme'),
'moodle-unige-logo' => $OUTPUT->image_url('moodle-unige-logo', 'theme'),
'redirection-menu-square' => $OUTPUT->image_url('redirection-menu-square', 'theme')
];
$templatecontext['flatnavigation'] = $PAGE->flatnav;
echo $OUTPUT->render_from_template('theme_unige/columns3', $templatecontext);
...@@ -463,6 +463,7 @@ select + .btn-group, .btn-group + .btn { ...@@ -463,6 +463,7 @@ select + .btn-group, .btn-group + .btn {
margin-top: -.4em; margin-top: -.4em;
margin-right: 1em; margin-right: 1em;
padding-top: 0.35em; padding-top: 0.35em;
margin-bottom: auto;
} }
.modtype_resource { .modtype_resource {
...@@ -680,6 +681,10 @@ select + .btn-group, .btn-group + .btn { ...@@ -680,6 +681,10 @@ select + .btn-group, .btn-group + .btn {
font-style: italic; font-style: italic;
} }
[data-region="blocks-column-left"] {
display: block;
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// ----- My courses // ----- My courses
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -732,50 +737,38 @@ select + .btn-group, .btn-group + .btn { ...@@ -732,50 +737,38 @@ select + .btn-group, .btn-group + .btn {
} }
} }
.block_course_overview { //block course overview moodle 3.8
border: none; .block_myoverview{
.block-controls {
display: none;
}
.card-title { .coursename {
display: none !important; font-size: 1.17rem;
color: $brand-primary;
} }
.card-body { .categoryname{
padding-top: 0; font-size: 0.8rem;
} }
.singleselect { .list-group-item{
margin-left: 0.4em; border: none;
} padding: 0.5em 1.25rem;
.course-list { .progress,.progress+.small{
padding-left: 2.2em; display: none;
padding-right: 1em;
.overview-icon {
float: right;
img {
cursor: pointer;
}
} }
}
.courseovbox { & > div > div > div {
border-bottom: none; display: flex;
} flex-direction: column;
}
.alert { .coursename {
margin-top: 1em; order: -1;
}
} }
.favourite_icon > i {
color: #000;
}
} }
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -1265,3 +1258,11 @@ select + .btn-group, .btn-group + .btn { ...@@ -1265,3 +1258,11 @@ select + .btn-group, .btn-group + .btn {
max-width: none; max-width: none;
} }
} }
// Fix Book TOC
@media (min-width: 1199px) {
//Hide Left Column (Book TOC)
[data-region="blocks-column-left"] {
display: none;
}
}
...@@ -25,7 +25,7 @@ if ($ADMIN->fulltree) { ...@@ -25,7 +25,7 @@ if ($ADMIN->fulltree) {
$title = get_string('navigationmenu', 'theme_unige'); $title = get_string('navigationmenu', 'theme_unige');
$description = get_string('navigationmenu_desc', 'theme_unige'); $description = get_string('navigationmenu_desc', 'theme_unige');
$default = "/my; $default = "/my;
/course;"; /course;";
$setting = new admin_setting_configtextarea($name, $title, $description, $default); $setting = new admin_setting_configtextarea($name, $title, $description, $default);
$setting->set_updatedcallback('theme_reset_all_caches'); $setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting); $page->add($setting);
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
"page_title": "Test page", "page_title": "Test page",
"favicon": "favicon.ico", "favicon": "favicon.ico",
"main_content": "<h1>Headings make html validators happier</h1>" "main_content": "<h1>Headings make html validators happier</h1>"
}, },
"bodyattributes":"", "bodyattributes":"",
"sidepreblocks": "<h2>Blocks html goes here</h2>", "sidepreblocks": "<h2>Blocks html goes here</h2>",
"hasblocks":true, "hasblocks":true,
...@@ -40,47 +40,48 @@ ...@@ -40,47 +40,48 @@
{{{ output.standard_top_of_body_html }}} {{{ output.standard_top_of_body_html }}}
{{>theme_unige/navbar}} {{> theme_unige/navbar }}
<div id="page" class="container-fluid"> <div id="page" class="container-fluid">
{{{ output.full_header }}} {{{ output.full_header }}}
<div id="page-content" class="row"> <div id="page-content" class="row pb-3">
<div id="region-main-box" class="col-12"> <div id="region-main-box" class="col-12">
{{#hasregionmainsettingsmenu}} {{#hasregionmainsettingsmenu}}
<div id="region-main-settings-menu" class="d-print-none {{#hasblocks}}has-blocks{{/hasblocks}}"> <div id="region-main-settings-menu" class="d-print-none {{#hasblocks}}has-blocks{{/hasblocks}}">
<div> {{{ output.region_main_settings_menu }}} </div> <div> {{{ output.region_main_settings_menu }}} </div>
</div> </div>
{{/hasregionmainsettingsmenu}} {{/hasregionmainsettingsmenu}}
<section id="region-main" {{#hasblocks}}class="has-blocks mb-3"{{/hasblocks}}> <section id="region-main" {{#hasblocks}}class="has-blocks mb-3"{{/hasblocks}} aria-label="{{#str}}content{{/str}}">
<div class="card">
<div class="card-body"> {{#hasregionmainsettingsmenu}}
{{#hasregionmainsettingsmenu}} <div class="region_main_settings_menu_proxy"></div>
<div class="region_main_settings_menu_proxy"></div> {{/hasregionmainsettingsmenu}}
{{/hasregionmainsettingsmenu}} {{{ output.course_content_header }}}
{{{ output.course_content_header }}} {{{ output.main_content }}}
{{{ output.main_content }}} {{{ output.activity_navigation }}}
{{{ output.activity_navigation }}} {{{ output.course_content_footer }}}
{{{ output.course_content_footer }}}
</div>
</div>
</section> </section>
{{#hasblocks}} {{#hasblocks}}
<section data-region="blocks-column" class="d-print-none"> <section data-region="blocks-column" class="d-print-none" aria-label="{{#str}}blocks{{/str}}">
{{{ sidepreblocks }}} {{{ sidepreblocks }}}
</section> </section>
{{/hasblocks}} {{/hasblocks}}
</div> </div>
</div> </div>
</div> </div>
{{{ output.standard_after_main_region_html }}}
{{> theme_unige/footer }}
</div> </div>
{{> theme_unige/footer }}
</body> </body>
</html> </html>
{{#js}} {{#js}}
require(['theme_boost/loader']); M.util.js_pending('theme_boost/loader');
require(['theme_boost/loader'], function() {
M.util.js_complete('theme_boost/loader');
});
require(['theme_boost/drawer'], function(mod) { require(['theme_boost/drawer'], function(mod) {
mod.init(); mod.init();
......
{{!
@template theme_boost/columns2
Admin time setting template.
Boost 2 column layout template.
Context variables required for this template:
* sitename - The name of the site
* output - The core renderer for the page
* bodyattributes - attributes for the body tag as a string of html attributes
* sidepreblocks - HTML for the blocks
* hasblocks - true if there are blocks on this page
* navdraweropen - true if the nav drawer should be open on page load
* regionmainsettingsmenu - HTML for the region main settings menu
* hasregionmainsettingsmenu - There is a region main settings menu on this page.
Example context (json):
{
"sitename": "Moodle",
"output": {
"doctype": "<!DOCTYPE html>",
"page_title": "Test page",
"favicon": "favicon.ico",
"main_content": "<h1>Headings make html validators happier</h1>"
},
"bodyattributes":"",
"sidepreblocks": "<h2>Blocks html goes here</h2>",
"hasblocks":true,
"navdraweropen":true,
"regionmainsettingsmenu": "",
"hasregionmainsettingsmenu": false
}
}}
{{> theme_boost/head }}
<body {{{ bodyattributes }}}>
<div id="page-wrapper">
{{{ output.standard_top_of_body_html }}}
{{> theme_unige/navbar }}
<div id="page" class="container-fluid">
{{{ output.full_header }}}
<div id="page-content" class="row pb-3">
<div id="region-main-box" class="col-12">
{{#hasregionmainsettingsmenu}}
<div id="region-main-settings-menu" class="d-print-none {{#hasblocks}}has-blocks{{/hasblocks}}">
<div> {{{ output.region_main_settings_menu }}} </div>
</div>
{{/hasregionmainsettingsmenu}}
{{#hastoc}}
<section data-region="blocks-column-left" aria-label="{{#str}}blocks{{/str}}">
{{{ sideleftblock }}}
</section>
{{/hastoc}}
<section id="region-main" {{#hasblocks}}class="has-blocks mb-3"{{/hasblocks}} aria-label="{{#str}}content{{/str}}">
{{#hasregionmainsettingsmenu}}
<div class="region_main_settings_menu_proxy"></div>
{{/hasregionmainsettingsmenu}}
{{{ output.course_content_header }}}
{{{ output.main_content }}}
{{{ output.activity_navigation }}}
{{{ output.course_content_footer }}}
</section>
{{#hasblocks}}
<section data-region="blocks-column" class="d-print-none" aria-label="{{#str}}blocks{{/str}}">
{{{ sidepreblocks }}}
</section>
{{/hasblocks}}
</div>
</div>
</div>
{{{ output.standard_after_main_region_html }}}
{{> theme_unige/footer }}
</div>
</body>
</html>
{{#js}}
M.util.js_pending('theme_boost/loader');
require(['theme_boost/loader'], function() {
M.util.js_complete('theme_boost/loader');
});
require(['theme_boost/drawer'], function(mod) {
mod.init();
if ($(document).scrollTop() >= 500)
$('.scroll-top-button').fadeIn(0);
else
$('.scroll-top-button').fadeOut(0);
if ($(document).scrollTop() >= 120)
$('#scroll-header').fadeIn(0);
else
$('#scroll-header').fadeOut(0);
if(document.getElementById("scroll-header")) {
document.getElementById("scroll-header").style.width = document.getElementById("page-header").offsetWidth - 30 + 'px';
}
$(window).resize(function() {
document.getElementById("scroll-header").style.width = document.getElementById("page-header").offsetWidth - 30 + 'px';
});
$(window).scroll(function () {
if ($(document).scrollTop() >= 500)
$('.scroll-top-button').fadeIn(200);
else
$('.scroll-top-button').fadeOut(200);
if ($(document).scrollTop() >= 120)
$('#scroll-header').fadeIn(200);
else
$('#scroll-header').fadeOut(200);
});
});
{{/js}}
{{!
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 boost/header
This template renders the header.
Example context (json):