Skip to content

Commit

Permalink
Code refactoring for Moodle coding guidelines compliance.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-milette committed Oct 8, 2024
1 parent b60b2c8 commit 3d615ea
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions classes/text_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,14 @@ private function getusergroupings($courseid, $userid) {
global $DB;

return $DB->get_records_sql('SELECT gp.id, gp.name, gp.idnumber
FROM {user} u
INNER JOIN {groups_members} gm ON u.id = gm.userid
INNER JOIN {groups} g ON g.id = gm.groupid
INNER JOIN {groupings_groups} gg ON gm.groupid = gg.groupid
INNER JOIN {groupings} gp ON gp.id = gg.groupingid
WHERE g.courseid = ? AND u.id = ?
GROUP BY gp.id
ORDER BY gp.name ASC', [$courseid, $userid]);
FROM {user} u
INNER JOIN {groups_members} gm ON u.id = gm.userid
INNER JOIN {groups} g ON g.id = gm.groupid
INNER JOIN {groupings_groups} gg ON gm.groupid = gg.groupid
INNER JOIN {groupings} gp ON gp.id = gg.groupingid
WHERE g.courseid = ? AND u.id = ?
GROUP BY gp.id
ORDER BY gp.name ASC', [$courseid, $userid]);
}

/**
Expand Down Expand Up @@ -608,7 +608,7 @@ private function rendercoursecards($rcourseids, $format = 'vertical') {
. ');height:100px;max-width:300px;padding-top:50%;background-size:cover;'
. 'background-repeat:no-repeat;background-position:center;"></div>
<div class="card-title pt-1 pr-3 pb-1 pl-3 m-0"><span class="sr-only">' . get_string('course') . ': </span>'
. $course->get_formatted_name() . '</div>
. $course->get_formatted_name() . '</div>
</a>
</div>
';
Expand Down Expand Up @@ -661,9 +661,11 @@ private function rendercoursecards($rcourseids, $format = 'vertical') {

$content .= '
<tr class="fc-coursecard-table">
<td class="text-coursename col-sm-12 col-md-3 d-block d-md-table-cell"><a href="' . $courseurl . '">' . $course->get_formatted_name() . '</a></td>
<td class="text-coursename col-sm-12 col-md-3 d-block d-md-table-cell"><a href="' . $courseurl . '">'
. $course->get_formatted_name() . '</a></td>
<td class="text-coursecategory col-sm-12 col-md-2 d-block d-md-table-cell">' . $category . '</td>
<td class="text-coursename col-sm-12 col-md-7 d-block d-md-table-cell" style="word-wrap:break-word;">' . $summary . '</td>
<td class="text-coursename col-sm-12 col-md-7 d-block d-md-table-cell" style="word-wrap:break-word;">'
. $summary . '</td>
</tr>
';
break;
Expand Down Expand Up @@ -695,9 +697,12 @@ private function getcoursecardinfo($format = null) {
<table class="table table-hover table-responsive">
<thead>
<tr>
<th scope="col" class="col-12 col-md-3 d-block d-md-table-cell">' . get_string('course') . '</th>
<th scope="col" class="col-12 col-md-2 d-block d-md-table-cell">' . get_string('category') . '</th>
<th scope="col" class="col-12 col-md-7 d-block d-md-table-cell">' . get_string('description') . '</th>
<th scope="col" class="col-12 col-md-3 d-block d-md-table-cell">'
. get_string('course') . '</th>
<th scope="col" class="col-12 col-md-2 d-block d-md-table-cell">'
. get_string('category') . '</th>
<th scope="col" class="col-12 col-md-7 d-block d-md-table-cell">'
. get_string('description') . '</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -1083,11 +1088,11 @@ private function generatortags(&$text) {
. "://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
$url .= (strpos($url, '?') ? '&' : '?');

// Get list of available languages
// Get list of available languages.
$availablelanguages = get_string_manager()->get_list_of_translations();
if (count($availablelanguages) > 1) {
foreach ($availablelanguages as $langcode => $langname) {
// Create a link for each language
// Create a link for each language.
$menu .= '-' . $langname . '|' . $url . 'lang=' . $langcode . PHP_EOL;
}
if (!empty($menu)) {
Expand Down Expand Up @@ -3250,7 +3255,8 @@ function ($matches) use ($USER) {
// Add request a course link.
$context = \context_system::instance();
if (!empty($CFG->enablecourserequests) && has_capability('moodle/course:request', $context)) {
$link = '<a href="' . (new \moodle_url('/course/request.php'))->out() . '">' . get_string('requestcourse') . '</a>';
$link = '<a href="' . (new \moodle_url('/course/request.php'))->out() . '">'
. get_string('requestcourse') . '</a>';
} else {
$link = '';
}
Expand Down

0 comments on commit 3d615ea

Please sign in to comment.