Moodle code style fixes part 5
This commit is contained in:
parent
e694cefde3
commit
4305438d15
|
@ -29,7 +29,6 @@ $systemcontext = context_system::instance();
|
|||
// Check if user has capability to manage this.
|
||||
require_capability('local/treestudyplan:configure', $systemcontext);
|
||||
|
||||
|
||||
$PAGE->requires->js_call_amd('local_treestudyplan/cfg-grades', 'init');
|
||||
|
||||
const GRADECFG_TABLE = "local_treestudyplan_gradecfg";
|
||||
|
@ -69,7 +68,6 @@ if ($_POST["action"] == "update") {
|
|||
$DB->update_record(GRADECFG_TABLE, $scalecfg);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$scalecfg = (object)[ "scale_id" => $scale->id, ];
|
||||
$requireinsert = false;
|
||||
|
@ -141,7 +139,6 @@ if ($_POST["action"] == "update") {
|
|||
}
|
||||
|
||||
|
||||
|
||||
// Process all available scales and load the current configuration for it.
|
||||
$data = [];
|
||||
foreach ($scales as $scale) {
|
||||
|
@ -189,7 +186,6 @@ foreach ($scales as $scale) {
|
|||
$data[] = $row;
|
||||
}
|
||||
|
||||
|
||||
print html_writer::start_tag("form", ["method" => "post", ]);
|
||||
print html_writer::tag("input", null, ['name' => "action", 'value' => 'update', 'type' => 'hidden']);
|
||||
|
||||
|
@ -211,18 +207,34 @@ $data = [];
|
|||
foreach ($gradecfgs as $g) {
|
||||
$row = [];
|
||||
$row[] = $g->grade_points;
|
||||
$row[] = html_writer::tag("input", null, ['name' => "g_{$g->grade_points}_min_completed", 'value' => "{$g->min_completed}", 'type' => 'text', "class" => "float", 'autocomplete' => 'off']);
|
||||
$row[] = html_writer::tag( "input", null,
|
||||
['name' => "g_{$g->grade_points}_min_completed",
|
||||
'value' => "{$g->min_completed}",
|
||||
'type' => 'text',
|
||||
"class" => "float",
|
||||
'autocomplete' => 'off']);
|
||||
$row[] = html_writer::tag("input", null, ['name' => "g_{$g->grade_points}_delete", 'type' => 'checkbox', ]);
|
||||
$data[] = $row;
|
||||
}
|
||||
|
||||
$row = [];
|
||||
$row[] = html_writer::tag("input", null, ['name' => "g_new_gradepoints", 'value' => '', 'type' => 'number', 'min' => '0', 'pattern' => '/d+', 'step' => '1', 'autocomplete' => 'off']);
|
||||
$row[] = html_writer::tag("input", null, ['name' => "g_new_min_completed", 'value' => '', 'type' => 'text', "class" => "float", 'autocomplete' => 'off']);
|
||||
$row[] = html_writer::tag("input", null,
|
||||
[ 'name' => "g_new_gradepoints",
|
||||
'value' => '',
|
||||
'type' => 'number',
|
||||
'min' => '0',
|
||||
'pattern' => '/d+',
|
||||
'step' => '1',
|
||||
'autocomplete' => 'off']);
|
||||
$row[] = html_writer::tag("input", null,
|
||||
[ 'name' => "g_new_min_completed",
|
||||
'value' => '',
|
||||
'type' => 'text',
|
||||
"class" => "float",
|
||||
'autocomplete' => 'off']);
|
||||
|
||||
$data[] = $row;
|
||||
|
||||
|
||||
$table = new html_table();
|
||||
$table->id = "";
|
||||
$table->attributes['class'] = 'generaltable m-roomtable';
|
||||
|
@ -233,7 +245,6 @@ $table->head[] = get_string('grade_points', 'local_treestudyplan');
|
|||
$table->head[] = get_string('min_completed', 'local_treestudyplan');
|
||||
$table->head[] = get_string('delete', );
|
||||
|
||||
|
||||
print $OUTPUT->heading(get_string('cfg_grades_grades', 'local_treestudyplan'));
|
||||
print html_writer::tag('div', html_writer::table($table), ['class' => 'flexible-wrap']);
|
||||
print html_writer::tag("input", null, ['value' => get_string("save"), 'type' => 'submit', "class" => "btn btn-primary"]);
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
namespace local_treestudyplan;
|
||||
require_once($CFG->libdir.'/externallib.php');
|
||||
|
||||
|
@ -43,9 +42,9 @@ abstract class aggregator {
|
|||
// Static list, since we'd need to implement a lot of static data for new aggregation methods anyway.
|
||||
// And this is faster than any dynamic method.
|
||||
return [
|
||||
"core", # use moodle core completion
|
||||
"core", // Use moodle core completion.
|
||||
"bistate",
|
||||
"tristate", # deprecated
|
||||
"tristate", // Deprecated.
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -61,8 +60,7 @@ abstract class aggregator {
|
|||
public static function createOrDefault($mod, $configstr) {
|
||||
try {
|
||||
return self::create($mod, $configstr);
|
||||
}
|
||||
catch(\ValueError $x) {
|
||||
} catch (\ValueError $x) {
|
||||
return self::create(self::FALLBACK, "");
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +69,8 @@ abstract class aggregator {
|
|||
$this->initialize($configstr);
|
||||
}
|
||||
|
||||
protected function initialize($configstr) {}
|
||||
protected function initialize($configstr) {
|
||||
}
|
||||
|
||||
public abstract function needSelectGradables();
|
||||
public abstract function isDeprecated();
|
||||
|
@ -125,7 +124,7 @@ abstract class aggregator {
|
|||
|
||||
$list = [];
|
||||
foreach (self::list() as $agid) {
|
||||
$a = self::create($agid, ""); // create new one with empty config string.
|
||||
$a = self::create($agid, ""); // Create new one with empty config string.
|
||||
$list[] = [
|
||||
'id' => $agid,
|
||||
'name' => get_string("{$agid}_aggregator_title", "local_treestudyplan"),
|
||||
|
@ -136,6 +135,4 @@ abstract class aggregator {
|
|||
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -26,8 +26,7 @@ use local_treestudyplan\local\helpers\webservicehelper;
|
|||
|
||||
require_once($CFG->libdir.'/externallib.php');
|
||||
|
||||
class associationservice extends \external_api
|
||||
{
|
||||
class associationservice extends \external_api {
|
||||
const CAP_EDIT = "local/treestudyplan:editstudyplan";
|
||||
const CAP_VIEW = "local/treestudyplan:viewuserreports";
|
||||
|
||||
|
@ -96,9 +95,7 @@ class associationservice extends \external_api
|
|||
|
||||
}
|
||||
|
||||
|
||||
public static function list_cohort_parameters()
|
||||
{
|
||||
public static function list_cohort_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
'like' => new \external_value(PARAM_TEXT, 'search text', VALUE_OPTIONAL),
|
||||
'exclude_id' => new \external_value(PARAM_INT, 'exclude members of this studyplan', VALUE_OPTIONAL),
|
||||
|
@ -106,14 +103,12 @@ class associationservice extends \external_api
|
|||
] );
|
||||
}
|
||||
|
||||
public static function list_cohort_returns()
|
||||
{
|
||||
public static function list_cohort_returns() {
|
||||
return new \external_multiple_structure(self::cohort_structure());
|
||||
}
|
||||
|
||||
// Actual functions.
|
||||
public static function list_cohort($like='', $excludeid=null, $contextid=1)
|
||||
{
|
||||
public static function list_cohort($like='', $excludeid=null, $contextid=1) {
|
||||
global $CFG, $DB;
|
||||
|
||||
// Only allow this if the user has the right to edit in this context.
|
||||
|
@ -130,7 +125,8 @@ class associationservice extends \external_api
|
|||
$sql .= " AND (j.studyplan_id IS NULL OR j.studyplan_id != :exclude_id)";
|
||||
$params['exclude_id'] = $excludeid;
|
||||
}
|
||||
if ($contextid > 1) { // system context returns all cohorts, including system cohorts.
|
||||
if ($contextid > 1) {
|
||||
// System context returns all cohorts, including system cohorts.
|
||||
// Otherwise, .
|
||||
$sql .= " AND contextid = :context_id";
|
||||
$params['context_id'] = $contextid;
|
||||
|
@ -145,8 +141,7 @@ class associationservice extends \external_api
|
|||
return $cohorts;
|
||||
}
|
||||
|
||||
public static function find_user_parameters()
|
||||
{
|
||||
public static function find_user_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
'like' => new \external_value(PARAM_TEXT, 'search text'),
|
||||
'exclude_id' => new \external_value(PARAM_INT, 'exclude members of this studyplan', VALUE_OPTIONAL),
|
||||
|
@ -154,14 +149,12 @@ class associationservice extends \external_api
|
|||
] );
|
||||
}
|
||||
|
||||
public static function find_user_returns()
|
||||
{
|
||||
public static function find_user_returns() {
|
||||
return new \external_multiple_structure(self::user_structure());
|
||||
}
|
||||
|
||||
// Actual functions.
|
||||
public static function find_user($like, $excludeid=null, $contextid=1)
|
||||
{
|
||||
public static function find_user($like, $excludeid=null, $contextid=1) {
|
||||
global $CFG, $DB;
|
||||
|
||||
// Only allow this if the user has the right to edit in this context (using system rights would make things more confusing).
|
||||
|
@ -191,16 +184,14 @@ class associationservice extends \external_api
|
|||
return $users;
|
||||
}
|
||||
|
||||
public static function connect_cohort_parameters()
|
||||
{
|
||||
public static function connect_cohort_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"studyplan_id" => new \external_value(PARAM_INT, 'id of studyplan', VALUE_OPTIONAL),
|
||||
"cohort_id" => new \external_value(PARAM_INT, 'id of cohort to link', VALUE_OPTIONAL),
|
||||
] );
|
||||
}
|
||||
|
||||
public static function connect_cohort_returns()
|
||||
{
|
||||
public static function connect_cohort_returns() {
|
||||
return new \external_single_structure([
|
||||
"success" => new \external_value(PARAM_BOOL, 'operation completed succesfully'),
|
||||
"msg" => new \external_value(PARAM_TEXT, 'message'),
|
||||
|
@ -208,8 +199,7 @@ class associationservice extends \external_api
|
|||
}
|
||||
|
||||
// Actual functions.
|
||||
public static function connect_cohort($studyplanid, $cohortid)
|
||||
{
|
||||
public static function connect_cohort($studyplanid, $cohortid) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$studyplan = studyplan::findById($studyplanid);
|
||||
|
@ -230,16 +220,14 @@ class associationservice extends \external_api
|
|||
|
||||
}
|
||||
|
||||
public static function disconnect_cohort_parameters()
|
||||
{
|
||||
public static function disconnect_cohort_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"studyplan_id" => new \external_value(PARAM_INT, 'id of studyplan', VALUE_OPTIONAL),
|
||||
"cohort_id" => new \external_value(PARAM_INT, 'id of cohort to link', VALUE_OPTIONAL),
|
||||
] );
|
||||
}
|
||||
|
||||
public static function disconnect_cohort_returns()
|
||||
{
|
||||
public static function disconnect_cohort_returns() {
|
||||
return new \external_single_structure([
|
||||
"success" => new \external_value(PARAM_BOOL, 'operation completed succesfully'),
|
||||
"msg" => new \external_value(PARAM_TEXT, 'message'),
|
||||
|
@ -247,8 +235,7 @@ class associationservice extends \external_api
|
|||
}
|
||||
|
||||
// Actual functions.
|
||||
public static function disconnect_cohort($studyplanid, $cohortid)
|
||||
{
|
||||
public static function disconnect_cohort($studyplanid, $cohortid) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$studyplan = studyplan::findById($studyplanid);
|
||||
|
@ -269,16 +256,14 @@ class associationservice extends \external_api
|
|||
|
||||
}
|
||||
|
||||
public static function connect_user_parameters()
|
||||
{
|
||||
public static function connect_user_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"studyplan_id" => new \external_value(PARAM_INT, 'id of studyplan', VALUE_OPTIONAL),
|
||||
"user_id" => new \external_value(PARAM_INT, 'id of user to link', VALUE_OPTIONAL),
|
||||
] );
|
||||
}
|
||||
|
||||
public static function connect_user_returns()
|
||||
{
|
||||
public static function connect_user_returns() {
|
||||
return new \external_single_structure([
|
||||
"success" => new \external_value(PARAM_BOOL, 'operation completed succesfully'),
|
||||
"msg" => new \external_value(PARAM_TEXT, 'message'),
|
||||
|
@ -286,8 +271,7 @@ class associationservice extends \external_api
|
|||
}
|
||||
|
||||
// Actual functions.
|
||||
public static function connect_user($studyplanid, $userid)
|
||||
{
|
||||
public static function connect_user($studyplanid, $userid) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$studyplan = studyplan::findById($studyplanid);
|
||||
|
@ -307,16 +291,14 @@ class associationservice extends \external_api
|
|||
}
|
||||
}
|
||||
|
||||
public static function disconnect_user_parameters()
|
||||
{
|
||||
public static function disconnect_user_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"studyplan_id" => new \external_value(PARAM_INT, 'id of studyplan', VALUE_OPTIONAL),
|
||||
"user_id" => new \external_value(PARAM_INT, 'id of user to link', VALUE_OPTIONAL),
|
||||
] );
|
||||
}
|
||||
|
||||
public static function disconnect_user_returns()
|
||||
{
|
||||
public static function disconnect_user_returns() {
|
||||
return new \external_single_structure([
|
||||
"success" => new \external_value(PARAM_BOOL, 'operation completed succesfully'),
|
||||
"msg" => new \external_value(PARAM_TEXT, 'message'),
|
||||
|
@ -324,8 +306,7 @@ class associationservice extends \external_api
|
|||
}
|
||||
|
||||
// Actual functions.
|
||||
public static function disconnect_user($studyplanid, $userid)
|
||||
{
|
||||
public static function disconnect_user($studyplanid, $userid) {
|
||||
global $CFG, $DB;
|
||||
$studyplan = studyplan::findById($studyplanid);
|
||||
webservicehelper::require_capabilities(self::CAP_EDIT, $studyplan->context());
|
||||
|
@ -344,21 +325,18 @@ class associationservice extends \external_api
|
|||
}
|
||||
}
|
||||
|
||||
public static function associated_users_parameters()
|
||||
{
|
||||
public static function associated_users_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"studyplan_id" => new \external_value(PARAM_INT, 'id of studyplan', VALUE_OPTIONAL),
|
||||
] );
|
||||
}
|
||||
|
||||
public static function associated_users_returns()
|
||||
{
|
||||
public static function associated_users_returns() {
|
||||
return new \external_multiple_structure(self::user_structure());
|
||||
}
|
||||
|
||||
// Actual functions.
|
||||
public static function associated_users($studyplanid)
|
||||
{
|
||||
public static function associated_users($studyplanid) {
|
||||
global $CFG, $DB;
|
||||
$studyplan = studyplan::findById($studyplanid);
|
||||
webservicehelper::require_capabilities(self::CAP_VIEW, $studyplan->context());
|
||||
|
@ -376,21 +354,18 @@ class associationservice extends \external_api
|
|||
return $users;
|
||||
}
|
||||
|
||||
public static function associated_cohorts_parameters()
|
||||
{
|
||||
public static function associated_cohorts_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"studyplan_id" => new \external_value(PARAM_INT, 'id of studyplan', VALUE_OPTIONAL),
|
||||
] );
|
||||
}
|
||||
|
||||
public static function associated_cohorts_returns()
|
||||
{
|
||||
public static function associated_cohorts_returns() {
|
||||
return new \external_multiple_structure(self::cohort_structure());
|
||||
}
|
||||
|
||||
// Actual functions.
|
||||
public static function associated_cohorts($studyplanid)
|
||||
{
|
||||
public static function associated_cohorts($studyplanid) {
|
||||
global $CFG, $DB;
|
||||
$studyplan = studyplan::findById($studyplanid);
|
||||
webservicehelper::require_capabilities(self::CAP_VIEW, $studyplan->context());
|
||||
|
@ -406,39 +381,34 @@ class associationservice extends \external_api
|
|||
return $cohorts;
|
||||
}
|
||||
|
||||
|
||||
public static function all_associated_parameters()
|
||||
{
|
||||
public static function all_associated_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"studyplan_id" => new \external_value(PARAM_INT, 'id of studyplan', VALUE_OPTIONAL),
|
||||
] );
|
||||
}
|
||||
|
||||
public static function all_associated_returns()
|
||||
{
|
||||
public static function all_associated_returns() {
|
||||
return new \external_multiple_structure(self::user_structure());
|
||||
}
|
||||
|
||||
// Actual functions.
|
||||
public static function all_associated($studyplanid)
|
||||
{
|
||||
public static function all_associated($studyplanid) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$studyplan = studyplan::findById($studyplanid);
|
||||
webservicehelper::require_capabilities(self::CAP_VIEW, $studyplan->context());
|
||||
|
||||
|
||||
$users = [];
|
||||
// SQL JOIN script selecting all users that have a cohort linked to this studyplan .
|
||||
// Or are directly linked.
|
||||
$sql = "SELECT DISTINCT u.id, u.username, u.firstname, u.lastname, u.idnumber, u.email
|
||||
FROM {user} u
|
||||
LEFT JOIN {cohort_members} cm ON u.id = cm.userid
|
||||
LEFT JOIN {local_treestudyplan_cohort} tc ON cm.cohortid = tc.cohort_id
|
||||
LEFT JOIN {local_treestudyplan_user} tu ON u.id = tu.user_id
|
||||
WHERE tc.studyplan_id = {$studyplanid}
|
||||
OR tu.studyplan_id = {$studyplanid}
|
||||
ORDER BY u.lastname, u.firstname";
|
||||
$sql = "SELECT DISTINCT u.id, u.username, u.firstname, u.lastname, u.idnumber, u.email"
|
||||
."FROM {user} u"
|
||||
."LEFT JOIN {cohort_members} cm ON u.id = cm.userid"
|
||||
."LEFT JOIN {local_treestudyplan_cohort} tc ON cm.cohortid = tc.cohort_id"
|
||||
."LEFT JOIN {local_treestudyplan_user} tu ON u.id = tu.user_id"
|
||||
."WHERE tc.studyplan_id = {$studyplan->id()}"
|
||||
."OR tu.studyplan_id = {$studyplan->id()}"
|
||||
."ORDER BY u.lastname, u.firstname";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
|
||||
foreach ($rs as $u) {
|
||||
|
@ -468,21 +438,18 @@ class associationservice extends \external_api
|
|||
});
|
||||
}
|
||||
|
||||
public static function cascade_cohortsync_parameters()
|
||||
{
|
||||
public static function cascade_cohortsync_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"studyplan_id" => new \external_value(PARAM_INT, 'id of studyplan', VALUE_OPTIONAL),
|
||||
] );
|
||||
}
|
||||
|
||||
public static function cascade_cohortsync_returns()
|
||||
{
|
||||
public static function cascade_cohortsync_returns() {
|
||||
return success::structure();
|
||||
}
|
||||
|
||||
// Actual functions.
|
||||
public static function cascade_cohortsync($studyplanid)
|
||||
{
|
||||
public static function cascade_cohortsync($studyplanid) {
|
||||
$studyplan = studyplan::findById($studyplanid);
|
||||
webservicehelper::require_capabilities(self::CAP_EDIT, $studyplan->context());
|
||||
|
||||
|
@ -501,6 +468,4 @@ class associationservice extends \external_api
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -169,7 +169,6 @@ class cascadecohortsync {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// 2: Check if there are cohort links for this studyplan in this course that should be removed.
|
||||
// A: Check if there are cohort links that are no longer related to this studyplan.
|
||||
// B: Check if these links are valid through another studyplan...
|
||||
|
@ -189,7 +188,8 @@ class cascadecohortsync {
|
|||
|
||||
$records = $DB->get_records("enrol", $searchparams);
|
||||
foreach ($records as $instance) {
|
||||
if (!empty($instance->customtext4)) { // only check the records that have studyplan information in the customtext4 field.
|
||||
if (!empty($instance->customtext4)) {
|
||||
// Only check the records that have studyplan information in the customtext4 field.
|
||||
// First check if the cohort is not one of the cohort id's we have associated.
|
||||
if (!in_array($instance->customint1, $cohortids)) {
|
||||
//\mtrace("Found cohort sync instance that is not currently liked to the studyplan: {$instance->id}");.
|
||||
|
|
|
@ -76,7 +76,6 @@ class cascadeusersync {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// We do not do any autoremoval for user syncs, to avoid students losing access to the course data.
|
||||
|
||||
}
|
||||
|
|
|
@ -25,8 +25,7 @@ require_once($CFG->libdir.'/externallib.php');
|
|||
|
||||
use \grade_item;
|
||||
|
||||
class completionscanner
|
||||
{
|
||||
class completionscanner {
|
||||
private static $modsupported = [];
|
||||
private static $coursestudents = [];
|
||||
private $scanner = null;
|
||||
|
@ -141,7 +140,6 @@ class completionscanner
|
|||
}
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'ungraded' => $ungraded,
|
||||
'completed' => $completed,
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
namespace local_treestudyplan;
|
||||
|
||||
|
||||
class contextinfo {
|
||||
public $context;
|
||||
public function __construct($context) {
|
||||
|
@ -65,5 +64,4 @@ class contextinfo {
|
|||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -66,7 +66,7 @@ class corecompletioninfo {
|
|||
COMPLETION_COMPLETE => "complete",
|
||||
COMPLETION_COMPLETE_PASS => "complete-pass",
|
||||
COMPLETION_COMPLETE_FAIL => "complete-fail",
|
||||
COMPLETION_COMPLETE_FAIL_HIDDEN => "complete-fail"]; // the front end won't differentiate between hidden or not.
|
||||
COMPLETION_COMPLETE_FAIL_HIDDEN => "complete-fail"]; // The front end won't differentiate between hidden or not.
|
||||
}
|
||||
return self::$COMPLETIONHANDLES[$completion] ?? "undefined";
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ class corecompletioninfo {
|
|||
global $DB, $CFG, $COMPLETIONCRITERIA_TYPES;
|
||||
|
||||
$conditions = [];
|
||||
$aggregation = "all"; // default.
|
||||
$aggregation = "all"; // Default.
|
||||
$info = [
|
||||
"conditions" => $conditions,
|
||||
"aggregation" => self::aggregation_handle($this->completion->get_aggregation_method()),
|
||||
|
@ -304,7 +304,6 @@ class corecompletioninfo {
|
|||
}
|
||||
|
||||
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
@ -509,7 +508,6 @@ class corecompletioninfo {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the percentage completed by a certain user, returns null if no completion data is available.
|
||||
*
|
||||
|
@ -665,5 +663,4 @@ class corecompletioninfo {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ class courseinfo {
|
|||
}
|
||||
|
||||
public function course() {
|
||||
return $this->course; // php arrays are assigned by copy.
|
||||
return $this->course; // Php arrays are assigned by copy.
|
||||
}
|
||||
|
||||
public function course_context() {
|
||||
|
@ -282,7 +282,6 @@ class courseinfo {
|
|||
}
|
||||
|
||||
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,7 @@ use \local_treestudyplan\local\helpers\webservicehelper;
|
|||
use \local_treestudyplan\completionscanner;
|
||||
use \local_treestudyplan\gradingscanner;
|
||||
|
||||
class courseservice extends \external_api
|
||||
{
|
||||
class courseservice extends \external_api {
|
||||
const CAP_EDIT = "local/treestudyplan:editstudyplan";
|
||||
const CAP_VIEW = "local/treestudyplan:viewuserreports";
|
||||
|
||||
|
@ -40,15 +39,13 @@ class courseservice extends \external_api
|
|||
* *
|
||||
************************/
|
||||
|
||||
public static function map_categories_parameters()
|
||||
{
|
||||
public static function map_categories_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"root_id" => new \external_value(PARAM_INT, 'root category to use as base', VALUE_DEFAULT),
|
||||
] );
|
||||
}
|
||||
|
||||
public static function map_categories_returns()
|
||||
{
|
||||
public static function map_categories_returns() {
|
||||
return new \external_multiple_structure(static::map_category_structure(false));
|
||||
}
|
||||
|
||||
|
@ -82,8 +79,9 @@ class courseservice extends \external_api
|
|||
if ($root->id == 0) {
|
||||
// On the system level, determine the user's topmost allowed catecories.
|
||||
$usertop = \core_course_category::user_top();
|
||||
if ($usertop->id == 0) { // top category..
|
||||
$children = $root->get_children(); // returns a list of çore_course_category, let it overwrite $children.
|
||||
if ($usertop->id == 0) {
|
||||
// Top category..
|
||||
$children = $root->get_children(); // Returns a list of çore_course_category, let it overwrite $children.
|
||||
} else {
|
||||
$children = [$usertop];
|
||||
}
|
||||
|
@ -97,15 +95,13 @@ class courseservice extends \external_api
|
|||
return $list;
|
||||
}
|
||||
|
||||
public static function get_category_parameters()
|
||||
{
|
||||
public static function get_category_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"id" => new \external_value(PARAM_INT, 'id of category'),
|
||||
] );
|
||||
}
|
||||
|
||||
public static function get_category_returns()
|
||||
{
|
||||
public static function get_category_returns() {
|
||||
return static::map_category_structure(false);
|
||||
}
|
||||
|
||||
|
@ -118,7 +114,7 @@ class courseservice extends \external_api
|
|||
global $DB;
|
||||
$catcontext = $cat->get_context();
|
||||
$ctxinfo = new contextinfo($catcontext);
|
||||
$children = $cat->get_children(); // only shows children visible to the current user.
|
||||
$children = $cat->get_children(); // Only shows children visible to the current user.
|
||||
$courses = $cat->get_courses();
|
||||
$model = [
|
||||
"id" => $cat->id,
|
||||
|
@ -144,20 +140,17 @@ class courseservice extends \external_api
|
|||
return $model;
|
||||
}
|
||||
|
||||
public static function list_accessible_categories_parameters()
|
||||
{
|
||||
public static function list_accessible_categories_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"operation" => new \external_value(PARAM_TEXT, 'type of operation ["view"|"edit"]', VALUE_DEFAULT), ]
|
||||
);
|
||||
}
|
||||
|
||||
public static function list_accessible_categories_returns()
|
||||
{
|
||||
public static function list_accessible_categories_returns() {
|
||||
return new \external_multiple_structure(static::map_category_structure(true));
|
||||
}
|
||||
|
||||
public static function list_accessible_categories($operation="edit")
|
||||
{
|
||||
public static function list_accessible_categories($operation="edit") {
|
||||
if ($operation == "edit") {
|
||||
$capability = self::CAP_EDIT;
|
||||
} else { // Operation == "view" || default.
|
||||
|
@ -216,20 +209,17 @@ class courseservice extends \external_api
|
|||
return $list;
|
||||
}
|
||||
|
||||
public static function list_used_categories_parameters()
|
||||
{
|
||||
public static function list_used_categories_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"operation" => new \external_value(PARAM_TEXT, 'type of operation ["view"|"edit"]', VALUE_DEFAULT),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function list_used_categories_returns()
|
||||
{
|
||||
public static function list_used_categories_returns() {
|
||||
return new \external_multiple_structure(static::map_category_structure(true));
|
||||
}
|
||||
|
||||
public static function list_used_categories($operation='edit')
|
||||
{
|
||||
public static function list_used_categories($operation='edit') {
|
||||
global $DB;
|
||||
if ($operation == "edit") {
|
||||
$capability = self::CAP_EDIT;
|
||||
|
@ -244,7 +234,6 @@ class courseservice extends \external_api
|
|||
}
|
||||
$rs->close();
|
||||
|
||||
|
||||
// Now filter the categories that the user has acces to by the used context id's.
|
||||
// (That should filter out irrelevant stuff).
|
||||
$cats = static::categories_by_capability($capability);
|
||||
|
@ -300,7 +289,6 @@ class courseservice extends \external_api
|
|||
return $list;
|
||||
}
|
||||
|
||||
|
||||
/**************************************
|
||||
*
|
||||
* Progress scanners for teacherview
|
||||
|
@ -338,9 +326,7 @@ class courseservice extends \external_api
|
|||
return $scanner->model();
|
||||
}
|
||||
|
||||
|
||||
public static function scan_completion_progress_parameters()
|
||||
{
|
||||
public static function scan_completion_progress_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"criteriaid" => new \external_value(PARAM_INT, 'CriteriaID to scan progress for', VALUE_DEFAULT),
|
||||
"studyplanid" => new \external_value(PARAM_INT, 'Study plan id to check progress in', VALUE_DEFAULT),
|
||||
|
@ -348,13 +334,11 @@ class courseservice extends \external_api
|
|||
]);
|
||||
}
|
||||
|
||||
public static function scan_completion_progress_returns()
|
||||
{
|
||||
public static function scan_completion_progress_returns() {
|
||||
return completionscanner::structure(VALUE_REQUIRED);
|
||||
}
|
||||
|
||||
public static function scan_completion_progress($criteriaid, $studyplanid, $courseid)
|
||||
{
|
||||
public static function scan_completion_progress($criteriaid, $studyplanid, $courseid) {
|
||||
global $DB;
|
||||
// Verify access to the study plan.
|
||||
$o = studyplan::findById($studyplanid);
|
||||
|
@ -368,24 +352,21 @@ class courseservice extends \external_api
|
|||
return $scanner->model();
|
||||
}
|
||||
|
||||
public static function scan_badge_progress_parameters()
|
||||
{
|
||||
public static function scan_badge_progress_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"badgeid" => new \external_value(PARAM_INT, 'Badge to scan progress for', VALUE_DEFAULT),
|
||||
"studyplanid" => new \external_value(PARAM_INT, 'Study plan id to limit progress search to (to determine which students to scan)', VALUE_DEFAULT),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function scan_badge_progress_returns()
|
||||
{
|
||||
public static function scan_badge_progress_returns() {
|
||||
return new \external_single_structure([
|
||||
"total" => new \external_value(PARAM_INT, 'Total number of students scanned'),
|
||||
"issued" => new \external_value(PARAM_INT, 'Number of issued badges'),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function scan_badge_progress($badgeid, $studyplanid)
|
||||
{
|
||||
public static function scan_badge_progress($badgeid, $studyplanid) {
|
||||
global $DB;
|
||||
// Check access to the study plan.
|
||||
$o = studyplan::findById($studyplanid);
|
||||
|
@ -412,5 +393,4 @@ class courseservice extends \external_api
|
|||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -50,7 +50,6 @@ class gradeinfo {
|
|||
private $cmid;
|
||||
private $coursesort;
|
||||
|
||||
|
||||
private static $contentitems = null;
|
||||
private $gradingscanner;
|
||||
|
||||
|
@ -217,7 +216,6 @@ class gradeinfo {
|
|||
return $model;
|
||||
}
|
||||
|
||||
|
||||
public static function user_structure($value=VALUE_REQUIRED) {
|
||||
return new \external_single_structure([
|
||||
"id" => new \external_value(PARAM_INT, 'grade_item id'),
|
||||
|
@ -296,8 +294,12 @@ class gradeinfo {
|
|||
|
||||
if ($giname == $model["name"] && $gitype == $model["type"]) {
|
||||
// We have a match.
|
||||
if (!isset($model["selected"])) { $model["selected"] = true;}
|
||||
if (!isset($model["required"])) { $model["required"] = false;}
|
||||
if (!isset($model["selected"])) {
|
||||
$model["selected"] = true;
|
||||
}
|
||||
if (!isset($model["required"])) {
|
||||
$model["required"] = false;
|
||||
}
|
||||
if ($model["selected"] || $model["required"]) {
|
||||
static::include_grade($gi->id, $item->id(), $model["selected"], $model["required"]);
|
||||
}
|
||||
|
@ -324,8 +326,8 @@ class gradeinfo {
|
|||
try {
|
||||
$gradable = new static($gi->id, $studyitem);
|
||||
$list[] = $gradable;
|
||||
} catch (\InvalidArgumentException $x) {
|
||||
}
|
||||
catch(\InvalidArgumentException $x) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -350,8 +352,7 @@ class gradeinfo {
|
|||
if ($r->include || $r->required) {
|
||||
$list[] = new static($r->grade_item_id, $studyitem);
|
||||
}
|
||||
}
|
||||
catch(\InvalidArgumentException $x) {
|
||||
} catch (\InvalidArgumentException $x) {
|
||||
// On InvalidArgumentException, the grade_item id can no longer be found.
|
||||
// Remove the link to avoid database record hogging.
|
||||
$DB->delete_records($table, ['id' => $r->id]);
|
||||
|
@ -396,5 +397,4 @@ class gradeinfo {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -25,8 +25,7 @@ require_once($CFG->libdir.'/externallib.php');
|
|||
|
||||
use \grade_item;
|
||||
|
||||
class gradingscanner
|
||||
{
|
||||
class gradingscanner {
|
||||
private static $modsupported = [];
|
||||
private static $coursestudents = [];
|
||||
private $scanner = null;
|
||||
|
@ -173,5 +172,4 @@ class gradingscanner
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -20,7 +20,6 @@
|
|||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
namespace local_treestudyplan\local\aggregators;
|
||||
|
||||
use \local_treestudyplan\courseinfo;
|
||||
|
@ -98,7 +97,6 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
|
|||
public function useRequiredGrades() { return True;}
|
||||
public function useItemConditions() { return False;}
|
||||
|
||||
|
||||
public function aggregate_binary_goals(array $completions, array $required = []) {
|
||||
// Function is public to allow access for the testing code.
|
||||
|
||||
|
@ -111,7 +109,6 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
|
|||
// - completion::INCOMPLETE - No goals have been started.
|
||||
// - completion::PROGRESS - All other states.
|
||||
|
||||
|
||||
$total = count($completions);
|
||||
$completed = 0;
|
||||
$progress = 0;
|
||||
|
@ -288,5 +285,4 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -20,7 +20,6 @@
|
|||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
namespace local_treestudyplan\local\aggregators;
|
||||
|
||||
use \local_treestudyplan\courseinfo;
|
||||
|
@ -101,7 +100,6 @@ class core_aggregator extends \local_treestudyplan\aggregator {
|
|||
// Option: Use course end grade to determine that...
|
||||
// Probably needs a config value in the aggregator....
|
||||
|
||||
|
||||
return completion::COMPLETED;
|
||||
} else {
|
||||
// Check if the course is over or not, if it is over, display failed.
|
||||
|
@ -159,7 +157,6 @@ class core_aggregator extends \local_treestudyplan\aggregator {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// CORE COMPLETION DOESN'T REALLY USE THE FUNCTIONS BELOW.
|
||||
// AGGREGATORS ARE GOING TO BE DEPRECATED ANYWAY... but used in legacy parts of this plugin.
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
namespace local_treestudyplan\local\aggregators;
|
||||
|
||||
use \local_treestudyplan\courseinfo;
|
||||
|
@ -159,5 +158,4 @@ class tristate_aggregator extends \local_treestudyplan\aggregator {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -20,7 +20,6 @@
|
|||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
namespace local_treestudyplan\local;
|
||||
|
||||
use Exception;
|
||||
|
@ -96,7 +95,6 @@ class gradegenerator {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
@ -146,12 +144,12 @@ class gradegenerator {
|
|||
}
|
||||
if ($r->done) {
|
||||
$score = rand(0, $int);
|
||||
$r->result = ($score > 20); // determine if the assignment was successful.
|
||||
$r->result = ($score > 20); // Determine if the assignment was successful.
|
||||
if (!$r->result) {
|
||||
$r->failed = !($score > 10);
|
||||
}
|
||||
} else {
|
||||
$r->result = false; // make sure a result property is always there.
|
||||
$r->result = false; // Make sure a result property is always there.
|
||||
$r->failed = true;
|
||||
}
|
||||
// Aways generate a little feedback.
|
||||
|
@ -295,5 +293,4 @@ class gradegenerator {
|
|||
return $path;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
namespace local_treestudyplan\local\helpers;
|
||||
|
||||
use DateTime;
|
||||
|
|
|
@ -20,11 +20,9 @@
|
|||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
namespace local_treestudyplan\local\helpers;
|
||||
require_once($CFG->dirroot.'/webservice/lib.php');
|
||||
|
||||
|
||||
class webservicehelper {
|
||||
/** @var \context_system */
|
||||
private static $systemcontext = null;
|
||||
|
@ -120,11 +118,11 @@ class webservicehelper {
|
|||
public static function find_context($contextid): \context{
|
||||
if (isset($contextid) && is_int($contextid) && $contextid > 0) {
|
||||
|
||||
if (!in_array($contextid, self::$validatedcontexts)) { // Cache the context and make sure it is only validated once...
|
||||
if (!in_array($contextid, self::$validatedcontexts)) {
|
||||
// Cache the context and make sure it is only validated once...
|
||||
try {
|
||||
$context = \context::instance_by_id($contextid);
|
||||
}
|
||||
catch(\dml_missing_record_exception $x) {
|
||||
} catch (\dml_missing_record_exception $x) {
|
||||
throw new \InvalidArgumentException("Context {$contextid} not available"); // Just throw it up again. catch is included here to make sure we know it throws this exception.
|
||||
}
|
||||
// Validate the found context.
|
||||
|
|
|
@ -20,10 +20,8 @@
|
|||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
namespace local_treestudyplan\local\ungradedscanners;
|
||||
|
||||
|
||||
class assign_scanner extends scanner_base {
|
||||
|
||||
protected function get_ungraded_submissions() {
|
||||
|
@ -53,7 +51,6 @@ class assign_scanner extends scanner_base {
|
|||
return $DB->get_fieldset_sql($sql);
|
||||
}
|
||||
|
||||
|
||||
public function count_ungraded($courseuserids=[]) {
|
||||
$ungraded = $this->get_ungraded_submissions();
|
||||
|
||||
|
|
|
@ -20,11 +20,9 @@
|
|||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
namespace local_treestudyplan\local\ungradedscanners;
|
||||
|
||||
require_once($CFG->dirroot.'/question/engine/states.php'); // for reading question state.
|
||||
|
||||
require_once($CFG->dirroot.'/question/engine/states.php'); // For reading question state.
|
||||
|
||||
class quiz_scanner extends scanner_base {
|
||||
|
||||
|
@ -46,7 +44,7 @@ class quiz_scanner extends scanner_base {
|
|||
$maxstatesql = "SELECT MAX(qas.sequencenumber) FROM {question_attempt_steps} qas WHERE qas.questionattemptid = {$r->attempt_id}";
|
||||
$max = $DB->get_field_sql($maxstatesql);
|
||||
if ($r->sequencenumber == $max) {
|
||||
$submissions[$r->userid] = true; // set array index based on user id, to avoid checking if value is in array.
|
||||
$submissions[$r->userid] = true; // Set array index based on user id, to avoid checking if value is in array.
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
namespace local_treestudyplan\local\ungradedscanners;
|
||||
use \grade_item;
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ class period {
|
|||
private static $CACHE = [];
|
||||
private static $PAGECACHE = [];
|
||||
|
||||
|
||||
private $r; // Holds database record.
|
||||
private $id;
|
||||
private $page;
|
||||
|
@ -81,7 +80,7 @@ class period {
|
|||
try {
|
||||
// Check if we have a next period to glance the start date of as a reference.
|
||||
$enddate = $DB->get_field(self::TABLE, "startdate", ["page_id" => $page->id(), "period" => $periodnr+1], MUST_EXIST);
|
||||
$pstart = strtotime($enddate)-(24*60*60); // subtract one day.
|
||||
$pstart = strtotime($enddate)-(24*60*60); // Subtract one day.
|
||||
} catch (\dml_missing_record_exception $x2) {
|
||||
// If not, do a fair guess.
|
||||
$pend = $pstart + $ptime;
|
||||
|
@ -206,8 +205,8 @@ class period {
|
|||
}
|
||||
}
|
||||
$id = $DB->insert_record(self::TABLE, $info);
|
||||
unset(self::$PAGECACHE[$fields['page_id']]); // invalidate the cache for this page.
|
||||
return self::findById($id); // make sure the new page is immediately cached.
|
||||
unset(self::$PAGECACHE[$fields['page_id']]); // Invalidate the cache for this page.
|
||||
return self::findById($id); // Make sure the new page is immediately cached.
|
||||
}
|
||||
|
||||
public function edit($fields) {
|
||||
|
@ -222,14 +221,14 @@ class period {
|
|||
$DB->update_record(self::TABLE, $info);
|
||||
//reload record after edit.
|
||||
$this->r = $DB->get_record(self::TABLE, ['id' => $this->id], "*", MUST_EXIST);
|
||||
unset(self::$PAGECACHE[$this->r->page_id]); // invalidate the cache for this page.
|
||||
unset(self::$PAGECACHE[$this->r->page_id]); // Invalidate the cache for this page.
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
global $DB;
|
||||
$DB->delete_records(self::TABLE, ['id' => $this->id]);
|
||||
unset(self::$PAGECACHE[$this->r->page_id]); // invalidate the cache for this page.
|
||||
unset(self::$PAGECACHE[$this->r->page_id]); // Invalidate the cache for this page.
|
||||
return success::success();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
namespace local_treestudyplan\privacy;
|
||||
use core_privacy\local\metadata\collection;
|
||||
use \core_privacy\local\request\userlist;
|
||||
|
@ -163,7 +162,6 @@ class provider implements \core_privacy\local\metadata\provider,
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Delete all data for all users in the specified context.
|
||||
* Used when a context is past it's data retention period
|
||||
|
@ -194,7 +192,6 @@ class provider implements \core_privacy\local\metadata\provider,
|
|||
|
||||
foreach ($contextlist->get_contexts() as $context) {
|
||||
|
||||
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
$sql = "SELECT s.id FROM {local_treestudyplan} INNER JOIN {local_treestudyplan_user} a ON a.studyplan_id = s.id
|
||||
WHERE ( a.user_id = :userid AND ( s.context_id IS NULL OR s.context_id == 0 OR s.context_id = :contextid))";
|
||||
|
|
|
@ -39,7 +39,6 @@ class reportinvite_form extends moodleform {
|
|||
$mform->addElement('hidden', 'update', 0);
|
||||
$mform->setType('update', PARAM_INT);
|
||||
|
||||
|
||||
$mform->addElement('text', 'name', get_string('invite_name', 'local_treestudyplan'), array('size' => 50)); // Add elements to your form.
|
||||
$mform->setType('name', PARAM_NOTAGS); //Set type of element.
|
||||
$mform->setDefault('name', ''); //Default value.
|
||||
|
@ -65,28 +64,23 @@ class reportinvite_form extends moodleform {
|
|||
parent::set_data($data);
|
||||
}
|
||||
|
||||
function get_data()
|
||||
{
|
||||
function get_data() {
|
||||
global $DB, $USER;
|
||||
|
||||
$data = parent::get_data();
|
||||
if ($data != NULL)
|
||||
{
|
||||
if (empty($data->user_id))
|
||||
{
|
||||
if ($data != NULL) {
|
||||
if (empty($data->user_id)) {
|
||||
$data->user_id = $USER->id;
|
||||
}
|
||||
|
||||
if (empty($data->update))
|
||||
{
|
||||
if (empty($data->update)) {
|
||||
$date = new DateTime("now", core_date::get_user_timezone_object());
|
||||
$date->setTime(0, 0, 0);
|
||||
|
||||
$data->idate = $date->getTimeStamp();
|
||||
}
|
||||
|
||||
if (empty($data->update))
|
||||
{
|
||||
if (empty($data->update)) {
|
||||
//create a new random key for the invite.
|
||||
do {
|
||||
$length = 20;
|
||||
|
|
|
@ -27,8 +27,7 @@ use \local_treestudyplan\local\helpers\webservicehelper;
|
|||
|
||||
require_once($CFG->libdir.'/badgeslib.php');
|
||||
|
||||
class studentstudyplanservice extends \external_api
|
||||
{
|
||||
class studentstudyplanservice extends \external_api {
|
||||
const CAP_VIEWOTHER = "local/treestudyplan:viewuserreports";
|
||||
/************************
|
||||
* *
|
||||
|
@ -36,15 +35,13 @@ class studentstudyplanservice extends \external_api
|
|||
* *
|
||||
************************/
|
||||
|
||||
public static function list_user_studyplans_parameters()
|
||||
{
|
||||
public static function list_user_studyplans_parameters() {
|
||||
return new \external_function_parameters([
|
||||
"userid" => new \external_value(PARAM_INT, 'id of student', VALUE_DEFAULT),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function list_user_studyplans_returns()
|
||||
{
|
||||
public static function list_user_studyplans_returns() {
|
||||
return new \external_multiple_structure(
|
||||
studyplan::simple_structure()
|
||||
);
|
||||
|
@ -70,15 +67,13 @@ class studentstudyplanservice extends \external_api
|
|||
* *
|
||||
************************/
|
||||
|
||||
public static function get_user_studyplans_parameters()
|
||||
{
|
||||
public static function get_user_studyplans_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"userid" => new \external_value(PARAM_INT, 'id of user'),
|
||||
] );
|
||||
}
|
||||
|
||||
public static function get_user_studyplans_returns()
|
||||
{
|
||||
public static function get_user_studyplans_returns() {
|
||||
return new \external_multiple_structure(
|
||||
studyplan::user_structure()
|
||||
);
|
||||
|
@ -105,16 +100,14 @@ class studentstudyplanservice extends \external_api
|
|||
* *
|
||||
************************/
|
||||
|
||||
public static function get_user_studyplan_parameters()
|
||||
{
|
||||
public static function get_user_studyplan_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"userid" => new \external_value(PARAM_INT, 'id of user'),
|
||||
"studyplanid" => new \external_value(PARAM_INT, 'id of specific studyplan to provide'),
|
||||
] );
|
||||
}
|
||||
|
||||
public static function get_user_studyplan_returns()
|
||||
{
|
||||
public static function get_user_studyplan_returns() {
|
||||
return studyplan::user_structure();
|
||||
}
|
||||
public static function get_user_studyplan($userid, $studyplanid) {
|
||||
|
@ -136,15 +129,13 @@ class studentstudyplanservice extends \external_api
|
|||
* *
|
||||
****************************/
|
||||
|
||||
public static function get_invited_studyplan_parameters()
|
||||
{
|
||||
public static function get_invited_studyplan_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"invitekey" => new \external_value(PARAM_RAW, 'invite key'),
|
||||
] );
|
||||
}
|
||||
|
||||
public static function get_invited_studyplan_returns()
|
||||
{
|
||||
public static function get_invited_studyplan_returns() {
|
||||
return new \external_multiple_structure(
|
||||
studyplan::user_structure()
|
||||
);
|
||||
|
@ -177,13 +168,11 @@ class studentstudyplanservice extends \external_api
|
|||
* *
|
||||
************************/
|
||||
|
||||
public static function list_own_studyplans_parameters()
|
||||
{
|
||||
public static function list_own_studyplans_parameters() {
|
||||
return new \external_function_parameters([]);
|
||||
}
|
||||
|
||||
public static function list_own_studyplans_returns()
|
||||
{
|
||||
public static function list_own_studyplans_returns() {
|
||||
return new \external_multiple_structure(
|
||||
studyplan::simple_structure()
|
||||
);
|
||||
|
@ -207,15 +196,13 @@ class studentstudyplanservice extends \external_api
|
|||
* *
|
||||
************************/
|
||||
|
||||
public static function get_own_studyplan_parameters()
|
||||
{
|
||||
public static function get_own_studyplan_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"id" => new \external_value(PARAM_INT, 'id of specific studyplan to provide', VALUE_DEFAULT),
|
||||
] );
|
||||
}
|
||||
|
||||
public static function get_own_studyplan_returns()
|
||||
{
|
||||
public static function get_own_studyplan_returns() {
|
||||
return new \external_multiple_structure(
|
||||
studyplan::user_structure()
|
||||
);
|
||||
|
@ -253,15 +240,13 @@ class studentstudyplanservice extends \external_api
|
|||
* *
|
||||
***************************/
|
||||
|
||||
public static function get_teaching_studyplans_parameters()
|
||||
{
|
||||
public static function get_teaching_studyplans_parameters() {
|
||||
return new \external_function_parameters( [
|
||||
"id" => new \external_value(PARAM_INT, 'id of specific studyplan to provide', VALUE_DEFAULT),
|
||||
] );
|
||||
}
|
||||
|
||||
public static function get_teaching_studyplans_returns()
|
||||
{
|
||||
public static function get_teaching_studyplans_returns() {
|
||||
return new \external_multiple_structure(
|
||||
studyplan::editor_structure()
|
||||
);
|
||||
|
|
|
@ -33,7 +33,6 @@ class studyitem {
|
|||
public const START = 'start';
|
||||
public const INVALID = 'invalid';
|
||||
|
||||
|
||||
public const TABLE = "local_treestudyplan_item";
|
||||
|
||||
private static $STUDYITEMCACHE = [];
|
||||
|
@ -63,7 +62,6 @@ class studyitem {
|
|||
return self::$STUDYITEMCACHE[$id];
|
||||
}
|
||||
|
||||
|
||||
public function __construct($id) {
|
||||
global $DB;
|
||||
$this->id = $id;
|
||||
|
@ -185,7 +183,6 @@ class studyitem {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Add incoming and outgoing connection info.
|
||||
$connout = studyitemconnection::find_outgoing($this->id);
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ class studyitemconnection {
|
|||
private $r;
|
||||
private $id;
|
||||
|
||||
|
||||
protected function __construct($r) {
|
||||
$this->r = $r;
|
||||
$this->id = $r->id;
|
||||
|
@ -64,7 +63,6 @@ class studyitemconnection {
|
|||
return $this->r->to_id;
|
||||
}
|
||||
|
||||
|
||||
public static function find_outgoing($itemid) {
|
||||
global $DB;
|
||||
$list = [];
|
||||
|
|
|
@ -316,7 +316,6 @@ class studyline {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return $model;
|
||||
|
||||
}
|
||||
|
|
|
@ -26,16 +26,14 @@ require_once($CFG->libdir.'/externallib.php');
|
|||
|
||||
class studyplan {
|
||||
|
||||
|
||||
const TABLE = "local_treestudyplan";
|
||||
private static $STUDYPLANCACHE = [];
|
||||
|
||||
|
||||
private $r; // Holds database record.
|
||||
private $id;
|
||||
private $aggregator;
|
||||
private $context = null; // Hold context object once retrieved.
|
||||
private $linkeduserids = null; // cache lookup of linked users (saves queries).
|
||||
private $linkeduserids = null; // Cache lookup of linked users (saves queries).
|
||||
private $pagecache = null;
|
||||
|
||||
public function aggregator() {
|
||||
|
@ -87,8 +85,7 @@ class studyplan {
|
|||
if (!isset($this->context)) {
|
||||
try {
|
||||
$this->context = contextinfo::by_id($this->r->context_id)->context;
|
||||
}
|
||||
catch(\dml_missing_record_exception $x) {
|
||||
} catch (\dml_missing_record_exception $x) {
|
||||
throw new \InvalidArgumentException("Context {$this->r->context_id} not available"); // Just throw it up again. catch is included here to make sure we know it throws this exception.
|
||||
}
|
||||
}
|
||||
|
@ -190,7 +187,6 @@ class studyplan {
|
|||
];
|
||||
}
|
||||
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
|
@ -205,8 +201,7 @@ class studyplan {
|
|||
}
|
||||
}
|
||||
$id = $DB->insert_record(self::TABLE, $info);
|
||||
$plan = self::findById($id); // make sure the new studyplan is immediately cached.
|
||||
|
||||
$plan = self::findById($id); // Make sure the new studyplan is immediately cached.
|
||||
|
||||
// Start temporary skräpp code.
|
||||
// Add a single page and copy the names.This keeps the data sane until the upgrade to .
|
||||
|
@ -538,7 +533,9 @@ class studyplan {
|
|||
}
|
||||
|
||||
public static function import_studyplan($content, $format="application/json", $contextid=1) {
|
||||
if ($format != "application/json") { return false;}
|
||||
if ($format != "application/json") {
|
||||
return false;
|
||||
}
|
||||
|
||||
$content = json_decode($content, true);
|
||||
if ($content["type"] == "studyplan" && $content["version"] >= 2.0) {
|
||||
|
@ -561,7 +558,9 @@ class studyplan {
|
|||
}
|
||||
|
||||
public function import_pages($content, $format="application/json") {
|
||||
if ($format != "application/json") { return false;}
|
||||
if ($format != "application/json") {
|
||||
return false;
|
||||
}
|
||||
$content = json_decode($content, true);
|
||||
if ($content["version"] >= 2.0) {
|
||||
if ($content["type"] == "studyplanpage") {
|
||||
|
@ -577,7 +576,7 @@ class studyplan {
|
|||
}
|
||||
|
||||
protected function import_pages_model($model) {
|
||||
$this->pages(); // make sure the page cache is initialized, since we will be adding to it.
|
||||
$this->pages(); // Make sure the page cache is initialized, since we will be adding to it.
|
||||
foreach ($model as $p) {
|
||||
$p["studyplan_id"] = $this->id();
|
||||
$page = studyplanpage::add($p);
|
||||
|
@ -687,5 +686,4 @@ class studyplan {
|
|||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -26,11 +26,9 @@ require_once($CFG->libdir.'/externallib.php');
|
|||
|
||||
class studyplanpage {
|
||||
|
||||
|
||||
const TABLE = "local_treestudyplan_page";
|
||||
private static $CACHE = [];
|
||||
|
||||
|
||||
private $r; // Holds database record.
|
||||
private $id;
|
||||
private $studyplan;
|
||||
|
@ -171,7 +169,7 @@ class studyplanpage {
|
|||
}
|
||||
|
||||
$id = $DB->insert_record(self::TABLE, $info);
|
||||
return self::findById($id); // make sure the new page is immediately cached.
|
||||
return self::findById($id); // Make sure the new page is immediately cached.
|
||||
}
|
||||
|
||||
public function edit($fields) {
|
||||
|
@ -410,7 +408,6 @@ class studyplanpage {
|
|||
return [ "format" => "application/json", "content" => $json];
|
||||
}
|
||||
|
||||
|
||||
public function export_model() {
|
||||
$model = [
|
||||
'fullname' => $this->r->fullname,
|
||||
|
@ -434,9 +431,10 @@ class studyplanpage {
|
|||
return $lines;
|
||||
}
|
||||
|
||||
|
||||
public function import_periods($content, $format="application/json") {
|
||||
if ($format != "application/json") { return false;}
|
||||
if ($format != "application/json") {
|
||||
return false;
|
||||
}
|
||||
$content = json_decode($content, true);
|
||||
if ($content["type"] == "periods" && $content["version"] >= 2.0) {
|
||||
return $this->import_periods_model($content["perioddesc"]);
|
||||
|
@ -448,7 +446,9 @@ class studyplanpage {
|
|||
}
|
||||
|
||||
public function import_studylines($content, $format="application/json") {
|
||||
if ($format != "application/json") { return false;}
|
||||
if ($format != "application/json") {
|
||||
return false;
|
||||
}
|
||||
$content = json_decode($content, true);
|
||||
if ($content["type"] == "studylines" && $content["version"] >= 2.0) {
|
||||
return $this->import_studylines_model($content["studylines"]);
|
||||
|
|
|
@ -29,14 +29,11 @@ require_once($CFG->libdir.'/gradelib.php');
|
|||
require_once($CFG->dirroot.'/course/modlib.php');
|
||||
|
||||
|
||||
|
||||
class studyplanservice extends \external_api
|
||||
{
|
||||
class studyplanservice extends \external_api {
|
||||
|
||||
const CAP_EDIT = "local/treestudyplan:editstudyplan";
|
||||
const CAP_VIEW = "local/treestudyplan:viewuserreports";
|
||||
|
||||
|
||||
/************************
|
||||
* *
|
||||
* list_studyplans *
|
||||
|
@ -193,7 +190,7 @@ class studyplanservice extends \external_api
|
|||
public static function edit_studyplan($id, $name, $shortname, $idnumber, $description, $periods, $startdate, $enddate, $aggregation="bistate", $aggregationconfig='', $contextid=0) {
|
||||
// Validate access in the intended context.
|
||||
$context = webservicehelper::find_context($contextid);
|
||||
webservicehelper::require_capabilities(self::CAP_EDIT, $context, false); // do not validate the context in this case, just check the permissions.
|
||||
webservicehelper::require_capabilities(self::CAP_EDIT, $context, false); // Do not validate the context in this case, just check the permissions.
|
||||
|
||||
$o = studyplan::findById($id);
|
||||
webservicehelper::require_capabilities(self::CAP_EDIT, $o->context());
|
||||
|
@ -305,7 +302,6 @@ class studyplanservice extends \external_api
|
|||
}
|
||||
|
||||
|
||||
|
||||
/************************
|
||||
* *
|
||||
* delete_studyline *
|
||||
|
@ -381,7 +377,6 @@ class studyplanservice extends \external_api
|
|||
return studyitem::editor_structure();
|
||||
}
|
||||
|
||||
|
||||
public static function get_studyitem($id) {
|
||||
$o = studyitem::findById($id);
|
||||
webservicehelper::require_capabilities([self::CAP_EDIT, self::CAP_VIEW], $o->context());
|
||||
|
@ -499,7 +494,6 @@ class studyplanservice extends \external_api
|
|||
return studyitem::reorder($resequence)->model();
|
||||
}
|
||||
|
||||
|
||||
/************************
|
||||
* *
|
||||
* delete_studyitem *
|
||||
|
@ -632,7 +626,6 @@ class studyplanservice extends \external_api
|
|||
// Do sanity checks.
|
||||
\external_api::validate_context($coursecontext);
|
||||
|
||||
|
||||
// Check correct capabilities.
|
||||
if (has_capability('local/treestudyplan:editstudyplan', studyitem::findById($itemid)->context()) ||
|
||||
is_enrolled($coursecontext, $USER, 'local/treestudyplan:selectowngradables')) {
|
||||
|
@ -731,10 +724,14 @@ class studyplanservice extends \external_api
|
|||
$gi->gradepass = $scalepass;
|
||||
|
||||
// Update grade_item.
|
||||
$result = $gi->update("local/treestudyplan"); // update, signalling with our signature and bulkupdate.
|
||||
$result = $gi->update("local/treestudyplan"); // Update, signalling with our signature and bulkupdate.
|
||||
|
||||
$debug = "";
|
||||
if ($result) { $updated = "converted";} else { $updated = "error";}
|
||||
if ($result) {
|
||||
$updated = "converted";
|
||||
} else {
|
||||
$updated = "error";
|
||||
}
|
||||
|
||||
// Next update the activity's table if it has a grade field.
|
||||
// Grade is generally set to the negative scale id if it is a scale.
|
||||
|
@ -745,8 +742,7 @@ class studyplanservice extends \external_api
|
|||
$gradevalue = intval(0-($scale->id));
|
||||
try {
|
||||
$DB->set_field($tablename, $fieldname, $gradevalue, ["id" => $gi->iteminstance]);
|
||||
}
|
||||
catch(\dml_exception $x) {
|
||||
} catch (\dml_exception $x) {
|
||||
$updated = "fail";
|
||||
$debug = strval($x);
|
||||
}
|
||||
|
@ -906,8 +902,7 @@ class studyplanservice extends \external_api
|
|||
} else {
|
||||
return $plan->export_plan();
|
||||
}
|
||||
}
|
||||
catch(\webservice_access_exception $x) {
|
||||
} catch (\webservice_access_exception $x) {
|
||||
return [ "format" => "", "content" => ""];
|
||||
}
|
||||
}
|
||||
|
@ -930,8 +925,7 @@ class studyplanservice extends \external_api
|
|||
$plan = studyplan::findById($studyplanid);
|
||||
// FIXME: Make sure this gets called for the page instead of the studyplan.
|
||||
return $plan->pages()[0]->export_studylines();
|
||||
}
|
||||
catch(\webservice_access_exception $x) {
|
||||
} catch (\webservice_access_exception $x) {
|
||||
return [ "format" => "", "content" => ""];
|
||||
}
|
||||
}
|
||||
|
@ -962,8 +956,7 @@ class studyplanservice extends \external_api
|
|||
|
||||
$result = studyplan::import_studyplan($content, $format, $contextid);
|
||||
return (new success($result, "During study plan import"))->model();
|
||||
}
|
||||
catch(\webservice_access_exception $x) {
|
||||
} catch (\webservice_access_exception $x) {
|
||||
return success::fail("Access denied")->model();
|
||||
}
|
||||
}
|
||||
|
@ -991,13 +984,11 @@ class studyplanservice extends \external_api
|
|||
// Once proper page management is implemented.
|
||||
$result = $plan->pages()[0]->import_studylines($content, $format);
|
||||
return ($result ? success::success() : success::fail())->model();
|
||||
}
|
||||
catch(\webservice_access_exception $x) {
|
||||
} catch (\webservice_access_exception $x) {
|
||||
return success::fail("Access denied")->model();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/********************************************************
|
||||
* *
|
||||
* Read and write course module title and desc *
|
||||
|
@ -1030,7 +1021,7 @@ class studyplanservice extends \external_api
|
|||
// Check the course exists.
|
||||
$course = \get_course($cm->course);
|
||||
// Require_login.
|
||||
require_login($course, false, $cm); // needed to setup proper $COURSE.
|
||||
require_login($course, false, $cm); // Needed to setup proper $COURSE.
|
||||
|
||||
// Get needed info to create the correct form.
|
||||
list($cm, $context, $module, $data, $cw) = \get_moduleinfo_data($cm, $course);
|
||||
|
@ -1101,7 +1092,6 @@ class studyplanservice extends \external_api
|
|||
$p = period::findById($id);
|
||||
webservicehelper::require_capabilities(self::CAP_EDIT, $p->page()->studyplan()->context());
|
||||
|
||||
|
||||
$p->edit([
|
||||
'fullname' => $fullname,
|
||||
'shortname' => $shortname,
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
namespace local_treestudyplan;
|
||||
|
||||
|
||||
class success {
|
||||
private $success;
|
||||
private $msg;
|
||||
|
@ -60,5 +59,4 @@ class success {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -25,7 +25,6 @@ namespace local_treestudyplan;
|
|||
class teachingfinder {
|
||||
const TABLE = "local_treestudyplan_teachers";
|
||||
|
||||
|
||||
public static function list_my_plans() {
|
||||
global $USER, $DB;
|
||||
$userid = $USER->id;
|
||||
|
@ -43,7 +42,6 @@ class teachingfinder {
|
|||
return $list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find The active studyplans where the specified user is a teacher
|
||||
* (Has the mod/assign::grade capability in one of the linked courses)
|
||||
|
@ -109,5 +107,4 @@ class teachingfinder {
|
|||
return (int)($r->update_time);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -71,7 +71,6 @@ if (!empty($options["all"])) {
|
|||
$plans = studyplan::find_by_shortname($options["studyplan"]);
|
||||
}
|
||||
|
||||
|
||||
$generator = new gradegenerator();
|
||||
$generator->fromFile($options["file"]);
|
||||
|
||||
|
|
|
@ -56,7 +56,6 @@ list($options, $unrecognised) = cli_get_params([
|
|||
'd' => 'dryrun'
|
||||
]);
|
||||
|
||||
|
||||
if ($unrecognised) {
|
||||
$unrecognised = implode(PHP_EOL . ' ', $unrecognised);
|
||||
cli_error(get_string('cliunknowoption', 'core_admin', $unrecognised));
|
||||
|
@ -85,10 +84,8 @@ $authplugin->sync_roles($user);
|
|||
login_attempt_valid($user);
|
||||
complete_user_login($user);
|
||||
|
||||
|
||||
////////////////////////////////.
|
||||
|
||||
|
||||
if (empty($options['studyplan']) && empty($options["all"])) {
|
||||
cli_error('Missing mandatory argument studyplan.', 2);
|
||||
}
|
||||
|
@ -102,7 +99,6 @@ if (!empty($options["all"])) {
|
|||
$generator = new gradegenerator();
|
||||
$generator->fromFile($options["file"]);
|
||||
|
||||
|
||||
$assignments = [];
|
||||
|
||||
cli_writeln(count($plans)." studyplans found:");
|
||||
|
@ -116,7 +112,8 @@ foreach ($plans as $plan) {
|
|||
cli_writeln(" ** {$line->name()} **");
|
||||
$items = studyitem::find_studyline_children($line);
|
||||
foreach ($items as $item) {
|
||||
if ($item->type() == studyitem::COURSE) { // only handle courses for now.
|
||||
if ($item->type() == studyitem::COURSE) {
|
||||
// Only handle courses for now.
|
||||
$courseinfo = $item->getcourseinfo();
|
||||
cli_writeln(" # {$courseinfo->shortname()}");
|
||||
|
||||
|
|
|
@ -67,5 +67,4 @@ $capabilities = [
|
|||
),
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
|
|
|
@ -49,7 +49,6 @@ function xmldb_local_treestudyplan_upgrade($oldversion) {
|
|||
|
||||
if ($oldversion < 2020120301) {
|
||||
|
||||
|
||||
// Define field studyitem_id to be added to local_treestudyplan_gradeinc.
|
||||
$table = new xmldb_table('local_treestudyplan_gradeinc');
|
||||
$field = new xmldb_field('studyitem_id', XMLDB_TYPE_INTEGER, '20', null, null, null, null, 'include');
|
||||
|
@ -64,7 +63,6 @@ function xmldb_local_treestudyplan_upgrade($oldversion) {
|
|||
// Launch add key studyitem_id-id.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
|
||||
// Treestudyplan savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2020120301, 'local', 'treestudyplan');
|
||||
}
|
||||
|
@ -156,7 +154,6 @@ function xmldb_local_treestudyplan_upgrade($oldversion) {
|
|||
upgrade_plugin_savepoint(true, 2021082601, 'local', 'treestudyplan');
|
||||
}
|
||||
|
||||
|
||||
if ($oldversion < 2021082700) {
|
||||
|
||||
$table = new xmldb_table('local_treestudyplan_gradecfg');
|
||||
|
@ -262,7 +259,6 @@ function xmldb_local_treestudyplan_upgrade($oldversion) {
|
|||
// Launch drop key studyplan_id-id.
|
||||
$dbman->drop_key($table, $key);
|
||||
|
||||
|
||||
/******
|
||||
* Create the page table and copy data from treestudyplan there
|
||||
* Also re-link the studylines to the newly created page instead of the studyplan
|
||||
|
@ -342,7 +338,6 @@ function xmldb_local_treestudyplan_upgrade($oldversion) {
|
|||
// Launch add key page_id-id.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
|
||||
/***
|
||||
* Create Period table and make a period record for all studyplan periods
|
||||
*/
|
||||
|
@ -363,7 +358,6 @@ function xmldb_local_treestudyplan_upgrade($oldversion) {
|
|||
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
|
||||
$table->add_key('page_id-id', XMLDB_KEY_FOREIGN, ['page_id'], 'local_treestudyplan_page', ['id']);
|
||||
|
||||
|
||||
// Conditionally launch create table for local_treestudyplan_period.
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
|
@ -387,7 +381,7 @@ function xmldb_local_treestudyplan_upgrade($oldversion) {
|
|||
for ($i=0; $i < $pcount; $i++) {
|
||||
$pnum = $i+1;
|
||||
$pstart = $ystart + ($i*$ptime);
|
||||
$pend = ($pstart + $ptime)-(24*60*60); // minus one day.
|
||||
$pend = ($pstart + $ptime)-(24*60*60); // Minus one day.
|
||||
|
||||
$o = [ "page_id" => $r->id,
|
||||
"period" => $pnum,
|
||||
|
@ -471,7 +465,6 @@ function xmldb_local_treestudyplan_upgrade($oldversion) {
|
|||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
|
||||
// Treestudyplan savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2023080900, 'local', 'treestudyplan');
|
||||
}
|
||||
|
@ -494,6 +487,5 @@ function xmldb_local_treestudyplan_upgrade($oldversion) {
|
|||
upgrade_plugin_savepoint(true, 2023082100, 'local', 'treestudyplan');
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
|
@ -26,7 +26,7 @@ require_once("./lib.php");
|
|||
require_once($CFG->libdir.'/weblib.php');
|
||||
require_once($CFG->dirroot.'/local/treestudyplan/classes/reportinvite_form.php');
|
||||
|
||||
$add = optional_param('add', '', PARAM_ALPHANUM); // module name.
|
||||
$add = optional_param('add', '', PARAM_ALPHANUM); // Module name.
|
||||
$update = optional_param('update', 0, PARAM_INT);
|
||||
$resend = optional_param('resend', 0, PARAM_INT);
|
||||
$delete = optional_param('delete', 0, PARAM_INT);
|
||||
|
@ -45,7 +45,6 @@ if ($update > 0) {
|
|||
$PAGE->set_heading(get_string('invite_desc_new', 'local_treestudyplan'));
|
||||
}
|
||||
|
||||
|
||||
// Check if user has capability to manage study plan units.
|
||||
require_login();
|
||||
|
||||
|
@ -59,8 +58,7 @@ if (!empty($add)) {
|
|||
} else if (!empty($update)) {
|
||||
$data = $DB->get_record("local_treestudyplan_invit", array('id' => $update));
|
||||
$data->update = $update;
|
||||
if (empty($data) || $data->user_id != $USER->id)
|
||||
{
|
||||
if (empty($data) || $data->user_id != $USER->id) {
|
||||
print_error('invalidaction');
|
||||
exit;
|
||||
}
|
||||
|
@ -68,25 +66,20 @@ if (!empty($add)) {
|
|||
} else if (!empty($resend)) {
|
||||
$data = $DB->get_record("local_treestudyplan_invit", array('id' => $resend));
|
||||
$data->resend = $resend;
|
||||
if (empty($data) || $data->user_id != $USER->id)
|
||||
{
|
||||
if (empty($data) || $data->user_id != $USER->id) {
|
||||
print_error('invalidaction');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Do some resending of an invitation.
|
||||
local_treestudyplan_send_invite($data->id);
|
||||
|
||||
|
||||
|
||||
redirect("$CFG->wwwroot/local/treestudyplan/invitations.php?sent={$resend}");
|
||||
print $OUTPUT->footer();
|
||||
exit;
|
||||
} else if (!empty($delete)) {
|
||||
$data = $DB->get_record("local_treestudyplan_invit", array('id' => $delete));
|
||||
$data->delete = $delete;
|
||||
if (empty($data) || $data->user_id != $USER->id)
|
||||
{
|
||||
if (empty($data) || $data->user_id != $USER->id) {
|
||||
print_error('invalidaction');
|
||||
exit;
|
||||
}
|
||||
|
@ -106,20 +99,17 @@ $mform->set_data($data);
|
|||
if ($mform->is_cancelled()) {
|
||||
redirect("$CFG->wwwroot/local/treestudyplan/invitations.php");
|
||||
} else if ($data = $mform->get_data()) {
|
||||
if (!empty($data->update))
|
||||
{
|
||||
if (!empty($data->update)) {
|
||||
|
||||
$id = $data->update;
|
||||
$data->id = $id;
|
||||
|
||||
$DB->update_record('local_treestudyplan_invit', $data);
|
||||
|
||||
|
||||
redirect("$CFG->wwwroot/local/treestudyplan/invitations.php");
|
||||
|
||||
}
|
||||
else if (!empty($data->add))
|
||||
{
|
||||
else if (!empty($data->add)) {
|
||||
|
||||
$id = $DB->insert_record("local_treestudyplan_invit", $data, true);
|
||||
|
||||
|
@ -128,12 +118,10 @@ if ($mform->is_cancelled()) {
|
|||
|
||||
redirect("$CFG->wwwroot/local/treestudyplan/invitations.php?sent={$id}");
|
||||
}
|
||||
else if (!empty($data->resend))
|
||||
{
|
||||
else if (!empty($data->resend)) {
|
||||
|
||||
}
|
||||
else if (!empty($data->delete))
|
||||
{
|
||||
else if (!empty($data->delete)) {
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -145,13 +133,11 @@ if ($mform->is_cancelled()) {
|
|||
|
||||
} else {
|
||||
$data = null;
|
||||
if ($unitid > 0)
|
||||
{
|
||||
if ($unitid > 0) {
|
||||
|
||||
}
|
||||
$mform->display();
|
||||
}
|
||||
|
||||
|
||||
|
||||
print $OUTPUT->footer();
|
|
@ -39,8 +39,7 @@ if ($categoryid > 0) {
|
|||
|
||||
} else if ($contextid > 0) {
|
||||
$studyplancontext = context::instance_by_id($contextid);
|
||||
if (in_array($studyplancontext->contextlevel, [CONTEXT_SYSTEM, CONTEXT_COURSECAT]))
|
||||
{
|
||||
if (in_array($studyplancontext->contextlevel, [CONTEXT_SYSTEM, CONTEXT_COURSECAT])) {
|
||||
$categoryid = $studyplancontext->instanceid;
|
||||
}
|
||||
else
|
||||
|
@ -50,7 +49,7 @@ if ($categoryid > 0) {
|
|||
} else {
|
||||
// If no context is selected, find the first available one.
|
||||
$availablecontexts = courseservice::list_accessible_categories_with_usage("edit");
|
||||
$contextid=1; // fallback to system context.
|
||||
$contextid=1; // Fallback to system context.
|
||||
foreach ($availablecontexts as $ctx) {
|
||||
if ($ctx->count > 0) {
|
||||
$contextid = $ctx->ctxid;
|
||||
|
@ -76,16 +75,13 @@ if ($studyplancontext->id > 1) {
|
|||
$PAGE->navbar->add(get_string('cfg_plans', 'local_treestudyplan'));
|
||||
}
|
||||
|
||||
|
||||
// Load javascripts and specific css.
|
||||
$PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/bootstrap-vue/bootstrap-vue.css'));
|
||||
$PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devstyles.css'));
|
||||
$PAGE->requires->js_call_amd('local_treestudyplan/page-edit-plan', 'init', [$studyplancontext->id, $categoryid]);
|
||||
|
||||
|
||||
$catlist = courseservice::list_accessible_categories_with_usage("edit");
|
||||
|
||||
|
||||
// Local translate function.
|
||||
function t($str, $param=null, $plugin='local_treestudyplan') {
|
||||
print get_string($str, $plugin, $param);
|
||||
|
@ -94,7 +90,6 @@ function t($str, $param=null, $plugin='local_treestudyplan') {
|
|||
print $OUTPUT->header();
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<div id='root'>
|
||||
<div class='vue-loader' v-show='false'>
|
||||
|
|
|
@ -77,8 +77,7 @@ print "</thead>";
|
|||
|
||||
print "<tbody>";
|
||||
if (count($invites) > 0) {
|
||||
foreach ($invites as $invite)
|
||||
{
|
||||
foreach ($invites as $invite) {
|
||||
$testlink = $INVITEDURL."?key={$invite->invitekey}";
|
||||
print "<tr data-id='{$invite->id}'>";
|
||||
print "<td data-field='name'>{$invite->name}</td>";
|
||||
|
@ -112,6 +111,4 @@ print "<a class='btn btn-info' href='/local/treestudyplan/edit-invite.php?add=tr
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
print $OUTPUT->footer();
|
|
@ -32,7 +32,7 @@ $PAGE->set_pagelayout('base');
|
|||
$PAGE->set_context($systemcontext);
|
||||
|
||||
// See if we can get a valid user for this invited.
|
||||
$invitekey = optional_param('key', '', PARAM_ALPHANUM); // module name.
|
||||
$invitekey = optional_param('key', '', PARAM_ALPHANUM); // Module name.
|
||||
$PAGE->set_url("/local/treestudyplan/invited.php", array('key' => $invitekey));
|
||||
|
||||
$invite = $DB->get_record_select("local_treestudyplan_invit", $DB->sql_compare_text("invitekey"). " = " . $DB->sql_compare_text(":invitekey"), ['invitekey' => $invitekey]);
|
||||
|
@ -41,10 +41,8 @@ if (empty($invite)) {
|
|||
$PAGE->set_title(get_string('invalid_invitekey_title', 'local_treestudyplan'));
|
||||
$PAGE->set_heading(get_string('invalid_invitekey_title', 'local_treestudyplan'));
|
||||
|
||||
|
||||
print $OUTPUT->header();
|
||||
|
||||
|
||||
// Render page for skill level 0 (global).
|
||||
|
||||
print "<div class='box errorbox alert alert-danger'>";
|
||||
|
|
|
@ -39,7 +39,6 @@ $string['treestudyplan:viewuserreports'] = "View study plan of others";
|
|||
$string['treestudyplan:forcescales'] = 'Advanced: Allow studyplan manager to force assignment scales to setting (manual modes only)';
|
||||
$string['treestudyplan:selectowngradables'] = 'Teachers can select gradables in their own courses in study plan view mode (manual modes only)';
|
||||
|
||||
|
||||
$string['report'] = 'Progress report';
|
||||
$string['report_invited'] = 'Progress report for {$a}';
|
||||
$string['report_index'] = 'View student progress reports';
|
||||
|
@ -242,7 +241,6 @@ $string['bistate_aggregator_desc'] = 'Goals are completed or not (e.g. not start
|
|||
$string['core_aggregator_title'] = 'Moodle course completion';
|
||||
$string['core_aggregator_desc'] = 'Use Moodle core completion';
|
||||
|
||||
|
||||
$string['setting_bistate_heading'] = 'Defaults for Completed + Required goalsn';
|
||||
$string['settingdesc_bistate_heading'] = 'Set the defaults for this aggregation method';
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ $string['treestudyplan:viewuserreports'] = "Studieplannen van anderen bekijken";
|
|||
$string['treestudyplan:forcescales'] = 'Gevorderd: Studyplanbeheerder kan alle opdrachten in studieplan instellen op specifieke resultaatschaal (alleen handmatige modes)';
|
||||
$string['treestudyplan:selectowngradables'] = 'Docenten kunnen in hun eigen cursussen zelf activiteiten selecteren in een studieplan (docentenweergave, alleen handmatige modes)';
|
||||
|
||||
|
||||
$string['report'] = 'Voortgangsrapport';
|
||||
$string['report_invited'] = 'Voortgang van {$a}';
|
||||
$string['report_index'] = 'Studieplannen van studenten inzien';
|
||||
|
|
30
lib.php
30
lib.php
|
@ -56,8 +56,7 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) {
|
|||
{
|
||||
|
||||
$userstudyplans = studyplan::find_for_user($USER->id);
|
||||
if (!empty($userstudyplans))
|
||||
{
|
||||
if (!empty($userstudyplans)) {
|
||||
|
||||
// Create studyplan node.
|
||||
$node = navigation_node::create(
|
||||
|
@ -83,15 +82,13 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) {
|
|||
$invitenode->showinflatnavigation = false;
|
||||
$node->add_node($invitenode);
|
||||
|
||||
|
||||
$navigation->add_node($node, 'mycourses');
|
||||
}
|
||||
else {
|
||||
$hideprimary_hrefs[] = "/local/treestudyplan/myreport.php";
|
||||
}
|
||||
if ( has_capability('local/treestudyplan:viewuserreports', context_system::instance())
|
||||
|| webservicehelper::has_capability_in_any_category('local/treestudyplan:viewuserreports'))
|
||||
{
|
||||
|| webservicehelper::has_capability_in_any_category('local/treestudyplan:viewuserreports')) {
|
||||
$node = navigation_node::create(
|
||||
get_string("link_viewplan", "local_treestudyplan"),
|
||||
new moodle_url($CFG->wwwroot . "/local/treestudyplan/view-plan.php", array()),
|
||||
|
@ -109,8 +106,7 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) {
|
|||
}
|
||||
if ( has_capability('local/treestudyplan:editstudyplan', context_system::instance())
|
||||
|| webservicehelper::has_capability_in_any_category('local/treestudyplan:editstudyplan')
|
||||
)
|
||||
{
|
||||
) {
|
||||
$node = navigation_node::create(
|
||||
get_string("cfg_plans", "local_treestudyplan"),
|
||||
new moodle_url($CFG->wwwroot . "/local/treestudyplan/edit-plan.php", array()),
|
||||
|
@ -144,12 +140,10 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) {
|
|||
$invitenode->showinflatnavigation = false;
|
||||
$navigation->add_node($invitenode, 'mycourses');
|
||||
|
||||
|
||||
// Now using some javascript magic, we'll hide the links that are not accessible.
|
||||
$PAGE->requires->js_call_amd('local_treestudyplan/primary-nav-tools', 'hide_primary', [$hideprimary_hrefs]);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function local_treestudyplan_extend_navigation_category_settings($navigation, context_coursecat $coursecategorycontext) {
|
||||
|
@ -222,20 +216,16 @@ function local_treestudyplan_send_invite($inviteid) {
|
|||
'sender' => "{$USER->firstname} {$USER->lastname}",
|
||||
'link' => $invitehref];
|
||||
|
||||
if ($invite->allow_details || $invite->allow_calendar || $invite->allow_badges)
|
||||
{
|
||||
if ($invite->allow_details || $invite->allow_calendar || $invite->allow_badges) {
|
||||
$data['permissions'] = get_string('invite_mail_permissions', 'local_treestudyplan');
|
||||
$data['permissions'] .= "<ul>\n";
|
||||
if ($invite->allow_details )
|
||||
{
|
||||
if ($invite->allow_details ) {
|
||||
$data['permissions'] .= "<li>".get_string('invite_allow_details', 'local_treestudyplan')."</li>\n";
|
||||
}
|
||||
if ($invite->allow_calendar)
|
||||
{
|
||||
if ($invite->allow_calendar) {
|
||||
$data['permissions'] .= "<li>".get_string('invite_allow_calendar', 'local_treestudyplan')."</li>\n";
|
||||
}
|
||||
if ($invite->allow_badges)
|
||||
{
|
||||
if ($invite->allow_badges) {
|
||||
$data['permissions'] .= "<li>".get_string('invite_allow_badges', 'local_treestudyplan')."</li>\n";
|
||||
}
|
||||
|
||||
|
@ -287,7 +277,7 @@ function local_treestudyplan_get_cohort_path($cohort) {
|
|||
function($ctx) { return $ctx->get_context_name(false);},
|
||||
$cohortcontext->get_parent_contexts(true)
|
||||
);
|
||||
array_pop($ctxpath); // pop system context off the list.
|
||||
array_pop($ctxpath); // Pop system context off the list.
|
||||
$ctxpath = array_reverse($ctxpath);
|
||||
$ctxpath[] = $cohort->name;
|
||||
|
||||
|
@ -297,7 +287,6 @@ function local_treestudyplan_get_cohort_path($cohort) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
function local_treestudyplan_output_fragment_mod_edit_form($args) {
|
||||
global $CFG;
|
||||
global $DB;
|
||||
|
@ -315,7 +304,7 @@ function local_treestudyplan_output_fragment_mod_edit_form($args) {
|
|||
$course = \get_course($cm->course);
|
||||
|
||||
// Require_login.
|
||||
require_login($course, false, $cm); // needed to setup proper $COURSE.
|
||||
require_login($course, false, $cm); // Needed to setup proper $COURSE.
|
||||
|
||||
list($cm, $context, $module, $data, $cw) = \get_moduleinfo_data($cm, $course);
|
||||
|
||||
|
@ -332,5 +321,4 @@ function local_treestudyplan_output_fragment_mod_edit_form($args) {
|
|||
|
||||
return $mform->render();
|
||||
|
||||
|
||||
}
|
34
myreport.php
34
myreport.php
|
@ -55,23 +55,23 @@ function t($str, $param=null, $plugin='local_treestudyplan') {
|
|||
}
|
||||
|
||||
print $OUTPUT->header();
|
||||
?>
|
||||
<div class="m-buttonbar" style="margin-bottom: 1em; text-align: right;">
|
||||
<?php if (!$teachermode) { ?>
|
||||
<a class="btn btn-primary" href="invitations.php" id="manage_invites"><i class="fa fa-share"></i> <?php t('manage_invites'); ?></a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div id='root'>
|
||||
<div class='vue-loader' v-show='false'>
|
||||
<div class="spinner-border text-primary" role="status">
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-cloak>
|
||||
<r-report v-model="studyplans" <?php print ($teachermode?"teachermode":""); ?> ></r-report>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
print '<div class="m-buttonbar" style="margin-bottom: 1em; text-align: right;">';
|
||||
|
||||
if (!$teachermode) {
|
||||
print '<a class="btn btn-primary" href="invitations.php" id="manage_invites"><i class="fa fa-share"></i>'.t('manage_invites').'</a>';
|
||||
}
|
||||
|
||||
print "</div>";
|
||||
print "<div id='root'>";
|
||||
print " <div class='vue-loader' v-show='false'>";
|
||||
print " <div class='spinner-border text-primary' role='status'>";
|
||||
print " <span class='sr-only'>Loading...</span>";
|
||||
print " </div>";
|
||||
print " </div>";
|
||||
print " <div v-cloak>";
|
||||
print " <r-report v-model='studyplans' " . ($teachermode ? "teachermode" : "")." ></r-report>";
|
||||
print " </div>";
|
||||
print "</div>";
|
||||
|
||||
print $OUTPUT->footer();
|
|
@ -42,7 +42,6 @@ if ($hassiteconfig) {
|
|||
$page = new admin_settingpage('local_treestudyplan_settings',
|
||||
get_string('settingspage', 'local_treestudyplan', null, true));
|
||||
|
||||
|
||||
// GOAL AGGREGATION SETTINGS.
|
||||
$page->add(new admin_setting_heading('local_treestudyplan/aggregation_heading',
|
||||
get_string('setting_aggregation_heading', 'local_treestudyplan'),
|
||||
|
@ -139,7 +138,6 @@ if ($hassiteconfig) {
|
|||
get_string('cfg_plans', 'local_treestudyplan', null, true),
|
||||
$CFG->wwwroot . '/local/treestudyplan/edit-plan.php'));
|
||||
|
||||
|
||||
/**************************************
|
||||
*
|
||||
* Settings page: Cohort sync
|
||||
|
@ -149,7 +147,6 @@ if ($hassiteconfig) {
|
|||
$pagecsync = new admin_settingpage('local_treestudyplan_settings_cohortsync',
|
||||
get_string('settingspage_csync', 'local_treestudyplan', null, true));
|
||||
|
||||
|
||||
// Description heading.
|
||||
$pagecsync->add(new admin_setting_heading('local_treestudyplan/csync_heading',
|
||||
get_string('setting_csync_heading', 'local_treestudyplan'),
|
||||
|
|
|
@ -39,8 +39,7 @@ if ($categoryid > 0) {
|
|||
|
||||
} else if ($contextid > 0) {
|
||||
$studyplancontext = context::instance_by_id($contextid);
|
||||
if (in_array($studyplancontext->contextlevel, [CONTEXT_SYSTEM, CONTEXT_COURSECAT]))
|
||||
{
|
||||
if (in_array($studyplancontext->contextlevel, [CONTEXT_SYSTEM, CONTEXT_COURSECAT])) {
|
||||
$categoryid = $studyplancontext->instanceid;
|
||||
}
|
||||
else
|
||||
|
@ -50,7 +49,7 @@ if ($categoryid > 0) {
|
|||
} else {
|
||||
// If no context is selected, find the first available one.
|
||||
$availablecontexts = courseservice::list_accessible_categories_with_usage("view");
|
||||
$contextid=1; // fallback to system context.
|
||||
$contextid=1; // Fallback to system context.
|
||||
foreach ($availablecontexts as $ctx) {
|
||||
if ($ctx->count > 0) {
|
||||
$contextid = $ctx->ctxid;
|
||||
|
|
Loading…
Reference in New Issue
Block a user