II. P RINCIPIOS D EL D ERECHO P ENAL
2. Principio de legalidad
2.4. Prohibición de retroactividad Lex Praevia
The selection and manipulation of groups of concepts as described in the previous section of this chapter does not cover those scenarios where further modification and usage of the selection is needed later on in the adaptation specification.
To do this, the creation of semi-permanent/permanent objects is needed to store the data. It is proposed that a structure similar to those that appear in many object oriented programming languages is used, namely that of ordered lists.
Indeed the examples in the previous section (where groups of concepts are selected using conditions) can be considered to result in ordered lists, whereupon further operations can be carried out on those lists. For example, the selection and action below:
PM.GM.Concepts[show==false].show=true
can be considered to be composed of two parts, firstly the creation of a list of concepts:
PM.GM.Concepts[show==false] and then the action upon those concepts
.show=true
Even the object GM.Concepts is a list of all concepts in the Goal Domain and can be treated in the same way.
113
6.5.3.1 List Creation
The creation of lists has already been partly covered through conditional selection of concepts. However, in order to enable us to keep complex expressions compact – and also store the list for later access – we can store the list as a variable in the adaptation specification. Operations to add and remove concepts from a list are also necessary.
In LAG, the following extensions to the language have been implemented in LAG 4.0 onwards. To set a variable in the adaptation specification, we use the same syntax as assigning a standard variable type.
UM.accessList = PM.GM.Concepts[access==true]
The above example sets a list of concepts (selected using the condition
PM.GM.Concept.access == true) to the User Model variable
accessList. In the extended grammar, items can be added or removed from a
list after initialization, by using the ‘add’ and ‘remove’ keywords. Both keywords can also be used to group operations on two lists. To add or remove a concept from a list we use the following syntax:
variable {remove|add} concept
For example, if we wished to add the current concept in a for-each loop to a list stored in a custom UM variable ‘accessList’ we would do the following:
114 To remove all accessed concepts from the UM.accessList list we would do the following:
UM.accessList remove UM.GM.Concepts[accessed>0]
The example would remove all the concepts in the list UM.GM.Concepts[accessed>0] from the list stored in the UM.accessList variable.
6.5.3.2 List Manipulation
The extended LAG language also allows list manipulation, including list sorting. Lists in the extended LAG adaptation language are sorted by the order in which the elements were added to them. In the case of a condition filter being used, it will be in the hierarchical order of the content domain. However, a different order can be imposed on a list at a later point, by using the ‘sortBy’ list operation, similar to the standard SQL [77] construct (also appearing in XQuery [89] and other languages).
If we want to carry out operations on the list itself, we need to use the keyword ‘list’, hence the ‘sortBy’ operation would be carried out as in the following example:
GM.Concept[access==true].list.sortBy title {ASC|DSC}
where title is the attribute that is to be sorted, and ASC/DSC stands for an ascending/descending alpha-numerical sort.
This can be, for example, used to return the size of the list:
115 or to select the elements in the list by their position in the list:
GM.Concept[access==true].list[position>1]
The latter continues to be based on XPath [89] syntax, a standard in itself, and used in other standards as well (e.g., in XQuery [89]).
As shown in multiple examples above and in the previous sections, many operations on lists can be carried out on the list as a whole. Take, for example, the following code where we create and then modify a list as a list operation in a single instruction:
UM.introConcepts =
UM.GM.Concept[type=="Introduction"]
UM.introConcepts.show = true
However, this is not enough to be able to treat the concepts in a list individually. For example, an if-else check on a condition would need to be dealt with over multiple lines and on an individual basis.
A change in the LAG grammar is proposed to solve this issue, introducing the ‘for- in’ loop construct used in other scripting languages such as JavaScript [90]. The renaming (via the ‘in’ construct) is needed in order for the referencing mechanism to be shortened, avoiding unnecessarily complicating the code. The syntax for the construct is shown via the following example:
116 for ( c in GM.Concept[type=="Introduction"] ) (
PM.c.show = true )
which loops through each sublesson of type ‘Introduction’, and individually sets each one to be shown. This syntax has the advantage of allowing extra processing to be carried out on each individual concept, if the pedagogical aims require it.