diff --git a/classes/output/mobile.php b/classes/output/mobile.php index 599b3b1..9a9e846 100644 --- a/classes/output/mobile.php +++ b/classes/output/mobile.php @@ -15,6 +15,7 @@ // along with Moodle. If not, see . namespace mod_sortvoting\output; +use context_module; defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot . '/mod/sortvoting/lib.php'); @@ -89,8 +90,10 @@ public static function mobile_sort_voting_view($args): array { return $a['position'] <=> $b['position']; }); + $canseeresults = \mod_sortvoting\permission::can_see_results($sortvoting, context_module::instance($cm->id)); + // Result of existing votes. - $existingvotes = sortvoting_get_response_data($sortvoting); + $existingvotes = $canseeresults ? sortvoting_get_response_data($sortvoting) : []; $maxvotescount = empty($existingvotes) ? 0 : (int) max(array_column($existingvotes, 'votescount')); $data = [ @@ -98,6 +101,7 @@ public static function mobile_sort_voting_view($args): array { 'allowupdate' => $allowupdate, 'options' => $optionsclean, 'max' => count($options), + 'canseeresults' => $canseeresults, 'votes' => $existingvotes, 'maxvotescount' => $maxvotescount, ]; diff --git a/mobile/js/mobile_sortvoting.js b/mobile/js/mobile_sortvoting.js index 7de4771..4bfc68c 100644 --- a/mobile/js/mobile_sortvoting.js +++ b/mobile/js/mobile_sortvoting.js @@ -20,8 +20,6 @@ * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ this.submitResponses = () => { - // TODO: Check if all elements of the positions array are unique. - // TODO: Add allowupdate option. let promise; promise = Promise.resolve(); promise.then(() => { @@ -43,7 +41,7 @@ this.submitResponses = () => { return this.sortVotingProvider.submitResponses(this.module.instance, votes).then(() => { // Responses have been sent to server or stored to be sent later. - this.CoreDomUtilsProvider.showToast(this.TranslateService.instant('plugin.mod_sortVoting.votesuccess')); + this.CoreDomUtilsProvider.showToast(this.TranslateService.instant('plugin.mod_sortvoting.votesuccess')); // Check completion since it could be configured to complete once the user submits a vote. this.CoreCourseProvider.checkModuleCompletion(this.courseId, this.module.completiondata); diff --git a/templates/mobile_sort_voting_view.mustache b/templates/mobile_sort_voting_view.mustache index 7ef0d60..6ec353b 100644 --- a/templates/mobile_sort_voting_view.mustache +++ b/templates/mobile_sort_voting_view.mustache @@ -17,7 +17,7 @@ {{! @template mod_sortvoting/mobile_sort_voting_view - TODO describe template mobile_sort_voting_view + Template for showing list of options to sort and the results of the votes on the mobile app. Example context (json): { @@ -29,13 +29,17 @@ <%sortvoting.intro%> -

{{ 'plugin.mod_sortvoting.instructions' | translate }}

+ <%#allowupdate%> +

{{ 'plugin.mod_sortvoting.instructions' | translate }}

+ <%/allowupdate%> <%#options%>
- + <%#allowupdate%> + + <%/allowupdate%> <% text %>
@@ -49,34 +53,32 @@ <%/allowupdate%>
-TODO: Check if user has permission to view results. - - - - - - - - - + + {{ 'plugin.mod_sortvoting.option' | translate }} + <%#votes%> - - - - + + <%text%> + <%/votes%> - -
+ + <%#canseeresults%> + + + +
- {{ 'mod_sortvoting.position' | translate }} + {{ 'plugin.mod_sortvoting.position' | translate }}
-
{{ 'mod_sortvoting.option' | translate }}
+ + <%#showvotescount%>
<%/showvotescount%> <%^showvotescount%> @@ -84,11 +86,20 @@ TODO: Check if user has permission to view results. <%/showvotescount%> <%position%>
-
<%text%>
-
- \ No newline at end of file + + + <%/canseeresults%> + + diff --git a/templates/sort_voting_results.mustache b/templates/sort_voting_results.mustache index cba73c7..93709ec 100644 --- a/templates/sort_voting_results.mustache +++ b/templates/sort_voting_results.mustache @@ -17,7 +17,7 @@ {{! @template mod_sortvoting/sort_voting_results - Template for showing list of options to sort. + Template for showing the results of the votes. Example context (json): {