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

Created an autograder for R programming language #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Leelavathi-R
Copy link

This is an R autograder designed to grade simple calculator operations(+,-,*,/). Both the source code and the driver program are written in R.

Copy link

coderabbitai bot commented Aug 9, 2024

Walkthrough

Walkthrough

The changes introduce a structured workflow for a calculator lab project in R, enhancing build management with a comprehensive Makefile, basic arithmetic functions, and a robust testing framework. New documentation aids student understanding of project requirements. The implementation sets the groundwork for future enhancements while ensuring correctness through detailed testing and validation processes.

Changes

Files Change Summary
R-calculator/Makefile Introduced a Makefile to automate handout creation, tarfile generation, and cleanup tasks for the lab project.
R-calculator/R-calculator-handout/README Added specifications for the "Two Sum" Python problem, including input/output requirements and optimization criteria.
R-calculator/R-calculator-handout/calculator.R Defined basic arithmetic functions (add, subtract, multiplication, division) that currently return 0, indicating incomplete implementation.
R-calculator/R-calculator-handout/driver.R Created a testing framework in R to validate calculator operations, including a scoring system for test results in JSON format.
R-calculator/R-calculator-handout/tests.R Introduced a structured format for custom test cases to validate the calculator functionality.
R-calculator/R-calculator.rb Defined a module Hello that initializes an assessment for a course, extending the AssessmentBase module.
R-calculator/README.md Provided documentation for the project, detailing assessment requirements, directory structure, and hand-in format.
R-calculator/autograde-Makefile Automated the grading environment setup by defining tasks for extracting files, copying source code, and executing grading scripts.
R-calculator/src/README Specified the intended functionality of calculator.R, noting the input parameters and expected results.
R-calculator/src/calculator.R Introduced arithmetic functions that perform basic calculations, providing a straightforward interface.
R-calculator/src/tests.R Set up a list of custom test cases to facilitate organized testing of the calculator functions.
R-calculator/writeup/calculator.html Created a lab write-up in HTML format describing the objectives and submission process for the calculator assignment.
R-calculator/src/README-handout Added a README specifying the functionality of the calculator.R program and outlining input/output expectations.

Sequence Diagram(s)

sequenceDiagram
    participant Student
    participant Makefile
    participant RScript
    participant TestCases

    Student->>Makefile: Run Makefile
    Makefile->>Makefile: Clean environment
    Makefile->>Makefile: Generate handouts
    Makefile->>RScript: Execute calculator.R
    RScript->>TestCases: Run test cases
    TestCases->>RScript: Validate results
    RScript-->>Student: Output test results
Loading

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1df88db and 33d6818.

Files selected for processing (1)
  • R-calculator/src/README-handout (1 hunks)
Files skipped from review due to trivial changes (1)
  • R-calculator/src/README-handout

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

Outside diff range, codebase verification and nitpick comments (2)
R-calculator/autograde-Makefile (1)

1-7: Consider adding error handling and comments for clarity.

While the Makefile is functional, it lacks error handling and comments that describe each step. Consider adding set -e at the top to stop execution on errors and comments to clarify the purpose of each command.

Additionally, ensure that autograde.tar exists in the expected location when running the all target. You might want to add a check for this file before attempting to extract it.

+ # Extract the autograder archive
  tar xvf autograde.tar
+ # Copy the calculator script to the source directory
  cp -r calculator.R src
+ # Run the R driver script
  (cd src && Rscript driver.R;)
R-calculator/R-calculator.rb (1)

3-11: Clarify module naming and functionality.

The module name Hello is not descriptive of its purpose. Consider renaming it to something more indicative of its functionality.

Additionally, the assessmentInitialize method initializes an empty @problems array but does not populate it. Ensure that this is intentional and that the array will be populated later in the workflow.

module CalculatorAssessment
  include AssessmentBase

  def assessmentInitialize(course)
    super("calculator_assessment", course)
    @problems = []
  end
end

Comment on lines +1 to +12
add <-function(a,b){
return 0
}
subtract <-function(a,b){
return 0
}
multiplication <-function(a,b){
return 0
}
division <-function(a,b){
return 0
}
Copy link

Choose a reason for hiding this comment

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

Implement arithmetic operations.

The functions add, subtract, multiplication, and division currently return 0. These are placeholders and should be implemented to perform the respective arithmetic operations.

If these are intended as stubs for now, ensure that this is documented and that there is a plan to implement the actual logic.

add <- function(a, b) {
  return(a + b)
}

subtract <- function(a, b) {
  return(a - b)
}

multiplication <- function(a, b) {
  return(a * b)
}

division <- function(a, b) {
  if (b == 0) {
    stop("Division by zero error")
  }
  return(a / b)
}

Comment on lines +1 to +12
add <-function(a,b){
return 0
}
subtract <-function(a,b){
return 0
}
multiplication <-function(a,b){
return 0
}
division <-function(a,b){
return 0
}
Copy link

Choose a reason for hiding this comment

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

Implement arithmetic operations in functions.

The functions add, subtract, multiplication, and division are currently placeholders returning 0. They need to be implemented to perform the respective arithmetic operations.

Would you like guidance on how to implement these functions, or should I open a GitHub issue to track this task?

Comment on lines +8 to +9
a <- case$inputs[1]
b <- case$inputs[1]
Copy link

Choose a reason for hiding this comment

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

Fix incorrect variable assignment.

The variable b is incorrectly assigned the value of case$inputs[1]. It should be assigned case$inputs[2] to correctly use the second input value.

-  b <- case$inputs[1]
+  b <- case$inputs[2]
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
a <- case$inputs[1]
b <- case$inputs[1]
a <- case$inputs[1]
b <- case$inputs[2]

Comment on lines +10 to +14

if ((a + b == add(a, b)) &&
(a - b == subtract(a, b)) &&
(a * b == multiplication(a, b)) &&
(a / b == division(a, b))) {
Copy link

Choose a reason for hiding this comment

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

Add error handling for division by zero.

Currently, there is no check for division by zero, which could cause a runtime error.

if (b == 0) {
  print('---Failed! Division by zero---')
} else if ((a + b == add(a, b)) &&
           (a - b == subtract(a, b)) &&
           (a * b == multiplication(a, b)) &&
           (a / b == division(a, b))) {
  is_passed <- is_passed + 1
  print('---Passed!---')
} else {
  print('---Failed!---')
}

R-calculator/R-calculator-handout/README Show resolved Hide resolved
Comment on lines +8 to +9
a <- case$inputs[1]
b <- case$inputs[1]
Copy link

Choose a reason for hiding this comment

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

Fix input assignment for test cases.

The variable b is incorrectly assigned the value of a. It should be assigned the second element of case$inputs.

-  b <- case$inputs[1]
+  b <- case$inputs[2]
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
a <- case$inputs[1]
b <- case$inputs[1]
a <- case$inputs[1]
b <- case$inputs[2]

R-calculator/src/README-handout Outdated Show resolved Hide resolved
@Leelavathi-R Leelavathi-R reopened this Aug 9, 2024
@Leelavathi-R
Copy link
Author

@jlge Can you review my PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant