Skip to content

Commit 509bf1e

Browse files
committed
Implemented the task - CD-418 and Bug fixes - CD-417.
1 parent eb82f10 commit 509bf1e

16 files changed

+226
-92
lines changed

lang/en/local_learningtools.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,4 @@
246246
$string['strftimemonthnamedate'] = '%B %d, %Y';
247247
$string['subplugintype_ltool_plural'] = 'Learning Tools';
248248
$string['strbookmarked'] = "<i class='fa fa-bookmark'></i> Bookmarked";
249-
$string['strbookmark'] = "<i class='fa fa-bookmark'></i> Bookmark";
249+
$string['strbookmark'] = "<i class='fa fa-bookmark'></i> Bookmark";

ltool/bookmarks/amd/build/learningbookmarks.min.js

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

ltool/bookmarks/amd/build/learningbookmarks.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.

ltool/bookmarks/amd/src/learningbookmarks.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,22 +182,22 @@ define(['core/str', 'core/ajax', 'core/notification', 'jquery'],
182182
let bookmarkmarked = document.getElementById('bookmarks-marked');
183183
if (response.bookmarksstatus) {
184184
if (button) {
185-
button.addClass('active');
186-
button.addClass('btn-link');
187-
button.find('i').removeClass('fa-bookmark-o').addClass('fa-bookmark');
188-
String.get_string('strbookmarked', 'local_learningtools').then(function(langString) {
189-
button.html(langString);
185+
require(['mod_contentdesigner/elements'], function(Elements) {
186+
var chapterId = formData.itemid;
187+
if (chapterId) {
188+
Elements.refreshContent();
189+
}
190190
});
191191
} else {
192192
bookmarkmarked.classList.add('marked');
193193
}
194194
} else {
195195
if (button) {
196-
button.removeClass('active');
197-
button.removeClass('btn-link');
198-
button.find('i').removeClass('fa-bookmark').addClass('fa-bookmark-o');
199-
String.get_string('strbookmark', 'local_learningtools').then(function(langString) {
200-
button.html(langString);
196+
require(['mod_contentdesigner/elements'], function(Elements) {
197+
var chapterId = formData.itemid;
198+
if (chapterId) {
199+
Elements.refreshContent();
200+
}
201201
});
202202
} else {
203203
bookmarkmarked.classList.remove('marked');

ltool/bookmarks/classes/bookmarkstool_filter.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,41 @@
3333
*/
3434
class bookmarkstool_filter {
3535

36+
/**
37+
* @var int
38+
*/
39+
public $userid;
40+
41+
/**
42+
* @var int
43+
*/
44+
public $courseid;
45+
46+
/**
47+
* @var int
48+
*/
49+
public $child;
50+
51+
/**
52+
* @var array
53+
*/
54+
public $urlparams;
55+
56+
/**
57+
* @var int
58+
*/
59+
public $teacher;
60+
61+
/**
62+
* @var string
63+
*/
64+
public $baseurl;
65+
66+
/**
67+
* @var string
68+
*/
69+
public $pageurl;
70+
3671
/**
3772
* Loads bookmarks tools info.
3873
* @param int $userid current userid

ltool/bookmarks/lib.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
defined('MOODLE_INTERNAL') || die();
2727

2828
require_once($CFG->dirroot. '/local/learningtools/lib.php');
29+
2930
/**
3031
* Defines ltool bookmarks nodes for my profile navigation tree.
3132
*
@@ -119,6 +120,8 @@ function ltool_bookmarks_user_save_bookmarks($contextid, $data) {
119120
if ($itemtype == 'chapter') {
120121
$sql .= " AND itemtype = ? AND itemid = ?";
121122
$params = array_merge($params , [$itemtype, $itemid]);
123+
} else {
124+
$sql .= " AND itemtype = ''";
122125
}
123126
$bookrecord = $DB->get_record_sql($sql, $params);
124127

@@ -167,6 +170,8 @@ function ltool_bookmarks_user_save_bookmarks($contextid, $data) {
167170
if ($itemtype == 'chapter') {
168171
$selectdelete .= " AND itemtype = ? AND itemid = ?";
169172
$deletedparams = array_merge($deletedparams, [$itemtype, $itemid]);
173+
} else {
174+
$selectdelete .= " AND itemtype = ''";
170175
}
171176
$DB->delete_records_select('ltool_bookmarks_data', $selectdelete, $deletedparams);
172177
// Add event to user delete the bookmark.
@@ -247,7 +252,8 @@ function ltool_bookmarks_check_page_bookmarks_exist($contextid, $pageurl, $useri
247252
FROM {ltool_bookmarks_data}
248253
WHERE " . $DB->sql_compare_text('pageurl', 255). " = " . $DB->sql_compare_text('?', 255) . "
249254
AND contextid = ?
250-
AND userid = ?";
255+
AND userid = ?
256+
AND itemtype = ''";
251257
$params = array($pageurl, $contextid, $userid);
252258
if ($DB->record_exists_sql($sql, $params)) {
253259
$pagebookmarks = true;

0 commit comments

Comments
 (0)