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

Programming exercises: Add open repository button for editors and instructors in LocalVC #9898

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

Conversation

SimonEntholzer
Copy link
Contributor

@SimonEntholzer SimonEntholzer commented Nov 28, 2024

Checklist

General

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

Instructors and editors are not able to open the student's repository when they are assessing submissions.

Description

Adds the "open repository" link, identically how it is for external repositories for LocalVC repositories.

Steps for Testing

  1. Create a programming exercise, and submit with a student.
  2. As the instructor/editor set the submission due date, and change to manual assessment.
  3. Navigate to the assessment dashboard -> assess new submission
  4. There should be an "Go to repository" link, which leads to the student's repository.
  5. Make sure the link is not displayed if you assess a submission as a tutor

Exam Mode Testing

  1. Create an exam with a programming exercise
  2. Participate with a student
  3. Assess with an instructor/editor and tutor
  4. The "Go to repository" link should be visible for the instructor.

Note: For test-runs, the button we do not show the repository button, as the repository view is not supported for test-run participation repositories yet. This will be added in a follow up.

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

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Exam Mode Test

  • Test 1
  • Test 2

Test Coverage

Client

Class/File Line Coverage Confirmation (assert/expect)
code-editor-tutor-assessment-container.component.ts 89.09% ✅ ❌
navigation.utils.ts 88.33% ✅ ❌

Screenshots

image

Summary by CodeRabbit

  • New Features

    • Introduced conditional rendering for repository links based on user permissions.
    • Added functionality to generate links for local repositories based on user roles and local version control status.
    • Enhanced UI with an external link icon for better navigation experience.
  • Bug Fixes

    • Improved error handling and user feedback mechanisms remain unchanged, ensuring stability.
  • Documentation

    • Updated navigation utility to include a new function for constructing local repository links.

@SimonEntholzer SimonEntholzer requested a review from a team as a code owner November 28, 2024 17:42
@github-actions github-actions bot added the client Pull requests that update TypeScript code. (Added Automatically!) label Nov 28, 2024
@SimonEntholzer SimonEntholzer changed the title Exam: Add open repository button for editors and instructors in LocalVC Programming exercises: Add open repository button for editors and instructors in LocalVC Nov 28, 2024
Copy link

coderabbitai bot commented Nov 28, 2024

Walkthrough

The changes in this pull request involve modifications to the code-editor-tutor-assessment-container component in an Angular application. The updates introduce conditional rendering logic based on user permissions, specifically checking if the user has at least editor permissions before displaying a link to their independent repository. Additionally, a new function for generating local repository links has been added to the navigation utilities, enhancing the component's functionality without altering existing error handling or control flow.

Changes

File Change Summary
src/main/webapp/app/exercises/programming/assess/code-editor-tutor-assessment-container.component.html Modified conditional rendering logic to check user permissions before displaying repository links.
src/main/webapp/app/exercises/programming/assess/code-editor-tutor-assessment-container.component.ts Added localRepositoryLink and isAtLeastEditor properties; updated initialization logic in ngOnInit.
src/main/webapp/app/utils/navigation.utils.ts Introduced getLocalRepositoryLink function to generate URLs for local repositories based on various parameters.

Possibly related PRs

Suggested labels

tests, bugfix, programming

Suggested reviewers

  • JohannesStoehr
  • az108
  • krusche
  • florian-glombik

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

🧹 Outside diff range and nitpick comments (4)
src/main/webapp/app/utils/navigation.utils.ts (1)

155-164: Implementation aligns well with PR objectives

The function successfully implements the URL generation needed for the "open repository" feature, supporting both regular and exam scenarios. This enables instructors to access students' repositories during assessment, which was the main goal of the PR.

Consider adding unit tests to verify the URL generation for different scenarios:

  • Regular course repository access
  • Exam repository access
  • Test run repository access
src/main/webapp/app/exercises/programming/assess/code-editor-tutor-assessment-container.component.html (1)

108-114: Consider enhancing link accessibility.

While the implementation is solid, consider adding an aria-label to provide more context for screen readers, especially since the link contains an icon in the local repository case.

         <a
             class="ms-2 me-5"
             href="{{ participation?.userIndependentRepositoryUri }}"
             target="_blank"
             rel="noopener noreferrer"
+            aria-label="{{ 'artemisApp.exerciseAssessmentDashboard.programmingExercise.goToRepo' | translate }}"
             jhiTranslate="artemisApp.exerciseAssessmentDashboard.programmingExercise.goToRepo"
         ></a>

And for the local repository link:

         <a
             class="ms-2 me-5"
             [routerLink]="localRepositoryLink"
             target="_blank"
             rel="noopener noreferrer"
+            aria-label="{{ 'artemisApp.exerciseAssessmentDashboard.programmingExercise.goToRepo' | translate }}"
             jhiTranslate="artemisApp.exerciseAssessmentDashboard.programmingExercise.goToRepo"
         >

Also applies to: 116-124

src/main/webapp/app/exercises/programming/assess/code-editor-tutor-assessment-container.component.ts (2)

87-87: Add JSDoc documentation for the new properties.

While the property names are self-descriptive, adding JSDoc documentation would improve maintainability by explaining:

  • The purpose of localRepositoryLink array
  • The implications of isAtLeastEditor flag
  • When these properties are used

Example documentation:

+/** Array containing the repository link segments for local version control */
 localRepositoryLink: string[];

+/** Flag indicating whether the current user has at least editor permissions */
 isAtLeastEditor = false;

+/** FontAwesome icon for external links */
 faExternalLink = faExternalLink;

Also applies to: 92-92, 116-116


193-193: Consider using explicit boolean conversion.

The code is functionally correct, but the boolean conversion could be more explicit for better readability.

Consider this refactor:

-this.isAtLeastEditor = !!this.exercise.isAtLeastEditor;
+this.isAtLeastEditor = Boolean(this.exercise.isAtLeastEditor);

The initialization of localRepositoryLink is well-structured and includes all necessary parameters.

Also applies to: 201-208

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4eaba4e and c857506.

📒 Files selected for processing (3)
  • src/main/webapp/app/exercises/programming/assess/code-editor-tutor-assessment-container.component.html (1 hunks)
  • src/main/webapp/app/exercises/programming/assess/code-editor-tutor-assessment-container.component.ts (4 hunks)
  • src/main/webapp/app/utils/navigation.utils.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/main/webapp/app/exercises/programming/assess/code-editor-tutor-assessment-container.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/programming/assess/code-editor-tutor-assessment-container.component.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/main/webapp/app/utils/navigation.utils.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

🔇 Additional comments (3)
src/main/webapp/app/utils/navigation.utils.ts (1)

155-164: ⚠️ Potential issue

Several improvements needed for the getLocalRepositoryLink function

  1. The test run case appears to return an assessment URL instead of a repository URL, which seems inconsistent with the function's purpose.
  2. Missing JSDoc documentation as required by the coding guidelines.
  3. Return type annotation should be explicit for better type safety.

Here's the suggested implementation:

+/**
+ * Generates a URL array for accessing a local repository
+ * @param courseId - The ID of the course
+ * @param exerciseId - The ID of the exercise
+ * @param participationId - The ID of the participation
+ * @param exerciseGroupId - The ID of the exercise group (optional, default: 0)
+ * @param examId - The ID of the exam (optional, default: 0)
+ * @param isTestRun - Flag indicating if this is a test run (optional, default: false)
+ * @returns Array of URL segments for router navigation
+ */
-export const getLocalRepositoryLink = (courseId: number, exerciseId: number, participationId: number, exerciseGroupId: number = 0, examId = 0, isTestRun = false): string[] => {
+export const getLocalRepositoryLink = (courseId: number, exerciseId: number, participationId: number, exerciseGroupId: number = 0, examId = 0, isTestRun = false): string[] => {
     if (isTestRun) {
-        return ['/course-management', courseId.toString(), 'exams', examId.toString(), 'test-runs', 'assess'];
+        return ['/course-management', courseId.toString(), 'exams', examId.toString(), 'test-runs', 'repository'];
     }
     const suffix = ['programming-exercises', exerciseId.toString(), 'participations', participationId.toString(), 'repository'];
 
     return examId > 0
         ? ['/course-management', courseId.toString(), 'exams', examId.toString(), 'exercise-groups', exerciseGroupId.toString(), ...suffix]
         : ['/course-management', courseId.toString(), ...suffix];
 };

Let's verify the usage of this function and similar patterns in the codebase:

src/main/webapp/app/exercises/programming/assess/code-editor-tutor-assessment-container.component.html (1)

106-125: LGTM! Clean implementation of repository access controls.

The implementation correctly follows the requirements by:

  • Gating repository access to users with editor permissions
  • Supporting both local and external repository scenarios
  • Using proper security attributes for external links
  • Following the new Angular @if syntax
src/main/webapp/app/exercises/programming/assess/code-editor-tutor-assessment-container.component.ts (1)

32-32: LGTM: Import statements are properly organized.

The new imports follow Angular's style guide and are correctly placed with related imports.

Also applies to: 36-36

coderabbitai[bot]
coderabbitai bot previously approved these changes Nov 28, 2024
Copy link

@HawKhiem HawKhiem 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.

The open repository button is indeed only visible for instructor

Screenshot 2024-11-28 232422
Screenshot 2024-11-28 232433
Screenshot 2024-11-28 232720

@github-actions github-actions bot mentioned this pull request Nov 29, 2024
20 tasks
Copy link

@sawys777 sawys777 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 worked as described

Copy link
Contributor

@florian-glombik florian-glombik left a comment

Choose a reason for hiding this comment

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

Tested as editor on ts2 for a course and an exam programming exercise, worked as described

Copy link
Contributor

@coolchock coolchock left a comment

Choose a reason for hiding this comment

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

tested in testing session, works as expected

Copy link
Contributor

@kaancayli kaancayli left a comment

Choose a reason for hiding this comment

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

Tested during testing session. Works as expected. Code LGTM

Copy link
Contributor

@FelixTJDietrich FelixTJDietrich 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 TS2 with instructor and tutor and it worked as expected, for tutors the button is not visible and for instructors it is.

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!) maintainer-approved The feature maintainer has approved the PR ready to merge
Projects
Status: Maintainer Approved
Development

Successfully merging this pull request may close these issues.

7 participants