Skip to content

Commit

Permalink
#204 - feature deactive course cards admin setting
Browse files Browse the repository at this point in the history
  • Loading branch information
moniNaydenov committed Oct 4, 2023
1 parent 8c930d5 commit 86289e4
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changes

### Unreleased

* 2023-10-04 - Improvement: implement new settings for Course overview block, solves #204
* 2023-10-01 - Bugfix: Smart menus did not support multilanguage filters, solves #376.
* 2023-09-28 - Release: Make sure that Smart Menu SCSS does not affect installations which do not use smart menus, solves #380.
* 2023-09-22 - Bugfix: Transition in second level in user menu was wrong, solves #397
Expand Down
11 changes: 11 additions & 0 deletions lang/en/theme_boost_union.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,17 @@
$string['loginformtransparencysetting'] = 'Login form transparency';
$string['loginformtransparencysetting_desc'] = 'With this setting, you can make the login form slightly transparent to let the background image shine through even more.';

// Settings: Dashboard tab.
$string['dashboardtab'] = 'Dashboard';
// ... Section: Course overview block.
$string['courseoverviewheading'] = 'Course overview block';
// ... ... Setting: Show course image in Course overview block.
$string['courseoverviewshowcourseimagessetting'] = 'Show course images';
$string['courseoverviewshowcourseimagessetting_desc'] = 'With this setting, you can control whether the course image is visible inside the Course overview block.';
// ... ... Setting: Show course completion progress in Course overview block.
$string['courseoverviewshowprogresssetting'] = 'Show course completion progress';
$string['courseoverviewshowprogresssetting_desc'] = 'With this setting, you can control whether the course completion progress is visible inside the Course overview block.';

// Settings: Course tab.
$string['coursetab'] = 'Course';
// ... Section: Course header.
Expand Down
3 changes: 3 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ function theme_boost_union_get_extra_scss($theme) {
// Setting: Mark external links.
$content .= theme_boost_union_get_scss_to_mark_external_links($theme);

// Setting: Course overview block.
$content .= theme_boost_union_get_scss_courseoverview_block($theme);

return $content;
}

Expand Down
36 changes: 36 additions & 0 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1342,3 +1342,39 @@ function theme_boost_union_get_scss_to_mark_external_links($theme) {
}
return $scss;
}

/**
* Adds appropriate scss to hide the course image and/or the course progress in the course overview block, depending
* on the theme settings courseoverviewshowcourseimages and courseoverviewshowcourseprogress respectively.
*
* @param theme_config $theme The theme config object.
* @return string
*/
function theme_boost_union_get_scss_courseoverview_block($theme) {
// Initialize SCSS snippet.
$scss = '';

// Selector for the course overview block.
$courseoverviewblockselector = '.block_myoverview.block div[data-region="courses-view"]';

// Get the course image setting, defaults to true.
$showcourseoverviewcourseimages = isset($theme->settings->courseoverviewshowcourseimages) ?
$theme->settings->courseoverviewshowcourseimages == 'yes' : true;

// If the corresponding setting is set to 'no'.
if (!$showcourseoverviewcourseimages) {
$scss .= $courseoverviewblockselector . ' .course-summaryitem > .row > .col-md-2 { display: none !important; }' . PHP_EOL;
$scss .= $courseoverviewblockselector . ' .course-listitem > .row > .col-md-2 { display: none !important; }' . PHP_EOL;
$scss .= $courseoverviewblockselector . ' .dashboard-card-img { display: none; }' . PHP_EOL;
}

// Get the course progress setting, defaults to true.
$showcourseprogress = isset($theme->settings->courseoverviewshowcourseprogress) ?
$theme->settings->courseoverviewshowcourseprogress == 'yes' : true;

// If the corresponding setting is set to 'no'.
if (!$showcourseprogress) {
$scss .= $courseoverviewblockselector . ' .progress-text { display: none !important; }' . PHP_EOL;
}
return $scss;
}
28 changes: 28 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,34 @@
// Add tab to settings page.
$page->add($tab);

// Create Dashboard tab.
$tab = new admin_settingpage('theme_boost_union_look_dashboard',
get_string('dashboardtab', 'theme_boost_union', null, true));

// Create Course overview block heading.
$name = 'theme_boost_union/courseoverview';
$title = get_string('courseoverviewheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);

// Setting: Show course images in the course overview block.
$name = 'theme_boost_union/courseoverviewshowcourseimages';
$title = get_string('courseoverviewshowcourseimagessetting', 'theme_boost_union', null, true);
$description = get_string('courseoverviewshowcourseimagessetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_YES, $yesnooption);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);

// Setting: Show course progress in the course overview block.
$name = 'theme_boost_union/courseoverviewshowcourseprogress';
$title = get_string('courseoverviewshowprogresssetting', 'theme_boost_union', null, true);
$description = get_string('courseoverviewshowprogresssetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_YES, $yesnooption);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);

// Add tab to settings page.
$page->add($tab);

// Create course tab.
$tab = new admin_settingpage('theme_boost_union_look_course',
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'theme_boost_union';
$plugin->version = 2023090101;
$plugin->version = 2023090101.01;
$plugin->release = 'v4.2-r2';
$plugin->requires = 2023042402.04;
$plugin->supported = [402, 402];
Expand Down

0 comments on commit 86289e4

Please sign in to comment.