Javaunittest question type
Note: You are currently viewing documentation for Moodle 3.1. Up-to-date documentation for the latest stable version of Moodle is probably available here: Javaunittest question type.
|Javaunittest question type|
The plugin is a new version of the sojunit question type developed by Süreç Özcan for Moodle 1.8 (https://moodle.org/mod/forum/discuss.php?d=102690).
For computer science courses this question type allows a teacher to create Java questions and test the knowledge of students about Java programming. The students type source code for a given interface in Java and the response gets graded automatically. This way the teacher can save time for corrections, which is particularly important when large number of students visit the course.
Figure 1. illustrates the editing view of the javaunittest question type. In this example the teacher created two javaunittest questions. In the first, the students have to implement the factorial function, in the second, the reverse string function. Every question has its own answer field with an interface given by the teacher.
The student implements the javaunitttest question on the question editing form and writes the response in the answer-field. Figure 2. illustrate an attempt.
After finishing the attempt the student submits the response. In case the student response compiles the response gets graded automatically with a JUnit test implemented by the teacher. The JUnit test evaluates the response and returns a value between 0 and 100%, which represents the correctness of the student's Java code. After that, the student's grade is computed automatically by Moodle from this percentage value. With compilation error the student's answer is graded as ,,wrong” with 0% correctness. After executing the grading, the student can view his given answer with a feedback about the test. The student gets all the questions with question text, the student-response and the compiler- or JUnti execution-output. This is illustrated in figures 3 and 4.
You need the following to use this question type:
Java and JUnit have to be installed on your server. In the configuration file the javac, java and junit variables have to be initialized with the proper value. Fore more information see the README.txt file in the plugin's directory.
In order to get an automatic grading for this question you need to create and implement a JUnit test-file. This file needs to match exactly the class and function names used in the source code given by the teacher. This code serves as interface between the JUnit test and the student's response. In the EXAMPLE_FILES directory, three examples were defined. For more information see the README.txt file in the EXAMPLE_FILES directory.