-
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.
New Feature: Restriction implemented GH-7
- Loading branch information
1 parent
9b943aa
commit f09d6eb
Showing
26 changed files
with
833 additions
and
102 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?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/>. | ||
|
||
namespace local_adele\course_completion; | ||
|
||
/** | ||
* | ||
* @package local_adele | ||
* @author Jacob Viertel | ||
* @copyright 2023 Wunderbyte GmbH | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
/** | ||
* class for conditional availability information of a 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 course_completion_status { | ||
|
||
/** @var int userid for a given user */ | ||
protected $userid; | ||
|
||
/** | ||
* Constructs with item details. | ||
* | ||
*/ | ||
public function __construct() { | ||
global $USER; | ||
$this->userid = $USER->id; | ||
} | ||
|
||
/** | ||
* Returns conditions depending on the conditions param. | ||
* | ||
* @param array $node | ||
* @param int $userid | ||
* @return array | ||
*/ | ||
public static function get_restriction_status($node, $userid): array { | ||
global $CFG; | ||
// First, we get all the available conditions from our directory. | ||
$path = $CFG->dirroot . '/local/adele/classes/course_restriction/conditions/*.php'; | ||
$filelist = glob($path); | ||
$completionstatus = []; | ||
// We just want filenames, as they are also the classnames. | ||
foreach ($filelist as $filepath) { | ||
$path = pathinfo($filepath); | ||
$filename = 'local_adele\\course_restriction\\conditions\\' . $path['filename']; | ||
// We instantiate all the classes, because we need some information. | ||
if (class_exists($filename)) { | ||
$conditionclass = new $filename(); | ||
$completionstatus[$path['filename']] = $conditionclass->get_restriction_status($node, $userid); | ||
} | ||
} | ||
return $completionstatus; | ||
} | ||
} |
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,77 @@ | ||
<?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_restriction; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
require_once($CFG->dirroot . '/local/adele/lib.php'); | ||
|
||
/** | ||
* Interface for a learning path course conditions. | ||
* | ||
* @package local_adele | ||
* @author Jacob Viertel | ||
* @copyright 2023 Wunderbyte GmbH | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
interface course_restriction { | ||
|
||
/** | ||
* 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 Information string (for admin) about all restrictions on | ||
* this item | ||
*/ | ||
public function get_description(); | ||
|
||
/** | ||
* 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). | ||
* | ||
* @param array $node | ||
* @param int $userid | ||
* @return array Information string (for admin) about all restrictions on | ||
* this item | ||
*/ | ||
public function get_restriction_status($node, $userid); | ||
|
||
} |
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,75 @@ | ||
<?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/>. | ||
|
||
namespace local_adele\course_restriction; | ||
|
||
/** | ||
* | ||
* @package local_adele | ||
* @author Jacob Viertel | ||
* @copyright 2023 Wunderbyte GmbH | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
/** | ||
* class for conditional availability information of a 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 course_restriction_info { | ||
|
||
/** @var int userid for a given user */ | ||
protected $userid; | ||
|
||
/** | ||
* Constructs with item details. | ||
* | ||
*/ | ||
public function __construct() { | ||
global $USER; | ||
$this->userid = $USER->id; | ||
} | ||
|
||
/** | ||
* Returns conditions depending on the conditions param. | ||
* | ||
* @return array | ||
*/ | ||
public static function get_restrictions(): array { | ||
|
||
global $CFG; | ||
// First, we get all the available conditions from our directory. | ||
$path = $CFG->dirroot . '/local/adele/classes/course_restriction/conditions/*.php'; | ||
$filelist = glob($path); | ||
|
||
$conditions = []; | ||
|
||
// We just want filenames, as they are also the classnames. | ||
foreach ($filelist as $filepath) { | ||
$path = pathinfo($filepath); | ||
$filename = 'local_adele\\course_restriction\\conditions\\' . $path['filename']; | ||
// We instantiate all the classes, because we need some information. | ||
if (class_exists($filename)) { | ||
$conditionclass = new $filename(); | ||
$conditions[] = $conditionclass->get_description(); | ||
} | ||
} | ||
return $conditions; | ||
} | ||
} |
Oops, something went wrong.