Skip to content

Commit

Permalink
…/results/2 : Implementated fix for this pipeline result, essentially just formating fixes
  • Loading branch information
moodle-FeliciaWilkes committed Mar 1, 2023
1 parent 0b2ed27 commit f35d901
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 111 deletions.
48 changes: 24 additions & 24 deletions classes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function get_auth_token() {

} else if ($token !== '' && $now <= $expiretime) {
mtrace('Token is valid.');
//define url for the next function
// Define url for the next function.
$url = get_config('tool_opensesame', 'baseurl') . '/v1/content?customerIntegrationId=' .
get_config('tool_opensesame', 'customerintegrationid') . '&limit=10';
$this->get_open_sesame_course_list($token, $url);
Expand Down Expand Up @@ -160,13 +160,13 @@ public function add_open_sesame_course($osdataobject, $token) {

$stringcategories = $osdataobject->oscategories;

//php compare each array elements choose the element that has the most items in it.
// PHP compare each array elements choose the element that has the most items in it.
$result = [];
$string = $stringcategories;

$firstdimension = explode(',', $string); // Divide by , symbol
foreach ($firstdimension as $temp) {
// Take each result of division and explode it by , symbol and save to result
// Take each result of division and explode it by , symbol and save to result.
$pos = strpos($temp, '|');
if ($pos !== false) {
$newtemp = substr_replace($temp, '', $pos, strlen('|'));
Expand Down Expand Up @@ -209,10 +209,10 @@ public function add_open_sesame_course($osdataobject, $token) {
$this->create_course_image($courseid, $thumbnailurl);
$scormpackagedownloadurl = $osdataobject->packagedownloadurl;
$allowedtype = get_config('tool_opensesame', 'allowedtypes');
if($allowedtype == SCORM_TYPE_LOCAL){
if ($allowedtype == SCORM_TYPE_LOCAL) {
$this->get_open_sesame_scorm_package($token, $scormpackagedownloadurl, $courseid);
}
if ($allowedtype == SCORM_TYPE_AICCURL){
if ($allowedtype == SCORM_TYPE_AICCURL) {
$this->get_open_sesame_scorm_package($token, $aicclaunchurl, $courseid);
}

Expand Down Expand Up @@ -241,7 +241,7 @@ public function determineurl(&$paging) {

public function get_open_sesame_course_list($token, $url) {
global $DB;
//Integrator issues request with access token
// Integrator issues request with access token.
$this->setHeader(['content_type: application/json', sprintf('Authorization: Bearer %s', $token)]);
$response = $this->get($url);
$statuscode = $this->get_http_code();
Expand Down Expand Up @@ -308,9 +308,9 @@ public function create_course_image($courseid, $thumbnailurl) {
'filepath' => '/', // Any path beginning and ending in /.
'filename' => 'courseimage' . $courseid . '.jpg', // Any filename.
];
//create course image
// Create course image.
$fs = get_file_storage();
//make sure there is not an image file to prevent an image file conflict
// Make sure there is not an image file to prevent an image file conflict.
$fs->delete_area_files($context->id, 'course', 'overviewfiles', 0);
// Create a new file containing the text 'hello world'.
$fs->create_file_from_url($fileinfo, $thumbnailurl);
Expand All @@ -320,7 +320,7 @@ public function get_open_sesame_scorm_package($token, $scormpackagedownloadurl,
mtrace('calling get_open_sesame_scorm_package');
global $CFG, $USER;
require_once($CFG->dirroot . '/lib/filestorage/file_storage.php');
//Integrator issues request with access token
// Integrator issues request with access token.
$this->setHeader([sprintf('Authorization: Bearer %s', $token)]);

$url = $scormpackagedownloadurl . '?standard=scorm';
Expand All @@ -329,9 +329,9 @@ public function get_open_sesame_scorm_package($token, $scormpackagedownloadurl,

$filename = 'scorm_' . $courseid . '.zip';
$path = $CFG->tempdir . '/filestorage/' . $filename;
//Download to temp directory
// Download to temp directory.
download_file_content($url, $headers, null, true, 300, 20, false, $path, false);
//create a file from temporary folder in the user file draft area
// Create a file from temporary folder in the user file draft area.
$context = context_course::instance($courseid);

$fs = get_file_storage();
Expand All @@ -343,15 +343,15 @@ public function get_open_sesame_scorm_package($token, $scormpackagedownloadurl,
'filepath' => '/', // Any path beginning and ending in /.
'filename' => $filename, // Any filename.
];
//clear file area
// Clear file area.
$fs->delete_area_files($context->id, 'mod_scorm', 'package', 0);
// Create a new file scorm.zip package inside of course.
$fs->create_file_from_pathname($fileinfo, $path);

//create a new user draft file from mod_scorm package
// Create a new user draft file from mod_scorm package.
// Get an unused draft itemid which will be used
$draftitemid = file_get_submitted_draft_itemid('packagefile');
// Copy the existing files which were previously uploaded into the draft area
// Copy the existing files which were previously uploaded into the draft area.
file_prepare_draft_area(
$draftitemid, $context->id, 'mod_scorm', 'package', 0);
$modinfo = get_fast_modinfo($courseid);
Expand All @@ -372,9 +372,9 @@ public function create_course_scorm_mod($courseid, $draftitemid) {
require_once($CFG->dirroot . '/mod/scorm/mod_form.php');
require_once($CFG->dirroot . '/completion/criteria/completion_criteria.php');

//get course
// Get course.
$course = $DB->get_record('course', ['id' => $courseid]);
//check course for modules
// Check course for modules.

$modscorm = 19;

Expand All @@ -384,7 +384,7 @@ public function create_course_scorm_mod($courseid, $draftitemid) {
['course' => $courseid, 'module' => $modscorm],
$strictness = IGNORE_MISSING
);
//found a course module scorm for this course update the activity
// Found a course module scorm for this course update the activity.
if ($cmid && $cmid !== null) {
$update = $cmid;
// Check the course module exists.
Expand All @@ -405,13 +405,13 @@ public function create_course_scorm_mod($courseid, $draftitemid) {
$cm->instance, $cm->id);

mtrace('preparing course scorm mod');
//below returns an array of $cm , $moduleinfo
// Below returns an array of $cm , $moduleinfo.
update_moduleinfo($cm, $moduleinfo, $course);

}
//only add a course module if none exist
// Only add a course module if none exist
if (!$cmid) {
//create top course section
// Create top course section.
$section = 0;
$sectionreturn = 0;
$add = 'scorm';
Expand Down Expand Up @@ -449,14 +449,14 @@ public function get_default_modinfo($courseid, $draftitemid, $module, $add = '0'
= null, $coursemodule = null) {
global $CFG;
$moduleinfo = new \stdClass();
//$moduleinfo->name is required

$moduleinfo->name = 'scorm_' . $courseid;
$moduleinfo->introeditor = ['text' => '',
'format' => '1', 'itemid' => ''];
$moduleinfo->showdescription = 0;
$moduleinfo->mform_isexpanded_id_packagehdr = 1;
require_once($CFG->dirroot . '/mod/scorm/lib.php');
//change scorm type depending on setting in config file default is SCORM_TYPE_LOCAL alternative option is SCORM_TYPE_AICCURL.
// Change scorm type depending on setting in config file default is SCORM_TYPE_LOCAL alternative option is SCORM_TYPE_AICCURL.

$moduleinfo->scormtype = get_config('tool_opensesame', 'allowedtypes');

Expand All @@ -465,7 +465,7 @@ public function get_default_modinfo($courseid, $draftitemid, $module, $add = '0'

}
$moduleinfo->packagefile = $draftitemid;
//update frequency is daily;
// Update frequency is daily.
$moduleinfo->updatefreq = 2;
$moduleinfo->popup = 0;
$moduleinfo->width = 100;
Expand Down Expand Up @@ -509,7 +509,7 @@ public function get_aicc_url($courseid){
public function set_self_enrollment($courseid, $active) {
mtrace('calling set_self_enrollment');
global $DB;
// get enrollment plugin
// Get enrollment plugin.
$instance = $DB->get_record('enrol', ['courseid' => $courseid, 'enrol' => 'self']);
$enrolplugin = enrol_get_plugin($instance->enrol);

Expand Down
3 changes: 2 additions & 1 deletion classes/task/opensesamesync.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use context_course;
use tool_opensesame\api;

defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/lib/filelib.php');
require_once($CFG->dirroot . '/course/lib.php');

Expand Down Expand Up @@ -59,7 +60,7 @@ public function execute($testing = null) {
* */
$api = new api;
$token = $api->get_auth_token();
//$api->get_open_sesame_course_list($token);

mtrace('opensesame just finished.');
return true;
}
Expand Down
24 changes: 12 additions & 12 deletions db/tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

// List of tasks.
defined('MOODLE_INTERNAL') || die();

$tasks = [
// First task configuration.
[
'classname' => 'tool_opensesame\task\opensesamesync',
'blocking' => 0,
'minute' => '*',
'hour' => 'R',
'day' => '*',
'dayofweek' => '*',
'month' => '*'
],
// Second task configuration.

[
'classname' => 'tool_opensesame\task\opensesamesync',
'blocking' => 0,
'minute' => '*',
'hour' => 'R',
'day' => '*',
'dayofweek' => '*',
'month' => '*'
],

];
2 changes: 0 additions & 2 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

/**
* Upgrade the plugin.
*
Expand Down
60 changes: 0 additions & 60 deletions index.php

This file was deleted.

2 changes: 1 addition & 1 deletion lang/en/tool_opensesame.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
$string['opensesameintegration'] = 'Integration Settings';
$string['pluginname'] = 'OpenSesame Integration';
$string['statuscode400'] =
'400 Bad Request response status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error';
'400 Bad Request response status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error';
20 changes: 10 additions & 10 deletions settings.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?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
Expand All @@ -25,13 +27,13 @@
global $CFG;

if ($hassiteconfig) {
//place settings category named opensesameintegration under tab courses
// Place settings category named opensesameintegration under tab courses.
$ADMIN->add('courses',
new admin_category('opensesameintegration', new lang_string('opensesamecat', 'tool_opensesame')),
);
// places the link to the settingspage under the new category
// Places the link to the settingspage under the new category.
$settings = new admin_settingpage('tool_opensesame', get_string('opensesameintegration', 'tool_opensesame'));
//creating new settings to add the new settingspage
// Creating new settings to add the new settingspage.

if (!is_array($CFG->forced_plugin_settings['tool_opensesame'])) {
$settings->add(new admin_setting_configtext('tool_opensesame/clientid', get_string('clientid', 'tool_opensesame'),
Expand All @@ -50,22 +52,20 @@
get_string('customerintegrationid', 'tool_opensesame'),
get_string('customerintegrationiddesc', 'tool_opensesame'), ''));

// add scorm type select
// Add scorm type select.
// Types allowed.
//DEF-730 BEGINNING

require_once($CFG->dirroot . '/mod/scorm/lib.php');
$options = array(
//SCORM_TYPE_LOCAL = 'local'
//SCORM_TYPE_AICCURL = 'aiccurl'
//'both' => new lang_string('localandaiccurl', 'tool_opensesame'),

SCORM_TYPE_LOCAL => new lang_string('onlylocal', 'tool_opensesame'),
SCORM_TYPE_AICCURL => new lang_string('onlyaiccurl', 'tool_opensesame')
);
$name = get_string('allowedtypes', 'tool_opensesame');
$desc = get_string('allowedtypes_desc', 'tool_opensesame');
$default = SCORM_TYPE_LOCAL;
$settings->add(new admin_setting_configselect('tool_opensesame/allowedtypes', $name, $desc, $default, $options));
//DEF-730 END
//add to the admin settings for opensesameintegration

// Add to the admin settings for opensesameintegration.
$ADMIN->add('opensesameintegration', $settings);
}
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2023013103; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2020061500; // Requires this Moodle version. 3.9
$plugin->requires = 2020061500; // Requires this Moodle version. 3.9.
$plugin->component = 'tool_opensesame'; // Full name of the plugin (used for diagnostics).

0 comments on commit f35d901

Please sign in to comment.