Changes between Version 41 and Version 42 of BoltRef
- Timestamp:
- Oct 28, 2008, 2:10:29 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
BoltRef
v41 v42 27 27 == Lessons == 28 28 29 A ''' Lesson''' contains instructional material.29 A '''lesson''' contains instructional material. 30 30 It may be an HTML file or a PHP script that generates HTML. 31 31 In either case, the HTML may contain embedded audio, video, Flash, or any other content. … … 41 41 42 42 == Exercises == 43 44 An '''exercise''' involves student interaction 45 (it may also contain instructional material). 46 It may have a notion of "score", in which each 47 interaction produces a number in [0..1] indicating the correctness of the response. 43 48 44 49 Exercises are PHP scripts that call Bolt API functions to create questions. … … 108 113 }}} 109 114 110 111 Like lessons, exercises can access student attributes 112 as well as their own attributes. 115 Like lessons, exercises can access student attributes as well as their own attributes. 113 116 114 117 == Attributes == … … 140 143 }}} 141 144 142 For example, suppose you want to use a larger font for female students: 143 {{{ 144 if ($student->sex == 2) { 145 echo '<style type="text/css"> 146 body {font-size: large;} 147 </style> 148 '; 149 } 150 }}} 151 152 An alternative way to vary content based on student attributes is 153 to use separate lesson files, selected in the course document (see below). 145 For example, suppose you want to show the student's name in a lesson: 146 {{{ 147 echo "Welcome, " . student_name(); 148 }}} 149 150 Course-defined student attributes are modified in 151 '''callback functions''' associated with exercises and exercise sets, as follows: 152 {{{ 153 set_student_attrs($attrs); 154 }}} 155 156 For example, you could have a (non-graded) exercise that asks the 157 student about their interests or education level, 158 and whose callback function records this information in the student's attributes. 154 159 155 160 == Course documents == … … 157 162 The structure of a Bolt course is defined by a PHP script called a '''course document'''. 158 163 The script calls Bolt API functions to create a hierarchy of '''units'''. 159 The API is as follows.164 The course document API is as follows. 160 165 161 166 === Lesson === … … 165 170 lesson( 166 171 filename('lesson_1.php?arg=4'), 167 [ title('The ecology of a conifer forest'),]172 [ attrs((object) array("name"=>"value")) ] 168 173 ); 169 174 }}} … … 175 180 parse_str($bolt_query_string); 176 181 }}} 177 ''' title''' :: a name shown to students182 '''attrs''' :: the lesson's attributes. 178 183 179 184 '''NOTE: the parameters of lesson() and all other course document API functions … … 186 191 exercise( 187 192 filename('bolt_sample_exercise1.php') 188 [ title('The ecology of a conifer forest'), ] 189 ); 190 }}} 191 192 The filename and title parameters are the same as for '''lesson()'''. 193 [ attrs((object) array("name"=>"value")) ] 194 [ callback("function_name") ] 195 ); 196 }}} 197 198 The filename and attrs parameters are the same as for '''lesson()'''. 199 200 If a callback function is specified, 201 it will be called on completion of the exercise. 202 Typically, this function will modify the user attributes based on the score 203 and/or the specific responses to the exercise. 204 The score is available using 205 {{{ 206 global $bolt_ex; 207 $score = $bolt_ex->score; 208 }}} 209 The specific responses are available using 210 {{{ 211 global $bolt_ex; 212 parse_str($bolt_ex->query_string); 213 }}} 214 215 The variable names are of the following forms 216 (N is the index of each question: 0, 1, ...). 217 {{{ 218 q_N (exclusive choice) 219 q_N_i (inclusive choice, item i) 220 pic_N_x, pic_N_y (image) 221 }}} 193 222 194 223 === Sequence === … … 201 230 unit2, 202 231 ... 232 [ attrs(), ] 203 233 ); 204 234 }}} … … 207 237 208 238 The '''select''' structure takes a set of units and a 'value function'. 209 The unit for which this value is greatest is shown. 239 This function is called with a '''$unit''' argument, 240 and can access the unit's attributes using 241 {{{ 242 $unit->get_attrs(); 243 }}} 244 It can access the student's attributes using the functions listed above. 245 The unit for which the function value is greatest is shown. 210 246 The value function may be partly or entirely random. 211 247 … … 222 258 unit2, 223 259 ... 224 ); 225 }}} 226 Example: 227 {{{ 228 function value($student, $unit) { 229 return abs($student->verbal_level - $unit->verbal_level); 260 [ attrs(), ] 261 ); 262 }}} 263 For example, suppose your course has a student verbal level attribute, 264 and you want to select among two lessons based on verbal level: 265 266 {{{ 267 function similar_reading_level($unit) { 268 $student_attrs = get_student_attrs(); 269 $unit_attrs = $unit->get_attrs(); 270 return abs($student_attrs->verbal_level - $unit_attrs->verbal_level); 230 271 } 231 272 232 273 select( 233 274 name('course'), 234 valuator(' value'),275 valuator('similar_reading_level'), 235 276 lesson( 236 filename('bolt_sample_lesson1.php') 277 filename('bolt_sample_lesson1.php'), 278 attrs((object)array("verbal_level", 9)) 237 279 ), 238 280 lesson( 239 281 filename('bolt_sample_lesson2.php') 282 attrs((object)array("verbal_level", 12)) 240 283 ), 241 284 ); … … 250 293 name('name'), 251 294 [ number(N), ] 295 [ attrs(), ] 252 296 unit1, 253 297 unit2, … … 290 334 name('name'), 291 335 [ number(N), ] 336 [ attrs(), ] 292 337 exercise1, 293 338 exercise2,