Type: New Feature
Affects Version/s: 1.9.1
Fix Version/s: None
Component/s: Question type: Sojunit
Environment:I have been developing this on Linux, but it should work on Windows as well. I have tried it out on Firefox. It should definitely work on Moodle 1.9.2+ and with some changes described in help.txt-file it should work on 1.8.2+ (haven't tested it again though).
I have developed a new question-type called sojunit and want to share it with the community.
Tim Hunt suggested me putting it into the contrib-tracker in order to have the latest version to work on - while still debugging.
I want to thank Tim Hunt for his great help while implementing this question-type!
In the question-type there is a section that includes 'Source Code' and 'Selected Source Code'. This won't work without installing the Source-Code-question-type (see attachment).
I have been thinking about creating quizzes for computer science classes and created a new architecture for this purpose with following idea:
In computer science classes the usage of source codes is essential. Corresponding to a given Source-Code-question-type (which I am still working on) which simply displays a nicely syntax-highlighted source code you can create a following group of questions. So the idea is to separate the source code from the questions.
You may display a Source-Code with its corresponding questions on one page and make a page break before the next group while organizing the questions for a quiz.
You may reference from this single question e.g. to special code lines of code fragments of the displayed Source Code to ask questions. Be creative! wink
Maybe this feature matches more for for example the multichoice or regexp question types (which I will post soon). But I wanted to enable this also in this question type.
The following is a copy of my Readme.txt-file inside of my plugin - this way you can get an idea of what it does:
For computer science courses this question type allows a student to type source code for a given interface in Java.
In case the student response compiles the response gets graded automatically. This way the teacher can save time for corrections. Otherwise the teacher needs to grade the student response manually (in Results-tab -> Overview-tab -> click on a students attempt -> a questions "Make comment or override grade"-link) in order to give partial scores instead of none.
After the quiz has been taken the given source code can be seen nicely syntax-highlighted in the gradings. In the quizzes "Results->Item analysis" the compiler or execution output get displayed for each students attempt. This way you can get a better overview about the problems of your students in coding.
There is also a security manager which checks for non-proper student-responses. This way you should not worry about the student messing up the system.
General Quiz settings
It is required to leave the quiz in Adaptive Mode in order to get the compiler outputs displayed. In dependence of the Adaptive Mode used you need to leave "Penalty factor" to "0" in question-settings. This way the student won't get penalties subtracted when pressing the "Submit"-button in order to see if his/her code compiles.
For an "exam" and "exercise with grading" in quiz-options set e.g. "Attempts allowed" to "1 attempt" and "Grading method" to "Last attempt". This way the student can send in their final answer once using "Submit all and finish"-button but because of the Adaptive Mode they can "Submit" their code several times for compilation tests.
If several Junit-questions used in a quiz - for usability reasons it is recommended to put one question on a page at a time using "page breaks". It is also possible to put several Junit-questions on one page though.
The idea of which output to display at what time for which test type is as follows:
- Types: exams, exercise-sheets with grading and exercises without grading:
gets displayed always
- Types: exams, exercise-sheets with grading:
Gets displayed allways after the quiz has been taken.
Settings: In "Students may review" in quiz-options uncheck in "Immediately after the attempt" "Feedback" so that the execution output does not get displayed and the student does not get extracted or demotivated while taking an exam. In the "exercise-sheets with grading" the student should not get to see this until after the quiz.
- Type: exercises without grading:
Display "immediately after the attempt" to student.
Settings: In "Students may review" in quiz-options in "Immediately after the attempt" leave "Feedback" selected in order to display also the execution output after an attempt to the student.
Given code for student:
Make sure the class and method names used in "Given code for student" are identical with the ones in your test class you want to use for this question. Otherwise the student response won't be executed and you will have to grade each student response manually.
The class names need to be non-public in order to allow several classes to be used in one JUnit-test-file.
Load test class:
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 written in the "Given code for student" HTML-editor.
The number of your implemented test cases need to match the number in "Default question grade". For each test case the student can get 1 point. If you have for example five test cases in your test-file you should set the "Default question grade" to "5". If the response of the student passes all test cases he/she will get 5 points out of 5. Otherwise each failed test case will subtract 1 point of the possible.