Skip to content

Commit 58f2f08

Browse files
committed
Content designer 1.5 behat features improved.
1 parent d5ae1bb commit 58f2f08

File tree

16 files changed

+297
-40
lines changed

16 files changed

+297
-40
lines changed

.github/workflows/moodle-ci.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [push, pull_request]
44

55
jobs:
66
test:
7-
runs-on: ubuntu-22.04
7+
runs-on: ubuntu-latest
88

99
services:
1010
postgres:
@@ -28,18 +28,18 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
include:
31-
- php: '7.4'
32-
moodle-branch: 'MOODLE_401_STABLE'
31+
- php: '8.3'
32+
moodle-branch: 'MOODLE_405_STABLE'
3333
database: 'mariadb'
34-
- php: '8.1'
35-
moodle-branch: 'MOODLE_403_STABLE'
34+
- php: '8.3'
35+
moodle-branch: 'MOODLE_405_STABLE'
3636
database: 'pgsql'
3737
- php: '8.2'
3838
moodle-branch: 'MOODLE_404_STABLE'
3939
database: 'mariadb'
40-
- php: '8.3'
41-
moodle-branch: 'MOODLE_405_STABLE'
42-
database: 'mariadb'
40+
- php: '8.2'
41+
moodle-branch: 'MOODLE_404_STABLE'
42+
database: 'pgsql'
4343
steps:
4444
- name: Check out repository code
4545
uses: actions/checkout@v2
@@ -62,6 +62,7 @@ jobs:
6262
6363
- name: Install moodle-plugin-ci
6464
run: |
65+
moodle-plugin-ci add-plugin --clone https://github.com/bdecentgmbh/moodle-local_learningtools.git --branch dev
6566
moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
6667
env:
6768
DB: ${{ matrix.database }}

amd/build/anime.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/build/editor.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/build/elements.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/src/elements.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ define(['jquery', 'core/fragment', 'core/templates', 'core/loadingicon', 'mod_co
9090
var filterChapter = [];
9191

9292
chapters.forEach((chapter) => {
93-
9493
var elementSelector = 'li.element-item[data-instanceid="' + chapter.dataset.instanceid + '"]';
9594
elementSelector += '[data-elementshortname="' + chapter.dataset.elementshortname + '"]';
9695
let chapterSelector = 'li.chapters-list[data-id="' + chapter.dataset.id + '"]';

cdelement/chapter/classes/element.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
namespace cdelement_chapter;
2626

27+
defined('MOODLE_INTERNAL') || die();
28+
2729
use mod_contentdesigner\editor;
2830
use moodle_exception;
2931

@@ -106,7 +108,8 @@ public function element_form(&$mform, $formobj) {
106108
1 => get_string('enabled', 'mod_contentdesigner'),
107109
];
108110
$default = get_config('cdelement_chapter', 'learningtools');
109-
$mform->addElement('select', 'learningtools', get_string('learningtools', 'mod_contentdesigner'), $learningtoolsoptions);
111+
$mform->addElement('select', 'learningtools', get_string('learningtools', 'mod_contentdesigner'),
112+
$learningtoolsoptions);
110113
$mform->addHelpButton('learningtools', 'learningtools', 'mod_contentdesigner');
111114
$mform->setDefault('learningtools', $default);
112115
}
@@ -387,6 +390,7 @@ public function generate_chapter_content($chapter, $visible=false, $render=false
387390
$list = [];
388391
$prevent = false;
389392
$record = $DB->get_record('contentdesigner', ['id' => $this->cm->instance]);
393+
$url = new \moodle_url('/mod/contentdesigner/view.php', ['id' => $this->cm->id]);
390394

391395
// Learning tools data.
392396
$learningtools = [
@@ -400,16 +404,17 @@ public function generate_chapter_content($chapter, $visible=false, $render=false
400404
'coursemodule' => $this->cm->id,
401405
'contextlevel' => CONTEXT_MODULE,
402406
'pagetype' => $PAGE->pagetype,
407+
'pageurl' => $url ."#chapters-list-" . $chapter->id,
403408
];
404409

405-
// Check if learning tools should be displayed
410+
// Check if learning tools should be displayed.
406411
if (!empty($chapter->learningtools)) {
407412
$context = \context_module::instance($this->cmid);
408-
$hasBookmarkCapability = has_capability('ltool/bookmarks:createbookmarks', $context);
409-
$hasNotesCapability = has_capability('ltool/note:createnote', $context);
413+
$hasbookmarkcapability = has_capability('ltool/bookmarks:createbookmarks', $context);
414+
$hasnotescapability = has_capability('ltool/note:createnote', $context);
410415

411-
// Only show learning tools if user has at least one capability
412-
if ($hasBookmarkCapability || $hasNotesCapability) {
416+
// Only show learning tools if user has at least one capability.
417+
if ($hasbookmarkcapability || $hasnotescapability) {
413418
$learningtools['show'] = true;
414419
// Check if the chapter is bookmarked by the user.
415420
$learningtools['bookmarked'] = $DB->record_exists('ltool_bookmarks_data', [
@@ -622,11 +627,11 @@ public function delete_element($instanceid) {
622627
// Deleted the Learningtools bookmarks and notes data.
623628
if ($dbman->table_exists('ltool_bookmarks_data')) {
624629
$DB->delete_records('ltool_bookmarks_data', ['itemid' => $instanceid, 'itemtype' => 'chapter']);
625-
}
630+
}
626631

627632
if ($dbman->table_exists('ltool_note_data')) {
628633
$DB->delete_records('ltool_note_data', ['itemid' => $instanceid, 'itemtype' => 'chapter']);
629-
}
634+
}
630635
if ($contents = $DB->get_records('contentdesigner_content', ['chapter' => $instanceid])) {
631636
foreach ($contents as $key => $value) {
632637
$element = editor::get_element($value->element, $this->cmid);

cdelement/chapter/db/upgrade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function xmldb_cdelement_chapter_upgrade($oldversion) {
8686
mod_contentdesigner\plugininfo\cdelement::update_plugins_config('element_chapter', 'cdelement_chapter');
8787
}
8888

89-
if ($oldversion < 2025041500) {
89+
if ($oldversion && $oldversion < 2025041500) {
9090
// Define field learningtools to be added to cdelement_chapter.
9191
$table = new xmldb_table('cdelement_chapter');
9292
$field = new xmldb_field('learningtools', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'visible');

cdelement/chapter/lib.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ function cdelement_chapter_output_fragment_update_progressbar($args) {
4040
}
4141
}
4242

43-
43+
/**
44+
* Check if the learning tools plugin is installed.
45+
*
46+
* @return bool True if the learning tools plugin is installed, false otherwise.
47+
*/
4448
function cdelement_chapter_has_learningtools() {
4549
return array_key_exists('learningtools', \core_component::get_plugin_list('local'));
4650
}

cdelement/chapter/styles.css

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
.contentdesigner-content .contentdesigner-wrapper .course-content-list li.chapters-list {
22
&.completed {
3-
&:has(.content-designer-learningtool-bookmark.active),
4-
&:has(.content-designer-learningtool-note.active) {
5-
border-color: #44ab58;
6-
}
3+
border-color: #44ab58;
74
}
8-
&:has(.content-designer-learningtool-bookmark.active),
9-
&:has(.content-designer-learningtool-note.active) {
5+
&:not(.completed):has(.content-designer-learningtool-bookmark.active),
6+
&:not(.completed):has(.content-designer-learningtool-note.active) {
107
border-color: #d3d3d3;
118
}
129
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
@mod @mod_contentdesigner @cdelement_chapter @chapter_bookmark @javascript
2+
Feature: Check content designer chapter element bookmark tool support
3+
4+
Background:
5+
Given the following "users" exist:
6+
| username | firstname | lastname | email |
7+
| teacher1 | Teacher | 1 | teacher1@example.com |
8+
| student1 | Student | 1 | student1@example.com |
9+
And the following "courses" exist:
10+
| fullname | shortname | category |
11+
| Course 1 | C1 | 0 |
12+
And the following "course enrolments" exist:
13+
| user | course | role |
14+
| teacher1 | C1 | editingteacher |
15+
| student1 | C1 | student |
16+
And the following "activity" exists:
17+
| activity | contentdesigner |
18+
| name | Demo content |
19+
| intro | Contentdesigner Description |
20+
| course | C1 |
21+
And I log out
22+
And I am on the "Demo content" "contentdesigner activity" page logged in as teacher1
23+
And I click on "Content editor" "link"
24+
And I click on ".contentdesigner-addelement .fa-plus" "css_element"
25+
And I click on ".elements-list li[data-element=chapter]" "css_element" in the ".modal-body" "css_element"
26+
And I set the following fields to these values:
27+
| Title | First chapter |
28+
| Display title | 1 |
29+
| Visibility | Visible |
30+
| Learning Tools | Enabled |
31+
And I press "Create element"
32+
And I click on "Content editor" "link"
33+
And I click on ".contentdesigner-addelement .fa-plus" "css_element"
34+
And I click on ".elements-list li[data-element=paragraph]" "css_element" in the ".modal-body" "css_element"
35+
And I set the following fields to these values:
36+
| Content | Lorem Ipsum is simply dummy text of the printing and typesetting industry.|
37+
| Title | Paragraph 01 |
38+
And I press "Create element"
39+
And I log out
40+
41+
@javascript
42+
Scenario: Learning tool status checked in chapter element settings.
43+
Given I am on the "Demo content" "contentdesigner activity" page logged in as teacher1
44+
And I click on "Content Designer" "link"
45+
Then I should see "First chapter"
46+
Then I should see "Bookmark" in the ".toolbar-block" "css_element"
47+
Then I should see "Notes" in the ".toolbar-block" "css_element"
48+
And I click on "Content editor" "link"
49+
And I click on ".element-item[data-elementshortname=chapter] .actions-list li[data-action=edit] a" "css_element"
50+
And I set the following fields to these values:
51+
| Title | First chapter - Learning tool disabled |
52+
| Learning Tools | Disabled |
53+
And I press "Update element"
54+
And I click on "Content Designer" "link"
55+
Then I should see "First chapter - Learning tool disabled"
56+
Then I should not see "Bookmark" in the ".toolbar-block" "css_element"
57+
Then I should not see "Notes" in the ".toolbar-block" "css_element"
58+
59+
@javascript
60+
Scenario: Learning tool status checked in chapter element general settings.
61+
Given I log in as "admin"
62+
And I navigate to "Plugins > Activity modules > Content Designer" in site administration
63+
And I set the field "Learning Tools" to "Enabled"
64+
And I press "Save changes"
65+
And I log out
66+
And I am on the "Demo content" "contentdesigner activity" page logged in as teacher1
67+
And I click on "Content editor" "link"
68+
And I click on ".contentdesigner-addelement .fa-plus" "css_element"
69+
And I click on ".elements-list li[data-element=chapter]" "css_element" in the ".modal-body" "css_element"
70+
And I set the following fields to these values:
71+
| Title | Second chapter |
72+
| Display title | 1 |
73+
| Visibility | Visible |
74+
And I press "Create element"
75+
And I am on the "Demo content" "contentdesigner activity" page logged in as teacher1
76+
And I click on "Content Designer" "link"
77+
Then I should see "First chapter"
78+
Then I should see "Bookmark" in the ".chapters-list:nth-child(2) .toolbar-block .content-designer-learningtool-bookmark" "css_element"
79+
Then I should see "Notes" in the ".chapters-list:nth-child(2) .toolbar-block .content-designer-learningtool-note" "css_element"
80+
And I click on "Content editor" "link"
81+
And I click on ".chapters-list:nth-child(2) .element-item[data-elementshortname='chapter'] .actions-list li[data-action=edit] a" "css_element"
82+
And I set the following fields to these values:
83+
| Title | Second chapter - Learning tool disabled |
84+
| Learning Tools | Disabled |
85+
And I press "Update element"
86+
And I click on "Content Designer" "link"
87+
Then I should see "Second chapter - Learning tool disabled"
88+
Then I should not see "Bookmark" in the ".chapters-list:nth-child(2) .toolbar-block" "css_element"
89+
Then I should not see "Notes" in the ".chapters-list:nth-child(2) .toolbar-block" "css_element"
90+
91+
@javascript
92+
Scenario: Use bookmark tool for chapter element content.
93+
Given I am on the "Demo content" "contentdesigner activity" page logged in as student1
94+
Then I should see "Bookmark" in the ".toolbar-block" "css_element"
95+
# Add a bookmark.
96+
And I click on "Bookmark" "button" in the ".toolbar-block" "css_element"
97+
Then I should see "Bookmarked" in the ".toolbar-block" "css_element"
98+
Then I should see "This chapter bookmarked successfully and you can view the bookmarks under profile / learning tools / bookmarks."
99+
Then I follow "Profile" in the user menu
100+
And I click on "Bookmarks" "link"
101+
Then I should see "C1: Demo content | Acceptance test site | First chapter" in the ".course-item" "css_element"
102+
Then I should see "View Chapter" in the ".button-block" "css_element"
103+
Then I should see "Course 1 / General" in the ".category-item" "css_element"
104+
And I click on "View Chapter" "button" in the ".button-block" "css_element"
105+
Then I should see "Demo content"
106+
Then I should see "First chapter"
107+
Then I should see "Bookmarked" in the ".toolbar-block" "css_element"
108+
# Remove a bookmark.
109+
And I click on "Bookmarked" "button" in the ".toolbar-block" "css_element"
110+
Then I should see "This chapter bookmark removed and you can view the bookmarks under profile / learning tools / bookmarks."
111+
Then I follow "Profile" in the user menu
112+
And I click on "Bookmarks" "link"
113+
Then I should not see "C1: Demo content"
114+
Then I should not see "C1: Demo content | Acceptance test site | First chapter"
115+
Then I should not see "View Chapter"
116+
And I log out

0 commit comments

Comments
 (0)