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

Add more grading systems #1441

Merged
merged 100 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 88 commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
367a9b5
Add and implement test: 'Basic grades test for 1 - 6 points with deci…
Jonas-Sander Mar 29, 2024
3266b32
Add and implement: '1 - 6 / (0.75 - 6) grading system returns correct…
Jonas-Sander Mar 29, 2024
70b2c74
Add devenv
Apr 2, 2024
1272652
Remove non-working script
Apr 2, 2024
ee272d5
add chrome
Apr 2, 2024
434446b
Install fvm if not installed.
Apr 2, 2024
9cc7b4d
refac packages
Apr 2, 2024
4c79dce
add license headers
Apr 2, 2024
ad5868d
add docs
Apr 2, 2024
9538ebb
run disable analytics cmds in parallel
Apr 2, 2024
94d42e2
Remove unused stuff
Apr 2, 2024
15906d2
docs
Apr 2, 2024
cb8661b
Move fvm commands to after fvm installation
Apr 2, 2024
8fb3070
Add doc comment.
Apr 3, 2024
1e0ff85
Add comment
Apr 3, 2024
2f92c0c
Merge branch 'main' into nix-dependencies
Jonas-Sander Apr 3, 2024
7728ce5
Merge remote-tracking branch 'origin/main' into other-grading-systems
Apr 3, 2024
69cbe7c
Merge remote-tracking branch 'origin/nix-dependencies' into other-gra…
Apr 3, 2024
b2629f3
First working UI version
Apr 3, 2024
20ec4b3
.
Apr 3, 2024
6a5938b
add comment
Apr 3, 2024
9a4f4b5
Merge remote-tracking branch 'origin/main' into other-grading-systems
Apr 3, 2024
e94bd10
Add and implement test: "1 - 6 grading system parses input grades cor…
Jonas-Sander Apr 4, 2024
bca4c7f
'1 - 6 grading system numbers that are too high/too low with throw an…
Jonas-Sander Apr 4, 2024
f112f84
Add distinct grading systems test: testThatExceptionIsThrownIfGradeWi…
Jonas-Sander Apr 4, 2024
d62747b
Inline method
Jonas-Sander Apr 4, 2024
7679e41
Remove todo
Jonas-Sander Apr 4, 2024
5fb0111
Add ZeroToHundredPercentWithDecimalsGradingSystem with tests
Jonas-Sander Apr 4, 2024
2a58b21
Delete TODO
Jonas-Sander Apr 4, 2024
a95ccf1
Add gradingSystem, decimalsAllowed to InvalidGradeValueException
Jonas-Sander Apr 4, 2024
8d1ddf1
Create InvalidGradeValueException super class
Jonas-Sander Apr 4, 2024
58ad98f
Move .gradeAsNum to InvalidGradeValueException
Jonas-Sander Apr 4, 2024
82a0064
Remove todos
Jonas-Sander Apr 4, 2024
6739ed3
Add non working grade display test
Jonas-Sander Apr 4, 2024
c4ddc50
add md file
Jonas-Sander Apr 5, 2024
911b421
Revert "Add non working grade display test"
Apr 5, 2024
5e3b42d
Use CalculatedGradeResult class in tests and add suffix and only pass…
Apr 5, 2024
bc66cab
Rename CalculatedGradeResult to GradeValue
Apr 5, 2024
d3cd39e
Only return displayGrades if they are special representations / Fix d…
Apr 5, 2024
da8373d
Change GradingSystem.toDouble to toNum
Apr 5, 2024
c820c74
Migrate to GradingSystemSpec
Apr 5, 2024
ee0b6f8
format code
Apr 5, 2024
c3e529c
Add and implement: 'A suffix is only returned by percentage grade sys…
Apr 5, 2024
8b666ac
Fix displaying grades
Apr 5, 2024
d95597b
.
Apr 5, 2024
f346d5c
.
Apr 8, 2024
0986b25
Add `GradingSystem.austrianBehaviouralGrades`
Apr 8, 2024
7be0834
Add `GradingSystem.oneToFiveWithDecimals`
Apr 8, 2024
5a9254c
Change min for GradingSystem.oneToSixWithDecimals to `0.66`.
Apr 8, 2024
40a21ce
Add grading system `GradingSystem.sixToOneWithDecimals`
Apr 8, 2024
dd57776
add comment
Apr 8, 2024
f968519
add TODO
Apr 8, 2024
f3e9520
Make 1+-6 NonDiscretePossibleGradesResult and add IMap<String, num>? …
Apr 9, 2024
9f64ac9
Add test: 'Austrian behavioural grades returns correct possible grades'
Apr 9, 2024
d53f5d0
refactor PossibleGradesResult
Apr 9, 2024
eb98678
Create `_fromSpecialGradesMap`
Apr 9, 2024
71f5dfd
Change zeroToFivteenPointsSpec to NonDiscretePossibleGradesResult
Apr 9, 2024
889f250
Refactor to GradingSystemSpec.fromSpecialGradesMap
Apr 9, 2024
ef51779
rename discrete to nonNumerical
Apr 9, 2024
670948e
Rename getSpecialDisplayableGradeIfAvailable to getSpecialDisplayable…
Apr 9, 2024
1bbac64
Move `toNumOrThrow` logic to `_GradingSystem`.
Apr 9, 2024
b2d5ddc
Add missing tests for grading systems
Apr 9, 2024
137e5ce
Add GradingSystem.values.numericalAndContinuous test: '$gradingSystem…
Apr 9, 2024
dbe3a49
Add test: '$gradingSystem parses basic number input correctly.'
Apr 9, 2024
17a95f9
Fix numbers in austrianBehaviouralGradesSpec
Apr 9, 2024
5e2a8d1
Add negative numbers to test
Apr 9, 2024
189c0fa
Make way too high numbers higher
Apr 9, 2024
de593ef
Delete todo
Apr 9, 2024
21d9f10
Fix comment
Apr 9, 2024
6eface7
Change 1-5 min to 0.66 and add docs
Apr 9, 2024
6f44a96
Add `GradingSystemSpec.continuousFromPossibleGradesResult`
Apr 9, 2024
597bdb3
Rename file to `grading_systems.dart`
Apr 9, 2024
82975ca
Remove TODOs
Apr 9, 2024
7e07499
Remove .md
Apr 9, 2024
e7f156f
Add `$gradingSystem special values sanity test`
Apr 9, 2024
864bde7
Remove unnecessary tests.
Apr 9, 2024
6a4a8bb
Change build_runner -c to 1
Jonas-Sander Apr 9, 2024
6942221
Revert "Change build_runner -c to 1"
Jonas-Sander Apr 9, 2024
49f27eb
Switch lines around
Apr 10, 2024
de45202
Add `GradingSystem.zeroToFivteenPointsWithDecimals`.
Apr 10, 2024
cab454c
Update HasDecimals extension
Apr 10, 2024
0de83f8
Add commented out decimalsAllowed test logic
Apr 10, 2024
a6f760c
format
Apr 10, 2024
2e77596
Change `GradingSystem.sixToOneWithDecimals` max to 6.34
Apr 10, 2024
c1eafbc
Rename `GradeService.createTerm` to `GradeService.addTerm`.
Apr 10, 2024
2abd717
Format code.
Apr 10, 2024
1932a70
Run sz build_runner build
Apr 10, 2024
c2414e8
Revert "Run sz build_runner build"
Apr 10, 2024
29361f4
Add Flutter Clean step
nilsreichardt Apr 10, 2024
7a1ca50
Fix comment spacing
nilsreichardt Apr 10, 2024
b4deafa
Comment out pub get
nilsreichardt Apr 10, 2024
5332c96
Move flutter as real dependency
nilsreichardt Apr 10, 2024
6b8ac02
Revert "Move flutter as real dependency"
nilsreichardt Apr 10, 2024
e460c25
Remove clean
nilsreichardt Apr 10, 2024
e5262c4
Revert clean step
nilsreichardt Apr 10, 2024
3315ad5
Add `--exclude` option to repo CLI
nilsreichardt Apr 10, 2024
1ebc658
Exclude holidays package
nilsreichardt Apr 10, 2024
dc0da90
Revert "Add `--exclude` option to repo CLI"
nilsreichardt Apr 10, 2024
12cf218
Revert "Exclude holidays package"
nilsreichardt Apr 10, 2024
4faa738
Merge branch 'main' into other-grading-systems
nilsreichardt Apr 10, 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
96 changes: 85 additions & 11 deletions app/lib/grades/grades_service/grades_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export '../models/subject_id.dart';
export '../models/term_id.dart';

part 'src/term.dart';
part 'src/grading_system.dart';
part 'src/grading_systems.dart';

class GradesService {
final rx.BehaviorSubject<IList<TermResult>> terms;
Expand Down Expand Up @@ -77,7 +77,7 @@ class GradesService {
terms.add(termRes);
}

void createTerm({
void addTerm({
required TermId id,
required String name,
required GradeTypeId finalGradeType,
Expand Down Expand Up @@ -190,9 +190,9 @@ class GradesService {
///
/// For example the values for the grading system "1-6 with plus and minus"
/// would be: `['1+', '1', '1-', '2+', [...] '5+', '5', '5-', '6']`
IList<String> getPossibleGrades(GradingSystem gradingSystem) {
PossibleGradesResult getPossibleGrades(GradingSystem gradingSystem) {
final gs = gradingSystem.toGradingSystem();
return gs.possibleValues;
return gs.possibleGrades;
}

IList<GradeType> getPossibleGradeTypes() {
Expand Down Expand Up @@ -242,6 +242,19 @@ class GradesService {
}
}

class InvalidGradeValueException extends Equatable implements Exception {
final String gradeInput;
final GradingSystem gradingSystem;

const InvalidGradeValueException({
required this.gradeInput,
required this.gradingSystem,
});

@override
List<Object?> get props => [gradeInput, gradingSystem];
}

class SubjectNotFoundException extends Equatable implements Exception {
final SubjectId id;

Expand Down Expand Up @@ -269,7 +282,54 @@ class GradeTypeNotFoundException extends Equatable implements Exception {
List<Object?> get props => [id];
}

enum GradingSystem { oneToSixWithPlusAndMinus, zeroToFivteenPoints }
enum GradingSystem {
oneToSixWithPlusAndMinus(isNumericalAndContinous: true),
zeroToFivteenPoints(isNumericalAndContinous: true),
zeroToFivteenPointsWithDecimals(isNumericalAndContinous: true),
oneToSixWithDecimals(isNumericalAndContinous: true),
zeroToHundredPercentWithDecimals(isNumericalAndContinous: true),
oneToFiveWithDecimals(isNumericalAndContinous: true),
sixToOneWithDecimals(isNumericalAndContinous: true),
austrianBehaviouralGrades(isNumericalAndContinous: false);

final bool isNumericalAndContinous;

const GradingSystem({required this.isNumericalAndContinous});
}

extension NumericalAndContinuous on List<GradingSystem> {
IList<GradingSystem> get numericalAndContinuous =>
where((gs) => gs.isNumericalAndContinous).toIList();
}

sealed class PossibleGradesResult {
const PossibleGradesResult();
}

class NonNumericalPossibleGradesResult extends PossibleGradesResult {
final IList<String> grades;

const NonNumericalPossibleGradesResult(this.grades);
}

class ContinuousNumericalPossibleGradesResult extends PossibleGradesResult {
final num min;
final num max;
final bool decimalsAllowed;

/// Special non-numerical grade strings that have an assigned numerical value.
///
/// For example [GradingSystem.oneToSixWithPlusAndMinus] might have the values:
/// `{'1+':0.75,'1-':1.25, /**...*/ '5-':5.25}`.
final IMap<String, num> specialGrades;

const ContinuousNumericalPossibleGradesResult({
required this.min,
required this.max,
required this.decimalsAllowed,
this.specialGrades = const IMapConst({}),
});
}

/// The predefined types of grades that can be used.
///
Expand Down Expand Up @@ -322,7 +382,7 @@ class GradeType extends Equatable {

class GradeResult {
final GradeId id;
final CalculatedGradeResult value;
final GradeValue value;
final bool isTakenIntoAccount;
final Date date;

Expand All @@ -337,7 +397,7 @@ class GradeResult {
class SubjectResult {
final SubjectId id;
final String name;
final CalculatedGradeResult? calculatedGrade;
final GradeValue? calculatedGrade;
final WeightType weightType;
final IMap<GradeTypeId, Weight> gradeTypeWeights;
final IList<GradeResult> grades;
Expand All @@ -363,7 +423,7 @@ class SubjectResult {
class TermResult {
final TermId id;
final GradingSystem gradingSystem;
final CalculatedGradeResult? calculatedGrade;
final GradeValue? calculatedGrade;
IList<SubjectResult> subjects;
final bool isActiveTerm;
final String name;
Expand All @@ -383,12 +443,26 @@ class TermResult {
});
}

class CalculatedGradeResult {
class GradeValue extends Equatable {
double get asDouble => asNum.toDouble();
final num asNum;
final String displayableGrade;

CalculatedGradeResult({required this.asNum, required this.displayableGrade});
/// Only available if there is a special displayable grade for the calculated
/// grade. For example, if the calculated grade is 2.25, the displayable grade
/// could be '2+' for the (1-6 with +-) grading system.
final String? displayableGrade;

/// A suffix that should be appended to the displayable grade.
/// For example for the 0-100% grading system, this would be '%'.
final String? suffix;

@override
List<Object?> get props => [asNum, displayableGrade, suffix];

const GradeValue(
{required this.asNum,
required this.displayableGrade,
required this.suffix});
}

class Grade {
Expand Down
161 changes: 0 additions & 161 deletions app/lib/grades/grades_service/src/grading_system.dart

This file was deleted.

Loading
Loading