I'm trying to extract CodeRunner student answers for plagiarism detection. But firstly, I'm having trouble extracting student answers from Moodle. To export answers for a quiz, I open a quiz then go to quiz "settings:Results:Responses". Then "Download table data" as json.
Unfortunately it loses
all the \n new line characters from the student's code. It does the same, whether I export to json or csv. So a student's
exported Python-code answer might look like this:
def
evaluate_knapsack_fitness(chromosome, item_values, item_weights): assert len(chromosome)==len(item_values)
assert len(chromosome)==len(item_weights) total_value=0
total_weight=0 for i in range(len(chromosome)):
if chromosome[i]==1:
total_weight+=item_weights[i]
total_value+=item_values[i] if
total_weight>max_knapsack_weight: return 0
else: return total_value
It's
not easy to restore the \n characters. I have a heuristic (any
consecutive 6 spaces not preceded by a space replace to \n) but it's not
working perfectly. For example, when a student has some white space at
the end of their program
line, then it gets it wrong. Is there a better solution? If not, could
coderunner be modified export answers with a "\n" in there or
"<CR>" or something similar to indicate explicitly each new line
character; assuming it is Moodle that forces CodeRunner to remove all those new-line
characters in the first place?
As my reconstructed answers
have slightly incorrect spacings, the indentations are sometimes wrong,
which means JPlag cannot parse the Python code correctly. My current
workaround is to use MOSS, which appears to complain less about
incorrect indentations. I'm still working on the script to parse the
exported student answers into a format MOSS/JPlag can handle. It can
join the answers students make in multiple quizzes, making the
plagiarism detection for small programming exercises slightly more
reliable. If anyone wants this script then let me know.