Question Authors' Forum

custom checking C/C++ program student answer

 
Picture of Abhinav Dayal
custom checking C/C++ program student answer
by Abhinav Dayal - Friday, 27 October 2017, 12:59 AM
 

I am trying to create a C program question, where I expect student to write complete program and use dynamic memory allocation using malloc. In Python, I have used template grading to check for certain conditions e.g. if student used list comprehension or not etc. Can anyone help with similar tests that we can perform for a C question.

Picture of Richard Lobb
Re: custom checking C/C++ program student answer
by Richard Lobb - Monday, 30 October 2017, 6:01 PM
 

If you use a Python-scripted C question as explained in the section on implementing new languages, you can perform any checks you like on the student's answer before compiling and running it.

We've recently developed a C question type scripted in Python that uses astyle for checking style and layout, the Python pycparser module for parsing the student's program (letting us do things like check for certain constructs being used and to limit the number of lines per function) and can optionally run the student's code with valgrind. I can let you have it if you like but frankly it's way too complicated (around 900 lines of Python) and I think you'd be better off developing your own question type that just does what you want.

Richard