-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tenant and token creation added. Now separate for first time setup
- Loading branch information
1 parent
786c4f6
commit dd447eb
Showing
16 changed files
with
581 additions
and
192 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["^ ","~:classpath",["~#set",[]],"~:project-hash","","~:project-root","/var/www/html/moodle/mod/cmi5launch","~:kondo-config-hash","56f27dae6e4a876734bf42298a7d3dc91d05917f53c9d98543cfd410bd88afe0","~:dependency-scheme","jar","~:analysis",null,"~:analysis-checksums",["^ "],"~:project-analysis-type","~:project-and-full-dependencies","~:version",12,"~:stubs-generation-namespaces",["^1",[]]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Form for cmi5 connection, namely basic info - player url, user name and password. | ||
* | ||
* @copyright 2023 Megan Bohland | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
// Moodleform is defined in formslib.php. | ||
require_once("$CFG->libdir/formslib.php"); | ||
|
||
class setup_cmi5 extends moodleform { | ||
// Add elements to form. | ||
public function definition() { | ||
// A reference to the form is stored in $this->form. | ||
// A common convention is to store it in a variable, such as `$mform`. | ||
$mform = $this->_form; // Don't forget the underscore! | ||
|
||
// Add elements to your form. Second arg is the name of element | ||
// Player url. | ||
$mform->addElement('text', 'cmi5url', get_string('cmi5launchplayerurl', 'cmi5launch')); | ||
// Set type of element. | ||
$mform->setType('cmi5url', PARAM_NOTAGS); | ||
// Default value. | ||
$mform->setDefault('cmi5url', get_string('cmi5launchplayerurl_default', 'cmi5launch')); // The second arg here is the default value and appears in the text box. | ||
// Add a rule to make this field required. | ||
$mform->addRule('cmi5url', 'This is needed to connect to player', 'required'); | ||
// Add a help button with a help message. | ||
$mform->addHelpButton('cmi5url', 'cmi5launchplayerurl', 'cmi5launch'); | ||
|
||
// User name. | ||
$mform->addElement('text', 'cmi5name', get_string('cmi5launchbasicname', 'cmi5launch')); | ||
// Set type of element. | ||
$mform->setType('cmi5name', PARAM_NOTAGS); | ||
// Default value. | ||
$mform->setDefault('cmi5name', get_string('cmi5launchbasicname_default', 'cmi5launch')); // The second arg here is the default value and appears in the text box. | ||
// Add a rule to make this field required. | ||
$mform->addRule('cmi5name', 'This is needed to connect to player', 'required'); | ||
// Add a help button with a help message. | ||
$mform->addHelpButton('cmi5name', 'cmi5launchbasicname', 'cmi5launch'); | ||
|
||
// Password. | ||
// Add elements to your form. Second arg is the name of element | ||
$mform->addElement('text', 'cmi5password', get_string('cmi5launchbasepass', 'cmi5launch')); | ||
// Set type of element. | ||
$mform->setType('cmi5password', PARAM_NOTAGS); | ||
// Default value. | ||
$mform->setDefault('cmi5password', get_string('cmi5launchbasepass_default', 'cmi5launch')); // The second arg here is the default value and appears in the text box. | ||
// Add a rule to make this field required. | ||
$mform->addRule('cmi5password', 'This is needed to connect to player', 'required'); | ||
// Below is the help button, it sucks you have to push it to see the help text, but it is there | ||
$mform->addHelpButton('cmi5password', 'cmi5launchbasepass', 'cmi5launch'); | ||
|
||
$this->add_action_buttons(); | ||
} | ||
|
||
// Custom validation should be added here. | ||
function validation($data, $files) { | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Form for cmi5 connection, to enter tenant name. | ||
* | ||
* @copyright 2023 Megan Bohland | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
// moodleform is defined in formslib.php | ||
require_once("$CFG->libdir/formslib.php"); | ||
|
||
class setup_tenant extends moodleform { | ||
|
||
// Add elements to form. | ||
public function definition() { | ||
// A reference to the form is stored in $this->form. | ||
// A common convention is to store it in a variable, such as `$mform`. | ||
$mform = $this->_form; // Don't forget the underscore! | ||
|
||
// Add elements to your form. Second arg is the name of element | ||
$mform->addElement('text', 'cmi5tenant', get_string('cmi5launchtenantnamesetup', 'cmi5launch')); | ||
// Add a help button with a help message. | ||
$mform->addHelpButton('cmi5tenant', 'cmi5launchtenantnamesetup', 'cmi5launch'); | ||
|
||
// Set type of element. | ||
$mform->setType('cmi5tenant', PARAM_NOTAGS); | ||
// Default value. | ||
$mform->setDefault('cmi5tenant', get_string('cmi5launchtenantname_default', 'cmi5launch')); // The second arg here is the default value and appears in the text box. | ||
// Add a rule to make this field required. | ||
$mform->addRule('cmi5tenant', 'This is needed to connect to player', 'required'); | ||
|
||
// $mform->addElement('header', 'cmi5instructions', 'Please enter a tenant name. When submitted it will create a tenant in the cmi5 player and automatically retrieve and save a bearer token for it as well.'); | ||
$mform->addElement('html', '<p>Please enter a tenant name. When submitted it will create a tenant in the cmi5 player and automatically retrieve and save a bearer token for it as well</p>'); | ||
|
||
$this->add_action_buttons(); | ||
} | ||
|
||
// Custom validation should be added here. | ||
function validation($data, $files) { | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Form for cmi5 connection, and tenant and token. | ||
* | ||
* @copyright 2023 Megan Bohland | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
// moodleform is defined in formslib.php | ||
require_once("$CFG->libdir/formslib.php"); | ||
|
||
|
||
class setup_token extends moodleform { | ||
// Add elements to form. | ||
public function definition() { | ||
// A reference to the form is stored in $this->form. | ||
// A common convention is to store it in a variable, such as `$mform`. | ||
$mform = $this->_form; // Don't forget the underscore! | ||
|
||
// Elements are diff inputs in form | ||
|
||
|
||
// Add elements to your form. Second arg is the name of element | ||
$mform->addElement('text', 'cmi5token', get_string('cmi5launchtenanttoken', 'cmi5launch')); | ||
// Set type of element. | ||
$mform->setType('cmi5token', PARAM_NOTAGS); | ||
// Default value. | ||
$mform->setDefault('cmi5token', get_string('cmi5launchtenanttoken_default', 'cmi5launch')); // The second arg here is the default value and appears in the text box. | ||
// These three go together for making one eleme | ||
// $mform->addElement('button', 'generatetoken', 'Generate Token'); | ||
// Add a rule to make this field required. | ||
$mform->addRule('cmi5token', 'This is needed to connect to player', 'required'); | ||
|
||
$this->add_action_buttons(); | ||
} | ||
|
||
// Custom validation should be added here. | ||
function validation($data, $files) { | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Page to create cmi5 connection, and tenant and token. | ||
* | ||
* @copyright 2023 Megan Bohland | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
|
||
// NEeded for moodle pae. sets up loabl | ||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php'); | ||
|
||
// Tell moodle about our page, tell it what the url is.\\ | ||
$PAGE->set_url('/mod/cmi5launch/setup.php'); | ||
// Tell moodle the context, in this case the site context (it's system wide not a course or course page.) | ||
$PAGE->set_context(\context_system::instance()); | ||
// Title tells what is on tab | ||
$PAGE->set_title(title: 'CMI5 Setup'); | ||
|
||
//whenyou want to out put html use the moodle core output rendereer: often overridden in theme | ||
echo $OUTPUT->header(); | ||
|
||
// Easier tom ake template as objec ttypecast to array | ||
$templatecontext = (object) [ | ||
'texttodisplay' => 'This is the setup page for CMI5. Here you can create a new tenant for your CMI5 player. Please enter a name for your tenant below.', | ||
]; | ||
// now render the mustache template we made. | ||
// takes template and template context - basically some vairables pasded into template and used to render stuff. | ||
echo $OUTPUT->render_from_template('mod_cmi5launch/setup', $templatecontext); | ||
|
||
// When we first come here lets check if there are plugin settings for username, passowrd, and url, there should nt be so display the form. | ||
// If there are, then we should display the tenant form. | ||
// Retrieve the three settings from the database. | ||
$playerurl = get_config('cmi5launch', 'cmi5launchplayerurl'); | ||
$playername = get_config('cmi5launch', 'cmi5launchbasicname'); | ||
$playerpass = get_config('cmi5launch', 'cmi5launchbasepass'); | ||
|
||
$playerpass = null; | ||
echo "<br>"; | ||
echo"Settings are: "; | ||
echo $playerurl . " "; | ||
echo "<br>"; | ||
echo $playername; | ||
echo "<br>"; | ||
echo $playerpass; | ||
// If the settings are not set, then display the first form. | ||
if(!$playerurl || !$playername || !$playerpass){ | ||
|
||
redirect(url: $CFG->wwwroot . '/mod/cmi5launch/setupform.php', message: 'Cancelled'); | ||
|
||
} | ||
|
||
|
||
|
||
echo $OUTPUT->footer(); | ||
?> | ||
|
||
|
||
<form id="gobackform" action="../../admin/settings.php" method="get"> | ||
<input id="section" name="section" type="hidden" value="modsettingcmi5launch"> | ||
|
||
</form> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.