Git Product home page Git Product logo

odeialba / moodle-mod_sortvoting Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 211 KB

This plugin allows sorting a list of options by preference of the user, instead of just selecting one.

Home Page: https://moodle.org/plugins/mod_sortvoting

License: GNU General Public License v3.0

PHP 84.13% Mustache 7.04% JavaScript 8.47% CSS 0.35%
moodle moodle-activity moodle-plugin preferential-voting vote-application vote-system ranked-voting voting php preference

moodle-mod_sortvoting's Introduction

Preference Voting Build Status

This plugin lets you rank multiple options in order of preference, instead of just choosing one.

This way, the most preferred option by all the voters can win, even if it is not the most popular one.

This voting method is also known as Condorcet method.

Examples:

Setup:

  • Available options A, B, C, D
  • People voting 5

Traditional voting:

Votes:

  • User1 = A
  • User2 = A
  • User3 = B
  • User4 = C
  • User5 = D

Results in traditional voting:

  • A = 2
  • B = 1
  • C = 1
  • D = 1

Explanation:

A gets 2 votes from user1 and user2 and all the other options get one vote each. Users 3, 4 and 5 might prefer to have the option B before having the option A, but since the majority voted for A, A will be the winner.

Voting with the plugin:

Votes:

  • User1:
    • A
    • B
    • C
    • D
  • User2:
    • A
    • B
    • D
    • C
  • User3:
    • B
    • D
    • C
    • A
  • User4:
    • C
    • B
    • D
    • A
  • User5:
    • D
    • B
    • C
    • A

Results voting with the plugin:

  • B
  • D
  • C
  • A

Explanation:

If we calculate the average position of the options in the votes the winner would be B.

Installing via uploaded ZIP file

  1. Log in to your Moodle site as an admin and go to Site administration > Plugins > Install plugins.
  2. Upload the ZIP file with the plugin code. You should only be prompted to add extra details if your plugin type is not automatically detected.
  3. Check the plugin validation report and finish the installation.

Installing manually

The plugin can be also installed by putting the contents of this directory to

{your/moodle/dirroot}/mod/sortvoting

Afterwards, log in to your Moodle site as an admin and go to Site administration > Notifications to complete the installation.

Alternatively, you can run

$ php admin/cli/upgrade.php

to complete the installation from the command line.

TODO - Roadmap

  • Allow students to see results using a plugin setting
  • Detailed view of the results
  • More tests (PHPUnit and Behat)
  • Colors! Colors are always nice!

License

2023 Odei Alba [email protected]

This program 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.

This program 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 this program. If not, see https://www.gnu.org/licenses/.

moodle-mod_sortvoting's People

Contributors

odeialba avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

agusaar

moodle-mod_sortvoting's Issues

Fix & character

If an option contains & character, & is shown. It should show exactly as it is written in the options.

Code error in Moodle activities block

Preferencevotingcodingerrordebuggingresults
Preferencevotingcodngbug
preferencvotingcodingbugerrormessage

I have added a preference voting system to a moodle course and it works fine. When I use the link to preference voting in the activities block, I get the error documented. Can you please help? We use the activities block for short-cuts to particular types of activities.
Have also added screenshot of debugging messages for developer. Hope this helps.
Norbert

Remove ROUND on results query

ROUND on the results query makes the results be less precise. It was there because the average position was shown on the results on the first version. Now that the position is calculated after the query, ROUND only makes the results not to be precise.

Add an option to make votes anonymous

Add a setting to make voting anonymous (this will make sense after #22 is done).
Once the user voted when the voting was anonymous, keep it anonymous even if the status changes later.

Improve the reports

At the moment the reports are showing only the general results of the voting. It would be nice to have more detailed report showing what positions each option received, each voting of each user, etc.

Show number of votes on the results

Show how many votes the activity received somewhere in the results tab.

If there is an option that received a different amount of votes, show the number of votes next to the option (maybe a new column). That can happen because of this known bug: #16

The results only show the first group on the app

If the activity is set for students to be able to see the results, on the browser the student can change the group, but in the app the student can only see the first group that he belongs to (or maybe from a group that they don't even belong).

Change behaviour so once the student has voted, they are taken automatically to the results screen

At the moment the students have to click on the 'responses' option within the menu bar at top to see the responses, this isn't obvious and especially on a small screen where this items disappears into the hamburger icon - is easily missed. Could it be changed so that if the item is set to allow students to see the results, when they save their response it automatically takes them to the results page (this is what the choice activity does).

Add standard instructions

Add in some standard instructions e.g. "Change the options below into the desired order, so your first choice is at the top....."

Add ci for Moodle 4.3

Make sure the plugin works with Moodle 4.3, add the version in supported versions and add the version to the ci file.

missing privacy api

/
Moodle uses a privacy API for GDPR compliance to allow plugins to specify how they deal with user data. Your plugin stores user data in a number of tables which will need to be included in the privaci api classes.

Sites that use continuous integration processes will not be able to use your plugin because Moodle runs unit tests which check to see if all extra plugins include the privacy class.

More information on the privacy class is here:
https://docs.moodle.org/dev/Privacy_API

Students can see results before voting

There is an option that allows the students to see the results after they have submitted a vote. There is a bug that allows users to see the results before they have voted when this option is enabled.

Improve sending a new vote after adding a new option

Once the vote has been submitted and the user can't vote again, if a new option is added, the user will be able to vote again.

The problem is that if only one user votes, the new option will be placed in the wrong place, because the average position is where that user placed it (because only one user has voted for it).

There is no perfect solution, but here are some ideas:

  • Take in count only votes of users after the new option was added.
  • Mark with a different color the options that don't have all the votes.
  • Add two tables: One with only old options and one with new options (adding only votes containing the new option).
  • Add a counter of votes next to each option.
  • ...

Show the number of votes on the results page.

On the results page, could you identify how many people have voted - if the student is the first person to vote, then the response will match their answer, but they won't know if that is because they are the only contributor or if there are lots of contributors and the collective have agreed with that individual.

I am aware that hovering over the table heading shows this - but this isn't obvious, and would be clearer if displayed somehow without the need to hover.

consider adding github actions support - it's free and very useful.

Some of the tests run by the Moodle.org plugins db can be run via github actions on each commit in your github repo. Enabling this helps you to make sure future changes to your plugin will continue to follow the guidelines.

the short version - grab this file:
https://github.com/moodlehq/moodle-plugin-ci/blob/master/gha.dist.yml
rename it as ci.yml and put into the directory .github/workflows within tyour project eg:
https://github.com/danmarsden/moodle-mod_attendance/blob/MOODLE_311_STABLE/.github/workflows/ci.yml

then on every commit you make to github it will fire off a request to run the tests and will give you traffic lights beside each commit and generate a report.

Inform user if they already voted

After voting, I still see "Change the options below into the desired order, so your preferred choice is at the top and your least favourite choice is at the bottom." on the main tab

I can't edit the options though, so maybe we could improve this text?

Error when user has no group and 'Allow students to see the results' is enabled

I could not replicate it, but this bug was reported:
This error happens only in the app. If you have a user without any group and you have the option 'Allow students to see the results' enabled, when the user submits a vote, there is an error saying: Coding error detected, it must be fixed by a programmer: moodle_database::get_in_or_equal() does not accept empty arrays
The error might come from trying to show the results from a group that doesn't exist.
If the user is in a group or if the options 'Allow students to see the results' is disabled, there is no error.

Make the cards stand out more from the background

Is it worth making the draggable cards slightly more distinct - I have done this by adding some CSS to give the cards a thin grey border, but not everyone will have the ability or know-how to do this.

This was the CSS that I personally added to my site:

/Adds a border around the cards in the preference sorting activity/
li.d-flex.card.p-3.mb-2.optionitem.draggable {
border-style: solid;
border-color: #c0c0c0;
border-width: thin;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.