-
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.
Merge pull request #61 from integral-learning/dev
Release v1.6.0
- Loading branch information
Showing
18 changed files
with
786 additions
and
194 deletions.
There are no files selected for viewing
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,39 @@ | ||
<?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 mod_mumie\event; | ||
defined('MOODLE_INTERNAL') || die; | ||
|
||
/** | ||
* The mod_mumie course module viewed event. | ||
* | ||
* @package mod_mumie | ||
* @copyright 2017-2023 integral-learning GmbH (https://www.integral-learning.de/) | ||
* @author Filip Sacha ([email protected]) | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class course_module_viewed extends \core\event\course_module_viewed { | ||
/** | ||
* Init method. | ||
* | ||
* @return void | ||
*/ | ||
protected function init() { | ||
$this->data['crud'] = 'r'; | ||
$this->data['edulevel'] = self::LEVEL_PARTICIPATING; | ||
$this->data['objecttable'] = 'mumie'; | ||
} | ||
} |
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,57 @@ | ||
<?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 mod_mumie\synchronization\context; | ||
|
||
/** | ||
* This class holds context for multiple MUMIE Tasks required for some XAPI requests. | ||
* | ||
* @package mod_mumie | ||
* @copyright 2017-2023 integral-learning GmbH (https://www.integral-learning.de/) | ||
* @author Tobias Goltz ([email protected]) | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class context implements \JsonSerializable { | ||
/** | ||
* @var array | ||
*/ | ||
private array $objectcontexts; | ||
|
||
/** | ||
* Create a new instance. | ||
*/ | ||
public function __construct() { | ||
$this->objectcontexts = array(); | ||
} | ||
|
||
/** | ||
* Add a new ObjectContext to this context. | ||
* @param string $objectid | ||
* @param object_context $objectcontext | ||
* @return void | ||
*/ | ||
public function add_object_context(string $objectid, object_context $objectcontext): void { | ||
$this->objectcontexts[$objectid] = $objectcontext; | ||
} | ||
|
||
/** | ||
* Custom json serialization. | ||
* @return array | ||
*/ | ||
public function jsonSerialize() : array { | ||
return $this->objectcontexts; | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
classes/grades/synchronization/context/context_provider.php
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,93 @@ | ||
<?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 mod_mumie\synchronization\context; | ||
|
||
use mod_mumie\locallib; | ||
use auth_mumie\user\mumie_user; | ||
use stdClass; | ||
|
||
/** | ||
* This class is used to create the context that is required for some XAPI requests. | ||
* | ||
* @package mod_mumie | ||
* @copyright 2017-2023 integral-learning GmbH (https://www.integral-learning.de/) | ||
* @author Tobias Goltz ([email protected]) | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class context_provider { | ||
/** | ||
* Get context for a given list of MUMIE Tasks and users. | ||
* | ||
* @param array $mumietasks | ||
* @param array $users | ||
* @return context | ||
*/ | ||
public static function get_context(array $mumietasks, array $users): context { | ||
global $CFG; | ||
require_once($CFG->dirroot . "/mod/mumie/classes/grades/synchronization/context/context.php"); | ||
$context = new context(); | ||
foreach ($mumietasks as $mumietask) { | ||
if (self::requires_context($mumietask)) { | ||
$context->add_object_context( | ||
locallib::get_mumie_id($mumietask), | ||
self::create_object_context($mumietask, $users) | ||
); | ||
} | ||
} | ||
return $context; | ||
} | ||
|
||
/** | ||
* Check whether a MUMIE Task requires context for XAPI requests. | ||
* @param stdClass $mumie | ||
* @return bool | ||
*/ | ||
public static function requires_context(stdClass $mumie): bool { | ||
return str_starts_with($mumie->taskurl, "worksheet_") | ||
&& $mumie->duedate > 0; | ||
} | ||
|
||
/** | ||
* Create a new object_context instance for a given list of users. | ||
* | ||
* @param stdClass $mumie | ||
* @param array $users | ||
* @return object_context | ||
*/ | ||
private static function create_object_context(stdClass $mumie, array $users): object_context { | ||
global $CFG; | ||
require_once($CFG->dirroot . "/mod/mumie/classes/grades/synchronization/context/object_context.php"); | ||
$context = new object_context(); | ||
foreach ($users as $user) { | ||
$context->add_user_context($user->get_sync_id(), self::create_user_context($mumie, $user)); | ||
} | ||
return $context; | ||
} | ||
|
||
/** | ||
* Create a new user_context instance for a given user and MUMIE Task | ||
* @param stdClass $mumie | ||
* @param mumie_user $user | ||
* @return user_context | ||
*/ | ||
private static function create_user_context(stdClass $mumie, mumie_user $user): user_context { | ||
global $CFG; | ||
require_once($CFG->dirroot . "/mod/mumie/classes/grades/synchronization/context/user_context.php"); | ||
require_once($CFG->dirroot . '/mod/mumie/lib.php'); | ||
return new user_context(mumie_get_deadline_in_ms(locallib::get_effective_duedate($user->get_moodle_id(), $mumie))); | ||
} | ||
} |
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,57 @@ | ||
<?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 mod_mumie\synchronization\context; | ||
|
||
/** | ||
* This class represents a single MUMIE Tasks context required for some XAPI requests. | ||
* | ||
* @package mod_mumie | ||
* @copyright 2017-2023 integral-learning GmbH (https://www.integral-learning.de/) | ||
* @author Tobias Goltz ([email protected]) | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class object_context implements \JsonSerializable { | ||
/** | ||
* @var array | ||
*/ | ||
private array $usercontexts; | ||
|
||
/** | ||
* Create a new instance. | ||
*/ | ||
public function __construct() { | ||
$this->usercontexts = array(); | ||
} | ||
|
||
/** | ||
* Add a new context for a given user. | ||
* @param string $userid | ||
* @param user_context $usercontext | ||
* @return void | ||
*/ | ||
public function add_user_context(string $userid, user_context $usercontext): void { | ||
$this->usercontexts[$userid] = $usercontext; | ||
} | ||
|
||
/** | ||
* Custom JSON serializer. | ||
* @return array | ||
*/ | ||
public function jsonSerialize() { | ||
return $this->usercontexts; | ||
} | ||
} |
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,48 @@ | ||
<?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 mod_mumie\synchronization\context; | ||
|
||
/** | ||
* This class represents the context in which a user is working on a MUMIE Task. | ||
* | ||
* @package mod_mumie | ||
* @copyright 2017-2023 integral-learning GmbH (https://www.integral-learning.de/) | ||
* @author Tobias Goltz ([email protected]) | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class user_context implements \JsonSerializable { | ||
/** | ||
* @var int | ||
*/ | ||
private int $deadline; | ||
|
||
/** | ||
* Create new instance. | ||
* @param int $deadline | ||
*/ | ||
public function __construct(int $deadline) { | ||
$this->deadline = $deadline; | ||
} | ||
|
||
/** | ||
* Custom JSON serializer. | ||
* @return array|mixed | ||
*/ | ||
public function jsonSerialize() { | ||
return get_object_vars($this); | ||
} | ||
} |
Oops, something went wrong.