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

Learning analytics: Improve student course dashboard for better self-learning by showing active exercises #8839

Conversation

FelixTJDietrich
Copy link
Contributor

@FelixTJDietrich FelixTJDietrich commented Jun 21, 2024

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) 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.
  • 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 the dashboard does not show a good overview of active exercises where the student has the biggest learning effect #8829

Description

In the competency accordion of the student course dashboard:

  • Show all active exercises, also the ones that are open for practice, if the student did not yet reach at least 80% of max(gradedScore, practiceScore)
  • Sort exercises with lowest score (max(gradedScore, practiceScore)) first so the student knows immediately where they can make the biggest learning impact
  • Show “Congratulations! You finished all released units in this competency to at least 80% completion 🎉” if there is currently nothing to do for this competency

Steps for Testing

Prerequisites:

  • 1 Instructor (/Student)
  • 1 Course with the Student Analytics Dashboard enabled
  • 2 Competencies
  • 1 Ongoing Programming Exercise in Competency 1
  • Other exercises and lecture units for testing associated to a competency
  1. Log in to Artemis (For example on TS1 - Course: Test Course Felix T.J. Dietrich)
  2. Navigate to the course with dashboard enabled
  3. In Competency 1
    1. Press Start Exercise and participate
    2. Change due date of exercise to now
    3. Programming exercise should be visible for practice mode
    4. Press "Practice"
  4. Create a quiz exercise that can have score >= 80% through answers, associate with a competency!
  5. Participate via the dashboard in the quiz exercise
  6. Complete with more than 80% score
  7. Quiz exercise should then disappear from the dashboard
  8. After all released exercises / lecture units of a competency are completed (to at least 80% completion) a congratulations alert should be visible within the competency

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
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Test Coverage

N/A

Screenshots

image image

Summary by CodeRabbit

  • New Features

    • Enhanced score calculation for exercises to consider lastRatedScore more accurately in user scores and average scores.
    • Added congratulatory messages in the student analytics dashboard for achieving 80% completion in all released competency activities.
  • Improvements

    • Refined the competency accordion component to handle conditional rendering based on the presence of course, nextLectureUnits, and nextExercises.
    • Improved handling and display of competency exercises, considering release dates, practice availability, and completion thresholds.
  • Localization

    • Added new translations for congratulatory messages in German and English.
  • Refactor

    • Updated internal logic for better score computation and conditional rendering in the competency accordion component.

@github-actions github-actions bot added server Pull requests that update Java code. (Added Automatically!) client Pull requests that update TypeScript code. (Added Automatically!) labels Jun 21, 2024
@FelixTJDietrich FelixTJDietrich changed the title Learning analytics: Improve student dashboard for better self-learning by showing active exercises Learning analytics: Improve student course dashboard for better self-learning by showing active exercises Jun 21, 2024
@FelixTJDietrich FelixTJDietrich marked this pull request as ready for review June 21, 2024 15:37
@FelixTJDietrich FelixTJDietrich requested a review from a team as a code owner June 21, 2024 15:37
@FelixTJDietrich FelixTJDietrich added this to the 7.2.3 milestone Jun 21, 2024
Copy link

coderabbitai bot commented Jun 21, 2024

Walkthrough

The recent changes involve enhancing score calculations, improving conditional rendering in the competency accordion component, updating competency exercise handling, and adding new congratulatory messages in the student analytics dashboard. These modifications ensure more accurate score computations and enhance user engagement and interface responsiveness by refining component logic and improving user feedback.

Changes

File Change Summary
src/main/java/.../ExerciseMetricsRepository.java Refined score calculation to properly handle lastRatedScore and null values, enhancing accuracy in user score computations.
src/main/webapp/app/course/competencies/competency-accordion/...component.html Restructured conditional rendering logic to more logically display elements based on the existence of course, nextLectureUnits, and nextExercises, and added a success message for empty states.
src/main/webapp/app/course/competencies/competency-accordion/...component.ts Updated to filter, sort, and calculate scores for competency exercises based on release and due dates, practice availability, and completion thresholds.
src/main/webapp/i18n/de/studentAnalyticsDashboard.json Added a new congratulatory message for achieving 80% completion for all released activities within a competency.
src/main/webapp/i18n/en/studentAnalyticsDashboard.json Introduced a congratulatory message for users upon completing 80% of all released activities in a competency, enhancing user motivation and engagement.

Sequence Diagrams

Sequence diagrams generation is not applicable for the provided changes due to their scope and straightforward nature.


Recent review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between c9f3cbe and 862b75b.

Files selected for processing (1)
  • src/main/java/de/tum/in/www1/artemis/repository/metrics/ExerciseMetricsRepository.java (2 hunks)
Additional context used
Path-based instructions (1)
src/main/java/de/tum/in/www1/artemis/repository/metrics/ExerciseMetricsRepository.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

Additional comments not posted (2)
src/main/java/de/tum/in/www1/artemis/repository/metrics/ExerciseMetricsRepository.java (2)

68-68: Query improvement acknowledged.

The use of COALESCE to handle potential null values in lastRatedScore enhances the robustness and accuracy of the average score calculation.


83-83: Type safety and null handling in score retrieval.

Casting the lastRatedScore to DOUBLE after using COALESCE ensures that the data type matches the expected type of ScoreDTO and handles null values effectively.


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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: 1

Outside diff range comments (2)
src/main/webapp/app/course/competencies/competency-accordion/competency-accordion.component.ts (2)

Line range hint 37-39: Remove unnecessary type annotations.

Type annotations for confidence, mastery, and progress are inferred from their initial values and are therefore redundant. Removing these can clean up the code slightly.

- confidence: number = 0;
- mastery: number = 0;
- progress: number = 0;
+ confidence = 0;
+ mastery = 0;
+ progress = 0;

Line range hint 149-150: Avoid using non-null assertion operators.

The use of non-null assertion operators (!) is generally discouraged as they can lead to runtime errors if assumptions about non-nullability prove incorrect. Consider using optional chaining or explicit checks to handle potential null or undefined values safely.

- this.router.navigate(['/courses', this.course!.id, 'competencies', this.competency.id]);
+ this.router.navigate(['/courses', this.course?.id, 'competencies', this.competency.id]);

Also applies to: 218-218

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 21, 2024
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: 1

Outside diff range comments (2)
src/main/webapp/app/course/competencies/competency-accordion/competency-accordion.component.ts (2)

Line range hint 37-39: Redundant Type Annotations:

TypeScript's type inference is capable of deducing the types of confidence, mastery, and progress from their initial values. The explicit type annotations (number = 0) are redundant and can be omitted for cleaner code.

- confidence: number = 0;
- mastery: number = 0;
- progress: number = 0;
+ confidence = 0;
+ mastery = 0;
+ progress = 0;

Line range hint 148-149: Avoid Non-Null Assertions:

Using non-null assertions (!) bypasses TypeScript's strict null checks, which can lead to runtime errors if assumptions about non-nullability prove incorrect. Use optional chaining (?.) where possible to safely access nested properties.

- this.course!.id
+ this.course?.id

- this.competency.masteryThreshold!
+ this.competency.masteryThreshold

Also applies to: 217-217

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 21, 2024
Copy link
Contributor

@pzdr7 pzdr7 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 TS1.

  • Programming exercise -> Participated -> Set the due date -> Practice was available and worked.
  • Quiz with 90% score -> Participated via the dashboard -> was gone after completion
  • Participated again in the programming exercises and got 100% -> "Congratulations! You finished all released activities in this competency to at least 80% completion 🎉" ✅

Works as expected! 👍


Can you check if we need to adjust the coverage / add tests for the branch coverage?

Jest: "global" coverage threshold for branches (73.18%) not met: 73.16%

const exerciseIdToExercise = Object.fromEntries(courseExercises.map((exercise) => [exercise.id, exercise] as [number, Exercise]));
const activeCompetencyExercises = (this.metrics.competencyMetrics?.exercises?.[this.competency.id] ?? [])
.flatMap((exerciseId) => [exerciseIdToExercise[exerciseId]] ?? [])
.filter((exercise) => exercise.releaseDate?.isBefore(dayjs()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.filter((exercise) => exercise.releaseDate?.isBefore(dayjs()))
.filter((exercise) => !exercise.dueDate || exercise.releaseDate.isBefore(dayjs()))

Currently all exercises without a release date are filtered out

Copy link
Member

@Hialus Hialus Jun 22, 2024

Choose a reason for hiding this comment

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

I do not think this would solve this problem. An exercise can have a due date without having a release date, so it would still filter out those exercises.
Edit: (this is a response to Johannes's message)

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right, it was supposed to be the release Date each time:

Suggested change
.filter((exercise) => exercise.releaseDate?.isBefore(dayjs()))
.filter((exercise) => ! exercise.releaseDate || exercise.releaseDate?.isBefore(dayjs()))

const activeCompetencyExercises = (this.metrics.competencyMetrics?.exercises?.[this.competency.id] ?? [])
.flatMap((exerciseId) => [exerciseIdToExercise[exerciseId]] ?? [])
.filter((exercise) => exercise.releaseDate?.isBefore(dayjs()))
.filter((exercise) => exercise.dueDate?.isAfter(dayjs()) || isStartPracticeAvailable(exercise));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.filter((exercise) => exercise.dueDate?.isAfter(dayjs()) || isStartPracticeAvailable(exercise));
.filter((exercise) => !exercise.dueDate || exercise.dueDate.isAfter(dayjs()) || isStartPracticeAvailable(exercise));

Co-authored-by: Johannes Stöhr <38322605+JohannesStoehr@users.noreply.github.com>
coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 22, 2024
Hialus
Hialus previously requested changes Jun 22, 2024
const exerciseIdToExercise = Object.fromEntries(courseExercises.map((exercise) => [exercise.id, exercise] as [number, Exercise]));
const activeCompetencyExercises = (this.metrics.competencyMetrics?.exercises?.[this.competency.id] ?? [])
.flatMap((exerciseId) => [exerciseIdToExercise[exerciseId]] ?? [])
.filter((exercise) => exercise.releaseDate?.isBefore(dayjs()))
Copy link
Member

@Hialus Hialus Jun 22, 2024

Choose a reason for hiding this comment

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

I do not think this would solve this problem. An exercise can have a due date without having a release date, so it would still filter out those exercises.
Edit: (this is a response to Johannes's message)

const exerciseIdToMaxScore = Object.fromEntries(
activeCompetencyExercises.map((exercise) => {
const score =
exercise.studentParticipations?.flatMap((participation) => participation.results ?? []).reduce((max, result) => Math.max(max, result.score ?? 0), -1) ?? 0;
Copy link
Member

Choose a reason for hiding this comment

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

This statement could likely be simplified a bit, as Math.max can take a variable amount of args, so something similar to Math.max(-1, ...(ex.sp?.flatMap(...).map((result)=>result.score ?? 0))) should also work. For better readability you could put the flatMap/map result on a separate line.

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

Outside diff range comments (2)
src/main/webapp/app/course/competencies/competency-accordion/competency-accordion.component.ts (2)

Line range hint 37-39: Remove unnecessary type annotations.

The type annotations for confidence, mastery, and progress are inferred and thus redundant. Removing these will clean up the code.

- confidence: number = 0;
- mastery: number = 0;
- progress: number = 0;
+ confidence = 0;
+ mastery = 0;
+ progress = 0;

Line range hint 148-149: Avoid non-null assertions.

Non-null assertions have been used, which can lead to runtime errors if not handled properly. It's safer to use optional chaining.

- this.router.navigate(['/courses', this.course!.id, 'competencies', this.competency.id]);
+ this.router.navigate(['/courses', this.course?.id, 'competencies', this.competency.id]);

Also applies to: 217-217

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: 2

Outside diff range comments (2)
src/main/webapp/app/course/competencies/competency-accordion/competency-accordion.component.ts (2)

Line range hint 149-150: Avoid using non-null assertions.

Non-null assertions have been used, which can potentially lead to runtime errors if assumptions about data presence are incorrect.

  • Replace non-null assertions with safer checks like optional chaining or conditional checks to ensure robustness.
- this.course!.id
+ this.course?.id

Also applies to: 218-218


Line range hint 38-40: Remove unnecessary type annotations.

Type annotations for confidence, mastery, and progress are inferred from their initial values and can be removed to clean up the code.

- confidence: number = 0;
- mastery: number = 0;
- progress: number = 0;
+ confidence = 0;
+ mastery = 0;
+ progress = 0;

…ve-student-dashboard-for-self-learning' into feature/learning-analytics/improve-student-dashboard-for-self-learning
Copy link
Contributor

@JohannesStoehr JohannesStoehr left a comment

Choose a reason for hiding this comment

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

Code looks good enough to be an improvement, especially for GAD where the exercise dates are set. Please fix the selection of exercises in a follow up to also work without exercise dates

@krusche krusche merged commit 99d5044 into develop Jun 22, 2024
22 of 28 checks passed
@krusche krusche deleted the feature/learning-analytics/improve-student-dashboard-for-self-learning branch June 22, 2024 15:30
This pull request was closed.
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!) enhancement priority:high ready for review server Pull requests that update Java code. (Added Automatically!)
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants