Changes between Version 41 and Version 42 of BoltRef


Ignore:
Timestamp:
Oct 28, 2008, 2:10:29 PM (16 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BoltRef

    v41 v42  
    2727== Lessons ==
    2828
    29 A '''Lesson''' contains instructional material.
     29A '''lesson''' contains instructional material.
    3030It may be an HTML file or a PHP script that generates HTML.
    3131In either case, the HTML may contain embedded audio, video, Flash, or any other content.
     
    4141
    4242== Exercises ==
     43
     44An '''exercise''' involves student interaction
     45(it may also contain instructional material).
     46It may have a notion of "score", in which each
     47interaction produces a number in [0..1] indicating the correctness of the response.
    4348
    4449Exercises are PHP scripts that call Bolt API functions to create questions.
     
    108113}}}
    109114
    110 
    111 Like lessons, exercises can access student attributes
    112 as well as their own attributes.
     115Like lessons, exercises can access student attributes as well as their own attributes.
    113116
    114117== Attributes ==
     
    140143}}}
    141144
    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).
     145For example, suppose you want to show the student's name in a lesson:
     146{{{
     147echo "Welcome, " . student_name();
     148}}}
     149
     150Course-defined student attributes are modified in
     151'''callback functions''' associated with exercises and exercise sets, as follows:
     152{{{
     153set_student_attrs($attrs);
     154}}}
     155
     156For example, you could have a (non-graded) exercise that asks the
     157student about their interests or education level,
     158and whose callback function records this information in the student's attributes.
    154159
    155160== Course documents ==
     
    157162The structure of a Bolt course is defined by a PHP script called a '''course document'''.
    158163The script calls Bolt API functions to create a hierarchy of '''units'''.
    159 The API is as follows.
     164The course document API is as follows.
    160165
    161166=== Lesson ===
     
    165170lesson(
    166171    filename('lesson_1.php?arg=4'),
    167     [ title('The ecology of a conifer forest'), ]
     172    [ attrs((object) array("name"=>"value")) ]
    168173);
    169174}}}
     
    175180parse_str($bolt_query_string);
    176181}}}
    177  '''title''' :: a name shown to students
     182 '''attrs''' :: the lesson's attributes.
    178183
    179184'''NOTE: the parameters of lesson() and all other course document API functions
     
    186191exercise(
    187192    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
     198The filename and attrs parameters are the same as for '''lesson()'''.
     199
     200If a callback function is specified,
     201it will be called on completion of the exercise.
     202Typically, this function will modify the user attributes based on the score
     203and/or the specific responses to the exercise.
     204The score is available using
     205{{{
     206global $bolt_ex;
     207$score = $bolt_ex->score;
     208}}}
     209The specific responses are available using
     210{{{
     211global $bolt_ex;
     212parse_str($bolt_ex->query_string);
     213}}}
     214
     215The variable names are of the following forms
     216(N is the index of each question: 0, 1, ...).
     217{{{
     218q_N     (exclusive choice)
     219q_N_i   (inclusive choice, item i)
     220pic_N_x, pic_N_y   (image)
     221}}}
    193222
    194223=== Sequence ===
     
    201230    unit2,
    202231    ...
     232    [ attrs(), ]
    203233);
    204234}}}
     
    207237
    208238The '''select''' structure takes a set of units and a 'value function'.
    209 The unit for which this value is greatest is shown.
     239This function is called with a '''$unit''' argument,
     240and can access the unit's attributes using
     241{{{
     242$unit->get_attrs();
     243}}}
     244It can access the student's attributes using the functions listed above.
     245The unit for which the function value is greatest is shown.
    210246The value function may be partly or entirely random.
    211247
     
    222258   unit2,
    223259   ...
    224 );
    225 }}}
    226 Example:
    227 {{{
    228 function value($student, $unit) {
    229     return abs($student->verbal_level - $unit->verbal_level);
     260   [ attrs(), ]
     261);
     262}}}
     263For example, suppose your course has a student verbal level attribute,
     264and you want to select among two lessons based on verbal level:
     265
     266{{{
     267function 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);
    230271}
    231272
    232273select(
    233274    name('course'),
    234     valuator('value'),
     275    valuator('similar_reading_level'),
    235276    lesson(
    236         filename('bolt_sample_lesson1.php')
     277        filename('bolt_sample_lesson1.php'),
     278        attrs((object)array("verbal_level", 9))
    237279    ),
    238280    lesson(
    239281        filename('bolt_sample_lesson2.php')
     282        attrs((object)array("verbal_level", 12))
    240283    ),
    241284);
     
    250293    name('name'),
    251294    [ number(N), ]
     295    [ attrs(), ]
    252296    unit1,
    253297    unit2,
     
    290334    name('name'),
    291335    [ number(N), ]
     336    [ attrs(), ]
    292337    exercise1,
    293338    exercise2,