The JavaOnline question type plug-in is implementedusing the API’s of Java Standard Edition 6 (Sun Microsystems Inc, 2009c). NewAPI’s available in Java 6 make it possible for programs to compile source codeand these programs can reside on a remote server other than the Moodle server.The PHP/Java Bridge provides a communication channel between the Moodle server and the Java web server.
Moodle Learning Management System isdesigned and developed in PHP. Moodle has well defined and organized structuresfor each of its modules. There are different types of questions, likemultiple-choice questions, essay questions, description question and numericalquestions. Each of these questions extends default question class from Moodlequestionlib file. This library file provides basic data structure and datamodel that each of the question should implement. This library file providefunctionality such as creating answer field, creating edit form fields,creation of user sessions, resume user sessions, compare user session, storinguser response, delete question type, storing and retrieving responses fromdatabase and so on. These are referred to as “question types” in the MoodleLearning Management System. Developers can use Moodle development templatesthat are available on Moodle web-site to develop new plug-in for the Moodlesub-system.
The User Interface of JavaOnline isdeveloped using Html, Ajax, PHP and core libraries provided by the Moodleenvironment. Each of the question type modules in the Moodle uses the samefolder structure. The root folder for each module has the same name as questiontype. Under this folder, it has db folder that contains information aboutschema for new module. Moodle use XMLDB which xml based database and it isindependent of database provider. Moodle automatically translate xml tables toSQL DML statements and update the database. The lang folder which containsinformation about locale. The new module must contain two files with the samenaming pattern. The files are edit_MODULENAME_form.php and question-type.php.The naming pattern helps Moodle to identify the module’s functionality. Otherthan this, it also has module dependent files which are required for specificfunctionality.
JavaOnline provides two different views oneis for teaches and another for students, as is the case for all question typesin the Moodle. The teacher view allows teachers to create new JavaOnlinequestions by putting information about question. Teachers can put informationincluding Question name, Question text, expected output, Java program forstudents, Allow students to enter arguments and grade details. Teachers canalso specify number of allowable attempts by each student in the quiz creationpage.
This information generates unique question id for JavaOnline Question type and getstored in the database table called question_javaonline. Teacher can modify thequestion or quiz if required. Teacher can also see preview of a student view byclicking on the preview button. The Results tab in the teacher view gives thedetails about list of students with start time of attempt and status of thequiz such as open, completed and re-attempt. The figure 6c shows one openstatus of quiz and another closed quiz by the same student.
Byclicking on the particular student, teacher can drill down to list ofcompilation and execution attempts by that student in the top-bottom mannerwith last execution at the first. Teacher can also see the id of each attemptwith its success of failure status.
Inthe student view, students are provided with Java script enable text area. Thetext area has number of features such as Java syntax highlighting, shows cursorposition and line numbers, search the pattern, change the font size and fullscreen view. These features helps student to understand the Java syntax andmake it more user-friendly.
Students can enter Java program in the text box and click on compile or execute buttons.The execute button only gets enable if student has compiled programsuccessfully. The command line argument lets students to run time arguments totheir program. The compilation and execution sends Ajax based request to theserver and the response get appended back into the student browser without evenwaiting for browser to reload. The interface is design such a way that it worksin any browser. If students try to compile code which might be violating securitypolicy on the server, then response append error message in the browser.
There are three buttons at the end of thebrowser window. The “Save without submitting” button stores student responsebut it does not submit the quiz. The “Submit page” button submits the quiz andstarts new attempt. And the “Submit all and finish” button submits the currentattempt but do not start new attempt.
Eachclick on the compile button compiles the code on the server and returns thestatus of the compilation. It is Ajax based post method call to compileMe()function. The function checks privileges of requesting student and if student’ssession is expired or the student is not enrolled in the particular unit then itredirects it to login page with error message. The compileMe method firstchecks for previous attempts made by that student. It also verifies quiz statusso that students cannot compile program after its due date. If student has notmade any previous requests then it creates new answerId for that question andstores it to database. The javaonline adds three new tables into database. Theyare question_jonlineans, question_jonlinemyans and question_jonlineprogs. Thetable question_jonlineans has unique answerId based on studentId andquestionId. Using this answereId, table question_jonlinemyans stores eachcompilation response and result. The compiled Java program gets stored inquestion_jonlineprogs table. On successful compilation, Execute button getsenable on the browser which allows students to execute their program.
Eachattempt of compilation and execution are visible to teachers. Teachers can seeand browse through the detailed information of error such as line number, errormessage and error code. Teachers can also provide feedback to students. The plug-in also allows teachers to limit thestudents’ compilation and execution by specifying number of attempts allowed byeach student. Each attempt allows student to start question again with the newsession. The number of the session created by the same student gets stored inthe $state->responses. This is visible in the teachers’ view.
The JavaOnline compiler is anothercomponent of JavaOnline developed using Java SE 6 (Sun Microsystems Inc,2009c). This component runs independent from the Moodle server. It is a JARfile which is deployed on the web server. On the start up of the web server,this Jar file gets initialized and checks the path detail where studentsprograms get saved.
Java SE 6 (Sun Microsystems Inc, 2009c) isthe current major release of the Java SE platform. In this release they haveintroduced new package javax.tool that offers interfaces for retrieving andcompiling files passed as strings. Thus clients can locate and run Javacompilers from within a program. The package also pro-vides other interfacesthat generate diagnostics and override file access in order to support thecompilation process (described below).
Thenew JavaCompiler interface of the tool package invokes Java programming languagecompilers from programs. It is JSR 199 specification released in final form(Peter von der Ahé, 3 April, 2007). The interface can create Java classes bycompiling valid Java source, bypassing the previous need to validate byte code,or understand new object models of classes, methods, statements and expressions(David J.Biesack, Dec, 2007). It simplifies and standardizes the compilationprocess by providing one supported mechanism for code generation and loadingthat is not limited to passing a single file of source code. The JavaCompilerrelies on two services: DiagnosticListener and JavaFileManager to generate diagnosticsduring compilation. The following example shows creation of JavaCompilerobject.
The Diagnostic Interface usually reports aproblem at a specific position in a specific file. It supplies error detailslike the line number, column number, start position, end position, error message,source of error and kind of error. It also provides details about warning andinformation messages generated during compilation. The diagnostic listenerwhich is part of diagnostic interface that listen to error messages and it willbe written to default output by means of System.err. There is another classcalled diagnostic collector that has java bean properties which get initializedwhen diagnostic listener finds errors. The following example shows creation ofthe DiagnosticCollector.
TheFileObject Interface is an abstraction tool. In this context file meansabstraction of regular files and other sources of data. For example, a fileobject can be used to represent regular files, memory cache or data indatabase. All methods in this interface might also throw a securityException ifsecurity rules are violated. The StandardJavaFileManager interface serve twopurposes: it reduces the overhead of scanning files and reading Java archive(JAR) files. The following example (Sun Microsystems Inc, 2008) shows a codingpattern.
On successful program compilation, Javacompiler generates byte code in the form of class file. This file containsexecutable code in the form of instruction that Java virtual machine executes.The JavaOnline plug-in then uses Runtime.exec() method to execute. On some ofthe platforms, Runtime.exec() throws stackoverflow exception because of limitedoutput buffer size. To avoid this situation, JavaOnline itself provide inputand output buffers. On the execution, output gets stored in these buffers andpassed back to the user interface. On the execution error, the JavaOnlinefetches errors from System.err to buffer and send back to User Interface. Thefollowing example shows creation of new process using Runtime.exec() method.
AsJavaOnline question type plug-in developed using Java and PHP language,communication between these two different languages was major concern. Thisproblem is solved using PHP/Java Bridge (Jost Bökemeier, n. d.). PHP/JavaBridge is an implementation of a streaming XML-based network protocol, whichcan be used to connect a native script engine with the Java virtual machine.This API works under Java and PHP enable servers. The following example showsthe important library file that needs to be included in the PHP file to createthe Java objects using PHP.