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

Quiz exercises: Allow decimal point values for quiz questions #10232

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

badkeyy
Copy link
Contributor

@badkeyy badkeyy commented Jan 29, 2025

🚨 Contains Database Migration 🚨

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) and too complex database calls.
  • I strictly followed the principle of data economy for all database calls.
  • I strictly followed the server coding and design guidelines.
  • I added multiple integration tests (Spring) related to the features (with a high test coverage).
  • I added pre-authorization annotations according to the guidelines and checked the course groups for all new REST Calls (security).
  • I documented the Java code using JavaDoc style.

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data (e.g. using paging).
  • I strictly followed the principle of data economy for all client-server REST calls.
  • I strictly followed the client coding and design guidelines.
  • Following the theming guidelines, I specified colors only in the theming variable files and checked that the changes look consistent in both the light and the dark theme.
  • I added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I added authorities to all new routes and checked the course groups for displaying navigation elements (links, buttons).
  • I documented the TypeScript code using JSDoc style.
  • I added multiple screenshots/screencasts of my UI changes.
  • I translated all newly inserted strings into English and German.

Motivation and Context

Currently it is not possible to award fractions of a point for quiz questions. Issue #10148 asked to change that.

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 1 Course
  1. Log in to Artemis.
  2. Go to the Course Administration page.
  3. Create a quiz with any question type and configure them to award fractional points (e.g., 0.5 points).
  4. Verify that the quiz is created as expected.
  5. Participate in the quiz.
  6. Confirm that fractional points are awarded correctly.

Exam Mode Testing

Prerequisites:

  • 1 Instructor
  • 1 Students
  • 1 Exam
  1. Navigate to the Course Administration page
  2. Create a quiz in an exam including any question type and configure them to for example award 0.5 points
  3. Find the quiz to be created as specified
  4. Finish up configuring the exam
  5. Participate in the exam
  6. Find the fractional points to work correctly

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Performance Review

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance even for very large courses with more than 2000 students.
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance even for very large courses with more than 2000 students.

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Exam Mode Test

  • Test 1
  • Test 2

Performance Tests

  • Test 1
  • Test 2

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced quiz scoring system to support decimal point values.
    • Introduced more flexible point allocation for quiz questions, allowing scores of zero.
  • Improvements

    • Updated scoring validation to ensure only positive point values are considered valid.
    • Added support for half-point increments in multiple-choice question scoring.
  • Bug Fixes

    • Corrected point calculation and validation across multiple quiz question types to accommodate new scoring logic.

These changes provide more granular and precise scoring options for quiz questions, allowing for more nuanced evaluation of student performance.

@github-actions github-actions bot added server Pull requests that update Java code. (Added Automatically!) client Pull requests that update TypeScript code. (Added Automatically!) database Pull requests that update the database. (Added Automatically!). Require a CRITICAL deployment. quiz Pull requests that affect the corresponding module labels Jan 29, 2025
@badkeyy badkeyy changed the title Add decimal points to quiz exercise Quiz exercises: Add decimal points to quiz exercise Jan 29, 2025
@badkeyy badkeyy changed the title Quiz exercises: Add decimal points to quiz exercise Quiz exercises: Allow decimal point values for quiz questions Jan 29, 2025
@github-actions github-actions bot added tests exam Pull requests that affect the corresponding module labels Jan 30, 2025
@badkeyy badkeyy marked this pull request as ready for review January 30, 2025 02:34
@badkeyy badkeyy requested a review from a team as a code owner January 30, 2025 02:34
@badkeyy badkeyy linked an issue Jan 30, 2025 that may be closed by this pull request
Copy link

coderabbitai bot commented Jan 30, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 PMD (7.8.0)
src/main/java/de/tum/cit/aet/artemis/quiz/domain/QuizQuestion.java

The following rules are missing or misspelled in your ruleset file category/vm/bestpractices.xml: BooleanInstantiation, DontImportJavaLang, DuplicateImports, EmptyFinallyBlock, EmptyIfStmt, EmptyInitializer, EmptyStatementBlock, EmptyStatementNotInLoop, EmptySwitchStatements, EmptySynchronizedBlock, EmptyTryBlock, EmptyWhileStmt, ExcessiveClassLength, ExcessiveMethodLength, ImportFromSamePackage, MissingBreakInSwitch, SimplifyBooleanAssertion. Please check your ruleset configuration.

Walkthrough

The pull request introduces comprehensive modifications to the quiz scoring system across multiple files. The primary change involves transitioning from integer-based points to double-based points, allowing for more granular scoring. This affects the QuizQuestion domain class, various HTML templates for question editing, utility services, and test classes. The modifications enable zero-point questions and support half-point increments, providing more flexibility in quiz question scoring.

Changes

File Change Summary
src/main/java/de/tum/cit/aet/artemis/quiz/domain/QuizQuestion.java Updated points attribute from Integer to double, modified related methods (getPoints(), score(), setPoints()), and adjusted validation logic in isValid().
src/main/webapp/app/exercises/quiz/manage/drag-and-drop-question/drag-and-drop-question-edit.component.html Changed score input min attribute from 1 to 0.
src/main/webapp/app/exercises/quiz/manage/multiple-choice-question/multiple-choice-question-edit.component.html Changed score input min attribute from 1 to 0, added step="0.5" for decimal point increments.
src/main/webapp/app/exercises/quiz/manage/short-answer-question/short-answer-question-edit.component.html Updated variable binding from shortAnswerQuestion.points to question.points, changed score input min attribute from 1 to 0.
src/main/webapp/app/exercises/quiz/shared/quiz-manage-util.service.ts Updated validation logic to check if points are less than or equal to 0.
src/test/java/de/tum/cit/aet/artemis/exam/service/ExamQuizServiceTest.java Changed questionScore type from int to double, updated score calculation methods.
src/test/java/de/tum/cit/aet/artemis/quiz/util/QuizExerciseFactory.java Updated score values to use double literals (e.g., 2d instead of 2).
src/test/java/de/tum/cit/aet/artemis/quiz/QuizExerciseIntegrationTest.java Updated score method call to use double value for MultipleChoiceQuestion.
src/test/java/de/tum/cit/aet/artemis/quiz/QuizSubmissionIntegrationTest.java Changed total score accumulation from int to double, updated assertions for point counters.

Possibly related PRs

Suggested labels

exercise, bugfix

Suggested reviewers

  • Hialus
  • JohannesStoehr
  • pzdr7
  • EneaGore
  • SimonEntholzer
  • az108

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 53a6163 and 5eba6d2.

📒 Files selected for processing (1)
  • src/main/java/de/tum/cit/aet/artemis/quiz/domain/QuizQuestion.java (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/de/tum/cit/aet/artemis/quiz/domain/QuizQuestion.java
⏰ Context from checks skipped due to timeout of 90000ms (2)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (4)
src/main/java/de/tum/cit/aet/artemis/quiz/domain/QuizQuestion.java (1)

71-72: Consider using BigDecimal for precise decimal calculations.

While using Double allows for fractional points as intended, it might lead to precision issues in decimal arithmetic. Consider using BigDecimal if exact decimal representation is crucial for point calculations.

-    private Double points;
+    private BigDecimal points;
src/main/webapp/app/exercises/quiz/shared/quiz-manage-util.service.ts (1)

40-42: Improve type safety in points validation.

The condition handles undefined check correctly but could be more explicit about null checks and type coercion.

-    if (question.points == undefined || question.points <= 0 || question.points > MAX_QUIZ_QUESTION_POINTS) {
+    if (question.points === undefined || question.points === null || 
+        Number(question.points) <= 0 || Number(question.points) > MAX_QUIZ_QUESTION_POINTS) {
src/test/java/de/tum/cit/aet/artemis/quiz/util/QuizExerciseFactory.java (1)

444-444: Consider adding test cases with decimal scores.

While the conversion to double literals is correct, consider adding test factory methods that create questions with decimal point scores (e.g., 2.5, 3.5) to thoroughly test the new functionality.

Also applies to: 520-520

src/test/java/de/tum/cit/aet/artemis/quiz/QuizSubmissionIntegrationTest.java (1)

211-212: Consider adding test cases for edge cases in partial scoring.

The test covers basic partial scoring, but could benefit from additional test cases:

  • Scores very close to 0.5 (rounding boundary)
  • Maximum allowed decimal places
 quizExercise.getQuizQuestions().get(1).score(1d);
 quizExercise.getQuizQuestions().get(2).score(1d);
+// Add edge cases
+quizExercise.getQuizQuestions().get(1).score(0.49d); // Should round down
+quizExercise.getQuizQuestions().get(2).score(0.51d); // Should round up
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 72ca6ae and 6188a3b.

⛔ Files ignored due to path filters (2)
  • src/main/resources/config/liquibase/changelog/20250129173003_changelog.xml is excluded by !**/*.xml
  • src/main/resources/config/liquibase/master.xml is excluded by !**/*.xml
📒 Files selected for processing (9)
  • src/main/java/de/tum/cit/aet/artemis/quiz/domain/QuizQuestion.java (3 hunks)
  • src/main/webapp/app/exercises/quiz/manage/drag-and-drop-question/drag-and-drop-question-edit.component.html (1 hunks)
  • src/main/webapp/app/exercises/quiz/manage/multiple-choice-question/multiple-choice-question-edit.component.html (1 hunks)
  • src/main/webapp/app/exercises/quiz/manage/short-answer-question/short-answer-question-edit.component.html (1 hunks)
  • src/main/webapp/app/exercises/quiz/shared/quiz-manage-util.service.ts (2 hunks)
  • src/test/java/de/tum/cit/aet/artemis/exam/service/ExamQuizServiceTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/quiz/QuizExerciseIntegrationTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/quiz/QuizSubmissionIntegrationTest.java (5 hunks)
  • src/test/java/de/tum/cit/aet/artemis/quiz/util/QuizExerciseFactory.java (5 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/test/java/de/tum/cit/aet/artemis/quiz/QuizExerciseIntegrationTest.java
🧰 Additional context used
📓 Path-based instructions (8)
src/main/webapp/app/exercises/quiz/manage/multiple-choice-question/multiple-choice-question-edit.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/webapp/app/exercises/quiz/manage/drag-and-drop-question/drag-and-drop-question-edit.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/webapp/app/exercises/quiz/shared/quiz-manage-util.service.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/test/java/de/tum/cit/aet/artemis/exam/service/ExamQuizServiceTest.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

src/test/java/de/tum/cit/aet/artemis/quiz/QuizSubmissionIntegrationTest.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

src/main/webapp/app/exercises/quiz/manage/short-answer-question/short-answer-question-edit.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/java/de/tum/cit/aet/artemis/quiz/domain/QuizQuestion.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/test/java/de/tum/cit/aet/artemis/quiz/util/QuizExerciseFactory.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: client-tests
  • GitHub Check: server-tests
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Analyse
🔇 Additional comments (9)
src/main/java/de/tum/cit/aet/artemis/quiz/domain/QuizQuestion.java (1)

144-155: Update method signatures to match field type change.

The getter, setter, and score methods have been correctly updated to use Double. However, if you decide to use BigDecimal as suggested above, these methods would need to be updated accordingly.

src/main/webapp/app/exercises/quiz/shared/quiz-manage-util.service.ts (1)

Line range hint 128-133: LGTM! Error message handling is consistent.

The error message handling for invalid points is properly updated to match the new validation logic.

src/test/java/de/tum/cit/aet/artemis/quiz/util/QuizExerciseFactory.java (3)

107-107: LGTM! Consistent use of double literal.

The score value is correctly updated to use the double literal 2d.


153-153: LGTM! Consistent use of double literal.

The score value is correctly updated to use the double literal 3d.


225-225: LGTM! Consistent use of double literal.

The score value is correctly updated to use the double literal 4d.

src/test/java/de/tum/cit/aet/artemis/quiz/QuizSubmissionIntegrationTest.java (2)

354-356: LGTM!

The practice mode test correctly handles double-based scores and rounding.


164-166: Verify the rounding behavior in score calculations.

The change from integer to double-based score calculation requires careful handling of rounding. Ensure that:

  1. The rounding behavior is consistent across all score calculations
  2. The size of point counters array matches the rounded score value
✅ Verification successful

Rounding behavior in score calculations is consistent and correct

The rounding implementation is uniform across all score calculations, with proper decimal handling for:

  • Point counter array sizing using (int) Math.round(score + 1)
  • Student count calculations using decimal division before rounding
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other score calculations to verify consistent rounding
rg -A 2 "Math\.round" src/test/java/de/tum/cit/aet/artemis/quiz/

Length of output: 5885

src/main/webapp/app/exercises/quiz/manage/short-answer-question/short-answer-question-edit.component.html (1)

28-31: LGTM! Consistent with other question types.

The changes properly implement decimal point support with appropriate step value and minimum bound.

src/main/webapp/app/exercises/quiz/manage/drag-and-drop-question/drag-and-drop-question-edit.component.html (1)

24-33: LGTM! Implements decimal points consistently.

The implementation matches other question types and properly handles:

  • Zero-point minimum
  • Half-point increments
  • Change detection

badkeyy and others added 3 commits January 30, 2025 03:46
…tion/multiple-choice-question-edit.component.html

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 30, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/main/java/de/tum/cit/aet/artemis/quiz/domain/QuizQuestion.java (2)

144-155: Add validation and conversion logic for points.

Consider adding validation to ensure points are non-negative and within a reasonable range. Also, consider handling precision to avoid floating-point representation issues.

 public Double getPoints() {
     return points;
 }

 public QuizQuestion score(Double score) {
+    if (score != null) {
+        // Round to 2 decimal places to avoid floating-point precision issues
+        score = Math.round(score * 100.0) / 100.0;
+        // Ensure non-negative value
+        score = Math.max(0.0, score);
+    }
     this.points = score;
     return this;
 }

 public void setPoints(Double score) {
+    if (score != null) {
+        // Round to 2 decimal places to avoid floating-point precision issues
+        score = Math.round(score * 100.0) / 100.0;
+        // Ensure non-negative value
+        score = Math.max(0.0, score);
+    }
     this.points = score;
 }

Line range hint 223-231: Consider precision handling in score comparison.

The isAnswerCorrect method directly compares the calculated score with getPoints(). With decimal values, consider adding a small epsilon or using Double.compare() for more reliable comparison:

 public boolean isAnswerCorrect(SubmittedAnswer submittedAnswer) {
-    return makeScoringStrategy().calculateScore(this, submittedAnswer) == getPoints();
+    double calculatedScore = makeScoringStrategy().calculateScore(this, submittedAnswer);
+    return Math.abs(calculatedScore - getPoints()) < 0.0001; // Use small epsilon for floating-point comparison
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0e6105 and 7969467.

📒 Files selected for processing (2)
  • src/main/java/de/tum/cit/aet/artemis/quiz/domain/QuizQuestion.java (3 hunks)
  • src/test/java/de/tum/cit/aet/artemis/exam/service/ExamQuizServiceTest.java (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/main/java/de/tum/cit/aet/artemis/quiz/domain/QuizQuestion.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/test/java/de/tum/cit/aet/artemis/exam/service/ExamQuizServiceTest.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

🔇 Additional comments (3)
src/test/java/de/tum/cit/aet/artemis/exam/service/ExamQuizServiceTest.java (1)

365-367: Add test cases for decimal point values.

While the type changes and floating-point comparison are correct, consider adding specific test cases that verify:

  1. Fractional points (e.g., 0.5, 1.5)
  2. Edge cases (e.g., very small decimals)
  3. Rounding behavior

Also, consider extracting the delta value to a constant for better maintainability:

+    private static final double SCORE_COMPARISON_DELTA = 0.0001;
+
     private void checkStatistics(QuizExercise quizExercise) {
         // ...
         double questionScore = quizExerciseWithStatistic.getQuizQuestions().stream()
             .map(QuizQuestion::getPoints).reduce(0.0, Double::sum);
-        assertThat(quizExerciseWithStatistic.getMaxPoints()).isCloseTo(questionScore, within(0.0001));
+        assertThat(quizExerciseWithStatistic.getMaxPoints())
+            .isCloseTo(questionScore, within(SCORE_COMPARISON_DELTA));
src/main/java/de/tum/cit/aet/artemis/quiz/domain/QuizQuestion.java (2)

260-260: Proper implementation of double comparison.

The implementation correctly uses Double.compare() for floating-point comparison, addressing potential precision issues. This is a good practice for handling decimal values.


72-72: Verify database migration for points column type change.

The change from Integer to Double requires a database migration. While the PR objectives mention a migration exists, please ensure it handles:

  1. Data type conversion from INTEGER to DOUBLE
  2. Existing data transformation
  3. Proper column type definition for precision/scale
✅ Verification successful

Database migration for points column type change is properly implemented

The migration exists in 20250129173003_changelog.xml and correctly modifies the points column type to double in the quiz_question table. The change is properly structured and will handle the data type conversion automatically.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if a migration exists for the points column type change

# Look for migration files containing 'points' or 'quiz_question'
fd -e sql -e java -e xml . | rg -i "migration|changelog" | xargs rg -l -i "points|quiz_question"

Length of output: 253


Script:

#!/bin/bash
# Check the content of the recent changelog
cat src/main/resources/config/liquibase/changelog/20250129173003_changelog.xml

Length of output: 600

Copy link

@zagemello zagemello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on TS4, all works as expected.

Copy link

@Feras797 Feras797 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on TS3, everything works as described.
Fractional points possible.

Copy link

@alekspetrov9e alekspetrov9e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on TS4. Used fractional numbers for points and the grading worked appropriately.

Copy link

@SindiBuklaji SindiBuklaji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on TS5. Works as expected 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) database Pull requests that update the database. (Added Automatically!). Require a CRITICAL deployment. exam Pull requests that affect the corresponding module lock:artemis-test2 quiz Pull requests that affect the corresponding module ready for review server Pull requests that update Java code. (Added Automatically!) tests
Projects
Status: Ready For Review
Development

Successfully merging this pull request may close these issues.

Quiz: Decimal Points