The assignment question will be the same for both Python and C++:
Assignment:
Write a program that calculates the sum of the following numbers: 123 + 234 + 43352 and prints the result.
Expected Output:
43709
- Log in to your Moodle site as a teacher.
- Go to the course where you want to add the assignment and Turn editing on.
- In the section where you want to place the assignment, click Add an activity or resource.
- From the list, select Virtual Programming Lab (VPL).
-
Name the activity (e.g., "Sum Calculation in Python and C++").
-
In the Description field, provide instructions like:
- Description for Python: "Write a Python program that calculates the sum of 123, 234, and 43352, and prints the result."
- Description for C++: "Write a C++ program that calculates the sum of 123, 234, and 43352, and prints the result."
-
Under the Submission restrictions section, select both Python and C++ as allowed programming languages.
-
In the Grade section, set up your grading method and assign the maximum grade.
To ensure that students' code is evaluated, you will add an evaluation file.
-
In the Execution options tab:
- Enable Run to allow students to run their programs.
- Enable Evaluation if you want the assignment to be automatically graded.
-
In the Execution files tab:
- Click Create a new file and name it
vpl_evaluate.cases.
- Click Create a new file and name it
-
Add the following content to
vpl_evaluate.casesto check if the output is correct:For Python:
output == "43709\n"For C++:
output == "43709\n" -
Save the
vpl_evaluate.casesfile and the overall assignment.
You can also provide students with a sample template for Python and C++ to help them get started.
-
For Python:
# Python program to calculate sum of 123 + 234 + 43352 result = 123 + 234 + 43352 print(result)
-
For C++:
// C++ program to calculate sum of 123 + 234 + 43352 #include <iostream> using namespace std; int main() { int result = 123 + 234 + 43352; cout << result << endl; return 0; }
You can add these snippets in the Instructions or as a Preloaded code in the VPL interface if you want to guide students.
- Save and return to the course.
- Test the activity by submitting the code as a student to ensure that both the Python and C++ code are evaluated correctly and produce the expected output.
- Assignment: Calculate the total of 123 + 234 + 43352.
- Languages: Python and C++.
- Steps: Add the VPL activity, configure execution options, add evaluation cases, and optionally provide sample code.
Let me know if you need any further customizations or additional test cases!
Here's how students can answer the assignment in Moodle using VPL:
- Log in to Moodle as a student.
- Navigate to the course where the assignment has been posted.
- Find the VPL activity (e.g., "Sum Calculation in Python and C++") and click on it.
- Review the assignment instructions provided by the teacher:
- Task: Write a program that calculates the sum of 123 + 234 + 43352 and prints the result.
- Languages: The assignment can be answered in either Python or C++.
- Click Edit to begin writing your program.
- Select the programming language (either Python or C++) from the dropdown menu.
If the student selects Python, they should write the following code:
# Python program to calculate sum of 123, 234, and 43352
result = 123 + 234 + 43352
print(result)If the student selects C++, they should write the following code:
// C++ program to calculate sum of 123, 234, and 43352
#include <iostream>
using namespace std;
int main() {
int result = 123 + 234 + 43352;
cout << result << endl;
return 0;
}- After writing the code, the student can click on Save.
- To test their program, click on Run.
- The output window will display the result of the program. For this assignment, the expected result is
43709.
- The output window will display the result of the program. For this assignment, the expected result is
- Once satisfied with the result, the student clicks Submit to turn in the assignment for grading.
- The system may automatically evaluate the submission if the teacher enabled auto-grading with test cases (like checking for the output "43709").
- Python code: Write a script that prints the sum of 123, 234, and 43352.
- C++ code: Write a program using
coutto print the sum of the numbers. - Steps: Write the code, run it to test the result, and submit it.
Students should see their output and grades once they have submitted the assignment successfully. Let me know if you need more details!