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

Tests for Group Division #677

Open
wants to merge 33 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1328139
added php unit
TLE931 Aug 8, 2024
04f4dc5
Add empty test classes
jpih Aug 8, 2024
1952503
Update README.md
jpih Aug 8, 2024
e0e4a97
tests for balanced group division
TLE931 Aug 9, 2024
b068cbb
Merge remote-tracking branch 'refs/remotes/origin/feat/dev-division-t…
TLE931 Aug 9, 2024
74535f1
Add SlotAssignment and GroupCourseDivision test cases
jpih Aug 11, 2024
0b6199a
comments and camelCase
TLE931 Aug 11, 2024
72fc39b
prettier Formattierung
TLE931 Aug 11, 2024
ecb235d
Fix variable naming
jpih Aug 12, 2024
b49ae05
Merge branch 'feat/dev-division-tests' of https://github.com/fsr5-fha…
jpih Aug 12, 2024
8fba88a
Fix 'classes' value in CourseFactory
jpih Aug 12, 2024
d7a789b
- fixed camel case
TLE931 Aug 13, 2024
ec0e364
Add empty test classes
jpih Aug 8, 2024
4119b74
Update README.md
jpih Aug 8, 2024
50d5978
Add SlotAssignment and GroupCourseDivision test cases
jpih Aug 11, 2024
3a47b14
Fix variable naming
jpih Aug 12, 2024
c9ace1c
comments and camelCase
TLE931 Aug 11, 2024
7e994a5
prettier Formattierung
TLE931 Aug 11, 2024
87fd443
Fix 'classes' value in CourseFactory
jpih Aug 12, 2024
0a59329
- fixed camel case
TLE931 Aug 13, 2024
4872bcb
Merge remote-tracking branch 'refs/remotes/origin/feat/dev-division-t…
TLE931 Aug 27, 2024
0b6cab0
Merge remote-tracking branch 'origin/feat/dev-division-tests' into fe…
TLE931 Aug 27, 2024
7b11e0a
new tests written in Pest, add testing to CI
TLE931 Aug 27, 2024
dd90905
Merge branch 'dev' into feat/dev-group-division-tests
TLE931 Aug 30, 2024
9edc286
- lower lenience for average course balance with non drinkers
TLE931 Aug 30, 2024
781c90f
Update README.md testing
TLE931 Aug 30, 2024
0fe2c29
Merge branch 'dev' into feat/dev-group-division-tests
TLE931 Sep 9, 2024
f775a9c
compose update
TLE931 Sep 9, 2024
9334ed2
Merge branch 'dev' into feat/dev-group-division-tests
simonostendorf Sep 10, 2024
b3558c4
feat: remove course_id and use new CourseGroup pivot table
simonostendorf Sep 10, 2024
8426efd
- upgrade to pest 3.0
TLE931 Sep 13, 2024
bdaa998
rewrote course check
TLE931 Sep 13, 2024
afb9a9c
corrected finding the courseId for a group
TLE931 Sep 13, 2024
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
8 changes: 3 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ jobs:
DB_DATABASE: database/database.sqlite
run: |
php artisan db:seed
# - name: Execute tests (Unit and Feature tests) via PHPUnit
# env:
# DB_CONNECTION: sqlite
# DB_DATABASE: database/database.sqlite
# run: vendor/bin/phpunit
- name: Execute tests (Unit and Feature tests) via Pest
TLE931 marked this conversation as resolved.
Show resolved Hide resolved
run: |
./vendor/bin/pest
simonostendorf marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,6 @@ dist
# Generated files
.phpunit.cache

# PHPUnit
/app/phpunit.xml
/phpunit.xml

# Build data
/build/

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ npm run lint:fix
You can run the tests with:

```sh
vendor/bin/phpunit
php artisan test
```

### build
Expand Down
51 changes: 27 additions & 24 deletions app/Helpers/GroupBalancedDivision.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,35 +112,38 @@ protected function assignNonDrinkers()
{
$nonDrinkerRegs = $this->registrations->where('drinks_alcohol', '=', false);

$nonDrinkerFillRates = $this->calcFillRate($nonDrinkerRegs);
// check if there are any non drinkers
if ($nonDrinkerRegs->count() > 0) {
$nonDrinkerFillRates = $this->calcFillRate($nonDrinkerRegs);

// If you can satisfy minNonDrinkers requirement with a balanced fill, do it first
if (array_sum($nonDrinkerFillRates[min(array_keys($nonDrinkerFillRates))]) > $this->minNonDrinkers) {
$this->assignBalanced($nonDrinkerRegs, $nonDrinkerRegs);
}

// Assign yet unassigned non-drinkers
$nonDrinkerRegs = $nonDrinkerRegs->where('group_id', '=', null)
->shuffle();
// If you can satisfy minNonDrinkers requirement with a balanced fill, do it first
if (array_sum($nonDrinkerFillRates[min(array_keys($nonDrinkerFillRates))]) > $this->minNonDrinkers) {
$this->assignBalanced($nonDrinkerRegs, $nonDrinkerRegs);
}

// If chunking by minNonDrinkers would give more chunks than groups, increase chunk size by 1 until it fits
$nonDrinkersPerGroup = $this->minNonDrinkers;
while (($nonDrinkerRegs->count() / $nonDrinkersPerGroup) > $this->groups->count()) {
$nonDrinkersPerGroup++;
}
$chunks = $nonDrinkerRegs->chunk($nonDrinkersPerGroup);
// Assign yet unassigned non-drinkers
$nonDrinkerRegs = $nonDrinkerRegs->where('group_id', '=', null)
->shuffle();

// Assign each chunk to a group
foreach ($this->groups as $group) {
if ($chunks->count() == 0) {
return;
// If chunking by minNonDrinkers would give more chunks than groups, increase chunk size by 1 until it fits
$nonDrinkersPerGroup = $this->minNonDrinkers;
while (($nonDrinkerRegs->count() / $nonDrinkersPerGroup) > $this->groups->count()) {
$nonDrinkersPerGroup++;
}
$chunk = $chunks->pop();
$chunks = $nonDrinkerRegs->chunk($nonDrinkersPerGroup);

foreach ($chunk as $registration) {
$registration->group_id = $group->id;
$registration->queue_position = null;
$registration->save();
// Assign each chunk to a group
foreach ($this->groups as $group) {
if ($chunks->count() == 0) {
return;
}
$chunk = $chunks->pop();

foreach ($chunk as $registration) {
$registration->group_id = $group->id;
$registration->queue_position = null;
$registration->save();
}
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"laravel/sail": "^1.26",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.0",
"phpunit/phpunit": "^11.0.1",
"pestphp/pest": "^3.0",
"scrumble-nl/laravel-model-ts-type": "^10.4"
},
"autoload": {
Expand Down Expand Up @@ -62,7 +62,10 @@
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
Expand Down
Loading
Loading