In the first research phase there was assumed that a teacher preparing tasks to be solved by course participants knows mechanism of the MOODLE platform well and does not have to know issues concerning computer science. So, mechanisms, introduced into this environment, had to be prepared in a way enabling teacher to use his/her skills.
The initial step in the research was to adjust a teacher's window to new functionality, which is XML document structure management. For this purpose, the mod_form.php file for a new activity, called XML, was modified (Figure 2.3). Changes regarded both its construction and logic, it contained. Structure of the window was extended with a few elements. The most important one is the htmleditor named xml_entry (Figure 2.4), which is designed to be filled
with an XML document template structure. Because content of this element will be different for various tasks, the identifier of a task should be entered as well (task_number, Figure 2.5).
The provided XML template, for further use, has to be inserted into the database. Therefore, the validation function, which is run during the process of saving the newly defined activity, was equipped with required logic. Details of a database and credentials can to be provided by a teacher in next four fields (Figure 2.6):
$mform->addElement('text','dbhost',get_string('dbhost', 'xml'));
$mform->addElement('text','dbname',get_string('dbname', 'xml'));
$mform->addElement('text','dblogin',get_string('dblogin', 'xml'));
$mform->addElement('text','dbpassword',get_string('dbpass', 'xml'));
or can be prepared by a module administrator with usage of a setDefault function, as is presented below:
$mform->setDefault('dbhost','moodle_server');
This database, as mentioned above, must possess a special Tag_templates table, in which each tag from a template structure and its level in tags tree are stored in one row. Additionally, this information is complemented by the number of the task being created. However, before it is possible, XML template must be divided into substrings - one for each tag. This operation is also performed by the logic of the validation function. Unfortunately, usage of hmleditor element entailed problems regarding recognizing limiters of tags - e.g. < and >characters. They belong to a set of special symbols of HTML language and are represented by strings in form of < and > respectively. In consequence, obtaining string representing a tag must be preceded by extracting these chars. This problem can be avoided by using textarea elements:
$mform->addElement('textarea','xml_entry',get_string('XML entry','xml'));
$mform->addElement('textarea','synonyms',get_string('Synonyms','xml'));
During the process of XML template transformation a level of a tag is calculated as well. For example, if the aforementioned sample structure was taken into consideration, the result of acting of the validation function would consist of elements presented in the (Table 2.1).
List |
1 |
Univ Name |
2 |
Student |
3 |
BA |
4 |
Master |
4 |
The Validation function is also responsible for checking contents of Tag_template table. If rows of another template for the considered task are found, they are replaced by a newly defined set.
- 2041 reads