-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/completiontracking #299
Merged
Merged
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
5e78c2b
WIP: added custom completion rules
irinahpe a377ad3
added language strings and fixed some syntax errors
irinahpe 9448309
some codestyle fixes and added behat tests for custom completion rules
irinahpe 42d8715
modified behat backgrounds according to ratingallocate settings form
irinahpe c4e6082
modified behat and phpunit tests
irinahpe f3916c0
fixed behat test for completionallocation
irinahpe 73d16ab
fixed change of completion status for manual allocation and allocatio…
irinahpe 4176b98
changed behat test for completionallocation
irinahpe 2ec5972
WIP: added custom completion rules
irinahpe e2520d3
added language strings and fixed some syntax errors
irinahpe 59c3d9f
modified behat backgrounds according to ratingallocate settings form
irinahpe 71974f6
modified behat and phpunit tests
irinahpe 84bfd46
fixed behat test for completionallocation
irinahpe e8d8df0
fixed change of completion status for manual allocation and allocatio…
irinahpe 169a3bb
changed behat test for completionallocation
irinahpe 960b3db
modify behat tests for new ratingallocate navigation, check completio…
irinahpe e151376
fix changing completionsettings after users already completing the ac…
irinahpe e3f26be
codestyle fixes
irinahpe 089deaf
codestyle fixes
irinahpe 5862ec0
fix suffix for custom completion fields, fix behat test for completio…
irinahpe a5de155
run completion scheduled task in behat test for custom completion
irinahpe 868b464
edit ratingtime for behat test to run algorithm
irinahpe 1b6008a
change radiobutton name in behattest
irinahpe e1430a2
change fieldnames for ratingtime in behattest
irinahpe 8a1cea8
rollback for merging codestyle fixes
irinahpe 48e2bf4
codestyle fixes
irinahpe 0dc8906
codestyle fixes
irinahpe f14fc2b
replace get_suffix()
irinahpe 5df8598
delete use of _ratingallocate as suffix
irinahpe e532301
codestyle fix
irinahpe 289fb89
fix computation of completionstatus for user
irinahpe e2db7f3
change required moodle version
irinahpe 0f04901
Use latest version of moodle-plugin-ci to fix Node.js bug
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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/>. | ||
|
||
declare(strict_types=1); | ||
|
||
namespace mod_ratingallocate\completion; | ||
|
||
use context_module; | ||
use core_completion\activity_custom_completion; | ||
|
||
/** | ||
* Activity custom completion subclass for the ratingallocate activity. | ||
* | ||
* Class for defining the custom completion rules of ratingallocate and fetching the completion statuses | ||
* of the custom completion rules for a given ratingallocate instance and a user. | ||
* | ||
* @package mod_ratingallocate | ||
* @copyright Irina Hoppe Uni Münster | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class custom_completion extends activity_custom_completion { | ||
|
||
/** | ||
* Fetches the completion state for a given completion rule. | ||
* | ||
* @param string $rule The completion rule. | ||
* @return int The completion state. | ||
* @throws \moodle_exception | ||
*/ | ||
public function get_state(string $rule): int { | ||
global $DB; | ||
$status = false; | ||
$this->validate_rule($rule); | ||
|
||
$userid = $this->userid; | ||
$course = $this->cm->get_course(); | ||
$instance = $this->cm->instance; | ||
|
||
if (!$ratingallocaterecord = $DB->get_record('ratingallocate', ['id' => $instance])) { | ||
throw new \moodle_exception('Unable to find ratingallocate instance with id ' . $instance); | ||
} | ||
|
||
$modinfo = get_fast_modinfo($course, $userid)->instances['ratingallocate'][$instance]; | ||
$context = context_module::instance($modinfo->id); | ||
|
||
$ratingallocate = new \ratingallocate($ratingallocaterecord, $course, $this->cm, $context); | ||
|
||
if ($rule == 'completionvote') { | ||
$status = count($ratingallocate->get_rating_data_for_user($userid)) > 0; | ||
} else if ($rule == 'completionallocation') { | ||
$status = count($ratingallocate->get_allocations_for_user($userid)) > 0; | ||
} | ||
|
||
return $status ? COMPLETION_COMPLETE : COMPLETION_INCOMPLETE; | ||
} | ||
|
||
/** | ||
* Fetch the list of custom completion rules that this module defines. | ||
* | ||
* @return array | ||
*/ | ||
public static function get_defined_custom_rules(): array { | ||
return [ | ||
'completionvote', | ||
'completionallocation', | ||
]; | ||
} | ||
|
||
/** | ||
* Returns an associative array of the descriptions of custom completion rules. | ||
* | ||
* @return array | ||
*/ | ||
public function get_custom_rule_descriptions(): array { | ||
return [ | ||
'completionvote' => get_string('completionvote_desc', RATINGALLOCATE_MOD_NAME), | ||
'completionallocation' => get_string('completionallocation_desc', RATINGALLOCATE_MOD_NAME), | ||
]; | ||
} | ||
|
||
/** | ||
* Returns an array of all completion rules, in the order they should be displayed to users. | ||
* | ||
* @return array | ||
*/ | ||
public function get_sort_order(): array { | ||
return [ | ||
'completionview', | ||
'completionvote', | ||
'completionallocation', | ||
]; | ||
} | ||
} | ||
|
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
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one of these duplicates can be removed.