Changes between Version 21 and Version 22 of BoltTutorial


Ignore:
Timestamp:
Aug 18, 2008, 2:39:06 PM (16 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BoltTutorial

    v21 v22  
    1818 * Visit http://a.b.c/test/create_account.php and create an account for yourself.
    1919 * Visit http://a.b.c/test_ops/bolt_admin.php. Follow the instructions to create the Bolt database, then create a course named "Identifying California conifers" with short name "conifer1".
    20  * Copy the files from http://boinc.berkeley.edu/bolt_example to ~/projects/test/html/.
     20 * Check out the Bolt example files:
     21{{{
     22svn co http://boinc.berkeley.edu/svn/trunk/bolt_examples
     23}}}
     24and move them to the corresponding subdirectories of ~/projects/test/html/.
    2125
    2226== Lessons and sequences ==
    2327
    24 Let's start with a simple course consisting of 13 lessons.
     28Our first example is a course consisting of 13 lessons.
    2529Each lesson consists of a PHP or HTML file.
    26 The first lesson is '''conifer_intro.php''':
     30For example, the first lesson is
     31[/browser/trunk/bolt_examples/user/conifer_intro.php conifer_intro.php].
     32
     33The course structure is defined by a "course document",
     34[/browser/trunk/bolt_examples/inc/conifer1.php].
     35
     36A course document is like an outline for the course;
     37it is a hierarchy of '''units'''.
     38The bottom-level unites are '''lessons''' and '''exercises'''.
     39Each lesson is specified by:
    2740{{{
    28 <?php
    29 
    30 echo "
    31 <h2>California conifers</h2>
    32 
    33 Throughout California's Sierra Nevada mountains,
    34 and especially at high altitudes,
    35 the dominant plants are tall, straight trees called <b>conifers</b>.
    36 Conifers are remarkable in many ways:
    37 <ul>
    38 <li> They have existed in approximately their current form
    39 for 240 million years.
    40 <li>
    41 They display remarkable tenacity and adaptibility,
    42 managing to grow in the most unlikely places:
    43 <img src=jeffrey_pine.jpg>
    44 <p class=caption>A Jeffrey pine growing on granite in the High Sierra</p>
    45 <li> The largest living thing is a conifer:
    46 the General Sherman, a Giant Sequoia in Sequoia National Park.
    47 Its trunk volume is 52,500 cubic feet.
    48 <img src=general_sherman.jpg>
    49 <li>
    50 The oldest known living thing is a conifer:
    51 a 4,500-year-old bristlecone pine in the White Mountains
    52 (a mountain range that neighbors the Sierra Nevada).
    53 <img src=bristlecone-pine.jpg>
    54 <p class=caption>A bristlecone pine.</p>
    55 </ul>
    56 
    57 This course will teach you how to identify
    58 the most common types of California conifers.
    59 ";
    60 ?>
     41lesson(
     42   filename("file_name")
     43)
    6144}}}
    6245
    63 The course structure is defined by '''conifer1.php''':
     46The higher-level units are '''Bolt control structures'''.
     47In this example we use just one structure: '''sequence'''.
     48The syntax for a sequence is:
    6449{{{
    65 <?php
     50sequence(
     51   name("Name of the sequence"),
     52   lesson(filename("Filename")),
     53   [ ... other units ]
     54)
     55}}}
    6656
    67 require_once("../inc/conifer.inc");
     57Bolt control structures can be nested:
     58for example, the units in a sequence may include other sequences
     59as well as lessons and exercises.
    6860
    69 function intro_lessons() {
    70     return sequence(
    71         name('intro lessons'),
    72         lesson(
    73             title('Introduction'),
    74             filename('conifer_intro.php')
    75         ),
    76         lesson(
    77             title('Conifers and deciduous trees'),
    78             filename('conifer_decid.php')
    79         ),
    80         lesson(
    81             title('Conifers taxonomy'),
    82             filename('taxonomy.html')
    83         )
    84     );
    85 }
    86 
    87 function cypress_lessons() {
    88     return sequence(
    89         name('Cypress genera'),
    90         lesson(
    91             title('Incense-Cedar'),
    92             filename('incense-cedar.html')
    93         ),
    94         lesson(
    95             title('Juniper'),
    96             filename('juniper.html')
    97         ),
    98         lesson(
    99             title('Coast Redwood'),
    100             filename('coast-redwood.html')
    101         ),
    102         lesson(
    103             title('Giant Sequoia'),
    104             filename('giant-sequoia.html')
    105         ),
    106         lesson(
    107             title('Red Cedar'),
    108             filename('red-cedar.html')
    109         )
    110     );
    111 }
    112 
    113 function pine_lessons() {
    114     return random(
    115         name('Pine genera'),
    116         lesson(
    117             title('Pines'),
    118             filename('pine.html')
    119         ),
    120         lesson(
    121             title('Spruces'),
    122             filename('spruce.html')
    123         ),
    124         lesson(
    125             title('Douglas Fir'),
    126             filename('douglas-fir.html')
    127         ),
    128         lesson(
    129             title('Hemlock'),
    130             filename('hemlock.html')
    131         ),
    132         lesson(
    133             title('Firs'),
    134             filename('fir.html')
    135         )
    136     );
    137 }
    138 
     61The course document is a PHP file.
     62It must return a Bolt control structure.
     63In this case, this is done as follows (lines 75-79):
     64{{{
    13965return sequence(
    14066    name('course'),
     
    14470);
    14571
    146 ?>
     72}}}
    14773
    148 }}}
     74You can use the expressive power of PHP to simplify
     75and organize your course document.
     76For example:
     77
     78 * line 3: we include a separate file, '''conifer.inc''', which defines page header and footer functions.
     79 * lines 5, 23 and 49: we define functions '''intro_lessons()''', '''pine_lessons()''' and '''cypress_lessons''', each of which returns a sequence for a section of the course.
    14980
    15081Diagramatically, the course structure is:
     
    16091[[Image(bolt_l1.jpg, nolink)]]
    16192
    162 Note that below your lesson Bolt has added some navigation links
     93Note that below the lesson, Bolt has added some navigation links
    16394and a form to ask questions.
    16495Click on the "Next" button.
     
    174105it will work even if you go to a different computer).
    175106
    176 Now visit http://a.b.c.test/bolt.php again,
    177 and click on "History".
    178 You'll see something like:
    179 
    180 [[Image(bolt_history.jpg, nolink)]]
    181 
    182 Bolt has recorded your course interactions and their timing,
    183 in its database; this is used for course analytics (see part III of this tutorial).
    184 
    185107[BoltTutorialExercises Continue to Part II]
    186108