Skip to content

Commit

Permalink
Bug fixes - DES-844, DES-846, DES-862, DES-863.
Browse files Browse the repository at this point in the history
  • Loading branch information
vasanthlmsace committed May 21, 2024
1 parent be79518 commit 54e552e
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 49 deletions.
2 changes: 1 addition & 1 deletion amd/build/designer_section.min.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions amd/src/designer_section.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
* @param {array} popupActivities
* @param {bool} videoTime
* @param {bool} issubpanel
* @param {int} sectionreturn
*/
let DesignerSection = function(courseId, contextId, popupActivities, videoTime, issubpanel, sectionreturn) {
var self = this;
Expand Down
5 changes: 5 additions & 0 deletions backup/moodle2/backup_format_designer_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public function define_section_plugin_structure() {
$formatoptions->annotate_files($component, $file, null);
}
}
$formatoptions->annotate_files('local_designer', 'courseheaderbgimage', null);
$formatoptions->annotate_files('local_designer', 'coursebgimage', null);
$formatoptions->annotate_files('local_designer', 'additionalcontent', null);
$formatoptions->annotate_files('local_designer', 'prerequisiteinfo', null);

$plugin = $this->get_plugin_element(null, $this->get_format_condition(), 'designer');

return $plugin->add_child($formatoptions);
Expand Down
9 changes: 9 additions & 0 deletions backup/moodle2/restore_format_designer_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,14 @@ protected function after_restore_section() {
foreach ($files as $file => $component) {
$this->add_related_files($component, $file, 'course_section');
}

// Restore the courseheaderbgimage.
$this->add_related_files('local_designer', 'courseheaderbgimage', null, null, $this->step->get_task()->get_old_courseid());
// Restore the coursebgimage.
$this->add_related_files('local_designer', 'coursebgimage', null, null, $this->step->get_task()->get_old_courseid());
// Restore the additionalcontent.
$this->add_related_files('local_designer', 'additionalcontent', null, null, $this->step->get_task()->get_old_courseid());
// Restore the prerequisiteinfo.
$this->add_related_files('local_designer', 'prerequisiteinfo', null, null, $this->step->get_task()->get_old_courseid());
}
}
29 changes: 20 additions & 9 deletions classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ public function render_content($widget) {
$data->kanbanmode = true;
}
$data->startid = $startid;

$data->issectionpageclass = ($data->initialsection->sectionreturnid != 0) ? 'section-page-layout' : '';

if (!format_designer_has_pro()) {
$data->headermetadata = $this->course_header_metadata_details($course);
}
Expand Down Expand Up @@ -599,7 +600,18 @@ public static function criteria_progress($course, $userid) {
$completionactivities = $completion->get_criteria(COMPLETION_CRITERIA_TYPE_ACTIVITY);
$complteioncourses = $completion->get_criteria(COMPLETION_CRITERIA_TYPE_COURSE);

$count = count($completionactivities) + count($complteioncourses);
$count = count($completionactivities);

$isapplycompletioncourses = false;
if (!isset($course->calcourseprogress)) {
$isapplycompletioncourses = true;
} else if ($course->calcourseprogress == DESIGNER_PROGRESS_CRITERIA) {
$isapplycompletioncourses = true;
}

if ($isapplycompletioncourses) {
$count += count($complteioncourses);
}
$cmidentifier = "moduleinstance";

if (format_designer_has_pro()) {
Expand Down Expand Up @@ -628,7 +640,7 @@ public static function criteria_progress($course, $userid) {
$completed += ($data->completionstate == COMPLETION_COMPLETE ||
$data->completionstate == COMPLETION_COMPLETE_PASS) ? 1 : 0;
$modtooltiplink = html_writer::link($modules[$cmid]->url,
get_string('stractivity', 'format_designer') . " ". $modules[$cmid]->name);
get_string('stractivity', 'format_designer') . ": " . $modules[$cmid]->name);
if ($data->completionstate == COMPLETION_COMPLETE ||
$data->completionstate == COMPLETION_COMPLETE_PASS) {
$completedcriteria[] = $modtooltiplink;
Expand All @@ -639,13 +651,13 @@ public static function criteria_progress($course, $userid) {
}
}

if ($complteioncourses && !isset($course->calcourseprogress)) {
if ($isapplycompletioncourses && $complteioncourses) {
foreach ($complteioncourses as $coursecriteria) {
$courseid = $coursecriteria->courseinstance;
$course = get_course($courseid);
$completion = new \completion_info($course);
$coursetooltiplink = html_writer::link(new moodle_url('/course/view.php',
['id' => $course->id]), $course->fullname);
['id' => $course->id]), get_string('strcourse', 'format_designer') . ": " . $course->fullname);
if ($completion->is_course_complete($userid)) {
$completed += 1;
$completedcriteria[] = $coursetooltiplink;
Expand All @@ -657,14 +669,15 @@ public static function criteria_progress($course, $userid) {

if (format_designer_has_pro()) {

if ($course->calcourseprogress == DESIGNER_PROGRESS_SECTIONS && !empty($modinfo->sections)) {
if (isset($course->calcourseprogress) && $course->calcourseprogress == DESIGNER_PROGRESS_SECTIONS
&& !empty($modinfo->sections)) {
foreach ($modinfo->sections as $sectionno => $modnumbers) {
$section = course_get_format($course)->get_section($sectionno);
if ($section->visible) {
$sectionname = get_section_name($course, $section);
$sectionurl = new moodle_url('/course/view.php', ['id' => $course->id, 'section' => $sectionno]);
$sectiontooltiplink = html_writer::link($sectionurl,
get_string('strsection', 'format_designer') . " ". $sectionname);
get_string('strsection', 'format_designer') . ": ". $sectionname);
$realtiveactivities = isset($course->calsectionprogress) &&
($course->calsectionprogress == DESIGNER_PROGRESS_RELEVANTACTIVITIES) ? true : false;
if (\format_designer\options::is_section_completed($section, $course, $modinfo,
Expand Down Expand Up @@ -917,7 +930,6 @@ public function render_section_data(section_info $section, stdClass $course, $on
if ($course->coursetype == DESIGNER_TYPE_FLOW && count($modinfo->sections) <= 1) {
$sectioncollapsestatus = 'show';
}

// Calculate section width for single section format.
$section->widthclass = ($course->coursedisplay && !$this->page->user_is_editing() && !$onsectionpage && $sectionheader)
? $this->generate_section_widthclass($section) : '';
Expand Down Expand Up @@ -1094,7 +1106,6 @@ public function render_course_module($mod, $sectionreturn, $displayoptions = [],
$modclasses = 'activity ' . $mod->modname . ' modtype_' . $mod->modname . ' ' . $mod->extraclasses;

// Add course type flow animation class.
// TODO: check the animation settings.
if ($course->coursetype == DESIGNER_TYPE_FLOW && !$this->page->user_is_editing()) {
if ((isset($course->showanimation) && $course->showanimation)) {
$modclasses .= ' flow-animation ';
Expand Down
11 changes: 8 additions & 3 deletions lang/en/format_designer.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,10 @@
$string['courseduedate'] = 'Course due date';
$string['courseduedate_help'] = 'Course due date will shown in course timesection,
it only works when Learning tools and time management tool will be installed and enabled';
$string['activityprogress'] = 'Progress bar';
$string['activityprogress_help'] = 'The progress bar displays how many activities and prerequisites the student has already completed visually. A tooltip is provided to list the activities and prerequisites that are still "to do" and those that are already "completed"';
$string['activityprogress'] = 'Extended progress bar';
$string['activityprogress_help'] = '
The extended progress bar displays the progress of the student, based on the chosen calculation of course progress. Below the extended progress bar, the current progress is provided in text form (with support for Time Management due dates). A tooltip provides links to activities, prerequisites or sections.
';

$string['activity:icon'] = 'Activity icon';
$string['activity:visits'] = 'Activity visits';
Expand Down Expand Up @@ -267,6 +269,7 @@
$string['sectionsettings'] = 'Section';
$string['stractivity'] = 'Activity';
$string['strsection'] = "Section";
$string['strcourse'] = "Course";
$string['courseheader'] = 'Course header';
$string['popupactivitiesnotinstalled'] = 'Popup format must be installed in order to display the activities in popup.';
$string['listwidth'] = 'List width';
Expand Down Expand Up @@ -398,6 +401,7 @@
$string['courseprogresstype'] = 'Course Progress';
$string['calcourseprogress'] = "Calculation of course progress";
$string['calcourseprogress_help'] = "
<b> Completion criteria: </b> progress shall include all criteria that are conditions for course completion.<br>
<b> Relevant activities: </b> progress shall include only activities that are conditions for course completion.<br>
<b> All activities: </b> progress shall include all activities that have completion tracking configured.<br>
<b> Sections: </b> progress shall be based upon sections, not activities.<br>
Expand Down Expand Up @@ -550,4 +554,5 @@
$string['purposeclass'] = "Custom class for styling";
$string['sectionlink'] = 'Permalink';
$string['courseindicator'] = "Course status: ";
$string['strsectionlayout'] = "Section Layout";
$string['strsectionlayout'] = "Section Layout";
$string['completioncriteria'] = "Completion criteria";
53 changes: 24 additions & 29 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@

define('DESIGNER_CMPIND_METADATA', 'coursemetadata');

define('DESIGNER_PROGRESS_CRITERIA', 'criteria');

/**
* Main class for the Designer course format.
*
Expand Down Expand Up @@ -532,7 +534,13 @@ public static function course_format_options_list($foreditform = false) {
'default' => 0,
'type' => PARAM_INT,
],
];

// Include course header config.
if (format_designer_has_pro()) {
$courseformatoptions += (new local_designer\courseoptions($PAGE->course))->course_header_options_format_list();
}
$courseformatoptions += [
'coursecompletiondateinfo' => [
'default' => get_string('completiontrackingmissing', 'format_designer'),
'type' => PARAM_TEXT,
Expand All @@ -553,11 +561,6 @@ public static function course_format_options_list($foreditform = false) {
],
];

// Include course header config.
if (format_designer_has_pro()) {
$courseformatoptions += (new local_designer\courseoptions($PAGE->course))->course_header_options_format_list();
}

if (format_designer_has_pro() != 1 ) {
$userprofilefields = profile_get_user_fields_with_data(0);
if (!empty($userprofilefields)) {
Expand Down Expand Up @@ -907,6 +910,16 @@ public function designer_completion_enabled() {
return false;
}


/**
* Fetch the context of the current course.
*
* @return \context_course
*/
public function get_course_context() {
return $this->get_course() ? \context_course::instance($this->get_course()->id) : context_system::instance();
}

/**
* Adds format options elements to the course/section edit form.
*
Expand All @@ -920,6 +933,10 @@ public function create_edit_form_elements(&$mform, $forsection = false) {
global $COURSE, $PAGE, $CFG;

$elements = parent::create_edit_form_elements($mform, $forsection);
if (format_designer_has_pro()) {
// Update the pro fields course values strucuture, Prepare files.
local_designer\options::load_course_prepare_file($COURSE, $mform);
}
if (!$forsection && (empty($COURSE->id) || $COURSE->id == SITEID)) {
// Add "numsections" element to the create course form - it will force new course to be prepopulated
// with empty sections.
Expand Down Expand Up @@ -1580,30 +1597,8 @@ public function get_section_options(int $sectionid): array {
* @return stdClass
*/
public function get_course() {
global $CFG, $PAGE;
global $CFG, $PAGE, $DB;
$course = parent::get_course();
if ($PAGE->pagetype == 'course-edit') {
if (!isguestuser() && isloggedin()) {
if (isset($course->prerequisiteinfo) && is_string($course->prerequisiteinfo)) {
$coursecontext = context_course::instance($course->id);
$editoroptions = ['maxfiles' => -1, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'noclean' => true,
];
$editoroptions['context'] = $coursecontext;
$editoroptions['subdirs'] = file_area_contains_subdirs($coursecontext, 'local_designer', 'prerequisiteinfo', 0);
$course = file_prepare_standard_editor(
$course, 'prerequisiteinfo', $editoroptions,
$coursecontext, 'local_designer', 'prerequisiteinfo', 0
);
$course->prerequisiteinfo = $course->prerequisiteinfo_editor;
unset($course->prerequisiteinfo_editor);
}
} else {
$editoroptions['context'] = \context_system::instance();
$course = file_prepare_standard_editor(
$course, 'prerequisiteinfo', $editoroptions, null, 'local_designer', 'prerequisiteinfo', null,
);
}
}
// Course fields.
if (isset($course->coursefields)) {
$course->coursefields = is_string($course->coursefields) ? explode(',', $course->coursefields) : $course->coursefields;
Expand Down Expand Up @@ -1833,7 +1828,7 @@ function format_designer_coursemodule_standard_elements($formwrapper, $mform) {
$mform->addElement('select', $name, $title, $choice);
$mform->setType($name, PARAM_INT);
$mform->setDefault($name, $defalut);
if (isset($design->activityelements[$element]) && !empty($design->activityelements[$element])) {
if (isset($design->activityelements[$element])) {
$mform->setDefault($name, $design->activityelements[$element]);
}
$adv = 'activityelements_'.$element.'_adv';
Expand Down
1 change: 0 additions & 1 deletion templates/courseformat/courseindex/section.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
data-for="section"
data-id="{{id}}"
data-number="{{number}}"
role="treeitem"
aria-owns="courseindexcollapse{{number}}"
>
<div class="courseindex-item d-flex
Expand Down
6 changes: 1 addition & 5 deletions tests/behat/behat_format_designer.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ public function i_check_heroactivity_not_in_the_position($name, $pos): void {
* I set the completion.
*
* @Given /^I set the designer manual completion$/
* @throws DriverException The step is not available when Javascript is disabled
* @param string $selector
*/
public function i_set_the_manual_completion() {
global $CFG;
Expand All @@ -139,8 +137,7 @@ public function i_set_the_manual_completion() {
* I set the completion expected.
*
* @Given /^I set the designer completion expected "(?P<value>(?:[^"]|\\")*)"$/
* @throws DriverException The step is not available when Javascript is disabled
* @param string $selector
* @param string $value
*/
public function i_set_completion_expected($value) {
global $CFG;
Expand Down Expand Up @@ -341,5 +338,4 @@ public function i_turn_block_editing_mode_on() {
$this->execute('behat_general::i_click_on', ['Blocks editing on', 'button']);
}
}

}
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024031900; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2024052100; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2020061500; // Requires this Moodle version.
$plugin->component = 'format_designer'; // Full name of the plugin (used for diagnostics).
$plugin->release = 'Version 1.5';
Expand Down

0 comments on commit 54e552e

Please sign in to comment.