forked from justinhunt/moodle-mod_minilesson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.php
153 lines (125 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
<?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/>.
/**
* minilesson module admin settings and defaults
*
* @package mod
* @subpackage minilesson
* @copyright 2015 Justin Hunt ([email protected])
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
require_once($CFG->dirroot.'/mod/minilesson/lib.php');
use \mod_minilesson\constants;
use \mod_minilesson\utils;
if ($ADMIN->fulltree) {
/*
$settings->add(new admin_setting_configtextarea(constants::M_COMPONENT . '/defaultwelcome',
get_string('welcomelabel', constants::M_COMPONENT), get_string('welcomelabel_details', constants::M_COMPONENT), get_string('defaultwelcome',constants::M_COMPONENT), PARAM_TEXT));
*/
$settings->add(new admin_setting_configtext(constants::M_COMPONENT . '/apiuser',
get_string('apiuser', constants::M_COMPONENT),
get_string('apiuser_details', constants::M_COMPONENT), '', PARAM_TEXT));
$cloudpoodll_apiuser=get_config(constants::M_COMPONENT,'apiuser');
$cloudpoodll_apisecret=get_config(constants::M_COMPONENT,'apisecret');
$show_below_apisecret='';
//if we have an API user and secret we fetch token
if(!empty($cloudpoodll_apiuser) && !empty($cloudpoodll_apisecret)) {
$tokeninfo = utils::fetch_token_for_display($cloudpoodll_apiuser,$cloudpoodll_apisecret);
$show_below_apisecret=$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];
$cp_components=['filter_poodll','qtype_cloudpoodll','mod_readaloud','mod_wordcards','mod_solo','mod_englishcentral','mod_pchat',
'atto_cloudpoodll','tinymce_cloudpoodll', 'assignsubmission_cloudpoodll','assignfeedback_cloudpoodll'];
foreach($cp_components as $cp_component){
switch($cp_component){
case 'filter_poodll':
$apiusersetting='cpapiuser';
$apisecretsetting='cpapisecret';
break;
case 'mod_englishcentral':
$apiusersetting='poodllapiuser';
$apisecretsetting='poodllapisecret';
break;
default:
$apiusersetting='apiuser';
$apisecretsetting='apisecret';
}
$cloudpoodll_apiuser=get_config($cp_component,$apiusersetting);
if(!empty($cloudpoodll_apiuser)){
$cloudpoodll_apisecret=get_config($cp_component,$apisecretsetting);
if(!empty($cloudpoodll_apisecret)){
$amddata['apiuser']=$cloudpoodll_apiuser;
$amddata['apisecret']=$cloudpoodll_apisecret;
break;
}
}
}
$show_below_apisecret=$OUTPUT->render_from_template( constants::M_COMPONENT . '/managecreds',$amddata);
}
//get_string('apisecret_details', constants::M_COMPONENT)
$settings->add(new admin_setting_configtext(constants::M_COMPONENT . '/apisecret',
get_string('apisecret', constants::M_COMPONENT),$show_below_apisecret, '', PARAM_TEXT));
$regions = \mod_minilesson\utils::get_region_options();
$settings->add(new admin_setting_configselect(constants::M_COMPONENT . '/awsregion',
get_string('awsregion', constants::M_COMPONENT), '', 'useast1', $regions));
$langoptions = \mod_minilesson\utils::get_lang_options();
$settings->add(new admin_setting_configselect(constants::M_COMPONENT . '/ttslanguage',
get_string('ttslanguage', constants::M_COMPONENT), '', 'en-US', $langoptions));
// Transcriber options
$name = 'transcriber';
$label = get_string($name, constants::M_COMPONENT);
$details = get_string($name . '_details', constants::M_COMPONENT);
$default = constants::TRANSCRIBER_AUTO;
$options = utils::fetch_options_transcribers();
$settings->add(new admin_setting_configselect(constants::M_COMPONENT . "/$name",
$label, $details, $default, $options));
$name = 'containerwidth';
$label = get_string($name, constants::M_COMPONENT);
$details = get_string($name . '_details', constants::M_COMPONENT);
$default = constants::M_CONTWIDTH_COMPACT;
$options = utils::get_containerwidth_options();
$settings->add(new admin_setting_configselect(constants::M_COMPONENT . "/$name",
$label, $details, $default, $options));
// Reports Table
$name = 'reportstable';
$label = get_string($name, constants::M_COMPONENT);
$details = get_string($name . '_details', constants::M_COMPONENT);
$default = constants::M_USE_DATATABLES;
$options = utils::fetch_options_reportstable();
$settings->add(new admin_setting_configselect(constants::M_COMPONENT . "/$name",
$label, $details, $default, $options));
//animations
$name = 'animations';
$label = get_string($name, constants::M_COMPONENT);
$details = get_string($name . '_details', constants::M_COMPONENT);
$default = constants::M_ANIM_FANCY ;
$options = utils::fetch_options_animations();
$settings->add(new admin_setting_configselect(constants::M_COMPONENT . "/$name",
$label, $details, $default, $options));
$settings->add(new admin_setting_configtext(constants::M_COMPONENT . '/itemsperpage',
get_string('itemsperpage', constants::M_COMPONENT), get_string('itemsperpage_details', constants::M_COMPONENT), 10, PARAM_INT));
$modalsettings = array(0=>get_string('modaleditform_newpage', constants::M_COMPONENT),
1=>get_string('modaleditform_modalform', constants::M_COMPONENT));
$settings->add(new admin_setting_configselect(constants::M_COMPONENT . '/modaleditform',
get_string('modaleditform', constants::M_COMPONENT), get_string('modaleditform_details', constants::M_COMPONENT), 0, $modalsettings));
$promptstyle = \mod_minilesson\utils::get_prompttype_options();
$settings->add(new admin_setting_configselect(constants::M_COMPONENT . '/prompttype',
get_string('prompttype', constants::M_COMPONENT), '', constants::M_PROMPT_SEPARATE, $promptstyle));
$settings->add(new admin_setting_configcheckbox(constants::M_COMPONENT . '/enablesetuptab',
get_string('enablesetuptab', constants::M_COMPONENT), get_string('enablesetuptab_details',constants::M_COMPONENT), 0));
}