37 | | If a lesson is implemented as a PHP script, information about the student is available to it |
38 | | in a global variable $student, |
39 | | This information may be used to customize the page. |
40 | | The available information is: |
41 | | {{{ |
42 | | $student->sex; // 0=unknown, 1=male, 2=female (as in ISO 5218) |
43 | | $student->birth_year; |
44 | | $student->country; |
45 | | $student->name; |
| 37 | If a lesson is implemented as a PHP script, |
| 38 | it can access information about the student viewing the lesson, |
| 39 | as well as its own attributes (specified in the course document; see below). |
| 40 | |
| 41 | |
| 42 | == Exercises == |
| 43 | |
| 44 | Exercises are PHP scripts that call Bolt API functions to create questions. |
| 45 | The exercise API includes the following functions: |
| 46 | {{{ |
| 47 | exclusive_choice( |
| 48 | 'option1', |
| 49 | 'option2', |
| 50 | ... |
| 51 | [ weight(X) ] |
| 52 | ); |
| 53 | }}} |
| 54 | This specifies a multiple-choice question where at most one answer can be chosen. |
| 55 | The correct choice is the first one |
| 56 | (when the question is shown, the choices are presented in a random order). |
| 57 | |
| 58 | An exercise script can contain multiple questions. |
| 59 | If '''weight()''' is given, it specifies this question's grading weight; |
| 60 | the default is 1. |
| 61 | |
| 62 | {{{ |
| 63 | inclusive_choice( |
| 64 | array('option1', true|false), |
| 65 | array('option2', true|false), |
| 66 | [ weight(X) ] |
| 67 | ); |
| 68 | }}} |
| 69 | This specifies a multiple-choice question where any number of answers can be chosen. |
| 70 | |
| 71 | {{{ |
| 72 | image_rect( |
| 73 | image_filename, |
| 74 | array(xmin, xmax, ymin, ymax) |
| 75 | ); |
| 76 | ?> |
| 77 | }}} |
| 78 | This specifies a question where the student clicks on an image; |
| 79 | a correct answer is a click in the indicated subrectangle |
| 80 | ((0,0) is the upper left corner of the image). |
| 81 | |
| 82 | In addition to calling these functions, |
| 83 | an exercise script can intersperse text among the questions. |
| 84 | Example: |
| 85 | {{{ |
| 86 | <?php |
| 87 | echo 'Conifers are so named because:'; |
| 88 | exclusive_choice( |
| 89 | 'They carry their seeds in cones.' |
| 90 | 'They are cone-shaped.', |
| 91 | 'They originated during the Coniceous era.' |
| 92 | ); |
| 93 | ?> |
| 94 | }}} |
| 95 | |
| 96 | The same script is used to generate both the exercise page and the answer page |
| 97 | (where the student gets feedback on their response). |
| 98 | You may want to show different text on these two pages. |
| 99 | This can be done as follows: |
| 100 | {{{ |
| 101 | switch ($bolt_ex->mode) { |
| 102 | case BOLT_MODE_SHOW: |
| 103 | echo "This is the exercise page."; |
| 104 | break; |
| 105 | case BOLT_MODE_ANSWER: |
| 106 | echo "This is the answer page."; |
| 107 | break; |
| 108 | }}} |
| 109 | |
| 110 | |
| 111 | Like lessons, exercises can access student attributes |
| 112 | as well as their own attributes. |
| 113 | |
| 114 | == Attributes == |
| 115 | |
| 116 | Bolt allows arbitrary '''attributes''' to be associated with students and course units. |
| 117 | A few student attributes are pre-defined: country, sex and age. |
| 118 | All other attributes are specified by the course itself, |
| 119 | and are stored in a PHP data structure. |
| 120 | |
| 121 | The attributes of a course unit are specified in the course document. |
| 122 | They might include, for example: |
| 123 | * The [http://en.wikipedia.org/wiki/Reading_level reading level] of the content. |
| 124 | * The [http://en.wikipedia.org/wiki/Theory_of_multiple_intelligences intelligence type] emphasized by the content. |
| 125 | * The unit's level of detail. |
| 126 | * Keywords representing the student interests targeted by the content. |
| 127 | |
| 128 | A lesson or exercise can access its own attributes using: |
| 129 | {{{ |
| 130 | $attrs = item_attrs(); |
| 131 | }}} |
| 132 | |
| 133 | The attributes of a student are accessed using: |
| 134 | {{{ |
| 135 | student_sex(); // 0=unknown, 1=male, 2=female (as in ISO 5218) |
| 136 | student_age(); |
| 137 | student_country(); |
| 138 | student_name(); |
| 139 | $attrs = student_attrs(); // get course-defined attributes |
60 | | |
61 | | == Exercises == |
62 | | |
63 | | Exercises are PHP scripts that call Bolt API functions to create questions. |
64 | | The API is: |
65 | | {{{ |
66 | | exclusive_choice( |
67 | | 'option1', |
68 | | 'option2', |
69 | | ... |
70 | | [ weight(X) ] |
71 | | ); |
72 | | }}} |
73 | | This specifies a multiple-choice question where at most one answer can be chosen. |
74 | | The correct choice is the first one |
75 | | (when the question is shown, the choices are presented in a random order). |
76 | | |
77 | | An exercise script can contain multiple questions. |
78 | | If '''weight()''' is given, it specifies this question's grading weight; |
79 | | the default is 1. |
80 | | |
81 | | {{{ |
82 | | inclusive_choice( |
83 | | array('option1', true|false), |
84 | | array('option2', true|false), |
85 | | [ weight(X) ] |
86 | | ); |
87 | | }}} |
88 | | This specifies a multiple-choice question where any number of answers can be chosen. |
89 | | |
90 | | {{{ |
91 | | image_rect( |
92 | | image_filename, |
93 | | array(xmin, xmax, ymin, ymax) |
94 | | ); |
95 | | ?> |
96 | | }}} |
97 | | This specifies a question where the student clicks on an image; |
98 | | a correct answer is a click in the indicated subrectangle |
99 | | ((0,0) is the upper left corner of the image). |
100 | | |
101 | | In addition to calling these functions, |
102 | | an exercise script can intersperse text among the questions. |
103 | | Example: |
104 | | {{{ |
105 | | <?php |
106 | | echo 'Conifers are so named because:'; |
107 | | exclusive_choice( |
108 | | 'They carry their seeds in cones.' |
109 | | 'They are cone-shaped.', |
110 | | 'They originated during the Coniceous era.' |
111 | | ); |
112 | | ?> |
113 | | }}} |
114 | | |