When creating hands on exercises, how do you create and maintain separate views of similar code for labs, solutions, printed student guides, printed lab guides, and projected images?
For example, the following 3 views may be interesting: 1. Solution: A complete, debugged, production-ready solution. 2. Lab: A "starter" file with scaffolding that works to exercise the exercise, but with critical code fragments removed, and extra comments (or POD) as introduction and directions for the student. 3. Student Guide (or Projected Image) : A printable (projectile) subset of code, with scaffolding replaced by ellipses or comments, and main points highlighted. Extra points: 1. The "super source" uses a standard file format (XML, Perl) so that editor syntax highlighting can work. 2. The labs pass "perl -c" and run, even though parts are missing. 3. The projected images pass "perl -c", even though they're colorized and highlighted. 3. It integrates Test::Simple or Test::More. 4. The lab file "view" has $Test::More::TODO in blocks around the gutted/failing parts. 5. Running prove(1) passes the solution and fails the lab. 6. Projected Image has colorized syntax. 7. Student Guide has instructor supplied highlighting and annotations. I've been using the "obvious" method of being a digital ditch-digging, money at a typewriter. It's not great. I'm a human. I make mistakes and oversights. I change one but hot the other. The "ultimate" method seems to require a XML-like folding-editor that exists only in my mind. Where have you found the sweet spot? Michael P.S. Simplified "projected views" follow. I couldn't simulate the emboldened and colorized text, but I'm sure you get the ides. Solution ================================================================ Solution ================================================================ #! /usr/bin/perl use warnings; use strict; # Initialize hash... my %color_of = { # key value # fruit color apple => 'red', pear => 'yellow', banana => 'yellow', ); # Add a lemon... $color_of{lemon} = 'yellow'; # Age a banana... $color_of{banana} = 'brown'; # Loop through all the keys (fruits)... my $fruit (sort keys %color_of) { # Look up the value (color)... my $color = $color_of{$fruit}; # Display the key/value (fruit/color)... print "A $fruit is $color\n"; } Lab ================================================================ Lab ================================================================ #! /usr/bin/perl use warnings; use strict; =begin lab_guide In this exercise you will create a hash, add to it, delete from it, iterate over it, and display it. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque mi. Cras sodales purus et magna. Praesent nec est. Sed quis magna in mauris luctus laoreet. =end # Initialize hash... =begin lab_guide # Step 1. Create a %color_of hash that allows you to look up a fruit (key) and find its color (value). Initialize it with at least 4 fruit/color (key/value) pairs. =end my %color_of = { # key value # fruit color =begin lab_guide ## <<Your code goes here.>> =end ); # Add a lemon... =begin lab_guide # Step 2. Lemons are yellow. =end # Age a banana... =begin lab_guide # Step 3. The banans sat around too long. They are now brown. =end $color_of{banana} = 'brown'; =begin lab_guide Use a 'forach' loop and the 'keys' operator on the %color_of hash to iterate over all the keys (fruits). Inside the body, look up the value (color), then display both. =end Projected image ================================================================ Projected image ================================================================ my %color_of = { apple => 'red', pear => 'yellow', [....] ); $color_of{lemon} = 'yellow'; [...] my $fruit (sort keys %color_of) { my $color = $color_of{$fruit}; print "A $fruit is $color\n"; } -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED]