1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
/**
|
|
|
17 |
* Administration settings definitions for the hvp module.
|
|
|
18 |
*
|
|
|
19 |
* @package mod_hvp
|
|
|
20 |
* @copyright 2016 Joubel AS <contact@joubel.com>
|
|
|
21 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
22 |
*/
|
|
|
23 |
|
|
|
24 |
// Make sure we are called from an internal Moodle site.
|
|
|
25 |
defined('MOODLE_INTERNAL') || die();
|
|
|
26 |
|
|
|
27 |
require_once($CFG->dirroot . '/mod/hvp/lib.php');
|
|
|
28 |
require_once($CFG->dirroot . '/mod/hvp/classes/admin_setting_html.php');
|
|
|
29 |
|
|
|
30 |
global $PAGE;
|
|
|
31 |
|
|
|
32 |
// Redefine the H5P admin menu entry to be expandable.
|
|
|
33 |
$modltifolder = new admin_category('modhvpfolder', new lang_string('pluginname', 'mod_hvp'), $module->is_enabled() === false);
|
|
|
34 |
// Add the Settings admin menu entry.
|
|
|
35 |
$ADMIN->add('modsettings', $modltifolder);
|
|
|
36 |
$settings->visiblename = new lang_string('settings', 'mod_hvp');
|
|
|
37 |
// Add the Libraries admin menu entry.
|
|
|
38 |
$ADMIN->add('modhvpfolder', $settings);
|
|
|
39 |
$ADMIN->add('modhvpfolder', new admin_externalpage('h5plibraries',
|
|
|
40 |
get_string('libraries', 'hvp'), new moodle_url('/mod/hvp/library_list.php')));
|
|
|
41 |
|
|
|
42 |
if ($ADMIN->fulltree) {
|
|
|
43 |
// Make sure core is loaded.
|
|
|
44 |
$core = \mod_hvp\framework::instance('core');
|
|
|
45 |
|
|
|
46 |
// Settings is stored on the global $CFG object.
|
|
|
47 |
|
|
|
48 |
// Content state.
|
|
|
49 |
$settings->add(
|
|
|
50 |
new admin_setting_configcheckbox('mod_hvp/enable_save_content_state',
|
|
|
51 |
get_string('enablesavecontentstate', 'hvp'),
|
|
|
52 |
get_string('enablesavecontentstate_help', 'hvp'), 0));
|
|
|
53 |
$settings->add(
|
|
|
54 |
new admin_setting_configtext('mod_hvp/content_state_frequency',
|
|
|
55 |
get_string('contentstatefrequency', 'hvp'),
|
|
|
56 |
get_string('contentstatefrequency_help', 'hvp'), 30, PARAM_INT));
|
|
|
57 |
|
|
|
58 |
$PAGE->requires->js('/mod/hvp/library/js/jquery.js', true);
|
|
|
59 |
$PAGE->requires->js('/mod/hvp/library/js/h5p-display-options.js', true);
|
|
|
60 |
|
|
|
61 |
// Send usage statistics.
|
|
|
62 |
$settings->add(
|
|
|
63 |
new admin_setting_configcheckbox('mod_hvp/send_usage_statistics',
|
|
|
64 |
get_string('sendusagestatistics', 'hvp'),
|
|
|
65 |
get_string('sendusagestatistics_help', 'hvp',
|
|
|
66 |
'href="https://h5p.org/tracking-the-usage-of-h5p" target="_blank"'),
|
|
|
67 |
1)
|
|
|
68 |
);
|
|
|
69 |
|
|
|
70 |
$choices = array(
|
|
|
71 |
H5PDisplayOptionBehaviour::NEVER_SHOW => get_string('displayoptiondownloadnever', 'hvp'),
|
|
|
72 |
H5PDisplayOptionBehaviour::ALWAYS_SHOW => get_string('displayoptiondownloadalways', 'hvp'),
|
|
|
73 |
H5PDisplayOptionBehaviour::CONTROLLED_BY_PERMISSIONS => get_string('displayoptiondownloadpermission', 'hvp'),
|
|
|
74 |
H5PDisplayOptionBehaviour::CONTROLLED_BY_AUTHOR_DEFAULT_ON => get_string('displayoptionauthoron', 'hvp'),
|
|
|
75 |
H5PDisplayOptionBehaviour::CONTROLLED_BY_AUTHOR_DEFAULT_OFF => get_string('displayoptionauthoroff', 'hvp')
|
|
|
76 |
);
|
|
|
77 |
|
|
|
78 |
$embedchoices = array(
|
|
|
79 |
H5PDisplayOptionBehaviour::NEVER_SHOW => get_string('displayoptionnevershow', 'hvp'),
|
|
|
80 |
H5PDisplayOptionBehaviour::ALWAYS_SHOW => get_string('displayoptionalwaysshow', 'hvp'),
|
|
|
81 |
H5PDisplayOptionBehaviour::CONTROLLED_BY_PERMISSIONS => get_string('displayoptionpermissionsembed', 'hvp'),
|
|
|
82 |
H5PDisplayOptionBehaviour::CONTROLLED_BY_AUTHOR_DEFAULT_ON => get_string('displayoptionauthoron', 'hvp'),
|
|
|
83 |
H5PDisplayOptionBehaviour::CONTROLLED_BY_AUTHOR_DEFAULT_OFF => get_string('displayoptionauthoroff', 'hvp')
|
|
|
84 |
);
|
|
|
85 |
|
|
|
86 |
// Display options for H5P frame.
|
|
|
87 |
$settings->add(new admin_setting_heading('mod_hvp/display_options', get_string('displayoptions', 'hvp'), ''));
|
|
|
88 |
$settings->add(new admin_setting_configcheckbox('mod_hvp/frame', get_string('enableframe', 'hvp'), '', 1));
|
|
|
89 |
$settings->add(new admin_setting_configselect('mod_hvp/export', get_string('enabledownload', 'hvp'), '',
|
|
|
90 |
H5PDisplayOptionBehaviour::ALWAYS_SHOW, $choices));
|
|
|
91 |
$settings->add(new admin_setting_configselect('mod_hvp/embed', get_string('enableembed', 'hvp'), '',
|
|
|
92 |
H5PDisplayOptionBehaviour::ALWAYS_SHOW, $embedchoices));
|
|
|
93 |
$settings->add(new admin_setting_configcheckbox('mod_hvp/copyright', get_string('enablecopyright', 'hvp'), '', 1));
|
|
|
94 |
$settings->add(new admin_setting_configcheckbox('mod_hvp/icon', get_string('enableabout', 'hvp'), '', 1));
|
|
|
95 |
|
|
|
96 |
// Content Types header.
|
|
|
97 |
$settings->add(new admin_setting_heading('mod_hvp/hub_settings', get_string('hubsettingsheader', 'hvp'), ''));
|
|
|
98 |
|
|
|
99 |
// LRS.
|
|
|
100 |
$settings->add(
|
|
|
101 |
new admin_setting_configcheckbox('mod_hvp/enable_lrs_content_types',
|
|
|
102 |
get_string('enabledlrscontenttypes', 'hvp'),
|
|
|
103 |
get_string('enabledlrscontenttypes_help', 'hvp'), 0));
|
|
|
104 |
|
|
|
105 |
// Use H5P Hub.
|
|
|
106 |
$settings->add(
|
|
|
107 |
new admin_setting_configcheckbox(
|
|
|
108 |
'mod_hvp/hub_is_enabled',
|
|
|
109 |
get_string('enablehublabel', 'hvp'),
|
|
|
110 |
get_string('disablehubdescription', 'hvp'),
|
|
|
111 |
1
|
|
|
112 |
)
|
|
|
113 |
);
|
|
|
114 |
|
|
|
115 |
// Content Hub.
|
|
|
116 |
$hubinfo = $core->hubAccountInfo();
|
|
|
117 |
$settings->add(new admin_setting_heading(
|
|
|
118 |
'mod_hvp/content_hub_settings',
|
|
|
119 |
get_string('contenthub:settings:heading', 'hvp'),
|
|
|
120 |
''
|
|
|
121 |
));
|
|
|
122 |
|
|
|
123 |
$settings->add(new admin_setting_html(
|
|
|
124 |
'mod_hvp/content_hub_settings_box',
|
|
|
125 |
get_string('contenthub:settings:box', 'hvp'),
|
|
|
126 |
$hubinfo
|
|
|
127 |
));
|
|
|
128 |
|
|
|
129 |
// Load js for disable hub confirmation dialog functionality.
|
|
|
130 |
$PAGE->requires->js('/mod/hvp/library/js/jquery.js', true);
|
|
|
131 |
$PAGE->requires->js('/mod/hvp/library/js/h5p-event-dispatcher.js', true);
|
|
|
132 |
$PAGE->requires->js('/mod/hvp/library/js/h5p-confirmation-dialog.js', true);
|
|
|
133 |
$PAGE->requires->js('/mod/hvp/library/js/settings/h5p-disable-hub.js', true);
|
|
|
134 |
|
|
|
135 |
// Skip applying css when page has already loaded, since Moodle does not.
|
|
|
136 |
// allow us to require the css at this point.
|
|
|
137 |
if ($PAGE->state !== 2) {
|
|
|
138 |
$PAGE->requires->css('/mod/hvp/library/styles/h5p-confirmation-dialog.css');
|
|
|
139 |
$PAGE->requires->css('/mod/hvp/library/styles/h5p.css');
|
|
|
140 |
$PAGE->requires->css('/mod/hvp/library/styles/h5p-core-button.css');
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
// Find missing requirements.
|
|
|
144 |
$errors = $core->checkSetupErrorMessage()->errors;
|
|
|
145 |
|
|
|
146 |
$PAGE->requires->data_for_js('H5PDisableHubData', array(
|
|
|
147 |
'selector' => '#id_s_mod_hvp_hub_is_enabled',
|
|
|
148 |
'overlaySelector' => '#adminsettings',
|
|
|
149 |
'header' => get_string('confirmdialogheader', 'hvp'),
|
|
|
150 |
'confirmLabel' => get_string('confirmlabel', 'hvp'),
|
|
|
151 |
'cancelLabel' => get_string('cancellabel', 'hvp'),
|
|
|
152 |
'confirmationDialogMsg' => get_string('disablehubconfirmationmsg', 'hvp'),
|
|
|
153 |
'errors' => $errors
|
|
|
154 |
));
|
|
|
155 |
}
|
|
|
156 |
|
|
|
157 |
// Prevent Moodle from adding settings block in standard location.
|
|
|
158 |
$settings = null;
|