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, 5 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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>Worktime, New Tag</title>
  </head>

  <body>
    <h1>Worktime, New Tag</h1>

    <h2>Adding a New Tag</h2>
    <p>
      We will add the tag &lt;blue&gt; to the XML handler. It will
      change all text inside of it to be blue when viewing a webpage.
    </p>

    <ol>
      <li>
	First you will need to add the author role to domcc<br />
	Use the
	CUSR button on the remote, type in the username 'domcc' and then
	add the author role. Logout, and log back in. (You will also need
	to let the webserver have permission to enter domcc's home
	directory, do this by having domcc do <tt>chmod a+x /home/domcc
	</tt>
      </li>
      <li>
	Next create a homework problem. Something simple. In the text
	section of the homework problem. Surround the text of the
	problem with the tag pair &lt;blue&gt; and &lt;/blue&gt;
      </li>
      <li>
	When you view the problem you should see no change. (This is
	because by default browsers ignore tags they are unfamiliar
	with.)
      </li>
      <li>
	Next you will need to edit the londefdef.pm file in the xml
	subdriectory, and we will do the required actions to make a
	new tag handler.
      </li>
      <li>
	First we need to register the tag with the xml parser. Notice
	that at the top of the londefdef.pm file there is a call to
	register, right in front of the <tt>'m'</tt> put <tt>'blue',</tt>.
	Don't forget the comma.
      </li>
      <li>
	Next we need to create 2 functions. &amp;start_blue() and
	&amp;end_blue(). They will be called when the parser sees the
	start and end blue tags.
      </li>
      <li>
	Add 'Code Fragment 1' to the londefdef.pm file. Copy
	londefdef.pm to <tt>/home/httpd/lib/perl/Apache</tt> and
	restart the webserver. This is the last time I will tell you
	this.
      </li>
      <li>
	Go back and view your homework problem. You should see the two
	messages 'Starting the blue tag now!!!' and 'Ending the blue
	tag now!!!', notice that it appears a second time in the
	bottom section, that is because that is a parse of the answer
	target. We need to stop produicng oputput for any target other
	than web.
      </li>
      <li>
	Now change the code to be as in Code Fragment 2.
      </li>
      <li>
	Now it should only appear in the middle of the problem. Now
	lets make it turn the text blue.
      <li>
	Change you code to look like Code Fragment 3
      </li>
      <li>
	Now when you view the problem the text should appear in blue.
      </li>
    </ol>

<h3>Code fragment 1</h3>
    <pre>
sub start_blue {
  my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  my $result='';
  $result='&lt;br /&gt;Starting the blue tag now!!!&lt;br /&gt;';
  return $result;
}

sub end_blue {
  my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  my $result='';
  $result='&lt;br /&gt;Ending the blue tag now!!!&lt;br /&gt;';
  return $result;
}
    </pre>
    
<h3>Code fragment 2</h3>
        <pre>
sub start_blue {
  my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  my $result='';
<b>  if ($target eq 'web') {</b>
      <i>$result='&lt;br /&gt;Starting the blue tag now!!!&lt;br /&gt;';</i>
<b>  }</b>
  return $result;
}

sub end_blue {
  my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  my $result='';
<b>  if ($target eq 'web') {</b>
      <i>$result='&lt;br /&gt;Ending the blue tag now!!!&lt;br /&gt;';</i>
<b>  }</b>
  return $result;
}
    </pre>
<h3>Code fragment 2</h3>
        <pre>
sub start_blue {
  my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  my $result='';
  if ($target eq 'web') {
      <i>$result='&lt;font color="blue"&gt;';</i>
  }
  return $result;
}

sub end_blue {
  my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
  my $result='';
  if ($target eq 'web') {
      <i>$result='&lt;/font&gt;';</i>
  }
  return $result;
}
    </pre>
    <hr>
    <address><a href="mailto:albertel@mileva.lite.msu.edu">Guy Albertelli</a></address>
<!-- Created: Tue Jun 11 10:09:35 EDT 2002 -->
<!-- hhmts start -->
Last modified: Tue Jun 11 11:01:29 EDT 2002
<!-- hhmts end -->
  </body>
</html>

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