## Activities: Fair Allocation

mod_ratingallocate
Maintained by Learnweb – University of Münster, Tobias Reischmann, Ulm University
This Module lets you add an activity to courses, in which users can rate choices. You may then distribute the users fairly to the choices by maximising overall 'hapiness' in terms of ratings. This may be an alternative to the choice activity or first-come-first-served.
126 sites
24 fans

In the area of schools or universities, there are often allocation problems, where a group of pupils or students needs to be assigned to a bunch of resources. These resources may be study groups, thesis topics, or seminar slots.
Therefore often techniques as first come first serve are used, which is not seldom perceived as unfair by the students.

To reach a high acceptance for the distribution technique is module offers the students the possibility to rate the possible choices according to their preferences. For this purpose the module supports multiple different rating strategies (e.g. Yes-No, Order, Points, Lickert-scale).
After a predefined time period for the users to hand in their preferences, the distribution can be started. Here, an algorithm solves the distribution problem by maximizing the overall satisfaction.

• Choices have maximum sizes
• After the automated distribution, the allocations can be changed manually (including students with no rating)
• The students can be notifyed about their allocation via e-mail

We appreciate your commendation and reviews for this plugin in the comments. For bug reports and support requests create a ticket in the bug tracker which is linked below.

### Contributors

Learnweb – University of Münster (Lead maintainer)
Tobias Reischmann: Maintainer
Max Schulze: Initial committer
Alexander Bias: Feature contributor
Claus A. Us: Former Maintainer

### Awards

• Mon, 15 Aug 2016, 2:17 PM
Hi,
Many thanks for your contributions and I really like the design of this plugin, it is much more user friendly.
Our University plan to use this plugin for the optional class selection. But there's 2 issues I've encountered.
1. The exported allocation report does not contain the student ID. There is a column "ID", but it is not the student ID which can identify student with same name.
2. In the exported csv file, Chinese characters cannot display correctly.

Since the new semester will come soon and we plan to provide the optional class selection function to students at the end of this August. Would you please help with the 2 issues above?

Best wishes,
Lina
• Tue, 16 Aug 2016, 12:13 AM
Hello Lina,
To 1: The column "userid" in the report does belong to the students internal moodle userid. You can use it, for instance, to browse the profile of the user (http://your.moodle/user/profile.php?id=THEUSERID). The other field which could help you to identify students with the same name is the username. Since to my knowledge moodle does not allow to create the same username two times, this should be a unique identifier.
There are no plans at the moment to extend the report to custom user fields. I think you use one to store the student id assigned by the university. But if you would like to have a functionallity like that please put an issue in the github repository (Like above, see "Bug tracker"). Of course you are welcome to contribute extensions like that yourself.
To 2: This is no problem of the plugin but of the combination with the program you use to open the file. The report is encoded using UTF-8, which is quite common. If you use a program, which is capable of displaying UTF-8 encoding, you should be able to view Chinese characters, as well. For Microsoft Excel this should help: http://stackoverflow.com/questions/6002256/is-it-possible-to-force-excel-recognize-utf-8-csv-files-automatically#answer-6488070

I hope this helps you.
Best wishes,
Tobias
• Tue, 16 Aug 2016, 10:27 AM
Hi Tobias,
Many thanks for your kind help. That's really helpful. I've changed the code in ratingallocate/renderer.php and added the idnumber field into the export function and it works. We can now export the student ID information.
$ratingscells[$user->id][3] = $user->idnumber; Thanks again for the UTF8 issue, I've tried the data import function in Microsoft Excel, I changed the file origin to UTF-8, Chinese GB, simplified Chinese (Mac), simplified Chinese(Windows), I tried all the possible options but still cannot get the correct Chinese character. We will ask teachers to use English only as a temp solution. Thanks for you help. We really appreciate it. Best wishes, Lina • Tue, 16 Aug 2016, 3:17 PM Hi Lina, I checked the encoding issue again. For me it is working with 65001 : Unicode (UTF-8). However this might be dependend on the platform your server runs on or its configuration. Indeed the plugin itself does not define the encoding for the file. You can find the encoding of your server using YOURMOODLEINSTANCE/admin/phpinfo.php. There the encoding is displayed at Content-Type -> charset and at default_charset. I hope that information is helpful. Best wishes, Tobias • Thu, 18 Aug 2016, 11:33 AM Hi Tobias, Thanks for your prompt reply. I really appreciate it. I've installed the new release and it is good that we can export the email information now. I like the other features in the new release. Many thanks for your great contributions. About the encoding issue, I've checked the phpinfo.php on our server and it shows the following information: Content-Type text/html; charset=utf-8 The charset is utf-8, but didn't show if it is unicode or not. I'm reading this article:https://www.toptal.com/php/a-utf-8-primer-for-php-and-mysql From that article that I need to many changes to my moodle instance, I will investigate more about this. Many thanks for your help. Best wishes, Lina • Mon, 28 Nov 2016, 7:41 PM Hi Tobias, I have a request from a costumer. He's interested in the details of the algorithms used. I didn't found any additional information. Could you add some links or information to the documentation? Best wishes, Thomas • Tue, 13 Dec 2016, 3:18 PM Hi Tobias, Thanks a lot for this wonderful plugin. We've used this plugin to support the optional course allocation for all the students in our University. We love this plugin. Students have provided many feedbacks. One of the most important feedback is about the allocation result. Could you please help to check this feedback and to see if you could help with the function which we really need? Here's the detail information: We've selected "Rank Choices" as the rating strategy. Take the monday's optional courses for example. There will be 10 optional courses for 1000 students to choose. Each students can rank the 10 options from 1 to 10. But since this is optional courses, many students only want to attend their favorite courses. They want to have a function which they can select the courses that they don't want to attend. So that system won't allocate them into these courses. Would you please help to see if we can have this function? Many thanks. Best wishes, Lina • Thu, 15 Dec 2016, 10:22 PM Hey Thomas, you can find this information here: https://github.com/learnweb/moodle-mod_ratingallocate#algorithm Best wishes, Tobias • Tue, 10 Jan 2017, 5:05 AM Hi Tobias, is there a reason that 3.2-r1 (which does not add more than a language string according to https://github.com/learnweb/moodle-mod_ratingallocate/commits/master) is published but set to "unavailable" here? Thanks, Alex • Wed, 11 Jan 2017, 2:50 AM Hey Alex, the version 3.2-r1 does add one important aspect, which is the support of moodle 3.2. When I created this patch, I already read through all change logs for the new version and all should still work as before. However, there were changes in the behat framework and therefore the automatic tests fail currently. Until now I was not able to identify or fix this issue, which is why I do not want to publish a version with 3.2 support, yet. Behind the failures of the tests due to the changes in the behat framework other more severe failures could be hiding. Although, I don't think so, I set the version for now to unavailable. I will publish the next version as soon as possible (probably end of February). Best wishes, Tobias • Mon, 18 Sep 2017, 10:20 PM Hi All, This is my fisrt use of Fair Allocation. I have this server environment : Moodle 3.3.2 (Build: 20170911) PhP : 7.1;8 MariaDb : 5.5.52 The allocation are already published but when I chosse to creat groups from Allocation I have this error message : """""""""""""""""""""""""""""""""" Error writing to database More information about this error Debug info: Field 'description' doesn't have a default value INSERT INTO mdl_groups (courseid,name,idnumber,timecreated,timemodified) VALUES(?,?,?,?,?) [array ( 0 => '5980', 1 => '01. Des œufs au pesticide (Ph Bou et JM Fra)', 2 => 'ratingallocate_c_6', 3 => 1505741865, 4 => 1505741865, )] Error code: dmlwriteexception Stack trace: line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown line 1274 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end() line 1320 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw() line 251 of /group/lib.php: call to mysqli_native_moodle_database->insert_record() line 627 of /mod/ratingallocate/locallib.php: call to groups_create_group() line 756 of /mod/ratingallocate/locallib.php: call to ratingallocate->process_action_allocation_to_grouping() line 61 of /mod/ratingallocate/view.php: call to ratingallocate->handle_view() """""""""""""""""""""""""""""""""""" Could you help me to fix this problem? Thank you! Gabriel • Mon, 18 Sep 2017, 10:43 PM Hi Gabriel, it seems that for some reason your database does not allow to create entries within mdl_groups table without a description value defined. The install.xml of moodle within lib/db/install.xml states that the description field is allowed to be null. Additionally, there are multiple other locations in moodle code, where a group without a description is created. If you want a hotfix for your problem, you can add this line to your code: diff --git a/locallib.php b/locallib.php index 0323c21..cdbbf94 100644 --- a/locallib.php +++ b/locallib.php @@ -624,6 +624,7 @@ class ratingallocate {$data->courseid = $this->course->id;$data->name = $choices[$choice['key']]->title;
$data->idnumber =$groupid;
+ $data->description = '';$createdid = groups_create_group($data); groups_assign_grouping($groupingid, $createdid);$choiceids[$groupid]['groupid'] =$createdid;

However, I do not consider this as a problem of this plugin.
Grettings
Tobias
• Mon, 18 Sep 2017, 11:10 PM
Thank you very much. The proposed code works perfectly.
• Thu, 26 Oct 2017, 2:58 PM
Did someone try this with a lot of (280) Students?
I think about using this to allocate Students in a project week.
280 Students