SharezoneApp / sharezone-app

Sharezone is a collaborative school organization app for iOS, Android, macOS and web with +500,000 downloads. Built with Flutter & Firebase.
https://sharezone.net
European Union Public License 1.2
254 stars 46 forks source link

Grades service new api #1642

Open Jonas-Sander opened 1 month ago

Jonas-Sander commented 1 month ago
      final service = GradesService();

      final mathSubjectId = service.addSubject(
        id: const SubjectId('mathe'),
        SubjectInput(
          design: Design.random(Random(42)),
          name: 'Mathe',
          abbreviation: 'M',
          connectedCourses: const IListConst([
            // ...
          ]),
        ),
      );

      final termRef = service.addTerm(
        id: const TermId('02-10-term'),
        name: '02/10',
        finalGradeType: GradeType.schoolReportGrade.id,
        gradingSystem: GradingSystem.zeroToFifteenPoints,
        isActiveTerm: true,
      );
      // subject is implicitly added to term when creating a grade
      final gradeRef = termRef.subject(mathSubjectId).addGrade(
            GradeInput(
              value: '13',
              gradingSystem: GradingSystem.zeroToFifteenPoints,
              type: GradeType.oralParticipation.id,
              date: Date('2024-10-02'),
              takeIntoAccount: true,
              title: 'hallo',
              details: 'hello',
            ),
          );
      termRef.subject(mathSubjectId)
        ..changeFinalGradeType(GradeType.oralParticipation.id)
        ..changeGradeTypeWeight(
            GradeType.oralParticipation.id, Weight.factor(2));

      gradeRef.delete();
github-actions[bot] commented 1 month ago

Visit the preview URL for this PR (updated for commit 8e8a892):

https://sharezone-test--pr1642-grades-service-new-a-ql3iu9go.web.app

(expires Fri, 24 May 2024 11:22:45 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 4cb3ae61e1e018abfd9841fd3239f5b49ccc034b