-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e5feb3
commit 7c65e1f
Showing
21 changed files
with
808 additions
and
86 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Base class for a single booking option availability condition. | ||
* | ||
* All bo condition types must extend this class. | ||
* | ||
* @package local_adele | ||
* @author Jacob Viertel | ||
* @copyright 2023 Wunderbyte GmbH | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace local_adele\course_completion\conditions; | ||
|
||
use local_adele\course_completion\course_completion; | ||
|
||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
require_once($CFG->dirroot . '/local/adele/lib.php'); | ||
|
||
/** | ||
* Class for a single learning path course condition. | ||
* | ||
* @package local_adele | ||
* @author Jacob Viertel | ||
* @copyright 2023 Wunderbyte GmbH | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class manual implements course_completion { | ||
|
||
/** @var int $id Standard Conditions have hardcoded ids. */ | ||
public $id = COURSES_COND_MANUALLY; | ||
/** @var string $type of the redered condition in frontend. */ | ||
public $type = 'manual'; | ||
/** | ||
* Obtains a string describing this restriction (whether or not | ||
* it actually applies). Used to obtain information that is displayed to | ||
* students if the activity is not available to them, and for staff to see | ||
* what conditions are. | ||
* | ||
* The $full parameter can be used to distinguish between 'staff' cases | ||
* (when displaying all information about the activity) and 'student' cases | ||
* (when displaying only conditions they don't meet). | ||
* | ||
* @return array availability and Information string (for admin) about all restrictions on | ||
* this item | ||
*/ | ||
public function get_description():array { | ||
$description = $this->get_description_string(); | ||
$name = $this->get_name_string(); | ||
$label = $this->type; | ||
|
||
return [ | ||
'id' => $this->id, | ||
'name' => $name, | ||
'description' => $description, | ||
'label' => $label, | ||
'type' => $this->type, | ||
]; | ||
} | ||
|
||
/** | ||
* Helper function to return localized description strings. | ||
* | ||
* @return string | ||
*/ | ||
private function get_description_string() { | ||
$description = get_string('course_description_condition_manually', 'local_adele'); | ||
return $description; | ||
} | ||
|
||
/** | ||
* Helper function to return localized description strings. | ||
* | ||
* @return string | ||
*/ | ||
private function get_name_string() { | ||
$description = get_string('course_name_condition_manually', 'local_adele'); | ||
return $description; | ||
} | ||
|
||
/** | ||
* Helper function to return localized description strings. | ||
* | ||
* @return string | ||
*/ | ||
private function get_label_string() { | ||
$label = get_string('course_label_condition_manually', 'local_adele'); | ||
return $label; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?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 class contains a list of webservice functions related to the adele Module by Wunderbyte. | ||
* | ||
* @package local_adele | ||
* @author Jacob Viertel | ||
* @copyright 2023 Wunderbyte GmbH | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace local_adele\external; | ||
|
||
use context_system; | ||
use core_external\external_api; | ||
use core_external\external_function_parameters; | ||
use core_external\external_value; | ||
use core_external\external_single_structure; | ||
use local_adele\learning_paths; | ||
use moodle_exception; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
require_once($CFG->libdir . '/externallib.php'); | ||
|
||
/** | ||
* External Service for local adele. | ||
* | ||
* @package local_adele | ||
* @author Jacob Viertel | ||
* @copyright 2023 Wunderbyte GmbH | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class get_lp_user_path_relation extends external_api { | ||
|
||
/** | ||
* Describes the parameters for get_next_question webservice. | ||
* | ||
* @return external_function_parameters | ||
*/ | ||
public static function execute_parameters(): external_function_parameters { | ||
return new external_function_parameters([ | ||
'learningpathid' => new external_value(PARAM_INT, 'userid', VALUE_REQUIRED), | ||
'userid' => new external_value(PARAM_INT, 'userid', VALUE_REQUIRED), | ||
'learninggoalid' => new external_value(PARAM_INT, 'learninggoalid', VALUE_REQUIRED), | ||
'userpathid' => new external_value(PARAM_INT, 'userpathid', VALUE_REQUIRED), | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* Webservice for the local catquiz plugin to get next question. | ||
* | ||
* @param int $learningpathid | ||
* @return array | ||
*/ | ||
public static function execute($learningpathid, $userid, $learninggoalid, $userpathid): array { | ||
$params = self::validate_parameters(self::execute_parameters(), [ | ||
'userid' => $userid, | ||
'learninggoalid' => $learninggoalid, | ||
'learningpathid' => $learningpathid, | ||
'userpathid' => $userpathid, | ||
]); | ||
|
||
require_login(); | ||
|
||
$context = context_system::instance(); | ||
if (!has_capability('local/adele:canmanage', $context)) { | ||
throw new moodle_exception('norighttoaccess', 'local_adele'); | ||
} | ||
return learning_paths::get_learning_user_relation($params); | ||
} | ||
|
||
/** | ||
* Returns description of method result value. | ||
* | ||
* @return external_single_structure | ||
*/ | ||
public static function execute_returns(): external_single_structure { | ||
return new external_single_structure([ | ||
'user_id' => new external_value(PARAM_INT, 'Item id'), | ||
'username' => new external_value(PARAM_TEXT, 'Username'), | ||
'firstname' => new external_value(PARAM_TEXT, 'Firstname'), | ||
'lastname' => new external_value(PARAM_TEXT, 'Lastname'), | ||
'email' => new external_value(PARAM_RAW, 'email'), | ||
'json' => new external_value(PARAM_RAW, 'Flow Chart'), | ||
] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.