Skip to content

Commit

Permalink
Merge pull request #61 from integral-learning/dev
Browse files Browse the repository at this point in the history
Release v1.6.0
  • Loading branch information
fsacha authored Oct 25, 2023
2 parents 5f6d169 + b7bba98 commit a47faee
Show file tree
Hide file tree
Showing 18 changed files with 786 additions and 194 deletions.
9 changes: 9 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# MumieTask - Changelog

All important changes to this plugin will be documented in this file.
## [v1.6.0] - 2023-10-23
### Added
- Teachers can incorporate worksheets with a deadline
- The opening of a mummy activity is logged
- Added button to open multi problem selector to mod_form

### Changed
- On grade overview page: Moved button to open MUMIE Task above participant list to improve UX

## [v1.5.0] - 2023-05-09
### Added
- Teachers can now select worksheets in the problem selector. Worksheets are a collection of problems with a custom correction workflow
Expand Down
39 changes: 39 additions & 0 deletions classes/event/course_module_viewed.php
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 (filip.sacha@integral-learning.de)
* @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';
}
}
57 changes: 57 additions & 0 deletions classes/grades/synchronization/context/context.php
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 (tobias.goltz@integral-learning.de)
* @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 classes/grades/synchronization/context/context_provider.php
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 (tobias.goltz@integral-learning.de)
* @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)));
}
}
57 changes: 57 additions & 0 deletions classes/grades/synchronization/context/object_context.php
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 (tobias.goltz@integral-learning.de)
* @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;
}
}
48 changes: 48 additions & 0 deletions classes/grades/synchronization/context/user_context.php
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 (tobias.goltz@integral-learning.de)
* @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);
}
}
Loading

0 comments on commit a47faee

Please sign in to comment.