Skip to content

Commit

Permalink
Merge pull request #29 from bdecentgmbh/dev
Browse files Browse the repository at this point in the history
Call it 1.2
  • Loading branch information
stefanscholz authored Dec 12, 2024
2 parents c5d7e21 + 851763e commit 1c01a3c
Show file tree
Hide file tree
Showing 24 changed files with 213 additions and 45 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04

services:
postgres:
image: postgres:12.7
image: postgres:13
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
mariadb:
image: mariadb:10.5
image: mariadb:10.6.7
env:
MYSQL_USER: 'root'
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
Expand All @@ -28,15 +28,12 @@ jobs:
fail-fast: false
matrix:
include:
- php: '8.0'
moodle-branch: 'master'
- php: '8.3'
moodle-branch: 'MOODLE_405_STABLE'
database: 'pgsql'
- php: '7.4'
moodle-branch: 'master'
- php: '8.2'
moodle-branch: 'MOODLE_405_STABLE'
database: 'mariadb'
- php: '7.4'
moodle-branch: 'master'
database: 'pgsql'

steps:
- name: Check out repository code
Expand Down
2 changes: 1 addition & 1 deletion classes/plugininfo/ltool.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $h
return;
}

if (!$hassiteconfig or !file_exists($this->full_path('settings.php'))) {
if (!$hassiteconfig || !file_exists($this->full_path('settings.php'))) {
return;
}

Expand Down
2 changes: 2 additions & 0 deletions lang/en/local_learningtools.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,5 @@
$string['strftimemonthdateyear'] = '%B, %dth %Y';
$string['strftimeyearmonth'] = '%Y/%m/%d';
$string['strftimemonthnamedate'] = '%B %d, %Y';
$string['subplugintype_ltool'] = "Learning Tools";
$string['subplugintype_ltool_plural'] = "ltools";
18 changes: 12 additions & 6 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function local_learningtools_get_coursemodule_id($record) {
global $DB;

$contextinfo = $DB->get_record('context', array('id' => $record->contextid, 'contextlevel' => $record->contextlevel));
return $contextinfo->instanceid;
return isset($contextinfo->instanceid) ? $contextinfo->instanceid : 0;
}
/**
* Get the courses name.
Expand Down Expand Up @@ -221,13 +221,19 @@ function local_learningtools_get_course_categoryname($courseid) {
function local_learningtools_get_module_name($data, $mod = false) {
global $DB;
$coursemoduleinfo = $DB->get_record('course_modules', array('id' => $data->coursemodule));
if (empty($coursemoduleinfo)) {
return "";
}
$moduleinfo = $DB->get_record('modules', array('id' => $coursemoduleinfo->module));
if ($mod) {
return $moduleinfo->name;
if ($moduleinfo) {
if ($mod) {
return $moduleinfo->name;
}
// Get module instance name.
$report = get_coursemodule_from_instance($moduleinfo->name, $coursemoduleinfo->instance, $data->courseid);
return $report->name;
}
// Get module instance name.
$report = get_coursemodule_from_instance($moduleinfo->name, $coursemoduleinfo->instance, $data->courseid);
return $report->name;
return "";
}


Expand Down
35 changes: 35 additions & 0 deletions ltool/bookmarks/classes/bookmarkstool_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,41 @@
*/
class bookmarkstool_filter {

/**
* @var int
*/
public $userid;

/**
* @var int
*/
public $courseid;

/**
* @var int
*/
public $child;

/**
* @var array
*/
public $urlparams;

/**
* @var int
*/
public $teacher;

/**
* @var string
*/
public $baseurl;

/**
* @var string
*/
public $pageurl;

/**
* Loads bookmarks tools info.
* @param int $userid current userid
Expand Down
1 change: 1 addition & 0 deletions ltool/bookmarks/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
defined('MOODLE_INTERNAL') || die();

require_once($CFG->dirroot. '/local/learningtools/lib.php');

/**
* Defines ltool bookmarks nodes for my profile navigation tree.
*
Expand Down
2 changes: 2 additions & 0 deletions ltool/bookmarks/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
}
.bookmarks-list-info .activity-block .course-element .course-list .right-block {
margin-left: 30px;
justify-content: end;
}
.bookmarks-list-info .activity-block .course-element .course-list .right-block .calendar-block {
margin-right: 30px;
Expand All @@ -107,6 +108,7 @@
margin-right: 0;
}
.bookmarks-list-info .activity-block .course-element .course-list .right-block .button-block button {
min-width: 100px;
height: auto;
color: #fff;
font-size: 13px;
Expand Down
18 changes: 17 additions & 1 deletion ltool/bookmarks/tests/ltool_bookmarks_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,26 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace ltool_bookmarks;

/**
* Bookmarks subplugin for learningtools phpunit test cases defined.
* @runTestsInSeparateProcesses
*/
class ltool_bookmarks_test extends \advanced_testcase {


/**
* Summary of context
* @var object
*/
public $page;

/**
* Summary of context
* @var object
*/
public $context;

/**
* Create custom page instance and set admin user as loggedin user.
*
Expand All @@ -52,7 +67,8 @@ public function setup(): void {

/**
* Case to test the external method to create/delete bookmarks.
* @covers ::ltool_bookmarks_check_page_bookmarks_exist
* @covers \ltool_bookmarks\external::save_userbookmarks
* @runInSeparateProcess
* @return void
*/
public function test_external_test(): void {
Expand Down
2 changes: 1 addition & 1 deletion ltool/bookmarks/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'ltool_bookmarks';
$plugin->version = 2022022800;
$plugin->version = 2024120300;
$plugin->requires = 2020061501;


3 changes: 2 additions & 1 deletion ltool/focus/tests/behat/behat_focus.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ public function i_check_focus_mode_enable(): void {
$footerjs = "
return (
Y.one('#page-footer') &&
Y.one('#page-footer').getComputedStyle('display') === 'none'
Y.one('#page-footer').getComputedStyle('display') == 'none'
)
";

if (!$this->evaluate_script($footerjs)) {
throw new ExpectationException("Doesn't enable the focus mode", $this->getSession());
}
Expand Down
2 changes: 2 additions & 0 deletions ltool/focus/tests/behat/focus_visibility.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Feature: Check the focus ltool workflow.
And I check focus mode disable
And "#ltoolfocus-info" "css_element" should exist
And I click on "#ltoolfocus-info" "css_element"
Then I wait "5" seconds
And I check focus mode enable
And I am on "Course 1" course homepage
And I check focus mode enable
Expand All @@ -34,6 +35,7 @@ Feature: Check the focus ltool workflow.
And I click on FAB button
And "#ltoolfocus-info" "css_element" should exist
And I click on "#ltoolfocus-info" "css_element"
Then I wait "5" seconds
And I check focus mode enable
Then I log out
And I log in as "student1"
Expand Down
2 changes: 1 addition & 1 deletion ltool/focus/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'ltool_focus';
$plugin->version = 2022022800;
$plugin->version = 2024120300;
$plugin->requires = 2020061501;
1 change: 1 addition & 0 deletions ltool/note/classes/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/externallib.php');

/**
* Define external class.
*/
Expand Down
75 changes: 66 additions & 9 deletions ltool/note/classes/ltool_note_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,61 @@
* List of the user notes filter action.
*/
class ltool_note_filter {

/**
* @var int
*/
public $userid;

/**
* @var int
*/
public $selectcourse;

/**
* @var string
*/
public $sort;


/**
* @var int
*/
public $activity;


/**
* @var int
*/
public $childid;

/**
* @var string
*/
public $courseid;


/**
* @var int
*/
public $teacher;

/**
* @var array
*/
public $urlparams;

/**
* @var string
*/
public $pageurl;

/**
* @var string
*/
public $totalnotes;


/**
* Loads the notes info data.
* @param int $userid current user id
Expand Down Expand Up @@ -82,17 +137,17 @@ public function get_user_sql() {
$students = local_learningtools_get_students_incourse($this->courseid);
if (!empty($students)) {
list($studentsql, $userparams) = $DB->get_in_or_equal($students, SQL_PARAMS_NAMED);
$usersql .= 'userid '. $studentsql;
$usersql .= 'lnd.userid '. $studentsql;
}
} else {
$usersql = 'userid = :userid';
$usersql = 'lnd.userid = :userid';
$userparams = ['userid' => $this->childid];
}
} else if ($this->childid) {
$usersql = 'userid = :userid';
$usersql = 'lnd.userid = :userid';
$userparams = ['userid' => $this->childid];
} else {
$usersql = 'userid = :userid';
$usersql = 'lnd.userid = :userid';
$userparams = ['userid' => $this->userid];
}
return ['sql' => $usersql, 'params' => $userparams];
Expand All @@ -110,7 +165,7 @@ public function get_course_selector() {
$usercondition = $this->get_user_sql();
$usersql = $usercondition['sql'];
$userparams = $usercondition['params'];
$records = $DB->get_records_sql("SELECT * FROM {ltool_note_data} WHERE $usersql", $userparams);
$records = $DB->get_records_sql("SELECT * FROM {ltool_note_data} lnd WHERE $usersql", $userparams);
if (!empty($records)) {
foreach ($records as $record) {
$instanceblock = local_learningtools_check_instanceof_block($record);
Expand Down Expand Up @@ -153,10 +208,12 @@ public function get_activity_selector() {
$usercondition = $this->get_user_sql($this->courseid, $this->childid);
$usersql = $usercondition['sql'];
$userparams = $usercondition['params'];
$sql = "SELECT coursemodule, course FROM {ltool_note_data}
WHERE $usersql AND course = :course AND coursemodule != 0 GROUP BY coursemodule, course";
$sql = "SELECT lnd.coursemodule, lnd.course FROM {ltool_note_data} lnd
LEFT JOIN {course_modules} cm ON cm.id = lnd.coursemodule
WHERE $usersql AND cm.deletioninprogress != 0 AND lnd.course = :course AND lnd.coursemodule != 0
GROUP BY lnd.coursemodule, lnd.course";
$params = [
'course' => $this->selectcourse,
'course' => $this->selectcourse,
];

$params = array_merge($params, $userparams);
Expand Down Expand Up @@ -474,7 +531,7 @@ public function get_speater_plug($records) {
$list['instance'] = $this->get_instance_note($data);
$list['base'] = $this->get_title_note($data, $record);
$list['note'] = !empty($record->note) ? $record->note : '';
$list['time'] = userdate($record->timecreated, get_string("baseformat", "local_learningtools"), '', false);
$list['time'] = userdate($record->timemodified, get_string("baseformat", "local_learningtools"), '', false);
$list['viewurl'] = $this->get_view_url($record);

if (!empty($this->courseid) && !$this->childid) {
Expand Down
3 changes: 2 additions & 1 deletion ltool/note/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ function ltool_note_get_contextuser_notes($args) {
if (!empty($notesrecords)) {
foreach ($notesrecords as $note) {
$list['note'] = !empty($note->note) ? $note->note : '';
$list['time'] = userdate(($note->timecreated), get_string("baseformat", "local_learningtools"), '', false);
$list['time'] = userdate(($note->timemodified), get_string("baseformat", "local_learningtools"), '', false);
if (has_capability('ltool/note:manageownnote', $context)) {
$returnparams = array('returnurl' => $args['pageurl']);
$list['delete'] = ltool_note_delete_note_record($note, $returnparams);
Expand Down Expand Up @@ -355,6 +355,7 @@ function ltool_note_user_save_notes($contextid, $data) {
$record->pageurl = $data['pageurl'];
$record->note = format_text($data['ltnoteeditor'], FORMAT_HTML);
$record->timecreated = time();
$record->timemodified = time();

$notesrecord = $DB->insert_record('ltool_note_data', $record);
$eventcourseid = local_learningtools_get_eventlevel_courseid($context, $data['course']);
Expand Down
Loading

0 comments on commit 1c01a3c

Please sign in to comment.