Skip to content

Commit

Permalink
Merge pull request #41 from ADLMeganBohland/DB-fix
Browse files Browse the repository at this point in the history
Db fix
  • Loading branch information
ADLMeganBohland authored Jun 11, 2024
2 parents 8b678df + 10e69e6 commit 23531c6
Show file tree
Hide file tree
Showing 8 changed files with 414 additions and 57 deletions.
33 changes: 30 additions & 3 deletions classes/local/cmi5_connectors.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function cmi5launch_get_send_request_to_cmi5_player_get() {
public function cmi5launch_create_course($id, $tenanttoken, $filename) {

global $DB, $CFG;

$settings = cmi5launch_settings($id);

// Build URL to import course to.
Expand Down Expand Up @@ -101,10 +102,36 @@ public function cmi5launch_create_course($id, $tenanttoken, $filename) {
* @param $password - password.
* @param $newtenantname - the name the new tenant will be, retreived from Tenant Name textbox.
*/
public function cmi5launch_create_tenant($urltosend, $username, $password, $newtenantname) {
public function cmi5launch_create_tenant($newtenantname) {

global $CFG, $cmi5launchid;

$settings = cmi5launch_settings($cmi5launchid);

//$actor = $USER->username;
$username = $settings['cmi5launchbasicname'];
$playerurl = $settings['cmi5launchplayerurl'];
$password = $settings['cmi5launchbasepass'];
global $CFG;

// Build URL for launch URL request.
$url = $playerurl . "/api/v1/tenant";

echo "<br>";
echo "basicname: " . $username;
echo "<br>";

echo "<br>";
echo "password: " . $password;
echo "<br>";

echo "<br>";
echo "URL: " . $url;
echo "<br>";

echo "<br>";
echo "newtenantname: " . $newtenantname;
echo "<br>";
// The body of the request must be made as array first.
$data = array(
'code' => $newtenantname);
Expand All @@ -116,7 +143,7 @@ public function cmi5launch_create_tenant($urltosend, $username, $password, $newt
$data = json_encode($data);

// Sends the stream to the specified URL.
$result = $this->cmi5launch_send_request_to_cmi5_player_post('cmi5launch_stream_and_send', $data, $urltosend, $filetype, $username, $password);
$result = $this->cmi5launch_send_request_to_cmi5_player_post('cmi5launch_stream_and_send', $data, $url, $filetype, $username, $password);

// Check result and display message if not 200.
$resulttest = $this->cmi5launch_connectors_error_message($result, "creating the tenant");
Expand All @@ -125,7 +152,7 @@ public function cmi5launch_create_tenant($urltosend, $username, $password, $newt

// Decode returned response into array.
$returnedinfo = json_decode($result, true);

echo"It worked";
// Return an array with tenant name and info.
return $returnedinfo;
} else {
Expand Down
35 changes: 0 additions & 35 deletions classes/local/cmi5launch_helpers.php

This file was deleted.

4 changes: 2 additions & 2 deletions db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<FIELD NAME="launchtokenid" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="Launchtoken assigned by CMI5 player"/>
<FIELD NAME="lastrequesttime" TYPE="char" LENGTH="30" NOTNULL="false" SEQUENCE="false" COMMENT="Time a session was last requested. String as that is what is returned from player."/>
<FIELD NAME="launchmode" TYPE="char" LENGTH="25" NOTNULL="false" SEQUENCE="false" COMMENT="Launch mode, separate from launchmethod. It can be 'Normal', 'Browse', or 'Review"/>
<FIELD NAME="masteryscore" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The amount toward mastery score."/>
<FIELD NAME="masteryscore" TYPE="number" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The amount toward mastery score."/>
<FIELD NAME="score" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The score of session (returned from 'result' parameter in statements from LRS)."/>
<FIELD NAME="islaunched" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="Has session been launched?."/>
<FIELD NAME="isinitialized" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="Has session been intialized?."/>
Expand Down Expand Up @@ -128,7 +128,7 @@
<FIELD NAME="objectives" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="AUs objectives."/>
<FIELD NAME="description" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="AUs description."/>
<FIELD NAME="activitytype" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="Activity type of AU."/>
<FIELD NAME="masteryscore" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The amount it counts toward mastery score."/>
<FIELD NAME="masteryscore" TYPE="number" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The amount it counts toward mastery score."/>
<FIELD NAME="completed" TYPE="int" LENGTH="1" NOTNULL="false" DEFAULT="0" SEQUENCE="false" COMMENT="Whether an AU has met completed criteria (0 if false, 1 if true)"/>
<FIELD NAME="passed" TYPE="int" LENGTH="1" NOTNULL="false" DEFAULT="0" SEQUENCE="false" COMMENT="Whether an AU has met passed criteria (0 if false, 1 if true)"/>
<FIELD NAME="inprogress" TYPE="int" LENGTH="1" NOTNULL="false" DEFAULT="0" SEQUENCE="false" COMMENT="Whether an AU is in progress or not (been started) (0 if false, 1 if true)"/>
Expand Down
17 changes: 17 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ function xmldb_cmi5launch_upgrade($oldversion) {
global $DB;
$dbman = $DB->get_manager();

// Change masteryscore to number type because of decimal
if ($oldversion < 2024061115) {

// Changing type of field masteryscore on table cmi5launch_sessions to int.
$tablesessions = new xmldb_table('cmi5launch_sessions');
$tableaus = new xmldb_table('cmi5launch_aus');
$field = new xmldb_field('masteryscore', XMLDB_TYPE_NUMBER, '10', null, null, null, null, 'launchmode');
$field2 = new xmldb_field('masteryscore', XMLDB_TYPE_NUMBER, '10', null, null, null, null, 'activitytype');

// Launch change of type for field masteryscore in both tables.
$dbman->change_field_type($tablesessions, $field);
$dbman->change_field_type($tableaus, $field2);
// Cmi5launch savepoint reached.
upgrade_mod_savepoint(true, 2024061115, 'cmi5launch');
}


if ($oldversion < 2024032112) {

// Define index lmsid (not unique) to be dropped form cmi5launch_sessions.
Expand Down
21 changes: 15 additions & 6 deletions lang/en/cmi5launch.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,16 @@

// Cmi5 grades admin.
// Start Default LRS Admin Settings.
$string['cmi5launchgradesettings'] = 'Default values for cmi5 launch link activity settings';
$string['cmi5launchgradesettings'] = 'Default values ;ppppfor cmi5 launch link activity settings';
$string['cmi5launchgradesettings_help'] = 'These are site-wide, default values used when creating a new activity. Each activity has the ability to override and provide alternative values.';

$string['othersettings'] = 'Additional settings';

// Cmi5 settings

// Header.
$string['cmi5launchsettingsheader'] = 'cmi5 player settings';

// Cmi5 player root location.
$string['cmi5launchplayerurl'] = 'cmi5 player URL';
$string['cmi5launchplayerurl_help'] = 'The url to communicate with cmi5 player, can include port number(e.g. http://player.example.com or http://localhost:63398). Must NOT include a trailing forward slash.';
Expand All @@ -89,13 +94,17 @@
$string['cmi5launchcontenturl_default'] = '';

// Cmi5 player credentials.
$string['cmi5launchtenantname'] = 'cmi5 player: basic username';
$string['cmi5launchtenantname_help'] = 'The cmi5 tenant username.';
$string['cmi5launchbasicname'] = 'cmi5 player: basic username';
$string['cmi5launchbasicname_help'] = 'The cmi5 base username.';
$string['cmi5launchbasicname_default'] = '';

$string['cmi5launchtenantname'] = 'cmi5 player: The cmi5 tenant username.';
$string['cmi5launchtenantname_help'] = ' The tenant name attached to the token. Should only need to be used during initial setup. If for some reason the tenant name is changed a new token will need to be generated.';
$string['cmi5launchtenantname_default'] = '';

$string['cmi5launchtenantpass'] = 'cmi5 player: basic password';
$string['cmi5launchtenantpass_help'] = 'The cmi5 tenant password (secret).';
$string['cmi5launchtenantpass_default'] = '';
$string['cmi5launchbasepass'] = 'cmi5 player: basic password';
$string['cmi5launchbasepass_help'] = 'The cmi5 base password (secret).';
$string['cmi5launchbasepass_default'] = '';

$string['cmi5launchtenanttoken'] = 'cmi5 player: bearer token';
$string['cmi5launchtenanttoken_help'] = 'The cmi5 tenant bearer token (should be a long string).';
Expand Down
Loading

0 comments on commit 23531c6

Please sign in to comment.