2018-09-18 23:25:08 +02:00
|
|
|
<?php
|
|
|
|
if(isset($_SERVER['SCRIPT_FILENAME']))
|
|
|
|
{
|
2018-09-19 22:21:39 +02:00
|
|
|
// If SCRIPT_FILENAME is set, use that so the symlinked directories the developmen environment uses are handled correctly
|
|
|
|
$root = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
|
2018-09-18 23:25:08 +02:00
|
|
|
require_once($root."/config.php");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-19 22:21:39 +02:00
|
|
|
// If not, assume the cwd is not symlinked and proceed as we are used to
|
2018-09-18 23:25:08 +02:00
|
|
|
require_once("../../config.php");
|
|
|
|
}
|
|
|
|
|
2018-09-19 22:21:39 +02:00
|
|
|
// HOW DID WE ENSURE ONLY ADMINS CAN VIEW THIS PAGE?
|
|
|
|
|
2018-09-18 23:25:08 +02:00
|
|
|
require_once($CFG->libdir.'/adminlib.php');
|
|
|
|
|
|
|
|
admin_externalpage_setup("block_gradelevel_default_levels");
|
|
|
|
|
2018-09-19 22:21:39 +02:00
|
|
|
$action = optional_param('action', null, PARAM_ALPHA);
|
|
|
|
$data = optional_param('data', null, PARAM_ALPHA);
|
|
|
|
if(!empty($data))
|
|
|
|
{
|
|
|
|
$data = json_decode($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!empty($action) && confirm_sesskey())
|
|
|
|
{
|
|
|
|
switch($action) {
|
|
|
|
case 'submitchanges':
|
|
|
|
|
|
|
|
print_r($data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
redirect($PAGE->url);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$PAGE->requires->js_call_amd('block_gradelevel/leveleditor', 'init');
|
|
|
|
|
|
|
|
print $OUTPUT->header();
|
|
|
|
print $OUTPUT->heading(get_string('cfgpage_globallevels', 'block_gradelevel'));
|
|
|
|
|
|
|
|
$global_levels = $DB->get_records('block_gradelevel_levels', array('levelset_id' => 0));
|
|
|
|
usort( $global_levels, function( $a, $b) {
|
|
|
|
return ( $a->points < $b->points ) ? -1 : 1;
|
|
|
|
} );
|
|
|
|
|
|
|
|
$skill_id = 0;
|
|
|
|
print "<p>".get_string('levelcfg_description','block_gradelevel')."</p>";
|
|
|
|
print "<table id='level_config' data-skill='{$skill_id}'>";
|
|
|
|
print "<thead><tr><th>".get_string('levelcfg_head_points','block_gradelevel')."</th><th>".get_string('levelcfg_head_color','block_gradelevel')."</th></tr></thead>";
|
|
|
|
print "<tbody>";
|
|
|
|
foreach($global_levels as $lvl)
|
|
|
|
{
|
|
|
|
$color = ltrim($lvl->badgecolor,"#");
|
|
|
|
print "<tr data-rowid='{$lvl->id}'><td><input data-name='points' type='number' class='uint' value='{$lvl->points}'></td><td><input type='text' data-name='color' class='jscolor' value='{$color}'></td></tr>";
|
|
|
|
|
|
|
|
}
|
|
|
|
print "</tbody>";
|
|
|
|
print "<tfoot><tr><td class='block_gradelevel_addlevel' colspan='2'><a data-action='addlevel' href='#' onclick='return false;'>".get_string("levelcfg_addlevel",'block_gradelevel')."</a></td></td></tfoot>";
|
|
|
|
print "</table>";
|
|
|
|
print "<p><button data-action='savechanges'>".get_string('savechanges','core')."</button></p>";
|
2018-09-18 23:25:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-09-19 22:21:39 +02:00
|
|
|
print $OUTPUT->footer();
|
|
|
|
}
|