Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #4 from SecurityCompass/upstream_updates
Browse files Browse the repository at this point in the history
Upstream updates
  • Loading branch information
hrpatel authored Nov 9, 2018
2 parents f92298f + 99d3a1f commit f20fcc8
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 58 deletions.
114 changes: 67 additions & 47 deletions classes/output/core/course_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ protected function coursecat_courses(coursecat_helper $chelper, $courses, $total
}

$coursecount = 1;
$content .= html_writer::start_tag('div', array('class' => 'row'));
$content .= html_writer::start_tag('div', array('class' => 'card-deck'));
foreach ($courses as $course) {
$content .= $this->coursecat_coursebox($chelper, $course, 'col-md-3');
$content .= $this->coursecat_coursebox($chelper, $course);

if ($coursecount % 4 == 0) {
$content .= html_writer::end_tag('div');
$content .= html_writer::start_tag('div', array('class' => 'row'));
$content .= html_writer::start_tag('div', array('class' => 'card-deck'));
}

$coursecount ++;
Expand Down Expand Up @@ -187,9 +187,8 @@ protected function coursecat_coursebox(coursecat_helper $chelper, $course, $addi
require_once($CFG->libdir. '/coursecatlib.php');
$course = new course_in_list($course);
}
$content = html_writer::start_tag('div', array('class' => $additionalclasses));

$classes = trim('card clearfix');
$classes = trim('card');
if ($chelper->get_show_courses() >= self::COURSECAT_SHOW_COURSES_EXPANDED) {
$nametag = 'h3';
} else {
Expand All @@ -198,7 +197,7 @@ protected function coursecat_coursebox(coursecat_helper $chelper, $course, $addi
}

// End coursebox.
$content .= html_writer::start_tag('div', array(
$content = html_writer::start_tag('div', array(
'class' => $classes,
'data-courseid' => $course->id,
'data-type' => self::COURSECAT_TYPE_COURSE,
Expand All @@ -208,8 +207,6 @@ protected function coursecat_coursebox(coursecat_helper $chelper, $course, $addi

$content .= html_writer::end_tag('div'); // End coursebox.

$content .= html_writer::end_tag('div'); // End col-md-4.

return $content;
}

Expand All @@ -223,13 +220,7 @@ protected function coursecat_coursebox(coursecat_helper $chelper, $course, $addi
* @return string
*/
protected function coursecat_coursebox_content(coursecat_helper $chelper, $course) {
global $CFG;

$theme = \theme_config::load('moove');

if (!empty($theme->settings->courselistview)) {
return parent::coursecat_coursebox_content($chelper, $course);
}
global $CFG, $DB;

if ($course instanceof stdClass) {
require_once($CFG->libdir. '/coursecatlib.php');
Expand All @@ -238,25 +229,43 @@ protected function coursecat_coursebox_content(coursecat_helper $chelper, $cours

// Course name.
$coursename = $chelper->get_course_formatted_name($course);
$coursenamelink = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)),
$coursename, array('class' => $course->visible ? '' : 'dimmed'));
$courselink = new moodle_url('/course/view.php', array('id' => $course->id));
$coursenamelink = html_writer::link($courselink, $coursename, array('class' => $course->visible ? '' : 'dimmed'));

$content = $this->get_course_summary_image($course);
$content = $this->get_course_summary_image($course, $courselink);

// Course instructors.
if ($course->has_course_contacts()) {
$content .= html_writer::start_tag('div', array('class' => 'course-contacts'));

$instructors = $course->get_course_contacts();
foreach ($instructors as $key => $instructor) {
$name = $instructor['username'];
$url = $CFG->wwwroot.'/user/profile.php?id='.$key;
$picture = $this->get_user_picture($DB->get_record('user', array('id' => $key)));

$content .= "<a href='{$url}' class='contact' data-toggle='tooltip' title='{$name}'>";
$content .= "<img src='{$picture}' class='rounded-circle' alt='{$name}'/>";
$content .= "</a>";
}

$content .= html_writer::end_tag('div'); // Ends course-contacts.
}

$content .= html_writer::start_tag('div', array('class' => 'card-block'));
$content .= html_writer::start_tag('div', array('class' => 'card-body'));
$content .= "<h4 class='card-title'>". $coursenamelink ."</h4>";

// Display course summary.
if ($course->has_summary()) {
$content .= html_writer::start_tag('p', array('class' => 'card-text'));
$content .= $chelper->get_course_formatted_summary($course,
array('overflowdiv' => true, 'noclean' => true, 'para' => false));
array('overflowdiv' => true, 'noclean' => true, 'para' => false));
$content .= html_writer::end_tag('p'); // End summary.
}

$content .= html_writer::end_tag('div');

$content .= html_writer::start_tag('div', array('class' => 'card-block'));
$content .= html_writer::start_tag('div', array('class' => 'card-footer'));

// Print enrolmenticons.
if ($icons = enrol_get_course_info_icons($course)) {
Expand All @@ -267,34 +276,19 @@ protected function coursecat_coursebox_content(coursecat_helper $chelper, $cours

$content .= html_writer::start_tag('div', array('class' => 'pull-right'));
$content .= html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)),
get_string('access', 'theme_moove'), array('class' => 'card-link btn btn-primary'));
get_string('access', 'theme_moove'), array('class' => 'card-link btn btn-primary'));
$content .= html_writer::end_tag('div'); // End pull-right.

$content .= html_writer::end_tag('div'); // End card-block.

// Display course contacts. See course_in_list::get_course_contacts().
if ($course->has_course_contacts()) {
$content .= html_writer::start_tag('div', array('class' => 'card-footer teachers'));
$content .= html_writer::start_tag('ul');
foreach ($course->get_course_contacts() as $userid => $coursecontact) {
$name = $coursecontact['rolename'].': '.
html_writer::link(new moodle_url('/user/view.php',
array('id' => $userid, 'course' => SITEID)),
$coursecontact['username']);
$content .= html_writer::tag('li', $name);
}
$content .= html_writer::end_tag('ul'); // End teachers.
$content .= html_writer::end_tag('div'); // End teachers.
}

// Display course category if necessary (for example in search results).
if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT) {
require_once($CFG->libdir. '/coursecatlib.php');
if ($cat = coursecat::get($course->category, IGNORE_MISSING)) {
$content .= html_writer::start_tag('div', array('class' => 'coursecat'));
$content .= get_string('category').': '.
html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)),
$cat->get_formatted_name(), array('class' => $cat->visible ? '' : 'dimmed'));
html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)),
$cat->get_formatted_name(), array('class' => $cat->visible ? '' : 'dimmed'));
$content .= html_writer::end_tag('div'); // End coursecat.
}
}
Expand All @@ -308,29 +302,55 @@ protected function coursecat_coursebox_content(coursecat_helper $chelper, $cours
* @param stdClass $course the course object
* @return string
*/
protected function get_course_summary_image($course) {
protected function get_course_summary_image($course, $courselink) {
global $CFG;

$contentimage = '';
foreach ($course->get_course_overviewfiles() as $file) {
$isimage = $file->is_valid_image();
$url = file_encode_url("$CFG->wwwroot/pluginfile.php",
'/'. $file->get_contextid(). '/'. $file->get_component(). '/'.
$file->get_filearea(). $file->get_filepath(). $file->get_filename(), !$isimage);
'/'. $file->get_contextid(). '/'. $file->get_component(). '/'.
$file->get_filearea(). $file->get_filepath(). $file->get_filename(), !$isimage);
if ($isimage) {
$contentimage = html_writer::empty_tag('img', array('src' => $url, 'alt' => 'Course Image '. $course->fullname,
'class' => 'card-img-top w-100'));
break;
$contentimage = html_writer::link($courselink, html_writer::empty_tag('img', array(
'src' => $url,
'alt' => $course->fullname,
'class' => 'card-img-top w-100')));
break;
}
}

if (empty($contentimage)) {
$url = $CFG->wwwroot . "/theme/moove/pix/default_course.jpg";

$contentimage = html_writer::empty_tag('img', array('src' => $url, 'alt' => 'Course Image '. $course->fullname,
'class' => 'card-img-top w-100'));
$contentimage = html_writer::link($courselink, html_writer::empty_tag('img', array(
'src' => $url,
'alt' => $course->fullname,
'class' => 'card-img-top w-100')));
}

return $contentimage;
}

/**
* Get the user profile pic
*
* @param null $userobject
* @param int $imgsize
* @return moodle_url
* @throws \coding_exception
*/
protected function get_user_picture($userobject = null, $imgsize = 100) {
global $USER, $PAGE;

if (!$userobject) {
$userobject = $USER;
}

$userimg = new \user_picture($userobject);

$userimg->size = $imgsize;

return $userimg->get_url($PAGE);
}
}
3 changes: 2 additions & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ function theme_moove_rebuildcoursesections(\flat_navigation $flatnav) {
'icon' => $item->icon,
'type' => $item->type,
'key' => $item->key,
'parent' => $coursesections
'parent' => $coursesections,
'action' => $item->action
]));
}
}
Expand Down
32 changes: 25 additions & 7 deletions scss/moove/_frontpage.scss
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
#frontpage-course-list {
#frontpage-course-list,
#frontpage-category-combo {
h2 {
text-align: center;
color: $brand-primary;
margin-bottom: 2rem;
}

.courses .card .teachers ul {
list-style: none;
margin-bottom: 0;
padding-left: 0;
.card-deck .card .card-footer .icon {
height: 36px;
}

.course-contacts {
margin: -30px 6px -20px 6px;
text-align: right;

.contact {
margin: 0 3px;

img {
width: 48px;
border: 2px solid white;
cursor: pointer;
border-radius: 50%;
}
}
}
}

#frontpage-category-combo .courses .card-deck .card,
#frontpage-course-list .frontpage-course-list-all .card-deck .card {
margin-bottom: 2rem;
}

#page-site-index #mooveslideshow {
margin: 1rem 0;

Expand Down
14 changes: 14 additions & 0 deletions scss/moove/_navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,18 @@ nav.navbar {
}
}
}
}

.userloggedinas {
nav.navbar ul.navbar-nav .usermenu {
line-height: 35px;

.usertext .meta.viewingas {
line-height: initial;
}

.userbutton .avatars .realuser {
padding-top: 10px;
}
}
}
9 changes: 8 additions & 1 deletion scss/moove/_responsive.scss
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@
}
}
}

@media (min-width: 768px) {
body {
margin-left: 55px;
Expand All @@ -203,6 +202,14 @@
border-bottom-left-radius: $m-login-padding;
}
}

.card-deck .card {
flex-basis: calc(25% - 30px);
}

.pagelayout-mydashboard .card-deck .card {
flex-basis: calc(50% - 30px);
}
}

@media (max-width: 991px) {
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
defined('MOODLE_INTERNAL') || die();

// This is the version of the plugin.
$plugin->version = 2018070200;
$plugin->version = 2018090200;

// This is the version of Moodle this plugin requires.
$plugin->requires = 2018050800;
Expand All @@ -36,7 +36,7 @@
$plugin->component = 'theme_moove';

// This is the named version.
$plugin->release = '2.3.6';
$plugin->release = '2.3.8';

// This is a stable release.
$plugin->maturity = MATURITY_STABLE;
Expand Down

0 comments on commit f20fcc8

Please sign in to comment.