Skip to content

Commit 5b96b8d

Browse files
committed
2025112600 release code
1 parent bac0981 commit 5b96b8d

File tree

11 files changed

+232
-79
lines changed

11 files changed

+232
-79
lines changed

.github/workflows/moodle-ci.yml

Lines changed: 72 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
# Title of the workflow
12
name: Moodle Plugin CI
23

4+
# Run this workflow every time a new commit pushed to your repository or PR
5+
# created.
36
on:
47
push:
58
paths-ignore:
@@ -8,11 +11,14 @@ on:
811
paths-ignore:
912
- 'node_modules/**'
1013

11-
1214
jobs:
15+
# Set the job key. The key is displayed as the job name
16+
# when a job name is not provided
1317
test:
14-
runs-on: ubuntu-latest
18+
# Virtual environment to use.
19+
runs-on: ubuntu-22.04
1520

21+
# DB services you need for testing.
1622
services:
1723
postgres:
1824
image: postgres:13
@@ -22,25 +28,39 @@ jobs:
2228
ports:
2329
- 5432:5432
2430
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
31+
2532
mariadb:
2633
image: mariadb:10
2734
env:
2835
MYSQL_USER: 'root'
2936
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
3037
MYSQL_CHARACTER_SET_SERVER: "utf8mb4"
3138
MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci"
32-
3339
ports:
3440
- 3306:3306
3541
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3
3642

43+
# Determines build matrix. This is a list of PHP versions, databases and
44+
# branches to test our project against. For each combination a separate
45+
# build will be created. For example below 6 builds will be created in
46+
# total (7.4-pgsql, 7.4-mariadb, 8.0-pgsql, 8.0-mariadb, etc.). If we add
47+
# another branch, total number of builds will become 12.
3748
strategy:
3849
fail-fast: false
3950
matrix:
4051
include:
41-
- php: '8.3'
52+
- php: '8.4'
4253
moodle-branch: 'main'
4354
database: 'pgsql'
55+
- php: '8.4'
56+
moodle-branch: 'MOODLE_501_STABLE'
57+
database: 'mariadb'
58+
- php: '8.3'
59+
moodle-branch: 'MOODLE_500_STABLE'
60+
database: 'pgsql'
61+
- php: '8.3'
62+
moodle-branch: 'MOODLE_405_STABLE'
63+
database: 'mariadb'
4464
- php: '8.3'
4565
moodle-branch: 'MOODLE_404_STABLE'
4666
database: 'pgsql'
@@ -55,78 +75,93 @@ jobs:
5575
database: 'mariadb'
5676

5777
steps:
78+
# Check out this repository code in ./plugin directory
5879
- name: Check out repository code
59-
uses: actions/checkout@v2
80+
uses: actions/checkout@v4
6081
with:
6182
path: plugin
6283

84+
# Install PHP of required version. For possible options see https://github.com/shivammathur/setup-php
6385
- name: Setup PHP ${{ matrix.php }}
6486
uses: shivammathur/setup-php@v2
6587
with:
6688
php-version: ${{ matrix.php }}
67-
extensions: ${{ matrix.extensions }}
6889
ini-values: max_input_vars=5000
69-
# none to use phpdbg fallback. Specify pcov (Moodle 3.10 and up) or xdebug to use them instead.
90+
# If you are not using code coverage, keep "none". Otherwise, use "pcov" (Moodle 3.10 and up) or "xdebug".
91+
# If you try to use code coverage with "none", it will fallback to phpdbg (which has known problems).
7092
coverage: none
7193

94+
# Install this project into a directory called "ci", updating PATH and
95+
# locale, define nvm location.
7296
- name: Initialise moodle-plugin-ci
7397
run: |
74-
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
98+
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
7599
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
76100
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
77101
sudo locale-gen en_AU.UTF-8
78102
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
103+
104+
# Run the default install.
105+
# Optionally, it is possible to specify a different Moodle repo to use
106+
# (https://github.com/moodle/moodle.git is used by default) and define
107+
# ignore directives or any other env vars for install step. For more
108+
# details on configuring for specific requirements please refer to the
109+
# 'Help' page.
110+
#
111+
# env:
112+
# MOODLE_REPO=https://github.com/username/moodle.git
113+
# IGNORE_PATHS: 'ignore'
114+
# IGNORE_NAMES: 'ignore_name.php'
115+
# MUSTACHE_IGNORE_NAMES: 'broken.mustache'
116+
# CODECHECKER_IGNORE_PATHS: 'ignoreme'
117+
# CODECHECKER_IGNORE_NAMES: 'ignoreme_name.php'
118+
#
119+
# Other env vars are available for install, namely:
120+
# - DB_USER / DB_PASS / DB_NAME / DB_HOST / DB_PORT: used
121+
# by install to feed the corresponding --db-xxxx options.
122+
# - MOODLE_APP: used to install dependencies to run Behat tests
123+
# using the Moodle App.
79124
- name: Install moodle-plugin-ci
80125
run: |
81126
moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
82127
env:
83128
DB: ${{ matrix.database }}
84129
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
130+
# Uncomment this to run Behat tests using the Moodle App.
131+
# MOODLE_APP: 'true'
85132

133+
# Steps that are run for the purpose of testing. Any of these steps
134+
# can be re-ordered or removed to your liking. And of course, you can
135+
# add any of your own custom steps.
86136
- name: PHP Lint
87-
if: ${{ always() }}
137+
if: ${{ !cancelled() }} # prevents CI run stopping if step failed.
88138
run: moodle-plugin-ci phplint
89139

90-
- name: PHP Copy/Paste Detector
91-
continue-on-error: true # This step will show errors but will not fail
92-
if: ${{ always() }}
93-
run: moodle-plugin-ci phpcpd
94-
95140
- name: PHP Mess Detector
96-
continue-on-error: true # This step will show errors but will not fail
97-
if: ${{ always() }}
141+
continue-on-error: true
142+
if: ${{ !cancelled() }}
98143
run: moodle-plugin-ci phpmd
99144

100145
- name: Moodle Code Checker
101-
if: ${{ always() }}
102-
# Allow 3 warnings for privacy provider interfaces (Moodle <3.6)
103-
run: moodle-plugin-ci codechecker --max-warnings 3
146+
if: ${{ !cancelled() }}
147+
run: moodle-plugin-ci phpcs --max-warnings 3
104148

105149
- name: Moodle PHPDoc Checker
106-
if: ${{ always() }}
107-
run: moodle-plugin-ci phpdoc
150+
if: ${{ !cancelled() }}
151+
run: moodle-plugin-ci phpdoc --max-warnings 0
108152

109153
- name: Validating
110-
if: ${{ always() }}
154+
if: ${{ !cancelled() }}
111155
run: moodle-plugin-ci validate
112156

113157
- name: Check upgrade savepoints
114-
if: ${{ always() }}
158+
if: ${{ !cancelled() }}
115159
run: moodle-plugin-ci savepoints
116160

117-
# Mustache and Grunt are failing so commenting out for now
118-
# - name: Mustache Lint
119-
# if: ${{ always() }}
120-
# run: moodle-plugin-ci mustache
121-
122-
# - name: Grunt
123-
# if: ${{ always() }}
124-
# run: moodle-plugin-ci grunt --max-lint-warnings 0
125-
126161
- name: PHPUnit tests
127-
if: ${{ always() }}
128-
run: moodle-plugin-ci phpunit --fail-on-warning
162+
if: ${{ !cancelled() }}
163+
run: moodle-plugin-ci phpunit
129164

130-
- name: Behat features
131-
if: ${{ always() }}
132-
run: moodle-plugin-ci behat --profile chrome
165+
- name: Mark cancelled jobs as failed.
166+
if: ${{ cancelled() }}
167+
run: exit 1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ enabled by confirming that its corresponding icon under the 'Enable' column show
3535

3636
You can build all modules in Moodle by using the grunt amd command. To update the amd module from this plugin:
3737
1. Execute `npm install` on the root of the Moodle project.
38-
2. Navigate to `<moodle-root>/lib/editor/tiny/panoptoltibutton/amd/` and execute:
38+
2. Navigate to `<moodle-root>/lib/editor/tiny/plugins/panoptoltibutton/amd/` and execute:
3939

4040
```
4141
$ npx grunt amd

classes/plugininfo.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@
4444
*/
4545
class plugininfo extends plugin implements
4646
plugin_with_buttons,
47-
plugin_with_menuitems,
48-
plugin_with_configuration {
49-
47+
plugin_with_configuration,
48+
plugin_with_menuitems {
5049
/**
5150
* Get a list of the buttons provided by this plugin.
5251
*
@@ -105,7 +104,7 @@ public static function get_plugin_configuration_for_context(
105104
'resourcebase' => $resourcebase,
106105
'panoptoltibuttondescription' => get_string('panopto_button_description', 'tiny_panoptoltibutton'),
107106
'panoptoltibuttonlongdescription' => get_string('panopto_button_long_description', 'tiny_panoptoltibutton'),
108-
'unprovisionederror' => get_string('panopto_button_unprovisioned_error', 'tiny_panoptoltibutton')
107+
'unprovisionederror' => get_string('panopto_button_unprovisioned_error', 'tiny_panoptoltibutton'),
109108
];
110109
}
111110
}

classes/privacy/provider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@
3636
class provider implements
3737
// This plugin does not store any personal user data.
3838
\core_privacy\local\metadata\null_provider {
39-
4039
/**
4140
* Get the language string identifier with the component's language
4241
* file to explain why this plugin stores no data.
4342
*
4443
* @return string
4544
*/
46-
public static function get_reason() : string {
45+
public static function get_reason(): string {
4746
return 'privacy:metadata';
4847
}
4948
}

contentitem.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@
5555
$ltiviewerurl = new moodle_url(LTI_TINY_PATH);
5656
$resourcelinkid = sha1($ltiviewerurl->out(false) .
5757
'&' . $courseid .
58-
'&' . $course->timecreated
59-
);
58+
'&' . $course->timecreated);
6059
$lti->id = $resourcelinkid;
6160
}
6261
if (!isset($SESSION->lti_initiatelogin_status)) {
@@ -80,7 +79,18 @@
8079

8180
// Prepare the request.
8281
$request = lti_build_content_item_selection_request(
83-
$id, $course, $returnurl, '', '', [], [], false, false, false, false, false
82+
$id,
83+
$course,
84+
$returnurl,
85+
'',
86+
'',
87+
[],
88+
[],
89+
false,
90+
false,
91+
false,
92+
false,
93+
false
8494
);
8595

8696
// Get the launch HTML.

contentitem_return.php

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@
1515
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
1616

1717
/**
18-
* Handles content item return.
18+
* This script handles the content item return process.
19+
*
20+
* It processes LTI content item returns, validates the response, and either
21+
* triggers an error callback or dispatches the content items to the parent window.
1922
*
2023
* @package tiny_panoptoltibutton
21-
* @copyright 2023 Panopto
24+
* @copyright 2025 Panopto
2225
* @author Panopto
2326
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2427
*/
2528

2629
require_once(dirname(__FILE__) . '/../../../../../config.php');
30+
require_once($CFG->dirroot . '/blocks/panopto/lib/panopto_data.php');
2731
require_once($CFG->dirroot . '/blocks/panopto/lib/lti/panoptoblock_lti_utility.php');
2832
require_once($CFG->dirroot . '/mod/lti/lib.php');
2933
require_once($CFG->dirroot . '/mod/lti/locallib.php');
@@ -61,13 +65,11 @@
6165

6266
$errors = [];
6367

64-
// Affirm that the content item is a JSON object.
6568
if (!is_object($contentitems) && !is_array($contentitems)) {
6669
$errors[] = 'invalidjson';
6770
}
6871

6972
if ($islti1p3) {
70-
// Update content items data if this is lti 1.3 and not embed.
7173
$doctarget = $contentitems->{'@graph'}[0]->placementAdvice->presentationDocumentTarget
7274
? $contentitems->{'@graph'}[0]->placementAdvice->presentationDocumentTarget
7375
: ($contentitems->{'@graph'}[0]->iframe ? "iframe" : "frame");
@@ -80,12 +82,70 @@
8082
}
8183
}
8284

85+
// Provision the course for LTI.
86+
\panopto_data::provision_course_for_lti($courseid);
8387
?>
8488

8589
<script type="text/javascript">
86-
<?php if (count($errors) > 0): ?>
90+
<?php
91+
/**
92+
* Check for errors and handle accordingly.
93+
*
94+
* @package tiny_panoptoltibutton
95+
* @copyright 2025 Panopto
96+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
97+
*/
98+
if (count($errors) > 0) : ?>
99+
/**
100+
* Trigger the handleError callback with the errors.
101+
*
102+
* @package tiny_panoptoltibutton
103+
* @copyright 2025 Panopto
104+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
105+
*/
87106
parent.document.CALLBACKS.handleError(<?php echo json_encode($errors); ?>);
88-
<?php else: ?>
89-
parent.document.CALLBACKS.<?php echo $callback ?>(<?php echo json_encode($contentitems) ?>);
90-
<?php endif; ?>
107+
<?php
108+
/**
109+
* Handle successful content item return.
110+
*
111+
* @package tiny_panoptoltibutton
112+
* @copyright 2025 Panopto
113+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
114+
*/
115+
else : ?>
116+
/**
117+
* Trigger the handleContent callback with the content items.
118+
*
119+
* @package tiny_panoptoltibutton
120+
* @copyright 2025 Panopto
121+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
122+
*/
123+
parent.document.CALLBACKS.
124+
<?php
125+
/**
126+
* Trigger the handleContent callback with the content items.
127+
*
128+
* @package tiny_panoptoltibutton
129+
* @copyright 2025 Panopto
130+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
131+
*/
132+
echo $callback ?>(
133+
<?php
134+
/**
135+
* Trigger the handleContent callback with the content items.
136+
*
137+
* @package tiny_panoptoltibutton
138+
* @copyright 2025 Panopto
139+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
140+
*/
141+
echo json_encode($contentitems) ?>);
142+
<?php
143+
/**
144+
* End of if-else statement.
145+
*
146+
* @package tiny_panoptoltibutton
147+
* @copyright 2025 Panopto
148+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
149+
*/
150+
endif; ?>
91151
</script>

0 commit comments

Comments
 (0)