-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughWalkthroughThe 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
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
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Files skipped from review due to trivial changes (1)
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this 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 theall
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
add <-function(a,b){ | ||
return 0 | ||
} | ||
subtract <-function(a,b){ | ||
return 0 | ||
} | ||
multiplication <-function(a,b){ | ||
return 0 | ||
} | ||
division <-function(a,b){ | ||
return 0 | ||
} |
There was a problem hiding this comment.
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)
}
add <-function(a,b){ | ||
return 0 | ||
} | ||
subtract <-function(a,b){ | ||
return 0 | ||
} | ||
multiplication <-function(a,b){ | ||
return 0 | ||
} | ||
division <-function(a,b){ | ||
return 0 | ||
} |
There was a problem hiding this comment.
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?
a <- case$inputs[1] | ||
b <- case$inputs[1] |
There was a problem hiding this comment.
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.
a <- case$inputs[1] | |
b <- case$inputs[1] | |
a <- case$inputs[1] | |
b <- case$inputs[2] |
|
||
if ((a + b == add(a, b)) && | ||
(a - b == subtract(a, b)) && | ||
(a * b == multiplication(a, b)) && | ||
(a / b == division(a, b))) { |
There was a problem hiding this comment.
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!---')
}
a <- case$inputs[1] | ||
b <- case$inputs[1] |
There was a problem hiding this comment.
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.
a <- case$inputs[1] | |
b <- case$inputs[1] | |
a <- case$inputs[1] | |
b <- case$inputs[2] |
@jlge Can you review my PR? |
This is an R autograder designed to grade simple calculator operations(+,-,*,/). Both the source code and the driver program are written in R.