Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab Topic Completion color change #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.txt
100644 → 100755
Empty file.
Empty file modified backup/moodle2/restore_format_onetopic_plugin.class.php
100644 → 100755
Empty file.
Empty file modified composer.json
100644 → 100755
Empty file.
Empty file modified db/upgrade.php
100644 → 100755
Empty file.
Empty file modified db/upgradelib.php
100644 → 100755
Empty file.
Empty file modified duplicate.php
100644 → 100755
Empty file.
Empty file modified format.js
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion format.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
} else {
if (isset($USER->display[$course->id]) && $renderer->numsections >= $USER->display[$course->id]) {
$displaysection = $USER->display[$course->id];
} else if ($course->marker && $course->marker > 0 && $course->marker < $renderer->numsections) {
} else if ($course->marker && $course->marker > 0) {
$USER->display[$course->id] = $course->marker;
$displaysection = $course->marker;
} else {
Expand Down
Empty file modified lang/en/format_onetopic.php
100644 → 100755
Empty file.
Empty file modified lang/es/format_onetopic.php
100644 → 100755
Empty file.
Empty file modified lib.php
100644 → 100755
Empty file.
103 changes: 96 additions & 7 deletions renderer.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,18 @@ public function print_single_section_page($course, $sections, $mods, $modnames,
}
}


if ($this->section_activity_summary($thissection, $course, null)){
$topiccomplete = 'topiccomplete';
$topiccompleteicon = ' <i class="fa fa-check-circle"></i>';
} else {
$topiccomplete = '';
$topiccompleteicon = '';
}

$newtab = new tabobject("tab_topic_" . $section, $url,
'<div style="' . $customstyles . '" class="tab_content ' . $specialstyle . '">' .
'<span>' . $sectionname . "</span></div>", $sectionname);
'<div style="' . $customstyles . '" class="tab_content ' . $specialstyle . ' ' . $topiccomplete . '">' .
'<span>' . $sectionname . "</span>" . $topiccompleteicon . "</div>", $sectionname);

if (is_array($formatoptions) && isset($formatoptions['level'])) {

Expand All @@ -337,8 +346,15 @@ public function print_single_section_page($course, $sections, $mods, $modnames,
} else {
$firsttabtext = get_string('index', 'format_onetopic');
}
$tabs[$parentindex]->subtree[0]->text = '<div class="tab_content tab_initial">' .
$firsttabtext . "</div>";
if ($this->section_activity_summary($parentsection, $course, null)){
$topiccomplete = 'topiccomplete';
$topiccompleteicon = ' <i class="fa fa-check-circle"></i>';
} else {
$topiccomplete = '';
$topiccompleteicon = '';
}
$tabs[$parentindex]->subtree[0]->text = '<div class="tab_content tab_initial ' . $topiccomplete . '">' .
$firsttabtext . "" . $topiccompleteicon . "</div>";
$tabs[$parentindex]->subtree[0]->level = 2;

if ($displaysection == $section - 1) {
Expand Down Expand Up @@ -431,7 +447,6 @@ public function print_single_section_page($course, $sections, $mods, $modnames,
} else if ($this->_course->templatetopic == format_onetopic::TEMPLATETOPIC_LIST) {
echo $this->custom_course_section_cm_list($course, $thissection, $displaysection);
}

echo $this->courserenderer->course_section_add_cm_control($course, $displaysection, $displaysection);
echo $this->section_footer();
echo $this->end_section_list();
Expand All @@ -441,8 +456,8 @@ public function print_single_section_page($course, $sections, $mods, $modnames,
// Display section bottom navigation.
$sectionbottomnav = '';
$sectionbottomnav .= html_writer::start_tag('div', array('class' => 'section-navigation mdl-bottom'));
$sectionbottomnav .= html_writer::tag('span', $sectionnavlinks['previous'], array('class' => 'mdl-left'));
$sectionbottomnav .= html_writer::tag('span', $sectionnavlinks['next'], array('class' => 'mdl-right'));
$sectionbottomnav .= html_writer::tag('span', $sectionnavlinks['previous'], array('class' => 'float-left btn btn-secondary'));
$sectionbottomnav .= html_writer::tag('span', $sectionnavlinks['next'], array('class' => 'float-right btn btn-secondary'));
$sectionbottomnav .= html_writer::end_tag('div');
echo $sectionbottomnav;

Expand Down Expand Up @@ -526,6 +541,80 @@ public function print_single_section_page($course, $sections, $mods, $modnames,
}
}


/**
* Generate a summary of the activites in a section
*
* @param stdClass $section The course_section entry from DB
* @param stdClass $course the course record from DB
* @param array $mods (argument not used)
* @return string HTML to output.
*/
protected function section_activity_summary($thissection, $course, $mods) {
global $PAGE;
$modinfo = get_fast_modinfo($course);
if (empty($modinfo->sections[$thissection->section])) {
return '';
}
// Generate array with count of activities in this section.
$sectionmods = array();
$total = 0;
$complete = 0;
$cancomplete = isloggedin() && !isguestuser();
$completioninfo = new completion_info($course);
foreach ($modinfo->sections[$thissection->section] as $cmid) {
$thismod = $modinfo->cms[$cmid];

if ($thismod->modname == 'label') {
// Labels are special (not interesting for students)!
continue;
}

if ($thismod->uservisible) {
if (isset($sectionmods[$thismod->modname])) {
$sectionmods[$thismod->modname]['name'] = $thismod->modplural;
$sectionmods[$thismod->modname]['count']++;
}
else {
$sectionmods[$thismod->modname]['name'] = $thismod->modfullname;
$sectionmods[$thismod->modname]['count'] = 1;
}
if ($cancomplete && $completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE) {
$total++;
$completiondata = $completioninfo->get_data($thismod, true);
if ($completiondata->completionstate == COMPLETION_COMPLETE || $completiondata->completionstate == COMPLETION_COMPLETE_PASS) {
$complete++;
}
}
}
}

if (empty($sectionmods)) {
// No sections.
return '';
}


if ($total > 0) {
$completion = new stdClass;
$completion->complete = $complete;
$completion->total = $total;

$percent = 0;
if ($complete > 0) {
$percent = (int)(($complete / $total) * 100);
}

if($percent == 100) {
return true;
}

}

return false;
}


/**
* Generate the display of the header part of a section before
* course modules are included
Expand Down
4 changes: 4 additions & 0 deletions styles.css
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,8 @@

.format-onetopic .onetopic .content > .summary .iconhelp {
cursor: pointer;
}

.format-onetopic .onetopic .topiccomplete {
background-color: #3dff44;
}
Empty file modified version.php
100644 → 100755
Empty file.