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 JavaScript programming language template #8859

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

Conversation

magaupp
Copy link
Contributor

@magaupp magaupp commented Jun 23, 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.

Changes affecting Programming Exercises

  • High priority: I tested all changes and their related features with all corresponding user types on a test server configured with the integrated lifecycle setup (LocalVC and LocalCI).
  • I tested all changes and their related features with all corresponding user types on a test server configured with Gitlab and Jenkins.
  • I tested all changes and their related features with all corresponding user types on a test server configured with Gitlab and GitLab CI.

Motivation and Context

Description

This PR adds a programming language template for JavaScript.

The template runs tests using Jest. Student code and test code is transpiled with Babel to enable the use of ES6 modules.

The dependencies are cached in the docker image.

Steps for Testing

Prerequisites:

  • NodeJS installed
  • 1 Instructor
  • 1 Course
  • 1 Student

Setup

  1. Log in as Instructor to Artemis
  2. Navigate to Course Administration
  3. Create a new Programming Exercise
  4. Select Javascript as the programming language
  5. Fill out the required fields and click on Generate
  6. The Template Result should build and fail with 2 test cases
  7. The Solution Result should build and pass with 2 test cases

Local Test

  1. Clone the Test Repository into test/
  2. Clone the Solution Repository into test/assignment/
  3. Enter the test/ directory
  4. Run npm ci
  5. Run npm test
  6. The test should pass

Exercise Creation

  1. Implement a new testable function in test/assignment/src/math.js
  2. Push the changes to the Solution repository
  3. Add a new test for this function in test/src/math.test.js
  4. Push the changes to the Test repository
  5. Clone the Template Repository
  6. Add the function declaration and throw an exception in the body
  7. Push the changes to the Template repository
  8. The Template Result should build and fail with 3 test cases
  9. The Solution Result should build and pass with 3 test cases
  10. Click on the Edit button of the exercise
  11. Add the task with the function name to the problem statement
  12. Click on Save

Exercise Participation

  1. Log in as a Student
  2. Navigate to the exercise
  3. Start the exercise
  4. Solve the exercise incorrectly
  5. The tests should fail
  6. Solve the exercise correctly
  7. The tests should pass

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

Exam Mode Test

  • Test 1
  • Test 2

Test Coverage

Screenshots

Summary by CodeRabbit

  • New Features

    • Added JAVASCRIPT support for programming exercises and continuous integration services.
    • Introduced JavaScript templates for exercises, solutions, and tests, including package.json, .gitignore, and initial code & test files.
    • Added JavaScript build configurations for Jenkins and GitLab CI.
  • Bug Fixes

    • Fixed minor HTML formatting and translation issues in various web components.
  • Chores

    • Updated .gitignore files to exclude node_modules/ and relevant directories.

magaupp and others added 18 commits May 28, 2024 14:52
.gitattributes and .gitignore are ignored usually ignored by gradle, but we need them to be included for programming exercise templates.
This only applies to methods returning multiple Resources using a pattern. All use-cases expect non-directories only.
@github-actions github-actions bot added tests server Pull requests that update Java code. (Added Automatically!) client Pull requests that update TypeScript code. (Added Automatically!) config-change Pull requests that change the config in a way that they require a deployment via Ansible. template labels Jun 23, 2024
@magaupp magaupp temporarily deployed to artemis-test1.artemis.cit.tum.de June 26, 2024 12:55 — with GitHub Actions Inactive
@magaupp magaupp marked this pull request as ready for review June 26, 2024 15:02
@magaupp magaupp requested a review from a team as a code owner June 26, 2024 15:02
Base automatically changed from chore/programming-exercises/allow-all-template-filenames to develop June 27, 2024 18:23
Copy link

coderabbitai bot commented Jun 28, 2024

Warning

Rate limit exceeded

@magaupp has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 35 minutes and 51 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 6f4d3cc and 25d8a33.

Walkthrough

The changes introduce support for the JavaScript programming language across various parts of the Artemis platform. This includes adding JavaScript to supported languages in enums, Continuous Integration (CI) services (including GitLab, Jenkins, and local CI), defining build scripts, project templates, and test configurations. Additionally, minor adjustments in HTML templates improve syntax and logic for handling various UI elements.

Changes

File/Path Summary
.../ProgrammingLanguage.java Added JAVASCRIPT to the ProgrammingLanguage enum.
.../ContinuousIntegrationService.java Updated RepositoryCheckoutPath enum to include JAVASCRIPT in the path settings.
.../GitLabCIProgrammingLanguageFeatureService.java Added JAVASCRIPT support in GitLabCIProgrammingLanguageFeatureService class.
.../JenkinsProgrammingLanguageFeatureService.java Added JAVASCRIPT support in JenkinsProgrammingLanguageFeatureService class.
.../JenkinsBuildPlanService.java Updated the switch statement to support JAVASCRIPT for Jenkins build plan creators.
.../LocalCIProgrammingLanguageFeatureService.java Added JAVASCRIPT to the supported languages in LocalCIProgrammingLanguageFeatureService.
.../TemplateUpgradePolicyService.java Simplified getUpgradeService method by removing specific language cases.
.../javascript/default.sh Added a script for setting up, installing dependencies, and running tests.
.../javascript/regularRuns/.gitlab-ci.yml Introduced a GitLab CI configuration for JavaScript projects with test and upload stages.
.../javascript/exercise/.gitignore,.../solution/.gitignore Ignored node_modules/ in JavaScript exercise and solution templates.
.../javascript/exercise/index.js,.../solution/index.js Added module export statements for JavaScript projects.
.../javascript/exercise/package.json,.../solution/package.json Added configuration for JavaScript projects, naming them "artemis-exercise".
.../javascript/exercise/src/math.js,.../solution/src/math.js Introduced add and multiply functions (unimplemented in exercise, implemented in solution).
.../javascript/readme Added exercise template for math operations tasks.
.../javascript/test/... Introduced test configurations and test cases for JavaScript projects, including babel.config.json and package.json.
.../jenkins/javascript/regularRuns/pipeline.groovy Configured Jenkins build steps for JavaScript projects.
.../programming-exercise.model.ts Added JAVASCRIPT to the ProgrammingLanguage enum in the TypeScript model.
Various HTML files Fixed syntax, removed trailing commas, and adjusted CSS classes and bindings.

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

Outside diff range comments (1)
src/main/webapp/app/entities/programming-exercise.model.ts (1)

Line range hint 40-40: Replace any with a more specific type in WindMetadata.

The use of any for the author field in WindMetadata should be replaced with a more specific type to improve type safety and maintainability.

- author: string | any;
+ author: string | AuthorType; // Assuming AuthorType is defined elsewhere

@@ -97,7 +97,7 @@
<ng-template ngx-datatable-cell-template let-value="value" let-row="row">
<span
[ngClass]="{
'text-danger': row.jobTimingInfo.buildDuration > 240,
'text-danger': row.jobTimingInfo.buildDuration > 240
Copy link

Choose a reason for hiding this comment

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

Insert a comma for correct JavaScript syntax.

The array should be correctly formatted with commas to separate elements.

-                                    'text-danger': row.jobTimingInfo.buildDuration > 240
+                                    'text-danger': row.jobTimingInfo.buildDuration > 240,
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
'text-danger': row.jobTimingInfo.buildDuration > 240
'text-danger': row.jobTimingInfo.buildDuration > 240,
Tools
GitHub Check: client-style

[failure] 100-100:
Insert ,

Comment on lines +1 to +7
export function add(left, right) {
throw new Error('not implemented');
}

export function multiply(left, right) {
throw new Error('not implemented');
}
Copy link

Choose a reason for hiding this comment

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

Enhance the error messages for better user guidance.

The current error messages simply state "not implemented". It would be beneficial for users, especially beginners, to have a more descriptive message guiding them on what needs to be done.

-    throw new Error('not implemented');
+    throw new Error('Function add is not implemented. Replace this placeholder with your own implementation.');
-    throw new Error('not implemented');
+    throw new Error('Function multiply is not implemented. Replace this placeholder with your own implementation.');
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function add(left, right) {
throw new Error('not implemented');
}
export function multiply(left, right) {
throw new Error('not implemented');
}
export function add(left, right) {
throw new Error('Function add is not implemented. Replace this placeholder with your own implementation.');
}
export function multiply(left, right) {
throw new Error('Function multiply is not implemented. Replace this placeholder with your own implementation.');
}

@@ -7,7 +7,7 @@
<span
jhiTranslate="artemisApp.examParticipation.finish"
[translateValues]="{
title: exam.title,
title: exam.title
Copy link

Choose a reason for hiding this comment

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

Comma is required for JSON consistency.

The static analysis tool correctly identified that a comma is missing after title: exam.title. This is necessary to maintain JSON syntax consistency.

-                    title: exam.title
+                    title: exam.title,
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
title: exam.title
title: exam.title,
Tools
GitHub Check: client-style

[failure] 10-10:
Insert ,

@@ -0,0 +1,11 @@
import { math } from 'artemis-exercise';
Copy link

Choose a reason for hiding this comment

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

Correct the import statement to properly import the functions.

The current import statement imports math as an object which would require accessing the functions as math.add and math.multiply. However, the test cases are written as if add and multiply were imported directly.

- import { math } from 'artemis-exercise';
+ import { add, multiply } from 'artemis-exercise';
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { math } from 'artemis-exercise';
import { add, multiply } from 'artemis-exercise';

@@ -27,7 +27,7 @@
<tr
[ngClass]="{
'font-italic text-danger font-weight-bold': exercise.includedInOverallScore === IncludedInOverallScore.NOT_INCLUDED,
'font-italic text-warning font-weight-bold': exercise.includedInOverallScore === IncludedInOverallScore.INCLUDED_AS_BONUS,
'font-italic text-warning font-weight-bold': exercise.includedInOverallScore === IncludedInOverallScore.INCLUDED_AS_BONUS
Copy link

Choose a reason for hiding this comment

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

Insert missing commas in translation interpolation.

There are several places where commas are missing in translation interpolation, which could lead to syntax errors or unexpected behaviors.

- {{ 'artemisApp.exam.examSummary.points.youAchievedWithBonus' | artemisTranslate : { achievedPoints: overallAchievedPoints, normalPoints: maxPoints } }}
+ {{ 'artemisApp.exam.examSummary.points.youAchievedWithBonus' | artemisTranslate : { achievedPoints: overallAchievedPoints, normalPoints: maxPoints } }}

- {{ 'artemisApp.exam.examSummary.points.youAchieved' | artemisTranslate : { achievedPoints: overallAchievedPoints, normalPoints: maxPoints } }}
+ {{ 'artemisApp.exam.examSummary.points.youAchieved' | artemisTranslate : { achievedPoints: overallAchievedPoints, normalPoints: maxPoints } }}

- {{ 'artemisApp.exam.examSummary.points.youAchievedFromBonus.' + studentExamWithGrade.studentResult.gradeWithBonus.bonusStrategy | artemisTranslate : { achievedBonus: studentExamWithGrade.studentResult.gradeWithBonus.bonusGrade, bonusFromTitle: studentExamWithGrade.studentResult.gradeWithBonus.bonusFromTitle } }}
+ {{ 'artemisApp.exam.examSummary.points.youAchievedFromBonus.' + studentExamWithGrade.studentResult.gradeWithBonus.bonusStrategy | artemisTranslate : { achievedBonus: studentExamWithGrade.studentResult.gradeWithBonus.bonusGrade, bonusFromTitle: studentExamWithGrade.studentResult.gradeWithBonus.bonusFromTitle } }}

Also applies to: 111-111, 121-121, 131-131

Tools
GitHub Check: client-style

[failure] 30-30:
Insert ,

…javascript-template

# Conflicts:
#	src/main/java/de/tum/in/www1/artemis/domain/enumeration/ProgrammingLanguage.java
@magaupp magaupp force-pushed the feature/programming-exercises/javascript-template branch from 6f4d3cc to 25d8a33 Compare June 28, 2024 08:15
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!) config-change Pull requests that change the config in a way that they require a deployment via Ansible. ready for review server Pull requests that update Java code. (Added Automatically!) template tests
Projects
Status: Ready For Review
Development

Successfully merging this pull request may close these issues.

None yet

1 participant