Skip to content

Commit

Permalink
added panopto integration and code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins committed Sep 22, 2021
1 parent f2082f3 commit 4ead5ea
Show file tree
Hide file tree
Showing 120 changed files with 3,012 additions and 363 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ Enrich your videos by the powerful features of the social video player. Create p

# Changelog

### v1.8
* panopto integration

### v1.7
* annotation export
* visibility lock (needed ``ep5 version 1.4``)
* setting to enable/disable comments
* setting to enable/disable comments

### v1.6
* Fixed license issues
Expand Down
1 change: 1 addition & 0 deletions admin/admin_settings_license.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* This file is used to render the admin settings page
* @package mod_ivs
* @author Ghostthinker GmbH <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand Down
89 changes: 85 additions & 4 deletions amd/src/ivs_activity_settings_page.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,95 @@
define(['jquery'], function ($) {
define(['jquery', 'core/notification', 'core/custom_interaction_events', 'core/modal', 'core/modal_registry', 'core/modal_factory','core/templates','core/str','core/modal_events'], function($, Notification, CustomEvents, Modal, ModalRegistry, ModalFactory, Templates,Str,ModalEvents) {
return {
init: function () {
init: function (panopto_data) {
// register 'enable video question' change event
$('#id_match_question_enabled_value').change(function () {
set_display_option();
return;
});

// set option initially
set_display_option();
if (panopto_data) {

let servername = panopto_data.servername;
let instancename = panopto_data.instancename;
let sessiongroupid = panopto_data.sessiongroupid;
let iframeURL = 'https://' + servername + '/Panopto/Pages/Sessions/EmbeddedUpload.aspx?playlistsEnabled=false&instance=' + instancename + '&folderID=' + sessiongroupid;
let save = false;

let btn = document.createElement("button");
btn.innerHTML = panopto_data.buttonname;
btn.classList.add('btn');
btn.classList.add('btn-primary');
btn.classList.add('panopto-selector');
btn.style.marginLeft = '20px';
$('#id_panopto_video').after(btn);
let eventToOpenModal = $('.panopto-selector');

//The event to open the modal
ModalFactory.create({
type: ModalFactory.types.SAVE_CANCEL,
title: 'Panopto videos',
large: true,
body: Templates.render('mod_ivs/panopto_modal', {iframeurl: iframeURL}),
}, eventToOpenModal)
.done(function (modal) {
modal.getRoot().on(ModalEvents.save, function (e) {

// Stop the default save button behaviour which is to close the modal.
e.preventDefault();
modal.hide();
save = true;
win = document.getElementsByTagName('iframe')[1].contentWindow;
message = {cmd: 'createEmbeddedFrame'};
win.postMessage(JSON.stringify(message), 'https://' + servername);
});
});
;

window.addEventListener('message', (e) => {
let panopto_selected_video_data = JSON.parse(e.data);

if(panopto_selected_video_data.cmd === 'ready'){
win = document.getElementsByTagName('iframe')[1].contentWindow;
message = {cmd: 'createEmbeddedFrame'};
win.postMessage(JSON.stringify(message), 'https://' + servername);
}

if(panopto_selected_video_data.cmd === 'deliveryList'){
if(panopto_selected_video_data.ids.length > 1){
$('.modal-footer').children().first().attr('disabled',true);
$('.modal-footer').children().first().attr('title',panopto_data.tooltip);
}
else{
$('.modal-footer').children().first().attr('disabled',false);
$('.modal-footer').children().first().removeAttr('title',true);
}
}

if (panopto_selected_video_data.cmd === 'deliveryList' && save && panopto_selected_video_data.ids.length <= 1) {
let panopto_video_name = panopto_selected_video_data.names;
let panopto_video_id = panopto_selected_video_data.ids;
let panopto_data = JSON.stringify({
'servername': servername,
'instancename': instancename,
'sessiongroupid': sessiongroupid,
'videoname': panopto_video_name,
'sessionId': panopto_video_id
});
if(panopto_video_name.length == 1){
$('#id_panopto_video_json_field').val(panopto_data);
}
else{
$('#id_panopto_video_json_field').val('');
$('#id_panopto_video_json_field').attr('value','')
$('#id_panopto_video').attr('value','')
}

$('#id_panopto_video').val(panopto_video_name);
}
}
)
}

}
}
});
Expand Down
4 changes: 2 additions & 2 deletions annotation_overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Render all annotations
* @package mod_ivs
* @author Ghostthinker GmbH <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand Down Expand Up @@ -61,7 +62,6 @@

$renderer = $PAGE->get_renderer('ivs');


echo '<div class="ivs-annotations">';

$all_rendered_comments = [];
Expand All @@ -74,7 +74,7 @@

echo '</div>';

$renderable = new \mod_ivs\output\annotation_download($all_rendered_comments,$ivs,$cm);
$renderable = new \mod_ivs\output\annotation_download($all_rendered_comments, $ivs, $cm);
echo $renderer->render($renderable);


Expand Down
16 changes: 15 additions & 1 deletion backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* File for the backend
* @package mod_ivs
* @author Ghostthinker GmbH <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand Down Expand Up @@ -103,6 +104,12 @@

}

/**
* Callback for comments
* @param array $args
* @param array $postdata
* @param string $requestmethod
*/
function ivs_backend_comments($args, $postdata, $requestmethod) {
$videoid = $args[1];

Expand Down Expand Up @@ -191,6 +198,12 @@ function ivs_backend_comments($args, $postdata, $requestmethod) {
}
}

/**
* Callback for playbackcommands
* @param array $args
* @param array $postdata
* @param string $requestmethod
*/
function ivs_backend_playbackcommands($args, $postdata, $requestmethod) {
$videonid = $args[1];

Expand Down Expand Up @@ -232,6 +245,7 @@ function ivs_backend_playbackcommands($args, $postdata, $requestmethod) {
}

/**
* Exit call when errors appear
* @param string $data
* @param int $statuscode
*/
Expand All @@ -243,7 +257,7 @@ function ivs_backend_error_exit($data = "access denied", $statuscode = 403) {

/**
* Exit call when successfully ended tasks
* @param $data
* @param string|array $data
* @param int $statuscode
*/
function ivs_backend_exit($data, $statuscode = 200) {
Expand Down
1 change: 1 addition & 0 deletions backup/moodle2/backup_course_ivs_settings_step.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* This class is used to backup settings
* @package mod_ivs
* @author Ghostthinker GmbH <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand Down
7 changes: 4 additions & 3 deletions backup/moodle2/backup_ivs_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* This class is used to backup a ivs activity
* @package mod_ivs
* @author Ghostthinker GmbH <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -25,7 +26,9 @@
require_once($CFG->dirroot . '/mod/ivs/backup/moodle2/backup_ivs_stepslib.php');
require_once($CFG->dirroot . '/mod/ivs/backup/moodle2/backup_course_ivs_settings_step.class.php');


/**
* Class backup_ivs_activity_task
*/
class backup_ivs_activity_task extends backup_activity_task {

/**
Expand All @@ -38,8 +41,6 @@ protected function define_my_settings() {
/**
* Defines a backup step to store the instance data in the ivs.xml file
*/

// Todo: Wait for answer from moodle question at https://moodle.org/mod/forum/discuss.php?d=378747#p1528693.
protected function define_my_steps() {
$this->add_step(new backup_ivs_activity_structure_step('ivs_structure', 'ivs.xml'));
}
Expand Down
5 changes: 4 additions & 1 deletion backup/moodle2/backup_ivs_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* This class is used to backup a ivs activity
* @package mod_ivs
* @author Ghostthinker GmbH <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -23,7 +24,9 @@

defined('MOODLE_INTERNAL') || die;


/**
* Class backup_ivs_activity_structure_step
*/
class backup_ivs_activity_structure_step extends backup_activity_structure_step {

/**
Expand Down
12 changes: 8 additions & 4 deletions backup/moodle2/restore_ivs_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* This class is used to restore ivs activitys
* @package mod_ivs
* @author Ghostthinker GmbH <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -26,6 +27,9 @@
require_once($CFG->dirroot . '/mod/ivs/backup/moodle2/restore_ivs_stepslib.php');
require_once($CFG->dirroot . '/mod/ivs/backup/moodle2/restore_ivs_settingslib.php');

/**
* Class restore_ivs_activity_task
*/
class restore_ivs_activity_task extends restore_activity_task {

/**
Expand Down Expand Up @@ -78,9 +82,9 @@ public static function define_decode_rules() {

/**
* Define the restore log rules that will be applied
* by the {@link restore_logs_processor} when restoring
* by the {@see restore_logs_processor} when restoring
* ivs logs. It must return one array
* of {@link restore_log_rule} objects
* of {@see restore_log_rule} objects
*/
public static function define_restore_log_rules() {
$rules = array();
Expand All @@ -94,9 +98,9 @@ public static function define_restore_log_rules() {

/**
* Define the restore log rules that will be applied
* by the {@link restore_logs_processor} when restoring
* by the {@see restore_logs_processor} when restoring
* course logs. It must return one array
* of {@link restore_log_rule} objects
* of {@see restore_log_rule} objects
*
* Note this rules are applied when restoring course logs
* by the restore final task, but are defined here at
Expand Down
21 changes: 13 additions & 8 deletions backup/moodle2/restore_ivs_settingslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* This class is used to restore all settings
* @package mod_ivs
* @author Ghostthinker GmbH <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -27,33 +28,37 @@

defined('MOODLE_INTERNAL') || die;

/**
* Class restore_match_answer_setting
*/
class restore_match_answer_setting extends restore_activity_generic_setting {

/**
* Instantiates a setting object
* restore_match_answer_setting constructor.
*
* @param string $name Name of the setting
* @param string $vtype Type of the setting, eg {@link base_setting::IS_TEXT}
* @param mixed $value Value of the setting
* @param bool $visibility Is the setting visible in the UI, eg {@link base_setting::VISIBLE}
* @param int $status Status of the setting with regards to the locking, eg {@link base_setting::NOT_LOCKED}
* @param bool $visibility Is the setting visible in the UI, eg {@see base_setting::VISIBLE}
* @param int $status Status of the setting with regards to the locking, eg {@see base_setting::NOT_LOCKED}
*/
public function __construct($name, $value = null, $visibility = self::VISIBLE, $status = self::NOT_LOCKED) {
parent::__construct($name, self::IS_TEXT, $value, $visibility, $status);
$this->make_ui(self::UI_HTML_CHECKBOX, get_string("ivs_restore_include_match_answers", 'ivs'), null);
}
}

/**
* Class restore_videocomments_setting
*/
class restore_videocomments_setting extends restore_activity_generic_setting {

/**
* Instantiates a setting object
* restore_videocomments_setting constructor.
*
* @param string $name Name of the setting
* @param string $vtype Type of the setting, eg {@link base_setting::IS_TEXT}
* @param mixed $value Value of the setting
* @param bool $visibility Is the setting visible in the UI, eg {@link base_setting::VISIBLE}
* @param int $status Status of the setting with regards to the locking, eg {@link base_setting::NOT_LOCKED}
* @param bool $visibility Is the setting visible in the UI, eg {@see base_setting::VISIBLE}
* @param int $status Status of the setting with regards to the locking, eg {@see base_setting::NOT_LOCKED}
*/
public function __construct($name, $value = null, $visibility = self::VISIBLE, $status = self::NOT_LOCKED) {
parent::__construct($name, self::IS_TEXT, $value, $visibility, $status);
Expand Down
Loading

0 comments on commit 4ead5ea

Please sign in to comment.