From 6667efae7acb86f60b0ebd4dabb959bed759bc16 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Mon, 6 May 2013 11:56:16 +0530 Subject: Function to check C-C++ code Added a function which compiles C and C++ code submitted by the student. 1) If compilation is successful, then the submitted code is tested using test-cases. 2) To test the function written by the student, a C++ file calls the function and passes the argument to the function. Then the function checks for the expected return value. 3) If the return value is as expected, then a different set of arguments are passed, and the output is checked. 4) If for all set of arguments the output is as expected then the student code is graded correct else the error is displayed to the student. Changed the way the code is graded. Previously, the algorithm checked the student code for all test-cases. If all the test-cases were satisfied, the last-line of the program was reached and printed "All Correct". So at any point if a test-case fails, the last line is not reached as the program was terminate. When the string "All Correct" was found in the output, the code was graded as RIGHT else WRONG. This is not a proper way for code checking, as the student code *may* contain a print statement with the string('All Correct'), and thus can get program RIGHT even though it is WRONG. So now the student code is tested as follows: 1) The code checks for all test-cases. 2) If all test-cases are satisfied then it returns 0. 3) If any one of the test-case fails, the program is terminated and will return 1. 4) Now depending on the return status(0 or 1), it will grade the code. a) if 0 then RIGHT b) if 1 then WRONG This ensures, no manipulation from student side. --- testapp/templates/exam/question.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'testapp/templates') diff --git a/testapp/templates/exam/question.html b/testapp/templates/exam/question.html index 4f65b64..6ef1e99 100644 --- a/testapp/templates/exam/question.html +++ b/testapp/templates/exam/question.html @@ -76,8 +76,13 @@ function update_time()

{{ question.summary }} (Marks : {{ question.points }})


{{ question.description|safe }} - - {% if error_message %}
ERROR:
{{ error_message }}
{% endif %} + {% if error_message %} +
+ {% for e in error_message.splitlines %} + {{ e|join:"" }} +
+ {% endfor%} +
{% endif %}

{% csrf_token %} -- cgit From 781842c523ccf11b85e0be06e884b2cd585f3cb9 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Wed, 3 Jul 2013 12:41:00 +0530 Subject: clean code --- testapp/templates/exam/question.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testapp/templates') diff --git a/testapp/templates/exam/question.html b/testapp/templates/exam/question.html index 11ea1aa..1203c0e 100644 --- a/testapp/templates/exam/question.html +++ b/testapp/templates/exam/question.html @@ -92,7 +92,7 @@ function update_time() {% endfor %} {% else %} - +
-- cgit