Skip to content
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

Release Version 1.0.7 #38

Merged
merged 15 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ jobs:
- php: '8.0'
moodle-branch: 'MOODLE_402_STABLE'
database: mariadb
- php: '8.0'
moodle-branch: 'MOODLE_403_STABLE'
database: pgsql
- php: '8.0'
moodle-branch: 'MOODLE_403_STABLE'
database: mariadb
- php: '8.1'
moodle-branch: 'MOODLE_401_STABLE'
database: pgsql
Expand All @@ -73,6 +79,12 @@ jobs:
- php: '8.1'
moodle-branch: 'MOODLE_402_STABLE'
database: mariadb
- php: '8.1'
moodle-branch: 'MOODLE_403_STABLE'
database: pgsql
- php: '8.1'
moodle-branch: 'MOODLE_403_STABLE'
database: mariadb

steps:
- name: Check out repository code
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 1.0.7 - 2023-11-10
### Changed
- Added more precision to the calculation of the position on the results.
### Added
- Added ci changes for Moodle 4.3.
- Added the number of received votes to the results table. If there is an option with less votes than the rest, the number of votes will be shown next to the position.
### Fixed
- Fix the margins in the results page and the voting options.
- Fix & character in the options.

## 1.0.6 - 2023-10-27
### Added
- Added an option to show the results of the voting to the students.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ to complete the installation from the command line.

## TODO - Roadmap

- [ ] Allow students to see results using a plugin setting
- [X] Allow students to see results using a plugin setting
- [ ] Detailed view of the results
- [ ] More tests (PHPUnit and Behat)
- [ ] Colors! Colors are always nice!
Expand Down
3 changes: 2 additions & 1 deletion classes/output/sort_voting_results.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public function __construct(\stdClass $sortvoting) {
*/
public function export_for_template(renderer_base $output): array {
$existingvotes = sortvoting_get_response_data($this->sortvoting);
$maxvotescount = (int) max(array_column($existingvotes, 'votescount'));

return ['votes' => $existingvotes];
return ['votes' => $existingvotes, 'maxvotescount' => $maxvotescount];
}
}
1 change: 1 addition & 0 deletions lang/en/sortvoting.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@
$string['sortvotingsettings'] = 'Voting name';
$string['voteerror'] = 'There was an error saving your vote.';
$string['votesuccess'] = 'Your vote has been saved successfully.';
$string['xvotesreceived'] = '{$a} vote(s) received';
7 changes: 5 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,9 @@ function sortvoting_get_response_data(stdClass $sortvoting, bool $onlyactive = t
$useridssql = "AND sa.userid $useridssql";

$sql = "SELECT so.id,
ROUND(AVG(sa.position), 2) AS avg,
so.text
AVG(sa.position) AS avg,
so.text,
COUNT(sa.id) AS votescount
FROM {sortvoting_answers} sa
JOIN {sortvoting_options} so
ON sa.optionid = so.id
Expand All @@ -385,11 +386,13 @@ function sortvoting_get_response_data(stdClass $sortvoting, bool $onlyactive = t

$position = 1;
$previousvote = null;
$maxvotescount = (int) max(array_column($existingvotes, 'votescount'));
foreach ($existingvotes as $key => $vote) {
if ($previousvote !== null && $previousvote->avg !== $vote->avg) {
$position++;
}
$existingvotes[$key]->position = $position;
$existingvotes[$key]->showvotescount = $maxvotescount !== (int) $vote->votescount;
$previousvote = $vote;
}

Expand Down
2 changes: 1 addition & 1 deletion mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function definition() {
}

$repeateloptions['option']['helpbutton'] = ['sortoptions', 'sortvoting'];
$mform->setType('option', PARAM_CLEANHTML);
$mform->setType('option', PARAM_TEXT);

$mform->setType('optionid', PARAM_INT);

Expand Down
2 changes: 1 addition & 1 deletion templates/sort_voting_form.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<div class="mb-3">{{#str}}instructions, mod_sortvoting{{/str}}</div>

{{! This list is drag and drop sortable. }}
<ul id="sortvotinglist" class="fa-ul">
<ul id="sortvotinglist" class="ml-0 fa-ul">
{{#options}}
<li class="d-flex card p-3 mb-2 {{^allowupdate}}bg-gray-100{{/allowupdate}} {{#allowupdate}}optionitem draggable{{/allowupdate}}" {{#allowupdate}}data-drag-type="move" draggable="true"{{/allowupdate}}>
<div>
Expand Down
45 changes: 37 additions & 8 deletions templates/sort_voting_results.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -21,46 +21,75 @@

Example context (json):
{
"maxvotescount": "5",
"votes": [
{
"id": "1",
"position": "1",
"text": "A"
"text": "A",
"showvotescount": false,
"votescount": "5"
},
{
"id": "2",
"position": "2",
"text": "B"
"text": "B",
"showvotescount": false,
"votescount": "5"
},
{
"id": "3",
"position": "2",
"text": "C"
"text": "C",
"showvotescount": false,
"votescount": "5"
},
{
"id": "4",
"position": "3",
"text": "D"
"text": "D",
"showvotescount": true,
"votescount": "4"
},
{
"id": "5",
"position": "4",
"text": "E"
"text": "E",
"showvotescount": false,
"votescount": "5"
}
]
}
}}
<table class="m-3 table table-bordered">
<table class="table table-bordered">
<thead>
<tr>
<th class="w-25">{{#str}} position, mod_sortvoting {{/str}}</th>
<th class="w-25">
<div
data-toggle="tooltip"
data-placement="left"
class="text-info"
title="{{#str}} xvotesreceived, mod_sortvoting, {{maxvotescount}} {{/str}}"
>
{{#str}} position, mod_sortvoting {{/str}}
</div>
</th>
<th class="w-75">{{#str}} option, mod_sortvoting {{/str}}</th>
</tr>
</thead>
<tbody>
{{#votes}}
<tr>
<td>{{position}}</td>
<td>
<div {{#showvotescount}}
data-toggle="tooltip"
data-placement="left"
class="text-info"
title="{{#str}} xvotesreceived, mod_sortvoting, {{votescount}} {{/str}}"
{{/showvotescount}} >
{{position}}
</div>
</td>
<td>{{text}}</td>
</tr>
{{/votes}}
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'mod_sortvoting';
$plugin->release = '1.0.6';
$plugin->version = 2023102700;
$plugin->release = '1.0.7';
$plugin->version = 2023111000;
$plugin->requires = 2022041908;
$plugin->maturity = MATURITY_STABLE;
$plugin->dependencies = [];
Loading