Skip to content

Commit

Permalink
Improved course header features,
Browse files Browse the repository at this point in the history
- Mod pix icon support.
- Category value fixed on course fields.
- Added user fields in staff roles.
  • Loading branch information
raja-lmsace committed Oct 11, 2023
1 parent af55194 commit 4dece7f
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 85 deletions.
10 changes: 6 additions & 4 deletions classes/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ public function get_course_staff_users($course) {
$user = \core_user::get_user($userid);
profile_load_data($user);

$extrafields = profile_get_user_fields_with_data($userid);
foreach ($extrafields as $formfield) {
if ($course->{$formfield->inputname}) {
$customfield[]['value'] = $formfield->data;
if (format_designer_has_pro() != 1) {
$extrafields = profile_get_user_fields_with_data($userid);
foreach ($extrafields as $formfield) {
if ($course->{$formfield->inputname}) {
$customfield[]['value'] = $formfield->data;
}
}
}
$roles = get_user_roles($coursecontext, $userid, false);
Expand Down
14 changes: 12 additions & 2 deletions classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public function render_content($widget) {
}
$data->startclass = implode(' ', $startclass);
$data->startid = $startid;
$data->issectionpageclass = (optional_param('section', null, PARAM_INT)) ? 'section-page-layout' : '';

if (!format_designer_has_pro()) {
$data->timemanagement = $this->timemanagement_details($course);
Expand Down Expand Up @@ -843,17 +844,26 @@ public function render_section_data(section_info $section, stdClass $course, $on
if ($thismod->uservisible) {
if (isset($mods[$thismod->modname])) {
$mods[$thismod->modname]['name'] = $thismod->modplural;
$mods[$thismod->modname]['img'] = $CFG->wwwroot.'/mod/'.$thismod->modname.'/pix/monologo.png';
if (file_exists($CFG->dirroot.'/mod/'.$thismod->modname.'/pix/monologo.png')) {
$mods[$thismod->modname]['img'] = $CFG->wwwroot.'/mod/'.$thismod->modname.'/pix/monologo.png';
} else if (file_exists($CFG->dirroot.'/mod/'.$thismod->modname.'/pix/icon.png')) {
$mods[$thismod->modname]['img'] = $CFG->wwwroot.'/mod/'.$thismod->modname.'/pix/icon.png';
}
$mods[$thismod->modname]['count']++;
} else {
$mods[$thismod->modname]['name'] = $thismod->modfullname;
$mods[$thismod->modname]['img'] = $CFG->wwwroot.'/mod/'.$thismod->modname.'/pix/monologo.png';
if (file_exists($CFG->dirroot.'/mod/'.$thismod->modname.'/pix/monologo.png')) {
$mods[$thismod->modname]['img'] = $CFG->wwwroot.'/mod/'.$thismod->modname.'/pix/monologo.png';
} else if (file_exists($CFG->dirroot.'/mod/'.$thismod->modname.'/pix/icon.png')) {
$mods[$thismod->modname]['img'] = $CFG->wwwroot.'/mod/'.$thismod->modname.'/pix/icon.png';
}
$mods[$thismod->modname]['count'] = 1;
}
}
}
$templatecontext['sectioncountstatus'] = true;
$templatecontext['sectionmodcount'] = array_values($mods);
$templatecontext['sectionsingle'] = true;
}
if (format_designer_has_pro() && $section->section == 0) {
require_once($CFG->dirroot. "/local/designer/lib.php");
Expand Down
42 changes: 25 additions & 17 deletions lang/en/format_designer.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
$string['strprerequisiteinfo'] = "Prerequisite info";
$string['strprerequisiteinfo_help'] = "Display the text above the prerequisites.";
$string['displayheaderroleusers'] = "Choose the staff role";
$string['displayheaderroleusers_help'] = "";
$string['displayheaderroleusers_help'] = "Users with these selected roles will be displayed in the course header.";
$string['addtocontacts'] = "Add to contacts";
$string['message'] = "Message";
$string['mail'] = "Mail";
Expand Down Expand Up @@ -371,45 +371,53 @@
// Course background.
$string['coursebackground'] = 'Course Background';
$string['coursebackgroundcolor'] = 'Course Background Color';
$string['coursebackgroundcolor_help'] = '';
$string['coursebackgroundcolor_help'] = 'Use this option to choose a background color for the entire course. If a color is selected here, it will be applied as the background color for the course. This setting is optional, and you can leave it blank if you don\'t want to set a specific background color.';
$string['coursebackgroundimage'] = 'Course Background Image';
$string['coursebackgroundimage_help'] = '';
$string['coursebackgroundimage_help'] = 'If you wish to have an image as the background for the entire course, you can upload it here. Once uploaded, this image will be displayed as the background for the entire course. This setting is optional, and you can leave it blank if you prefer not to have a background image.';
$string['coursebackgroundtransparent'] = 'Transparent Course';
$string['coursebackgroundtransparent_help'] = '';
$string['coursebackgroundtransparent_help'] = 'If you select this option, the background color of container elements within the course that currently have a background color will be set to transparent. This can create a visually appealing effect where elements appear to float on top of the background';

// Course header.
$string['courseheadertype'] = 'Type';
$string['courseheadertype_help'] = '';
$string['courseheadertype_help'] = '<b>None</b>: This option will not add any header to the course page.<br>
<b>Hero</b>: Selecting this option will make the header span the full width of the page, providing a visually impactful course introduction.<br>
<b>Content</b>: Choosing this option will set the header width to match the course contents, maintaining a more compact design.';
$string['hero'] = 'Hero';
$string['content'] = 'Content';
$string['courseheadertimemanagement'] = 'Time Management';
$string['courseheadertimemanagement_help'] = '';
$string['courseheadertimemanagement_help'] = 'Select the time-related elements you want to display in the course header. You can choose multiple options from enrolment start date, enrolment end date, due date, and completed date.';
$string['courseprogresstype'] = 'Course Progress';
$string['courseprogresstype_help'] = '';
$string['courseprogresstype_help'] = '<b>Disabled</b>: This option will not display any course progress information in the header.<br>
<b>Progress Bar</b>: Selecting this option will display the course progress as a bar, visually indicating how much of the course is completed.<br>
<b>Donut</b>: Choosing this option will display the course progress as a donut chart, providing a different visual representation of progress.<br>';
$string['progressbar'] = 'Progress bar';
$string['donut'] = 'Donut';
$string['sectionprogresstype'] = 'Section Progress';
$string['sectionprogresstype_help'] = '';
$string['sectionprogresstype_help'] = '<b>Disabled</b>: This option will not display any section progress information in the header.<br>
<b>Progress Bar</b>: Selecting this option will display the section progress as a bar, showing the completion status of individual course sections.<br>
<b>Donut</b>: Choosing this option will display the section progress as a donut chart, offering an alternative visual representation.<br>';
$string['courseheadersummary'] = 'Summary';
$string['courseheadersummary_help'] = '';
$string['courseheadersummary_help'] = '<b>Disabled</b>: This option will not show any summary in the header.<br>
<b>Trimmed</b>: Selecting this option will trim the course summary based on the global setting "trim length."<br>
<b>Full</b>: Choosing this option will display the complete course summary.<br>';
$string['trimmed'] = 'Trimmed';
$string['full'] = 'Full';
$string['additionalcontent'] = 'Additional Content';
$string['additionalcontent_help'] = '';
$string['additionalcontent_help'] = 'Add any additional content that you want to appear at the bottom of the course header.';
$string['courseheaderbgcolor'] = 'Background color';
$string['courseheaderbgcolor_help'] = '';
$string['courseheaderbgcolor_help'] = 'Choose a background color to overlay on top of the background image. This color setting should support transparency if desired.';
$string['courseheadertextcolor'] = 'Text color';
$string['courseheadertextcolor_help'] = '';
$string['courseheadertextcolor_help'] = 'Select the color for text elements within the course header.';
$string['courseheaderbgimage'] = 'Background image';
$string['courseheaderbgimage_help'] = '';
$string['courseheaderbgimage_help'] = 'Upload a background image that you want to use for the course header.';
$string['courseheaderheight'] = 'Minimum Height';
$string['courseheaderheight_help'] = '';
$string['courseheaderheight_help'] = 'Specify the minimum height, in number, for the course header.';
$string['courseheadersize'] = 'Full Screen';
$string['courseheadersize_help'] = '';
$string['courseheadersize_help'] = 'If enabled, the course header will take up the full height of the screen.';
$string['userfields'] = 'User profile fields';
$string['userfields_help'] = 'Select fields to display under the staff users';
$string['userfields_help'] = 'Select profile fields to display below the user in the course header.';
$string['coursecustomfields'] = 'Course fields';
$string['coursecustomfields_help'] = '';
$string['coursecustomfields_help'] = 'Select the course fields from those available on the site that you want to display in the course header.';
$string['coursecompleted'] = 'Course completed';
$string['coursecustomfields_help'] = '';
// ...Coursefields icon.
Expand Down
37 changes: 21 additions & 16 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ public function extend_course_navigation($navigation, navigation_node $node) {

if (format_designer_has_pro()) {
// Include the designer pro styles.
$PAGE->requires->css('/local/designer/style/slick.css');
$styleurl = \local_designer\courseoptions::create($this->get_course())->designer_include_style();
$PAGE->requires->css($styleurl);
}
Expand Down Expand Up @@ -499,13 +500,15 @@ public static function course_format_options_list($foreditform = false) {
$courseformatoptions += (new local_designer\courseoptions($PAGE->course))->course_header_options_format_list();
}

$userprofilefields = profile_get_user_fields_with_data(0);
if (!empty($userprofilefields)) {
foreach ($userprofilefields as $field) {
$courseformatoptions[$field->inputname] = [
'default' => 0,
'type' => PARAM_INT,
];
if (format_designer_has_pro() != 1 ) {
$userprofilefields = profile_get_user_fields_with_data(0);
if (!empty($userprofilefields)) {
foreach ($userprofilefields as $field) {
$courseformatoptions[$field->inputname] = [
'default' => 0,
'type' => PARAM_INT,
];
}
}
}

Expand Down Expand Up @@ -739,15 +742,17 @@ public static function course_format_options_list($foreditform = false) {
'help_component' => 'format_designer',
];

$userprofilefields = profile_get_user_fields_with_data(0);
if (!empty($userprofilefields)) {
foreach ($userprofilefields as $field) {
$courseformatoptionsedit[$field->inputname] = [
'label' => $field->field->name,
'element_type' => 'advcheckbox',
'help' => 'profilefieditem',
'help_component' => 'format_designer',
];
if (format_designer_has_pro() != 1 ) {
$userprofilefields = profile_get_user_fields_with_data(0);
if (!empty($userprofilefields)) {
foreach ($userprofilefields as $field) {
$courseformatoptionsedit[$field->inputname] = [
'label' => $field->field->name,
'element_type' => 'advcheckbox',
'help' => 'profilefieditem',
'help_component' => 'format_designer',
];
}
}
}

Expand Down
69 changes: 27 additions & 42 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,27 @@
}

@media (min-width: 768px) {
.format-designer .header-maxwidth,
.format-designer .secondary-navigation,
.pagelayout-standard.format-designer #page.drawers .main-inner,
body.limitedwidth.format-designer #page.drawers .main-inner,
.pagelayout-standard.format-designer #page.drawers .footer-popover,
body.limitedwidth.format-designer #page.drawers .footer-popover {
max-width: none;
}
.format-designer.path-admin.path-admin-roles:not(.format-site) .header-maxwidth,
.format-designer.path-admin.path-admin-roles:not(.format-site) .secondary-navigation .navigation .nav-tabs,
.format-designer.path-admin.path-admin-tool-lp .header-maxwidth,
.format-designer.path-admin.path-admin-tool-lp .secondary-navigation .navigation .nav-tabs {
max-width: none;
}
#page.drawers.format-designer {
padding-left: 0;
padding-right: 0;
}
}

.format-designer.path-mod .header-maxwidth {
padding: 0 3rem;
background-color: #fff;
}
.format-designer #goto-top-link {
z-index: 1;
}
Expand Down Expand Up @@ -216,12 +223,11 @@
border: 1px solid #eee;
border-radius: 0;
padding: 5px 15px 20px;
margin-right: 1.5rem;
}
.format-designer .course-content ul.designer.course-type-normal li.section.main:before {
border: 0;
}
.format-designer .course-content ul.designer li.section .section-header-content .goto-section {
.format-designer .course-content ul.designer:not(.course-type-flow) li.section .section-header-content .goto-section {
float: right;
clear: both;
}
Expand Down Expand Up @@ -267,37 +273,7 @@
.format-designer:not(.editing) .course-content ul.designer.course-type-normal li.section.main.container {
width: 30%;
}

/* Section goto link */
.format-designer .course-content ul.designer.course-type-normal li.section .section-header-content .goto-section {
text-indent: -999em;
border: 0;
background: none;
padding: 0;
clear: none;
}
.format-designer .course-content ul.designer.course-type-normal li.section .section-header-content .goto-section:focus {
box-shadow: none;
}
.format-designer .course-content ul.designer.course-type-normal li.section .section-header-content a.goto-section:after {
content: '\f178';
font-size: 30px;
color: #000;
text-indent: 0;
margin: 0;
float: left;
}
/* End of Section goto link */

@media (min-width: 576px) {
.format-designer .course-content ul.designer.course-type-normal li.section.main {
max-width: none;
width: 30%;
flex: auto;
}
}
/* End of Course type - Normal*/

.format-designer ul.designer .card.card-list.notstarted {
border-left-color: var(--primary);
}
Expand Down Expand Up @@ -462,8 +438,8 @@ body.format-designer.editing ul.designer .section .circles-layout .activity .edi
/* format_topics CSS copied from boost to replicate basic styling for designer (based on topic) */
.format-designer .course-content ul.designer {
list-style: none;
padding: 0;
margin: 0;
padding: 0 0 20px 0;
margin: 0 0 20px 0;
clear: both;
}
.format-designer .course-content ul.designer li.section.main {
Expand Down Expand Up @@ -656,6 +632,14 @@ span.section-collapse-icon:before {
display: inline-block;
vertical-align: middle;
}
.format-designer.path-course-view.pagelayout-course #page {
background-color: transparent;
}
.format-designer #page #page-content section#region-main {
padding: 10px;
border-radius: 5px;
overflow: auto;
}
.format-designer.path-course-view.pagelayout-course #page #page-content section#region-main {
padding: 0;
overflow: visible;
Expand All @@ -664,9 +648,6 @@ span.section-collapse-icon:before {
max-width: none;
width: auto;
}
.format-designer .course-content ul.designer.single-section-layout li.section.main {
padding-right: 10px;
}
.format-designer .course-content ul.designer li.section.main.container .section-content-wrapper .right .section-collapsemenu {
margin-bottom: 10px;
}
Expand Down Expand Up @@ -1678,6 +1659,9 @@ ul li {
margin-left: 35px;
margin-bottom: 5px;
}
.format-designer .designer .section .content .section.card-layout li.activity .card.card-list.success {
min-height: 250px;
}
.format-designer .designer .section .content .section.card-layout li.activity .card.card-list .mod-indent-outer {
height: 100%;
}
Expand Down Expand Up @@ -2902,7 +2886,8 @@ body.format-designer.editing .designer .section .content .section.card-layout li
height: auto;
}
.format-designer .course-content ul.designer.course-type-flow {
display: contents;
/* display: contents; */
margin-top: 30px;
}
.format-designer .course-content ul.course-type-flow.designer .section.main .section-content-wrapper {
display: contents;
Expand Down Expand Up @@ -2941,7 +2926,7 @@ body.format-designer.editing .designer .section .content .section.card-layout li
bottom: 20px;
left: 20px;
}
.format-designer .course-content ul.designer.course-type-flow li.section .section-header-content .section-progress-info .progress {
.format-designer .course-content ul.designer.course-type-flow li.section .section-header-content .section-progress-info > div:not(.progress-donut) .progress {
height: 12px;
background: #fff;
}
Expand Down
2 changes: 1 addition & 1 deletion templates/courseformat/content.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
}
}
}}
<div id="{{uniqid}}-course-format" class="{{#startclass}}single-section-layout{{/startclass}}">
<div id="{{uniqid}}-course-format" class="{{#startclass}}single-section-layout{{/startclass}} {{issectionpageclass}}">
{{{timemanagement}}}
<h2 class="accesshide">{{{title}}}</h2>
{{{completionhelp}}}
Expand Down
4 changes: 2 additions & 2 deletions templates/section_layout.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}
}}

<div class="section-content-wrapper {{#sectionprogresscomp}} section-progress-info-completed {{/sectionprogresscomp}}">
<div class="section-content-wrapper {{#sectionprogresscomp}} section-progress-info-completed {{/sectionprogresscomp}}" {{#sectionsingle}} data-action="go-to-section-url" data-url="{{{sectionurl}}}" {{/sectionsingle}}>
{{#sectiondesignwhole}}
<div class="section-background-style section-design-whole" style="{{#sectionbackgroundstyle}} {{sectionbackgroundstyle}} {{/sectionbackgroundstyle}}">
{{#maskinner}}
Expand Down Expand Up @@ -203,7 +203,7 @@
</div>
{{/sectioncountstatus}}
{{#gotosection}}
<a href="{{{sectionurl}}}" class="goto-section btn btn-primary">{{#str}}gotosection, format_designer{{/str}}</a>
<a href="{{{sectionurl}}}" class="goto-section btn btn-primary" style="{{#sectiontextcolor}} {{sectiontextcolor}} {{/sectiontextcolor}}">{{#str}}gotosection, format_designer{{/str}}</a>
{{/gotosection}}
</div>

Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2023101100; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2023101101; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2020061500; // Requires this Moodle version.
$plugin->component = 'format_designer'; // Full name of the plugin (used for diagnostics).
$plugin->release = 'Version 1.4';
Expand Down

0 comments on commit 4dece7f

Please sign in to comment.