Changes between Version 20 and Version 21 of BoltTutorial


Ignore:
Timestamp:
Aug 16, 2008, 7:52:41 PM (16 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BoltTutorial

    v20 v21  
    2222== Lessons and sequences ==
    2323
    24 Let's start with a simple course consisting of two lessons.
     24Let's start with a simple course consisting of 13 lessons.
    2525Each lesson consists of a PHP or HTML file.
    26 Create the following files in ~/projects/test/html/user:
    27 
    28 '''conifer_intro.php''' (the first lesson):
     26The first lesson is '''conifer_intro.php''':
    2927{{{
    3028<?php
    3129
    3230echo "
     31<h2>California conifers</h2>
     32
    3333Throughout California's Sierra Nevada mountains,
    3434and especially at high altitudes,
    35 the dominant plants are tall, straight
    36 trees with narrow needle-like leaves.
    37 These trees are called <b>conifers</b>
    38 because they carry their seeds in cones.
    39 <p>
     35the dominant plants are tall, straight trees called <b>conifers</b>.
     36Conifers are remarkable in many ways:
     37<ul>
     38<li> They have existed in approximately their current form
     39for 240 million years.
     40<li>
     41They display remarkable tenacity and adaptibility,
     42managing 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:
     46the General Sherman, a Giant Sequoia in Sequoia National Park.
     47Its trunk volume is 52,500 cubic feet.
     48<img src=general_sherman.jpg>
     49<li>
     50The oldest known living thing is a conifer:
     51a 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
    4057This course will teach you how to identify
    4158the most common types of California conifers.
    42 
    4359";
    4460?>
    45 
    4661}}}
    4762
    48 '''conifer_decid.php''' (the second lesson):
     63The course structure is defined by '''conifer1.php''':
    4964{{{
    5065<?php
    5166
    52 echo "
    53 Trees can be classified into two groups:
    54 <b>coniferous</b> and <b>deciduous</b>.
    55 These groups differ in several ways:
     67require_once("../inc/conifer.inc");
    5668
    57 <ul>
    58 <li> Most conifers are 'evergreen':
    59 they maintain their leaves throughout the year.
    60 Deciduous trees drop their leaves in autumn.
    61 <li> Conifer leaves are either needles or overlapping scales,
    62 whereas deciduous leaves are broad and flat.
    63 
    64 <ul>
    65 ";
    66 
    67 ?>
    68 
    69 }}}
    70 
    71 '''course1.php''' (the 'course document', specifying the course structure
    72 and the page headers and footers):
    73 {{{
    74 <?php
    75 
    76 function bolt_header($title) {
    77     echo "
    78         <link rel=stylesheet href=conifer.css type=text/css>
    79         <table><tr><td width=600 height=126 background=images/conifers.jpg>
    80         <font size=6 color=#ffffff>
    81         &nbsp;Identifying<br>&nbsp;California<br>&nbsp;Conifers
    82         </font>
    83         </td></tr></table>
    84         <p>
    85         <h2>$title</h2>
    86     ";
     69function 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    );
    8785}
    8886
    89 function bolt_footer() {
    90     echo "
    91         <div id='footer'>
    92         <table width=100%><tr><td align=center>
    93         &copy; 2008
    94         </td></tr></table>
    95         </div>
    96     ";
     87function 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
     113function 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    );
    97137}
    98138
    99139return sequence(
    100140    name('course'),
    101     lesson(
    102         name('Introduction'),
    103         filename('conifer_intro.php')
    104     ),
    105     lesson(
    106         name('Conifers and deciduous trees'),
    107         filename('conifer_decid.php')
    108     )
     141    intro_lessons(),
     142    pine_lessons(),
     143    cypress_lessons()
    109144);
     145
    110146?>
    111 }}}
    112147
    113 '''conifer.css''': the CSS stylesheet
    114 {{{
    115 body {
    116     background-color: white;
    117     font-family: "Trebuchet MS", Verdana, Arial, Sans-Serif;
    118     font-size: 16px;
    119     color: black;
    120     width: 800px;
    121 }
    122 
    123 img {
    124     display: block;
    125     margin-top: 10px;
    126     margin-bottom: 10px;
    127     margin-left: auto;
    128     margin-right: auto;
    129     border: 0px;
    130 }
    131 
    132 p.caption {
    133     text-align: center;
    134     font-weight: bold;
    135     margin-left: auto;
    136     margin-right: auto;
    137 }
    138148}}}
    139149