Skip to content

Commit

Permalink
CTP-3838 - Improve card html
Browse files Browse the repository at this point in the history
Improve padding, only output progress html when completion enabled.
  • Loading branch information
stuartlamour committed Sep 25, 2024
1 parent c517fb5 commit 040e722
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
13 changes: 9 additions & 4 deletions block_pickup.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function fetch_recent_courses(): array {
global $USER, $DB;

// Get recent courses.
$sql = "SELECT c.id, c.fullname, c.visible, cc.name as catname
$sql = "SELECT c.id, c.fullname, c.visible, c.enablecompletion, cc.name as catname
FROM {user_lastaccess} ula
JOIN {course} c ON c.id = ula.courseid
JOIN {course_categories} cc ON cc.id = c.category
Expand Down Expand Up @@ -152,11 +152,16 @@ public function fetch_recent_courses(): array {
$course->coursecategory = $cr->catname;

/* Progress. */
if ($percentage = progress::get_course_progress_percentage($cr, $USER->id)) {
$percentage = floor($percentage);
$course->progress = $percentage;
if ($cr->enablecompletion) {
$course->progressenabled = true;
$course->progress = "0"; // Default.
if ($percentage = progress::get_course_progress_percentage($cr, $USER->id)) {
$percentage = floor($percentage);
$course->progress = $percentage;
}
}


/* Course image. */
$course->courseimage = course_summary_exporter::get_course_image($cr);
$template->courses[] = $course;
Expand Down
2 changes: 1 addition & 1 deletion templates/content.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
}
}}
<div id="block-pickup-content">
<div class="container">
<div class="container p-0 px-md-3">

{{! Header and link. }}
<div class="pb-3">
Expand Down
28 changes: 13 additions & 15 deletions templates/coursecard.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{{! Coursecard. }}
<div class="pickup-card h-100 bg-white position-relative pb-3">
{{^visible}}
<div class="position-absolute p-1" style="top:0;right: 0; z-index: 666;">
<div class="position-absolute p-1" style="top:0; right: 0; z-index: 666;">
<span class="badge badge-pill badge-warning border border-dark" >{{#str}} hiddenfromstudents {{/str}}</span>
</div>
{{/visible}}
Expand All @@ -44,26 +44,24 @@
</div>

{{! Name & Catagory. }}
<div class="pickup-card-details pt-2 px-3">
<div class="pickup-card-details px-3 pt-3">
<a href="{{viewurl}}" class="stretched-link font-weight-bold line-clamp-3">{{fullname}}</a>
<div class="line-clamp-1 text-muted"><small>{{coursecategory}}</small></div>
</div>

{{! Progress. }}
{{#progressenabled}}
<div class="dashboard-card-meta mt-auto px-3">

{{! Progress. }}
<div class="{{^progress}} invisible {{/progress}}">
<small>Progress: {{progress}}%</small>
<div class="progress ">
<div class="progress-bar bg-success" role="progressbar"
aria-label="{{#str}} progress {{/str}}"
aria-valuenow="{{progress}}"
style="width: {{progress}}%"
aria-valuemin="0"
aria-valuemax="100"></div>
</div>
<small>Progress: {{progress}}%</small>
<div class="progress">
<div class="progress-bar bg-success" role="progressbar"
aria-label="{{#str}} progress {{/str}}"
aria-valuenow="{{progress}}"
style="width: {{progress}}%"
aria-valuemin="0"
aria-valuemax="100"></div>
</div>
</div>

{{/progressenabled}}
</div>
</div>

0 comments on commit 040e722

Please sign in to comment.