Skip to content

Commit

Permalink
Fix progress bar
Browse files Browse the repository at this point in the history
Put info icon outside tag a
  • Loading branch information
gustavobazzo committed Feb 20, 2024
1 parent f27e414 commit 01363d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions src/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class filter_recitactivity extends moodle_text_filter {
protected $DEFAULT_TARGET = '_self';
/** @var object */
protected $stats = null;

protected const NO_COMPLETION = 0;
protected const COMPLETION_NOT_COMPLETED = 1;
protected const COMPLETION_COMPLETED = 2;
/**
* Setup function loads teachers and activities.
*
Expand Down Expand Up @@ -218,6 +222,12 @@ protected function setStats(){
$this->stats->course->nbCmCompleted = 0;

foreach($this->cmdatalist as $item) {
$completion = $this->getCmCompletion($item->cmInfo, $item->completion);

if($completion == self::NO_COMPLETION){
continue;
}

if(!isset($this->stats->section[$item->cmInfo->section])){
$this->stats->section[$item->cmInfo->section] = new stdClass();
$this->stats->section[$item->cmInfo->section]->nbCmTotal = 0;
Expand All @@ -227,7 +237,7 @@ protected function setStats(){
$this->stats->section[$item->cmInfo->section]->nbCmTotal++;
$this->stats->course->nbCmTotal++;

if($this->getCmCompletion($item->cmInfo, $item->completion) == 2){
if($completion == self::COMPLETION_COMPLETED){
$this->stats->section[$item->cmInfo->section]->nbCmCompleted++;
$this->stats->course->nbCmCompleted++;
}
Expand Down Expand Up @@ -269,7 +279,6 @@ protected function get_autolink($cmdata, $options = array()) {
$options['target'] = $this->DEFAULT_TARGET;
}


$activityicon = "";
if(isset($options['icon']) && $options['icon'] == true){
$activityicon = html_writer::empty_tag('img', array('src' => $cmdata->cmInfo->get_icon_url(), 'class' => 'iconlarge activityicon', 'alt' => '',
Expand Down Expand Up @@ -316,7 +325,8 @@ protected function get_autolink($cmdata, $options = array()) {

$activityName = html_writer::tag('span', $title, array('class' => 'instancename'));

return html_writer::tag('a', $activityicon . $activityName . $restrictioninfo, $attributes);
$autolink = html_writer::tag('a', $activityicon . $activityName, $attributes);
return html_writer::tag('span', $autolink . $restrictioninfo);
}

/**
Expand All @@ -339,16 +349,6 @@ protected function get_course_activity($name, $options = array()) {
$result->output = new stdClass();
$result->output->state = true;

$title = $result->cmData->rawname;
if (isset($options['title'])) {
$title = $options['title'];
}

$class = '';
if (isset($options['class'])) {
$class = $options['class'];
}

if (isset($options['roles'])) {
if(!$this->validateUserRoles($options['roles'])){
$result->output->state = false;
Expand Down Expand Up @@ -610,8 +610,8 @@ protected function getCmCompletionCheckbox(cm_info $mod, $completiondata){
}

$cmCompletion = $this->getCmCompletion($mod, $completiondata);
if($cmCompletion != 0){
$completionicon = ($cmCompletion == 2 ? 'fa-check-square-o' : 'fa-square-o');
if($cmCompletion != self::NO_COMPLETION){
$completionicon = ($cmCompletion == self::COMPLETION_COMPLETED ? 'fa-check-square-o' : 'fa-square-o');
$output .= "<i class='fa $completionicon'></i>";
}

Expand Down Expand Up @@ -769,7 +769,7 @@ protected function filterOptionFeedback($complement, $attributes, $match, &$resu
$cmCompletion = $this->getCmCompletion($cmData->cmInfo, $cmData->completion);

// cm is completed, nothing to display
if($cmCompletion == 2){
if($cmCompletion == self::COMPLETION_COMPLETED){
$result = str_replace($match, "", $result);
return;
}
Expand All @@ -785,7 +785,7 @@ protected function filterOptionFeedback($complement, $attributes, $match, &$resu
$dismissButton = "";

// cm is not completed or has no completion option
if($cmCompletion == 1){
if($cmCompletion == self::COMPLETION_NOT_COMPLETED){
$dismissButton = '<div class="d-flex justify-content-end"><button class="btn btn-sm text-nowrap btn-outline-secondary m-2" data-action="toggle-manual-completion" data-toggletype="manual:mark-done"
data-withavailability="1" data-cmid="'.$cmData->cmInfo->id.'" data-activityname="Ignore"
title='.get_string('dismissMsg','filter_recitactivity').' aria-label='.get_string('dismissMsg','filter_recitactivity').'>'.get_string('dismissMsg','filter_recitactivity').'</button></div>';
Expand Down
2 changes: 1 addition & 1 deletion src/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
$plugin->version = 2024020101; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2020061500.00; // Moodle 3.9.0
$plugin->component = 'filter_recitactivity'; // Full name of the plugin (used for diagnostics)
$plugin->release = 'v1.18.0-stable';
$plugin->release = 'v1.18.1-stable';
$plugin->maturity = MATURITY_STABLE;
$plugin->supported = [39, 401]; // Moodle 3.9.x, 3.10.x, 3.11.x and 4.0.x are supported.

0 comments on commit 01363d6

Please sign in to comment.