Skip to content

Commit

Permalink
Merge pull request #18 from kialo/PM-47393-embedded-resourcelink
Browse files Browse the repository at this point in the history
PM-47393 Embedded resourcelinks
  • Loading branch information
mk-kialo authored Jan 29, 2025
2 parents 6210036 + a2508a6 commit c3b461a
Show file tree
Hide file tree
Showing 25 changed files with 538 additions and 6,410 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ development/node_modules/

# macOS
.DS_Store

moodle/
15 changes: 15 additions & 0 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

248 changes: 247 additions & 1 deletion .idea/mod_kialo.iml

Large diffs are not rendered by default.

74 changes: 73 additions & 1 deletion .idea/phpunit.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion classes/kialo_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function get_tool(): Tool {
'kialo-edu', // Identifier.
'Kialo Edu', // Name.
$toolurl, // Audience.
$toolurl . "/lti/login", // OIDC initiation url.
$toolurl . "/lti/start", // OIDC initiation url.
$toolurl . '/lti/launch', // Launch url.
$toolurl . '/lti/deeplink' // Deep linking url.
);
Expand Down
10 changes: 10 additions & 0 deletions constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@
LtiConstants::AGS_SCOPE_SCORE,
];

/**
* Value used to indicate that the Kialo app should be displayed in the same Moodle window as an embed.
*/
const MOD_KIALO_DISPLAY_IN_EMBED = 'embed';

/**
* Value used to indicate that the Kialo app should be displayed in a new window.
*/
const MOD_KIALO_DISPLAY_IN_NEW_WINDOW = 'new-window';

/**
* In LTI the deployment ID identifies an LTI tool definition or installation. Moodle sends
* the same ID for all activities that are based on the same LTI external tool definition.
Expand Down
1 change: 1 addition & 0 deletions db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<FIELD NAME="discussion_title" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="The title of the discussion (when it was selected)."/>
<FIELD NAME="deployment_id" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The deployment ID of the discussion."/>
<FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="100" SEQUENCE="false" COMMENT="The maximum score or grade scale."/>
<FIELD NAME="display" TYPE="char" LENGTH="16" NOTNULL="true" DEFAULT="embed" SEQUENCE="false" COMMENT="How to display the discussion (embed or window)."/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
Expand Down
38 changes: 34 additions & 4 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,19 @@
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();
require_once(__DIR__ . '/../constants.php');

/**
* In this version grading was first introduced.
*/
const VERSION_GRADING_1 = 2024091805;

/**
* In this version display options (embed vs new window) were first introduced.
*/
const VERSION_DISPLAY_OPTIONS_1 = 2025012402;

/**
* Custom upgrade steps.
* @param int $oldversion
Expand All @@ -35,20 +43,42 @@ function xmldb_kialo_upgrade($oldversion = 0): bool {
global $CFG, $DB;

$dbman = $DB->get_manager();
$table = new xmldb_table('kialo');

if ($oldversion < VERSION_GRADING_1) {
// Define field 'grade' to be added to kialo.
$table = new xmldb_table('kialo');
$field = new xmldb_field('grade', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, false, 100, null);
$gradefield = new xmldb_field('grade', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, false, 100, null);

// Conditionally launch add field 'grade'.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
if (!$dbman->field_exists($table, $gradefield)) {
$dbman->add_field($table, $gradefield);
}

// Kialo savepoint reached.
upgrade_mod_savepoint(true, VERSION_GRADING_1, 'kialo');
}

if ($oldversion < VERSION_DISPLAY_OPTIONS_1) {
// Define field 'display' to be added to kialo.
$displayfield = new xmldb_field(
'display',
XMLDB_TYPE_CHAR,
'16',
false,
XMLDB_NOTNULL,
false,
MOD_KIALO_DISPLAY_IN_EMBED,
null
);

// Conditionally launch add field 'display'.
if (!$dbman->field_exists($table, $displayfield)) {
$dbman->add_field($table, $displayfield);
}

// Kialo savepoint reached.
upgrade_mod_savepoint(true, VERSION_DISPLAY_OPTIONS_1, 'kialo');
}

return true;
}
14 changes: 8 additions & 6 deletions development/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,21 @@ cp .env.example .env # before starting compose, check instructions in this file
docker compose up
```

At this point Moodle should be running locally on port 8080. You can use any hostname that resolves to localhost, e.g. `http://localhost:8080`. You can also add an entry to your `/etc/hosts` file to use a custom hostname like 'moodle.localhost'.

After you started Moodle for the first time, do the following to set some useful default settings:

* Copy `development/config.php` into `development/moodle` to apply some default settings useful for development.
* Import `development/config/kialo-admin-preset.xml` via http://localhost:8080/admin/tool/admin_presets/index.php?action=import.
* Import `development/config/kialo-admin-preset-universal.xml` via http://localhost:8080/admin/tool/admin_presets/index.php?action=import.

The admin presets are important, as they adjust Moodle's curl blocklist and allowed ports. Without that,
testing Kialo locally won't work, as communication will be blocked by Moodle.
This also enables web services for mobile (required for the mobile app) and enables debug messages for developers.

By default there is only one user with the username "user" and password "kialo1234". This is the admin user.

The folder `moodle` is mounted locally in the `development` folder. To test changes to the plugin code,
you can use `development/sync.sh` to copy over the code into the `moodle/mod/kialo` folder.A
To update the plugin in Moodle during development,
you have to use `development/sync.sh` to copy over the code into the `development/mod_kialo` folder,
which is mounted in the Moodle docker container.

### Moodle versions

Expand Down Expand Up @@ -91,10 +93,10 @@ To add a new dependency, run `composer require <package-name>`.
Whenever any dependency is changed (when `composer.lock` changes), you need to ensure to update `thirdpartylibs.xml` accordingly. Run the test `tests/thirdpartylibs_test.php` to check that
the thirdpartylibs.xml file is up to date.

If the test fails, run it with the env variable `UPDATE_THIRDPARTYLIBS=1` to automatically regenerate the file:
If the test fails, run it with the env variable `UPDATE_THIRDPARTYLIBSXML=1` to automatically regenerate the file:

```shell
UPDATE_THIRDPARTYLIBS=1 ./vendor/bin/phpunit tests/thirdpartylibs_test.php
UPDATE_THIRDPARTYLIBSXML=1 ./vendor/bin/phpunit tests/thirdpartylibs_test.php
```

## Linting
Expand Down
Loading

0 comments on commit c3b461a

Please sign in to comment.