Introduction
The CreateCourse applet is the module responsible for creation, deletion and editing of courses and registration and editing of students.
The CreateCourse applet can be regarded to consist of six modules (classes), which are:
Communication - CreateCourseDataLoader
All communication between the applet and the server are handled by a class called CreateCourseDataLoader. The communication is either performed using the GET or the POST method.
There are loosely speaking three different approaches that the applet use to communicate with the server,
they all use cgi calls to the server and are performed by the applet in a similar manner. The difference is mainly the response from the script, which in the case of Retrieval of data is data to perform some kind of action on and in the case of Storing of data and Command, just information about success or failure of the action. A success is indicated by a "1" as the first character in the response and a failure is indicated by a "0" as the first character in the response, this coding is used for all three types of calls to scripts.Ex: Getting students registered to a course, getting information about a course, etc.
If a retrieval of data from the server is to be performed a method used for server contact in the CreateCourseDataLoader calls a cgi script by using the appropriate URL for the script to contact (e.g. http://www.distancia.edu.uy/cgi-bin/getStudents.perl?subject=TEST). The method used for a retrieval call is GET as it is an idempotent performance (for a deeper technical discussion of the POST and GET methods see the Problems and solutions document). What then happens after the script has been called is that the cgi script returns an answer by writing the answer on STOUT. The calling method in the applet then reads the answer from this STDOUT stream.
An example of a retrieval - retrieving the names and cedulas of the students from the server.
Ex: Students that should be registered, adding access to a course for a teacher, etc.
Storing of data can mean transferring quite some data, but also transferring as little data as does a retrieval. For the transfers which do not fall out of range for the GET method, the method to use can be discussed. Storing of data is not an idempotent performance so it doesn't naturally fall into the use of GET, but as the GET method is less complicated (= faster) it could be considered a good idea to use it if possible. Therefore it is used whenever possible in the CreateCourseApplet. The only storing method (and actually the only method) in CreateCourseDataLoader that does not use GET for it's communication is the method for registration of students. The reason for that is that if more than two students are to be registered, then it is probable that the data to send to the script does not fit into the limits of the GET method. (For a deeper technical discussion of the POST and GET methods see the Problems and solutions document).
If GET is used, a Storing of data call is sent to the server in the same manner as a retrieval call, but the response from the script is only used for success/failure indication. If, on the other hand POST is used, then there is a slightly difference in how the server is contacted, but the response is as in the case of GET only used for indication of success/failure. (For more information about the POST call, see the source code for the method postToScript residing in CreateCourseDataLoader.)
Ex: Creating a course, deleting a course, etc.
The commands sent to the scripts from CreateCourseDataLoader are sent using the GET method. Even though a command isn't idempotent it is, like in the case Storing of data, preferable to use, because of it's advantages in performance. A command call is sent to the server in the same manner as a retrieval call, but the response from the script is only an indication of success or failure.
Data Structure - CoursesHashtable
The data held in CreateCourse applet is handled by the class CoursesHashtable. The data held in CoursesHashtable are the courses that the teacher has access to, and the data of the students for those courses. This is not really true however, the data of students for a particular course is not stored in CoursesHashtable until the course containing the students is marked for editing in the applet. When this is done, the students registered for the course are fetched from the server and put into CoursesHashtable. From hereafter, any consecutive editing of the course does not apply to a fetching from the server as the students are already fetched once.
The class CoursesHashtable is built up using a double nested hash table. Courses are the keys in the hash table and each course then holds one hash table with it's students in it (if the course have been marked for editing). The reason for the use of hash tables holding the courses and their corresponding students is to cut off as many of the time consuming connections to the server as possible. This approach leads to a bit more code in the applet as every change in the state of a course (such as students, access to the course, etc.) has to be updated on both the server and in the data structure of the applet.
The class Info consist of static variables, that are set on startup of the applet and then never changed. Except for the static variable two methods resides in this class too. They are methods for retrieval of the variables that are set to private in the Info class.
Info consist of:
The prompting window -
CCDBean
The CCDBean is a class that is constructed in the init phase (created
in myInit()). It is used for prompting the teacher, to ask the teacher
about a name of a course, if a course should be deleted, the user name
of a teacher that should be granted access for a special course and if
the teachers access should be removed.
There are two parameters that always should be set before showing the window. These are set using the methods setInput(boolean state) and setText(String text).
input, which is the variable set using setInput(boolean state) indicates whether the teacher should write something as an answer or not. If state is set to true, the teacher is expected to give an written answer and not just a Ok or Cancel answer.
theText, which is the variable set using setText(String text) is the text/question the teacher should give an answer to.
There are two buttons in the prompting window, the Ok button and the Cancel button. Ok means yes and Cancel means no when there are questions of the type "Do you want this to happen?". There is always the possibility for a teacher to Cancel the action about to be performed by simply clicking on the Cancel button. If text input is expected from the teacher (input set to true), then the teacher must have written something in the input area to have the possibility to leave the window with a click on the Ok button. If the Ok button is clicked without any answer having been written, then there is an error message showed in the window to the teacher. The teacher can then choose between typing down some answer text and click the Ok button or just click the Cancel button.
The type of answer (Ok or Cancel) is evaluated in the CreateCourseApplet when the prompting window is closed, which is done when a successful click on Ok or a click on Cancel has been performed.
Core Applet class - CreateCourseApplet
CreateCourseApplet is the core applet class. This class provides a graphical interface and handles the user interaction. CreateCourseApplet takes care of the user interaction in the way that it performs the necessary actions e.g. checks of data, and then calls the appropriate methods in the underlying classes for further handling.
On startup the browser calls the method init() that resides in the CreateCourseApplet.
As the applet is completely user driven, there is no need for the start()
method (which for example would be used in a demo).. What init() then does
is initiating the graphical components before calling a method called myInit().
myInit() launches the password dialog window and if the user name/password
is accepted, the initialization continue by having the CoursesHashtable
filled up with the courses that the teacher has access to and the list
with information subjects in the Info panel. The CCDBean dialog
window is also constructed in myInit() with the purpose to be used in future
prompting, but it is not shown. If the user name/password failed (i.e.
the user clicked the Cancel button in the password dialog) the only that
was initialized were then the graphical components, so no actions can be
performed by an unauthorized person.
The graphical interface provided to the user is built up by five panels.
One of the panels is always viewed and the others are then hidden behind
the viewed one, but with there tabs shown on top of the panel. In that
way the only performance needed to view another panel is a click on the
tab for the panel to be viewed and the panel corresponding to the tab is
shown.
There are five different panels:
The panels and the applets behavior on interaction are described here below. For information of "how" to interact with the different panels, please refer to the document UserCreateCourse, where images of the different panels are shown too.Only the important components of the panels are described. The label residing above the student list in the Edit Students panel named "Students" is for example not considered important, and will therefore not be described.
The panel Choose Course is the first panel showed to a teacher when opening the applet. There is a list in this panel, with the courses that the teacher has access to. There are also three buttons: the Ok, Delete and Create New Course buttons.
1.I The Ok button
When the Ok button is clicked, the students registered to the course that is marked in the list with the courses are fetched from the server (or from CoursesHashtable, if they have already been fetched before). The students of the course will then be put into the lists shown in the Register Students and Edit Students panels. The same action as described above is also taken if the teacher double clicks on a course in the list with courses. If there is no course marked in the courses list and the Ok button is clicked, nothing is done, except for an instruction message being showed to the teacher.
1.II The Delete button
If a course is marked in the courses list and the Delete Course button is clicked a window dialog asking the teacher if he wants to delete the course marked is showed. The teacher answers yes by clicking the Ok button in the dialog or no by clicking the Cancel button in the dialog. If Cancel was clicked, the dialog is made invisible (to be used for possible further prompting to the teacher in the future) and nothing else happens. If on the other hand the Ok button is clicked, then the course is deleted from the server and the course is removed from the CoursesHashtable and the list with courses.
If a course is not marked in the courses list and the Delete Course button is clicked, an instruction message is shown to the teacher, but nothing else is performed.
1.III The Create New Course button
If the teacher clicks on the Create New Course button a window dialog (the CCDBean) is launched to the teacher. The teacher is asked to fill in the name of the course to be created.
If a name is filled in and the Ok button in the dialog is clicked, a check is performed on the name of the data to make sure that it did not exist before (just checks that this teacher did not previously have a course with the same name, if there is another teacher with a course named the same, the server will not create the course anyway). If this check works out all right, a method in the CreateCourseDataLoader is called which in turn contacts the server and makes sure that the course is created on the server. If a positive response comes back from the server the CreateCourseApplet is notified about it and the new course is put into CoursesHashtable and the course list is updated. If a negative response is retrieved from the server, the user is notified about the problem (which then could be that the course already existed) and nothing else is performed.
If there is no name filled in in the window dialog and the teacher clicks the Ok button, a message is shown to the teacher, but the dialog is not shut down.
If the teacher rejects the creation of the new course by clicking the
Cancel button, the window is closed and nothing else happens.
The panel "Register Students" is the panel where the teachers registers new students for a course. The panel consists of a list with the students already registered, a text area where the students to be registered should be typed in, a Register button and a Clear button. One feature is that if a student in the student list is double clicked, the Edit Students panel is shown with the student that were double clicked set ready for editing of it's data.
2.I The Register button
If there is nothing written in the text area and the Register button is clicked, nothing will be done except for a message to the teacher.
If there is something written in the text area and the Register button is clicked, the CreateCourseApplet will send the text written in the text area and send it to a register method in the CreateCourseDataLoader. Some checks are then performed on the text and the lines that are considered correct student data lines are sent to a register script. The students (if any) that were registered correctly are then inserted in the CoursesHashtable and the student lists in the Register Students and Edit Students panel are updated with the new students. Depending on if the registration succeeded or failed different messages are shown to the teacher.
2.II The Clear button
If the Clear button is clicked, the text area is cleared from all text.
The panel "Edit Students" is the panel where the teachers edit data for students already registered to a course. The panel consists of two parts. The first part have a list with the students already registered, an Edit Student's Data button and a Delete Student button. The second part have a label with the old data of the student, a text field where the new data for the student should be typed in, a Cancel and a Commit button. The second part is not visible until a student has been marked in the student list of the first part and the Edit Student's Data button has been clicked.
3.I The first part - the Edit Student's Data button
If a student in the student list is marked and Edit Student's Data button is clicked (or if a student in the list is double clicked), the second part of the Edit Students panel will be visible and the data of the marked student can be edited. If no student were marked and the Edit Student's Data button was clicked, a message will be shown to the teacher, but nothing else happens.
3.II The first part - the Delete Students button
If a student in the student list is marked and the Delete Students button is clicked, the student marked will be removed from the registration of the course. The applet does this by calling a delete student method in the CreateCourseDataLoader, which in turn contacts a remove student script on the server. If the removal on the server was successful the marked student is removed from the CoursesHashtable and the student lists in the Register Students and Edit Students panels.
If the Delete Students button is clicked but no student was marked a message is given to the teacher, but nothing else happens.
3.III The second part
When a student is put into "editable mode", which happens when a student is marked in the student list and the Edit Student's Data button is clicked, a bunch of graphical components are made visible. The ones treated here are:
If the cancel button is clicked, the student is removed from the "editable mode" and the second part is made invisible.
3.V The second part - the Commit button
If there is data in the text field and the commit button is clicked, the data from the text field is checked to see if it is in accordance with the stated student syntax. If it is correct an update student method in CreateCourseDataLoader is called, which in turn contact an register or both an remove and an register student script on server. The decision depends on if the cedula number for the student was changed or not in the editing. If the update of the new data for the student succeeds the data for the student is updated in CoursesHashtable and the student lists in the Register Students and Edit Students panels. If the update was not successful on the server the applet is notified about it and a message is shown to the teacher.
If the text field is empty and the commit button is clicked, a message is shown to the teacher, but nothing else happens.
The Info panel consist of a text area, where information is shown, an information topics list and a Show button. It was thought that it might be helpful for the teacher to have help text easily available about each panel and the applet in general.
When viewing the Info panel, information about the last visited panel is shown (using the variable currentTab). To view information about any of the other panels or to view the general applet information the teacher either double clicks the topic of interest in the information topics list or marks the topic and then click the Show button. The information is then fetched from the class Info and put into the text area.
The Edit Course panel is used to view information about a course (creation date and the teachers who have access to it), grant access for other teachers to the course and to remove the teacher's own access to the course.
The panel consists of the Info of Course, Add new user and Remove your access buttons plus a text area to show information in.
5.I the Info of Course button
When the Info of Course button is clicked a get info method in CreateCourseDataLoader is called, which in turn calls the doCourseInfo script on the server. The response from the script is then showed in the text area if it was possible to retrieve the information, if not a message is shown to the teacher.
5.II the Add new user button
If the Add new user button is clicked, a dialog window is displayed asking for the user name of the teacher that will be granted access to this course. If a user name is typed down and the Ok button is clicked, the window is closed and the CreateCourseApplet calls an add user access method in CreateCourseDataLoader, which in turn contact the addCourseAccess script on the server. The script then responds with success/failure and depending of the response a message is shown to the teacher. If Cancel was clicked in the dialog window the dialog is closed and nothing more happens.
5.III the Remove your access button
If the Remove your access button is clicked, a window dialog
is launched to the teacher asking if the teacher wants to remove it's access
to the course or not. If the teacher then clicks the Cancel button in the
dialog, the dialog window is closed and a message is shown to the teacher.
If, on the other hand the teacher clicks the Ok button, the window dialog
is closed and the script removeCourseAccess on the server is contacted.
If the removal of the access succeeds on the server the course is removed
from the CoursesHashtable (and the students registered to the course,
residing in the hash table too) it will also be removed from the course
list in the Choose Course panel. The buttons in the Edit Course panel are
made uneditable, i.e. there cannot be any interaction with them anymore
and when the teacher switches panel from the Edit Course panel all the
panels except for the Choose Course and Info panels are made uneditables
(i.e. they cannot be viewed). They will remain uneditables until a new
course is chosen or created in the Choose Course panel.
The HTML page containing the applet is of a quite basic nature i.e.
it contains the size of the applet on the page and some parameters. The
parameters are used mainly by the CreateCourseDataLoader 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 were all put explicitly as parameters in the HTML page.
These are the parameters with examples