-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings.php
167 lines (146 loc) · 6.96 KB
/
settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?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/>.
/**
* This file defines the admin settings for this plugin
*
* @package qtype_cloudpoodll
* @copyright 2019 Justin Hunt {@link http://www.poodll.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
use qtype_cloudpoodll\constants;
use qtype_cloudpoodll\utils;
if ($ADMIN->fulltree) {
$plugin = constants::M_COMP;
$name = 'apiuser';
$label = get_string($name, $plugin);
$details = get_string('apiuser_details', $plugin);
$settings->add(new admin_setting_configtext("$plugin/$name", $label, $details, '', PARAM_TEXT));
$cloudpoodllapiuser = get_config(constants::M_COMP, 'apiuser');
$cloudpoodllapisecret = get_config(constants::M_COMP, 'apisecret');
$showbelowapisecret = '';
// if we have an API user and secret we fetch token
if(!empty($cloudpoodllapiuser) && !empty($cloudpoodllapisecret)) {
$tokeninfo = utils::fetch_token_for_display($cloudpoodllapiuser, $cloudpoodllapisecret);
$showbelowapisecret = $tokeninfo;
// if we have no API user and secret we show a "fetch from elsewhere on site" or "take a free trial" link
}else{
$amddata = ['apppath' => $CFG->wwwroot . '/' .constants::M_URL];
$cpcomponents = ['filter_poodll', 'mod_readaloud', 'mod_wordcards', 'mod_solo', 'mod_minilesson', 'mod_englishcentral', 'mod_pchat',
'atto_cloudpoodll', 'tinymce_cloudpoodll', 'assignfeedback_cloudpoodll', 'assignsubmission_cloudpoodll'];
foreach($cpcomponents as $cpcomponent){
switch($cpcomponent){
case 'filter_poodll':
$apiusersetting = 'cpapiuser';
$apisecretsetting = 'cpapisecret';
break;
case 'mod_englishcentral':
$apiusersetting = 'poodllapiuser';
$apisecretsetting = 'poodllapisecret';
break;
default:
$apiusersetting = 'apiuser';
$apisecretsetting = 'apisecret';
}
$cloudpoodllapiuser = get_config($cpcomponent, $apiusersetting);
if(!empty($cloudpoodllapiuser)){
$cloudpoodllapisecret = get_config($cpcomponent, $apisecretsetting);
if(!empty($cloudpoodllapisecret)){
$amddata['apiuser'] = $cloudpoodllapiuser;
$amddata['apisecret'] = $cloudpoodllapisecret;
break;
}
}
}
$showbelowapisecret = $OUTPUT->render_from_template( constants::M_COMP . '/managecreds', $amddata);
}
$name = 'apisecret';
$label = get_string($name, $plugin);
$settings->add(new admin_setting_configtext("$plugin/$name", $label, $showbelowapisecret, '', PARAM_TEXT));
// apicredshelper
/*
$name = 'apicredshelper';
$label = get_string($name, $plugin);
$details = get_string('apicredshelper_details', $plugin);
$settings->add(new qtype_cloudpoodll\setting\apicredshelper("$plugin/$name", $label, $details,''));
*/
$name = 'awsregion';
$label = get_string($name, $plugin);
$default = constants::REGION_USEAST1;
$options = utils::get_region_options();
$settings->add(new admin_setting_configselect("$plugin/$name", $label, '', $default, $options));
$name = 'expiredays';
$label = get_string('expiredays', $plugin);
$default = '365';
$options = utils::get_expiredays_options();
$settings->add(new admin_setting_configselect("$plugin/$name", $label, '', $default, $options));
$name = 'language';
$label = get_string($name, $plugin);
$default = 'en-US';
$options = utils::get_lang_options();
$settings->add(new admin_setting_configselect("$plugin/$name", $label, '', $default, $options));
// Audio record skin
$name = 'audioskin';
$label = get_string($name, $plugin);
$details = get_string($name, $plugin);
$default = constants::SKIN_123;
$options = utils::fetch_options_skins(constants::REC_AUDIO);
$settings->add(new admin_setting_configselect("$plugin/$name", $label, $details, $default, $options));
// Video record skin
$name = 'videoskin';
$label = get_string($name, $plugin);
$details = get_string($name, $plugin);
$options = utils::fetch_options_skins(constants::REC_VIDEO);
$settings->add(new admin_setting_configselect("$plugin/$name", $label,
$details, constants::SKIN_123, $options));
// Transcriber options
$name = 'transcriber';
$label = get_string($name, $plugin);
$details = get_string($name . '_details', $plugin);
$default = constants::TRANSCRIBER_AMAZONTRANSCRIBE;
$options = utils::fetch_options_transcribers();
$settings->add(new admin_setting_configselect("$plugin/$name", $label, $details, $default, $options));
// Student Player options
$name = 'studentplayer';
$label = get_string($name, $plugin);
$details = get_string($name . '_details', $plugin);
$default = constants::PLAYERTYPE_INTERACTIVETRANSCRIPT;
$options = utils::fetch_options_players();
$settings->add(new admin_setting_configselect("$plugin/$name", $label, $details, $default, $options));
// Teacher Player options
$name = 'teacherplayer';
$label = get_string($name, $plugin);
$settings->add(new admin_setting_configselect("$plugin/$name", $label, $details, $default, $options));
// Transcode audio/video
$name = 'transcode';
$label = get_string($name, $plugin);
$details = get_string($name . '_details', $plugin);
$options = [0 => get_string('no'), 1 => get_string('yes')];
$settings->add(new admin_setting_configselect("$plugin/$name", $label, $details, 1, $options));
// Default html5 fallback
$name = 'fallback';
$label = get_string($name, $plugin);
$details = get_string($name . '_details', $plugin);
$default = constants::FALLBACK_IOSUPLOAD;
$options = utils::fetch_options_fallback();
$settings->add(new admin_setting_configselect("$plugin/$name", $label, $details, $default, $options));
// SafeSave
$name = 'safesave';
$label = get_string($name, $plugin);
$details = get_string($name . '_details', $plugin);
$options = [0 => get_string('no'), 1 => get_string('yes')];
$settings->add(new admin_setting_configselect("$plugin/$name", $label, $details, 1, $options));
}