Technical description of the MakePage and ReadAnswer applets
 

Introduction

The MakePage and the ReadAnswer Applets are the modules responsible for creation/editing of QuestionPages, respectively displaying the student answers for the QuestionPages.

The two applets are similar in both the way they graphically displays the QuestionPages and the way these pages are stored. In fact most of the Java classes used are shared between the both applications. The applets are constructed using a five layer/module approach, the modules involved are:

The modules are not totally independent of each other but using this concept will aid in understanding how the applets work, Fig 1 is a picture describing the relations between the classes.
                    Fig.1 Schematic description of which class hold references to which.

Below will follow a description of the modules and their classes. For detailed information on the method level please refer to the javadoc generated documentation.


Communication

All communication between an applet and the server is placed in class called DataLoader. There are loosely speaking three types of communication. Retrieval of data, storing of data and command. All these types uses cgi calls and are in fact quite similar.

Retrieval

The retrieval is done by the DataLoader calling an cgi URL on the server using method GET. Depending on the cgi script called, a HTML page with data is returned. The page is parsed by the DataLoader and put into the appropriate data structure.

Example of a retrieval of the students names and cedulas from the server.

Storing

Storing of data involves more information being transferred from the applet to the server than in the retrieval of data case. There can also only be a limited amount of bytes sent if using the GET method. For these reasons the POST method is used for storing of data in the MakePageApplet and the ReadAnswerApplet. The main difference is that the variables are sent using an output stream to the URL and not like in the case with GET, in the URL itself. When storing information the cgi script on the server side parses the variables and saves them on disk, for an example see makeDataFile.perl which creates a data file for a QuestionPage on the server.

Command

Finally the command communication, e.g. delete a QuestionPage, is done in the same way as the retrieval of data (i.e. the cgi script is called with some variables here too). For example to delete a page, the subject that the page belongs to and the name of the page will be sent to rmPage.perl as arguments.


Data structures

There are two classes responsible for holding the data PageData and AnswerData. One new PageData instance is created for each new QuestionPage loaded from the server or created during the current session by the teacher. The PageData class have the information about the question text, the answer(s) and the correct answers for all the QuestionPages subquestions.

The AnswerData class contains information about a students answers to all QuestionPages. One new instance is created for each student that is loaded from the server. Both the PageData and AnswerData have methods that allow easy access to the data. One can for example ask a AnswerData to give the students answer for a specific subquestion on a specific QuestionPage.

The methods in the data structures are responsible for presenting the data in the same way independent of the type of QuestionPage; for example the answer of a student to an alternative QuestionPage will be one of the subquestion alternatives, but for a cross QuestionPage it will be the answer of another subquestion.

The PageData class is used by both applets, the AnswerData class is however only used by the ReadAnswerApplet as the MakePageApplet is not concerned with students. All the PageData and AnswerData objects are currently stored in hash tables in the DataLoader. These hash tables containing PageData and AnswerData objects could in future versions, with advantage, be placed as class variables in their respective classes. This would make the structure a bit more comprehensive.


Graphical Display

The graphical display classes are responsible for displaying the PageData and AnswerData objects to the user. Different graphical components are used depending on the type of QuestionPage. An alternative QuestionPages is for example displayed using a text fields for the question and the alternatives,  the right alternative is selected using radio buttons. When used by the MakePageApplet the graphical display classes must be able to alter the data in the PageData structure whenever the user changes something e.g. the text in the question text field. The classes involved are highly modulated to make it easier to later add new types of QuestionPages.

The classes could be divided into two subgroups, classes displaying only one subquestion and classes responsible for displaying all subquestions in the QuestionPage.

Subquestion display classes

These classes are AltPanel and CrossPanel, both classes extends QuestionPanel. Each class is designed to display its type of subquestion. The QuestionPanel is the super class of both classes. In addition to some basic methods the QuestionPanel class has one TextField and one Label for the question text.

The AltPanel has one TextField,Checkbox and Label  for each of the five alternatives. The CrossPanel has only two TextField and one Label, the extra TextField is used for displaying the number of the correct answer. The labels mentioned are used for displaying the number of the question and the alternative.

The components involved are not active i.e. they do not have any listeners added so they do not invoke any methods when there contents are changed by the user. Instead the subquestion classes have get and set methods allowing the classes described below to set the displayed text, respectively to get the modified text. The panels can be in two modes, one for each of the applets. In ReadAnswerApplet mode most of the components are set to be non editable, as the teacher should only use the applet to look at the students answers and not to modify the QuestionPage, as is the case in MakePageApplet mode.

QuestionPage display classes

These classes are TwoAltPanels and ThreeCrossPanels, the writtenPanel is also part of these classes. Each of these classes are Panels that contains a number of X subquestion Panels, the number X depends on the size of the subquestion panel. The exception is writtenPanel, as the subquestions of the written type are big (two text fields), and therefore can only one subquestion at the time be displayed. Due to this the written type does not have a specific class for each subquestion, instead both the text fields are put directly into the writtenPanel.

Because displaying all the subquestions at the same time is impossible, due to lack of screen space, the QuestionPage display classes uses a card scheme for displaying a QuestionPage. Each card contains X subquestions, thus giving the user the possibility to flip between the different cards to see all the subquestions of a QuestionPage.

To allow the applets to have methods for flipping between and displaying different pages, an interface is used. The interface ShowPanelInterface ensures that all the different Panels works in the same way independent of the type of QuestionPage. All the Panel classes thus implement the ShowPanelInterface. The ShowPanelInterface has methods defined for the following.

 

Core Applet classes

The core Applet classes are ReadAnswerApplet and MakePageApplet. The two Applets provides graphical components and handles user interaction. User actions like for example save QuestionPage and show QuestionPage are handled by calls to the underlying structures.

Some functions as the display of the password window and the loading of QuestionPages and Student Answers are only done at start-up. They are therefore put in the standard applet method init(), which is always called by the browser at the start-up of an applet. As the applets are completely user driven there is no need for the normal applet start() method. Each Applet have one instance of the DataLoader  (see the Communication section above), methods in the DataLoader class are invoked each time an applet wants to communicate with the server, the applet also uses the DataLoader to ask for specific PageData and AnswerData objects.

More common features

Both the applets uses a List to select the current QuestionPage, when the user selects a QuestionPage the applet ask the DataLoader for the corresponding PageData object. Depending on the type of PageData (cross,alt,written), the appropriate Panel is called with putPage(PageData) (see previous section). The student selection in the ReadAnswerApplet works in a similar way except for that the applet asks and sends the selected AnswerData object as well. Both applets also have two buttons used for flipping between subquestions. When clicked, the buttons simply invokes the corresponding method (showNextCard, showPreCard) in the current QuestionPage panel.

Below are some of the specific features for the two applets:

MakePageApplet

ReadAnswerApplet

Html pages

The Html pages containing the applets are of a quite basic nature, i.e. they contain the size of the applet on the page and some parameters. The parameters are mainly used by the DataLoader to know the URL to the cgi scripts etc. Some of them could of course have been retrieved by asking the applet where it came from, but for debugging reasons they are all put explicitly as parameters.

These are the parameters with examples:

Construction of Html applet wrapper pages for the PlugIn

To use the applets using the Java Plug-in, the Html pages have to be modified. This is with out doubt most easily done using the Java Plug-in Html converter provided by Sun. The converter automatically converts a normal applet Html page to a Plug-in page, making the browser call the Plug-in instead of running the applet itself.