File:  [LON-CAPA] / doc / techtips / worktime-2.html
Revision 1.1: download - view: text, annotated - select for diffs
Fri Jun 28 20:56:50 2002 UTC (22 years, 4 months ago) by albertel
Branches: MAIN
CVS tags: version_2_9_X, version_2_9_99_0, version_2_9_1, version_2_9_0, version_2_8_X, version_2_8_99_1, version_2_8_99_0, version_2_8_2, version_2_8_1, version_2_8_0, version_2_7_X, version_2_7_99_1, version_2_7_99_0, version_2_7_1, version_2_7_0, version_2_6_X, version_2_6_99_1, version_2_6_99_0, version_2_6_3, version_2_6_2, version_2_6_1, version_2_6_0, version_2_5_X, version_2_5_99_1, version_2_5_99_0, version_2_5_2, version_2_5_1, version_2_5_0, version_2_4_X, version_2_4_99_0, version_2_4_2, version_2_4_1, version_2_4_0, version_2_3_X, version_2_3_99_0, version_2_3_2, version_2_3_1, version_2_3_0, version_2_2_X, version_2_2_99_1, version_2_2_99_0, version_2_2_2, version_2_2_1, version_2_2_0, version_2_1_X, version_2_1_99_3, version_2_1_99_2, version_2_1_99_1, version_2_1_99_0, version_2_1_3, version_2_1_2, version_2_1_1, version_2_1_0, version_2_12_X, version_2_11_X, version_2_11_5_msu, version_2_11_5, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0_RC2, version_2_11_0_RC1, version_2_11_0, version_2_10_X, version_2_10_1, version_2_10_0_RC2, version_2_10_0_RC1, version_2_10_0, version_2_0_X, version_2_0_99_1, version_2_0_2, version_2_0_1, version_2_0_0, version_1_99_3, version_1_99_2, version_1_99_1_tmcc, version_1_99_1, version_1_99_0_tmcc, version_1_99_0, version_1_3_X, version_1_3_3, version_1_3_2, version_1_3_1, version_1_3_0, version_1_2_X, version_1_2_99_1, version_1_2_99_0, version_1_2_1, version_1_2_0, version_1_1_X, version_1_1_99_5, version_1_1_99_4, version_1_1_99_3, version_1_1_99_2, version_1_1_99_1, version_1_1_99_0, version_1_1_3, version_1_1_2, version_1_1_1, version_1_1_0, version_1_0_99_3, version_1_0_99_2, version_1_0_99_1, version_1_0_99, version_1_0_3, version_1_0_2, version_1_0_1, version_1_0_0, version_0_99_5, version_0_99_4, version_0_99_3, version_0_99_2, version_0_99_1, version_0_99_0, version_0_6_2, version_0_6, version_0_5_1, version_0_5, version_0_4, stable_2002_july, loncapaMITrelate_1, language_hyphenation_merge, language_hyphenation, conference_2003, bz6209-base, bz6209, STABLE, HEAD, GCI_3, GCI_2, GCI_1, BZ4492-merge, BZ4492-feature_horizontal_radioresponse, BZ4492-feature_Support_horizontal_radioresponse, BZ4492-Support_horizontal_radioresponse
- adding examples of programming in LON-CAPA

    1: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    2: <html>
    3:   <head>
    4:     <title>Worktime, New Tag</title>
    5:   </head>
    6: 
    7:   <body>
    8:     <h1>Worktime, New Tag</h1>
    9: 
   10:     <h2>Adding a New Tag</h2>
   11:     <p>
   12:       We will add the tag &lt;blue&gt; to the XML handler. It will
   13:       change all text inside of it to be blue when viewing a webpage.
   14:     </p>
   15: 
   16:     <ol>
   17:       <li>
   18: 	First you will need to add the author role to domcc<br />
   19: 	Use the
   20: 	CUSR button on the remote, type in the username 'domcc' and then
   21: 	add the author role. Logout, and log back in. (You will also need
   22: 	to let the webserver have permission to enter domcc's home
   23: 	directory, do this by having domcc do <tt>chmod a+x /home/domcc
   24: 	</tt>
   25:       </li>
   26:       <li>
   27: 	Next create a homework problem. Something simple. In the text
   28: 	section of the homework problem. Surround the text of the
   29: 	problem with the tag pair &lt;blue&gt; and &lt;/blue&gt;
   30:       </li>
   31:       <li>
   32: 	When you view the problem you should see no change. (This is
   33: 	because by default browsers ignore tags they are unfamiliar
   34: 	with.)
   35:       </li>
   36:       <li>
   37: 	Next you will need to edit the londefdef.pm file in the xml
   38: 	subdriectory, and we will do the required actions to make a
   39: 	new tag handler.
   40:       </li>
   41:       <li>
   42: 	First we need to register the tag with the xml parser. Notice
   43: 	that at the top of the londefdef.pm file there is a call to
   44: 	register, right in front of the <tt>'m'</tt> put <tt>'blue',</tt>.
   45: 	Don't forget the comma.
   46:       </li>
   47:       <li>
   48: 	Next we need to create 2 functions. &amp;start_blue() and
   49: 	&amp;end_blue(). They will be called when the parser sees the
   50: 	start and end blue tags.
   51:       </li>
   52:       <li>
   53: 	Add 'Code Fragment 1' to the londefdef.pm file. Copy
   54: 	londefdef.pm to <tt>/home/httpd/lib/perl/Apache</tt> and
   55: 	restart the webserver. This is the last time I will tell you
   56: 	this.
   57:       </li>
   58:       <li>
   59: 	Go back and view your homework problem. You should see the two
   60: 	messages 'Starting the blue tag now!!!' and 'Ending the blue
   61: 	tag now!!!', notice that it appears a second time in the
   62: 	bottom section, that is because that is a parse of the answer
   63: 	target. We need to stop produicng oputput for any target other
   64: 	than web.
   65:       </li>
   66:       <li>
   67: 	Now change the code to be as in Code Fragment 2.
   68:       </li>
   69:       <li>
   70: 	Now it should only appear in the middle of the problem. Now
   71: 	lets make it turn the text blue.
   72:       <li>
   73: 	Change you code to look like Code Fragment 3
   74:       </li>
   75:       <li>
   76: 	Now when you view the problem the text should appear in blue.
   77:       </li>
   78:     </ol>
   79: 
   80: <h3>Code fragment 1</h3>
   81:     <pre>
   82: sub start_blue {
   83:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
   84:   my $result='';
   85:   $result='&lt;br /&gt;Starting the blue tag now!!!&lt;br /&gt;';
   86:   return $result;
   87: }
   88: 
   89: sub end_blue {
   90:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
   91:   my $result='';
   92:   $result='&lt;br /&gt;Ending the blue tag now!!!&lt;br /&gt;';
   93:   return $result;
   94: }
   95:     </pre>
   96:     
   97: <h3>Code fragment 2</h3>
   98:         <pre>
   99: sub start_blue {
  100:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  101:   my $result='';
  102: <b>  if ($target eq 'web') {</b>
  103:       <i>$result='&lt;br /&gt;Starting the blue tag now!!!&lt;br /&gt;';</i>
  104: <b>  }</b>
  105:   return $result;
  106: }
  107: 
  108: sub end_blue {
  109:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  110:   my $result='';
  111: <b>  if ($target eq 'web') {</b>
  112:       <i>$result='&lt;br /&gt;Ending the blue tag now!!!&lt;br /&gt;';</i>
  113: <b>  }</b>
  114:   return $result;
  115: }
  116:     </pre>
  117: <h3>Code fragment 2</h3>
  118:         <pre>
  119: sub start_blue {
  120:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  121:   my $result='';
  122:   if ($target eq 'web') {
  123:       <i>$result='&lt;font color="blue"&gt;';</i>
  124:   }
  125:   return $result;
  126: }
  127: 
  128: sub end_blue {
  129:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  130:   my $result='';
  131:   if ($target eq 'web') {
  132:       <i>$result='&lt;/font&gt;';</i>
  133:   }
  134:   return $result;
  135: }
  136:     </pre>
  137:     <hr>
  138:     <address><a href="mailto:albertel@mileva.lite.msu.edu">Guy Albertelli</a></address>
  139: <!-- Created: Tue Jun 11 10:09:35 EDT 2002 -->
  140: <!-- hhmts start -->
  141: Last modified: Tue Jun 11 11:01:29 EDT 2002
  142: <!-- hhmts end -->
  143:   </body>
  144: </html>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>