Skip to content

Commit

Permalink
Fixed the Moodle plugin CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
vasanthlmsace committed Mar 13, 2024
1 parent f698c87 commit 6b9b6f8
Show file tree
Hide file tree
Showing 11 changed files with 159 additions and 64 deletions.
6 changes: 3 additions & 3 deletions classes/output/courseformat/content/cm/controlmenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public function get_action_menu(\renderer_base $output): ?action_menu {
$controls = $this->cm_control_items();

if (empty($controls) || (isset($mod->get_course()->coursedisplay) &&
$mod->get_course()->coursedisplay== COURSE_DISPLAY_MULTIPAGE)) {
$mod->get_course()->coursedisplay == COURSE_DISPLAY_MULTIPAGE)) {
return null;
}

// Convert control array into an action_menu.
$menu = new action_menu();
if (method_exists($menu, 'set_kebab_trigger')) {;
if (method_exists($menu, 'set_kebab_trigger')) {
$menu->set_kebab_trigger(get_string('edit'));
} else {
$icon = $output->pix_icon('i/menu', get_string('edit'));
Expand All @@ -86,4 +86,4 @@ public function get_action_menu(\renderer_base $output): ?action_menu {

return $menu;
}
}
}
11 changes: 8 additions & 3 deletions classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,16 @@ public function render_content($widget) {
$startclass[] = 'kanban-board';
$data->kanbanmode = true;
}
$data->startclass = implode(' ', $startclass);
$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);
}
if (format_designer_has_pro()) {
$startclass[] = ($course->activitydisplaymode == 'bypurpose') ? 'activity-purpose-mode' : 'activity-default-mode';
}
$data->startclass = implode(' ', $startclass);
return $this->render_from_template('format_designer/courseformat/content/section', $data);
}

Expand Down Expand Up @@ -393,7 +396,8 @@ public function completioninfo_icon(\completion_info $completioninfo) {
public static function get_course_completion_indicator($course) {
global $USER;

$progress = \core_completion\progress::get_course_progress_percentage($course, $USER->id);
$courseprogress = self::criteria_progress($course, $USER->id);
$progress = isset($courseprogress['percent']) ? $courseprogress['percent'] : 0;
$context = context_course::instance($course->id);
$status = "";
$class = "";
Expand Down Expand Up @@ -1026,7 +1030,8 @@ public function render_section_data(section_info $section, stdClass $course, $on
);
}
if (format_designer_has_pro()) {
$sectionbackgroundcolor = isset($section->sectiondesignerbackgroundcolor) ? $section->sectiondesignerbackgroundcolor : '';
$sectionbackgroundcolor = isset($section->sectiondesignerbackgroundcolor) ?
$section->sectiondesignerbackgroundcolor : '';
$templatecontext += \local_designer\courseheader::create($format)
->section_progress_type(round($sectionprogress), $sectionprogresscomp, $sectionbackgroundcolor);
}
Expand Down
46 changes: 35 additions & 11 deletions editsection_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class editsection_form extends moodleform {
* Definition of the form
*/
public function definition() {

global $CFG, $OUTPUT;
$mform = $this->_form;
$course = $this->_customdata['course'];
$sectioninfo = $this->_customdata['cs'];
Expand Down Expand Up @@ -68,6 +68,28 @@ public function definition() {
if (!empty($formatoptions)) {
$elements = $courseformat->create_edit_form_elements($mform, true);
}
// Check the moodle 4.3 higher.
if ($CFG->version >= 2023092300 && !empty($CFG->enableavailability)) {

$mform->addElement('header', 'availabilityconditions',
get_string('restrictaccess', 'availability'));
$mform->setExpanded('availabilityconditions', false);

// Availability field. This is just a textarea; the user interface
// interaction is all implemented in JavaScript. The field is named
// availabilityconditionsjson for consistency with moodleform_mod.
$mform->addElement('textarea', 'availabilityconditionsjson',
get_string('accessrestrictions', 'availability'),
['class' => 'd-none']
);
// Availability loading indicator.
$loadingcontainer = $OUTPUT->container(
$OUTPUT->render_from_template('core/loading', []),
'd-flex justify-content-center py-5 icon-size-5',
'availabilityconditions-loading'
);
$mform->addElement('html', $loadingcontainer);
}

$mform->_registerCancelButton('cancel');
}
Expand All @@ -80,18 +102,20 @@ public function definition_after_data() {

$mform = $this->_form;
$course = $this->_customdata['course'];
$context = context_course::instance($course->id);

if (!empty($CFG->enableavailability)) {
$mform->addElement('header', 'availabilityconditions',
get_string('restrictaccess', 'availability'));
$mform->setExpanded('availabilityconditions', false);

// Availability field. This is just a textarea; the user interface
// interaction is all implemented in JavaScript. The field is named
// availabilityconditionsjson for consistency with moodleform_mod.
$mform->addElement('textarea', 'availabilityconditionsjson',
get_string('accessrestrictions', 'availability'));
// Check the moodle 4.3 lower.
if ($CFG->version < 2023092300) {
$mform->addElement('header', 'availabilityconditions',
get_string('restrictaccess', 'availability'));
$mform->setExpanded('availabilityconditions', false);

// Availability field. This is just a textarea; the user interface
// interaction is all implemented in JavaScript. The field is named
// availabilityconditionsjson for consistency with moodleform_mod.
$mform->addElement('textarea', 'availabilityconditionsjson',
get_string('accessrestrictions', 'availability'));
}
\core_availability\frontend::include_all_javascript($course, null,
$this->_customdata['cs']);
}
Expand Down
43 changes: 24 additions & 19 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1580,28 +1580,29 @@ public function get_section_options(int $sectionid): array {
* @return stdClass
*/
public function get_course() {
global $CFG;
global $CFG, $PAGE;
$course = parent::get_course();

if (!isguestuser()) {
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);
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,
$coursecontext, 'local_designer', 'prerequisiteinfo', 0
$course, 'prerequisiteinfo', $editoroptions, null, 'local_designer', 'prerequisiteinfo', null,
);
$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)) {
Expand All @@ -1614,7 +1615,7 @@ public function get_course() {
$course->timemanagement = is_string($timemanagement) ? explode(',', $timemanagement) : $timemanagement;
}

if (format_designer_has_pro()) {
if ($PAGE->pagetype == 'course-edit' && format_designer_has_pro()) {
// Update the pro fields course values strucuture, Prepare files.
local_designer\options::update_structure_get_course($course);
}
Expand Down Expand Up @@ -1992,6 +1993,10 @@ function format_designer_editsetting_style($page) {
.dropdown-menu {';
$style .= 'right: 100% !important;';
$style .= '}';
$style .= '.format-designer .course-content ul.designer.kanban-board li.section#section-1 .right .dropdown
.dropdown-menu .dropdown-subpanel .dropdown-menu {';
$style .= 'right: 40px !important;';
$style .= '}';
echo html_writer::tag('style', $style, []);
}
}
Expand Down
3 changes: 1 addition & 2 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2401,6 +2401,7 @@ body.format-designer.editing .designer .section .content .section.card-layout li
margin: 0;
}
.format-designer .course-content ul.designer.kanban-board .kanban-board-activities {
padding-top: 25px;
overflow: auto;
display: flex;
}
Expand Down Expand Up @@ -2528,7 +2529,6 @@ body.format-designer.editing .designer .section .content .section.card-layout li
height: 50px;
}
.format-designer .designer .section.img-text.card-layout .activity.videotime.preview_mode .activity-block

.img-element .bg-overlay .img-block {
width: 50px;
height: 50px;
Expand Down Expand Up @@ -2809,7 +2809,6 @@ body.format-designer.editing .designer .section .content .section.card-layout li
}
.format-designer .designer .section .content .section.img-text.card-layout li.activity .action-html-card,
.format-designer .designer .section.img-text.card-layout .activity.videotime.preview_mode

.activity-block .badge.video-duration {
float: right;
position: static;
Expand Down
2 changes: 1 addition & 1 deletion templates/section_layout.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ data-target="{{#sectioncardcontentdirect}}_blank{{/sectioncardcontentdirect}}" d
{{^sectionprogresscomp}}
<div class="section-progress-bar">
<div class="progress">
<div class="progress-bar progress-bg-success" role="progressbar" style= "width: {{sectionprogress}}%" aria-valuenow="{{sectionprogress}}" aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar{{#sectionprogress}} progress-bg-success{{/sectionprogress}}{{^sectionprogress}} progress-not-started{{/sectionprogress}}" role="progressbar" style= "width: {{sectionprogress}}%" aria-valuenow="{{sectionprogress}}" aria-valuemin="0" aria-valuemax="100">
<span class="percentage">{{sectionprogress}}%</span>
</div>
</div>
Expand Down
6 changes: 2 additions & 4 deletions tests/behat/activity_completion_element.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Feature: Sections can be check activity completion element in designer format
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I edit the section "0" to layout "list"
Then I check the section "0" to layout "list"
Then "#section-0.section-type-list" "css_element" should exist
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| Enable completion tracking | Yes |
Expand All @@ -41,15 +41,13 @@ Feature: Sections can be check activity completion element in designer format
Scenario: Check the manual mark completion the activity
Given I am on the "Test assignment name" "assign activity editing" page logged in as teacher1
And I expand all fieldsets
And I set the following fields to these values:
| completion | 1 |
Then I set the designer manual completion
And I press "Save and return to course"
And I log out
And I log in as "student1"
And I am on "Course 1" course homepage
And I check the activity "assign1" to element "/descendant::div[contains(@class, 'notstarted')]"
And I am on "Course 1" course homepage
#When I toggle assignment manual completion designer "Test assignment name" "assign1"
And the manual completion button of "Test assignment name" is displayed as "Mark as done"
And I toggle the manual completion state of "Test assignment name"
And I am on "Course 1" course homepage
Expand Down
67 changes: 54 additions & 13 deletions tests/behat/behat_format_designer.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,32 @@ class behat_format_designer extends behat_base {
*/
public function i_edit_the_section_layout($sectionnumber, $layouttype) {
// If javascript is on, link is inside a menu.
if ($this->running_javascript()) {
$this->i_open_section_layout_edit_menu($sectionnumber);
}
global $CFG;
// Lower 4.3.
if ($CFG->version < 2023092300) {
if ($this->running_javascript()) {
$this->i_open_section_layout_edit_menu($sectionnumber);
}

// We need to know the course format as the text strings depends on them.
if (get_string_manager()->string_exists($layouttype, 'format_designer')) {
$strlayout = get_string($layouttype, 'format_designer');
// We need to know the course format as the text strings depends on them.
if (get_string_manager()->string_exists($layouttype, 'format_designer')) {
$strlayout = get_string($layouttype, 'format_designer');
} else {
$strlayout = get_string('link', 'format_designer');
}
$xpath = $this->execute("behat_course::section_exists", $sectionnumber);
$xpath .= "/descendant::div[contains(@id, 'section-designer-action')]/descendant::
div[contains(@class, 'dropdown-menu')]";
// Click on layout link.
$this->execute('behat_general::i_click_on_in_the',
[$strlayout, "link", $this->escape($xpath), "xpath_element"]
);
} else {
$strlayout = get_string('link', 'format_designer');
$this->execute('behat_course::i_open_section_edit_menu', [$sectionnumber]);
$actionmenu = "Section Layout > ". get_string($layouttype, 'format_designer');
$this->execute('behat_action_menu::i_choose_in_the_open_action_menu', [$actionmenu]);
$this->execute('behat_general::reload', []);
}
$xpath = $this->execute("behat_course::section_exists", $sectionnumber);
$xpath .= "/descendant::div[contains(@id, 'section-designer-action')]/descendant::div[contains(@class, 'dropdown-menu')]";
// Click on layout link.
$this->execute('behat_general::i_click_on_in_the',
[$strlayout, "link", $this->escape($xpath), "xpath_element"]
);
}

/**
Expand Down Expand Up @@ -109,6 +119,37 @@ 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
*/
public function i_set_the_manual_completion() {
global $CFG;
if ($CFG->version < 2023092300) {
$this->execute("behat_forms::i_set_the_field_to", ['completion', 1]);
} else {
$this->execute("behat_forms::i_set_the_field_to", ['Students must manually mark the activity as done', 1]);
}
}

/**
* 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 $value
*/
public function i_set_completion_expected($value) {
global $CFG;
if ($CFG->version < 2023092300) {
$this->execute("behat_forms::i_set_the_field_to", ['Expect completed on', $value]);
} else {
$this->execute("behat_forms::i_set_the_field_to", ['Set reminder in Timeline', $value]);
}
}

/**
* Opens a section edit menu if it is not already opened.
*
Expand Down
27 changes: 27 additions & 0 deletions tests/behat/course_progress_bar.feature
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,30 @@ Feature: Course progress bar checking criteria in designer format
And the manual completion button of "Demo assign 02" is displayed as "Mark as done"
And I toggle the manual completion state of "Demo assign 02"
And I should see "4 of 4 criteria completed" in the ".progress-block .activity-completed-block" "css_element"

Scenario: Display the course completion progress sorted by completion date
Given I log in as "admin"
And I am on "Course 1" course homepage
And I click on "Settings" "link" in the ".secondary-navigation" "css_element"
And I expand all fieldsets
And I set the field "Format" to "Designer format"
And I press "Save and display"
And I am on "Course 1" course homepage
And I turn block editing mode on
And I am on the "Test assignment name" "assign activity" page
And I click on "Settings" "link" in the ".secondary-navigation" "css_element"
And I expand all fieldsets
And I set the following fields to these values:
| id_completionexpected_enabled | 1 |
Then I set the designer completion expected "##1 Feb 2024 08:00##"
And I press "Save and display"
And I log out
And I am on the "Course 1" course page logged in as student1
And I am on the "Test assignment name 1" "assign activity" page
And I press "Mark as done"
And I am on "Course 1" course homepage
Then ".completion-info .badge-success" "css_element" should exist
And I am on the "Test assignment name" "assign activity" page
And I press "Mark as done"
And I am on "Course 1" course homepage
Then ".completion-info .badge-due-success" "css_element" should exist
10 changes: 3 additions & 7 deletions tests/behat/switching_layout_sections.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,11 @@ Feature: Sections can be switch the layouts in designer format
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on

Scenario: View the able to change the section layout
Given "#section-0" "css_element" should be visible
Then "#section-0 #section-designer-action button" "css_element" should be visible

Scenario: Check the switch the section layout
Given "#section-0" "css_element" should be visible
And I edit the section "0" to layout "list"
Then I check the section "0" to layout "list"
Then "#section-0.section-type-list" "css_element" should exist
And I edit the section "0" to layout "cards"
Then I check the section "0" to layout "card"
Then "#section-0.section-type-cards" "css_element" should exist
And I edit the section "0" to layout "link"
Then I check the section "0" to layout "link"
Then "#section-0.section-type-default" "css_element" should exist
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 = 2024022601; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2024022600; // 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 6b9b6f8

Please sign in to comment.