Question Authors' Forum

-parameters flag for Java

Picture of Anton Dil
-parameters flag for Java
by Anton Dil - Friday, 13 October 2017, 4:41 AM
I may be being a little lazy here in not having tried this out, but is it possible to read students' .class files and use reflection on them? I'm interested in finding out more about what they wrote.  In particular, can we get the .class files to contain parameter name information, as in Java 8 using the -parameters flag with the javac compiler? (And then read those .class files)


Picture of Richard Lobb
Re: -parameters flag for Java
by Richard Lobb - Sunday, 15 October 2017, 7:48 PM

I'm not quite sure what you're trying to achieve, and I'm not really a Java guru, so I think you might have to experiment a bit. Just a couple of comments:

  • If you simply want to analyse what students submitted for your own interest rather than for marking purposes, I'd suggest just downloading all the responses to a quiz as an Excel spreadsheet, via the Moodle Quiz > Results > Responses menu. If you open that spreadsheet in Open Office or Excel and save that as a .csv file you can analyse it at your leisure. I use the Python csv module to pull out the actual answers. I recommend going via Excel rather than exporting all the responses from Moodle as a .csv file, which seems to have issues when the responses are code.
  • If you want to analyse student responses as part of the marking process then your template code will have to be a script that compiles the student code first and then inspects it before running it. I always write such scripts in Python, using the subprocess module for compiling and running the student code in (say) Java. But you can presumably do the scripting in Java. With such a script approach you should be able to pass whatever command-line options you like to the compile and execute phases.