[LON-CAPA-cvs] cvs: doc /techtips worktime-2.html worktime-modify.html worktime-new-1.html worktime.html
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 28 Jun 2002 20:56:50 -0000
This is a MIME encoded message
--albertel1025297810
Content-Type: text/plain
albertel Fri Jun 28 16:56:50 2002 EDT
Added files:
/doc/techtips worktime-2.html worktime-modify.html
worktime-new-1.html worktime.html
Log:
- adding examples of programming in LON-CAPA
--albertel1025297810
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20020628165650.txt"
Index: doc/techtips/worktime-2.html
+++ doc/techtips/worktime-2.html
<!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 <blue> 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 <blue> and </blue>
</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. &start_blue() and
&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='<br />Starting the blue tag now!!!<br />';
return $result;
}
sub end_blue {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $result='';
$result='<br />Ending the blue tag now!!!<br />';
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='<br />Starting the blue tag now!!!<br />';</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='<br />Ending the blue tag now!!!<br />';</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='<font color="blue">';</i>
}
return $result;
}
sub end_blue {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $result='';
if ($target eq 'web') {
<i>$result='</font>';</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>
Index: doc/techtips/worktime-modify.html
+++ doc/techtips/worktime-modify.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Worktime, Modify Current Handler</title>
</head>
<body>
<h1>Worktime, Modify Current Handler</h1>
<p>
We are going to add a requested feature to loncapa. We want the
name of the file being editted to show up while in CSTR and
editing an html Page
</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
</tt>
<br />
<br />
</li>
<li>
Next we need to find who controls HTML file creation. And
understand where to make a change.
<br />
<br />
</li>
<li>
First we check loncapa_apache.conf, and it says
<pre><tt>
<LocationMatch "^/(res|\~).*\.(xml|html|htm|xhtml|xhtm)$">
SetHandler perl-script
PerlHandler Apache::lonxml
</LocationMatch>
</tt></pre>
</li>
<li>
Next we check the lonxml.pm handler subroutine (line
1180). And read the subrotine. Notice the comment:
<pre><tt>
#
# Edit action? Insert editing commands
#
</tt></pre>
<p> that make take a closer look at the surrounding
code. Looks like the line
<pre><tt>
$result='<html><body bgcolor="#FFFFFF"></body></html>';
</tt></pre>
Creates the webpage that has the edit field in it.
<br /> <br />
</li>
<li>
Lets change that line to be instead:
<pre><tt>
$result='<html><body bgcolor="#FFFFFF">';
$result.='<b>Hey is the correct location?</b>';
$result.='</body></html>';
</tt></pre>
And create a new .html file.
<br /> <br />
</li>
<li>
Looks like we were correct. So let us take a look around and
see if the file name is somewhere in a local variable. Notice
the line <pre>
my $file=&Apache::lonnet::filelocation("",$request->uri);
</pre>
and
<pre>
my $filecontents=&Apache::lonnet::getfile($file);
</pre>
Looks like $file contains the file name ,a $request->uri
would be the requested url.
<br /> <br />
</li>
<li>
Lets put the $request->uri in the message we print. Change
<pre>
$result.=';<b>Hey is the correct location?</b>';
</pre>
to
<pre>
$result.='<b>Editing file: '.$request->uri.'</b>';
</pre>
<br />
</li>
</ol>
<hr>
<address><a href="mailto:albertel@mileva.lite.msu.edu">Guy Albertelli</a></address>
<!-- Created: Tue Jun 11 11:22:10 EDT 2002 -->
<!-- hhmts start -->
Last modified: Tue Jun 11 12:02:22 EDT 2002
<!-- hhmts end -->
</body>
</html>
Index: doc/techtips/worktime-new-1.html
+++ doc/techtips/worktime-new-1.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Worktime Install, Changes Intro, Handler Creation</title>
</head>
<body>
<h1>Worktime Install, Changes Intro, Handler Creation</h1>
<h2> Install </h2>
<p>
To familiarise you with the system, first we will update these
systems from the current STABLE release to the latest release
</p>
<h3> CVS </h3>
<p>
First you will need to check out LON-CAPA from CVS
</p>
<p>
Login
</p>
<p>
<tt>cvs -d :pserver:username@zaphod.lite.msu.edu:/home/cvs login</tt>
</p>
<p> Checkout the LON-CAPA source code </p>
<p>
<tt>cvs -d :pserver:username@zaphod.lite.msu.edu:/home/cvs checkout LON-CAPA</tt>
</p>
<p> Add you current hosts.tab file to the CVS checkout </p>
<p><tt>cp /home/httpd/lonTabs/hosts.tab ~/loncapa/loncom/hosts.tab</tt></p>
<p> Build and Install the newest version of LON-CAPA </p>
<p><tt>cd ~/loncapa/loncom/build</tt></p>
<p><tt>su</tt></p>
<p><tt>make build</tt></p>
<p><tt>make install</tt></p>
<p> Restart the necessary services</p>
<p><tt>/etc/init.d/httpd restart</tt></p>
<p><tt>/etc/init.d/loncontrol restart</tt></p>
<hr />
<h2>Using CVS</h2>
<p> CVS is a code versioning system, that tracks changes in code
and supports multiple features to make multiple developers able
to coexist with the same central repository of code. It has many
options and commands. I highly suggest reading the CVS man page
<tt>man cvs</tt> at some time.
</p>
<p> The most useful commands you will have access to are</p>
<ul>
<li>
<tt>annotate</tt> this will number the code lines and also
print out who, when, and in what version a line was last
modified, this can be useful for tracking down when a change
was made, and discovering the reason behind it.
</li>
<li>
<tt>diff</tt> produces a diff between specified versions of
the code, if given no options if will inform you of the
differences between the current local file and the version
that was checked out. It also accepts all of the options that
the normal diff command accepts. I highly suggest using the -u
option (unified diffs).
</li>
<li>
<tt>log</tt> shows the log messages for a files or files,
those messages should provide a description of what the
changes in the code at least hoped to accomplish.
</li>
<li>
<tt>update</tt> will modify your local files to be 'updated'
to a specific repository version, by default it will update it
to the latest version of the code. You can also uses this
command to select a specific version and prevent cvs from
updating it. This happens by specifying a specific revision, tag
or date when running update. You can remove this 'stickiness'
with the use of the -A option. Also update by default won't
create any new directories that have been added by default, if
you want it to add directories use the -d option.
</li>
</ul>
<p>Common options to cvs commands</p>
<ul>
<li>
<tt>-r</tt> specify a specific file revision, (like -r 1.43)
or a specific tag (like -r STABLE)
</li>
<li>
<tt>-D</tt> specify a specific revision date, is accepts
absolute dates
(ex. 'Nov 30 23:30 2001') or relative dates
(ex. 'last week' or 'today')
</li>
</ul>
<p>
Some commands to try (in the loncom directory)
</p>
<pre>
cvs diff -u -r 1.40 -r 1.43 lond | less
cvs diff -u -r STABLE -r HEAD loncron | less
cvs log loncron | less
cvs update -r STABLE loncron
cvs update -D 'last week'
cvs update -A loncron
cvs annotate loncron | less
</pre>
<h3>Changing Code and detecting errors</h3>
<p>
We will change the lonhomework handler to act differently, and
we will cause it to throw errors
</p>
<ul>
<li>
Bring up loncapa/loncom/homework/lonhomework.html in a text
editor, and introduce a syntax error. (For example delete a ;
somewhere). Then save this version.
</li>
<li>
Open up a terminal and su to root. In this new window copy the
new version of lonhomework.html to the directory
<tt>/home/httpd/lib/perl/Apache</tt>. Then restart the webserver with
<tt>/etc/init.d/httpd restart</tt>
</li>
<li>
Note the error message you have just received.
</li>
<li>
Use the command <tt>cvs diff -u lonhomework.pm</tt> to see what
you changed.
</li>
<li>
Fix the previous error, and then in the subroutine <tt>handler</tt> add a
call to a function that doesn't exist. (Example, on line 438 on
lonhomework.html, add the line
<pre>
&idontexist();
</pre>
</li>
<li>
Repeat the copy, and httpd restart that you did before. And then
go a visit a homework problem.
</li>
<li>
You can find a perl error report in the file
/var/log/httpd/error_log You can use the tail command to quickly
see the end of a file.
</li>
</ul>
<h2>Making a new Handler</h2>
<p>
In the examples below <i>italicised</i> lines are lines of code
that changed from the previous example, <b>bold</b> lines are
lines that have been added to the example, and any time
"username" appears it should be replaced by your specific
username.
</p>
<h3>Example 1</h3>
<pre>
package Apache::workshop;
use strict;
use Apache::Constants qw(:common :http);
sub handler {
my $r=@_[0];
$r->content_type('text/html');
$r->send_http_header;
return OK if $r->header_only;
$r->print("The workshop handler");
return OK;
}
1;
__END__
</pre>
<h3>Example 2</h3>
<pre>
<Location /adm/workshop>
PerlAccessHandler Apache::lonacc
SetHandler perl-script
PerlHandler Apache::workshop
ErrorDocument 403 /adm/login
ErrorDocument 500 /adm/errorhandler
</Location>
<LocationMatch "^/(res|\~).*\.workshop$">
SetHandler perl-script
PerlHandler Apache::workshop
</LocationMatch>
</pre>
<h3>Example 3</h3>
<pre>
package Apache::workshop;
use strict;
use Apache::Constants qw(:common :http);
sub handler {
my $r=@_[0];
$r->content_type('text/html');
$r->send_http_header;
return OK if $r->header_only;
<i>$r->print("The workshop handler is in use by $ENV{'user.name'}");</i>
return OK;
}
1;
__END__
</pre>
<h3>Example 4</h3>
<pre>
package Apache::workshop;
use strict;
use Apache::Constants qw(:common :http);
<b>use Apache::lonnet;</b>
sub handler {
my $r=@_[0];
$r->content_type('text/html');
$r->send_http_header;
return OK if $r->header_only;
<i>$r->print("The workshop handler is in use by $ENV{'user.name'} looking for "
.$r->uri."<br>");</i>
<b>my $file=&Apache::lonnet::filelocation("",$r->uri);</b>
<b>my $contents=&Apache::lonnet::getfile($file);</b>
<b>$r->print($contents);</b>
return OK;
}
1;
__END__
</pre>
<h3>Example 5</h3>
<pre>
package Apache::workshop;
use strict;
use Apache::Constants qw(:common :http);
use Apache::lonnet;
sub handler {
my $r=@_[0];
$r->content_type('text/html');
$r->send_http_header;
return OK if $r->header_only;
$r->print("The workshop handler is in use by $ENV{'user.name'} looking for "
.$r->uri."<br>");
my $file=&Apache::lonnet::filelocation("",$r->uri);
my $contents=&Apache::lonnet::getfile($file);
<b>$contents=~s/simple/complex/g;</b>
$r->print($contents);
return OK;
}
1;
__END__
</pre>
<h3>Example 6</h3>
<pre>
package Apache::workshop;
use strict;
use Apache::Constants qw(:common :http);
use Apache::lonnet;
sub handler {
my $r=@_[0];
$r->content_type('text/html');
$r->send_http_header;
return OK if $r->header_only;
$r->print("The workshop handler is in use by $ENV{'user.name'} looking for "
.$r->uri."<br>");
my $file=&amp;Apache::lonnet::filelocation("",$r->uri);
my $contents=&amp;Apache::lonnet::getfile($file);
$contents=~s/simple/complex/g;
$r->print($contents);
<b>my %hash=&Apache::lonnet::get('workshop',['info']);
#handle any errors
if ($hash{'info'} =~ m/^error:.*/) {
$r->print("<br>An error -$hash{'info'}- occured");
} else {
$r->print("<br>Last time you said $hash{'info'}");
}
if ($ENV{'form.info'}) {
$r->print("<br>Now you say $ENV{'form.info'}");
$hash{'info'}=$ENV{'form.info'};
&Apache::lonnet::put('workshop',\%hash);
}</b>
return OK;
}
1;
__END__
</pre>
<h3>Example 7</h3>
<pre>
<html>
<head><title> A simple file </title></head>
<body>
This is a simple file
</body>
</html>
</pre>
<h3>Example 8</h3>
<pre>
<html>
<head><title> A simple file </title></head>
<body>
This is a simple file
<b><form method="POST" action="/~domcc/a.workshop">
<input type="text" name="info"></input>
<input type="submit" name="Submit"></input>
</form></b>
</body>
</html>
</pre>
<ol>
<li>
You will need to add the author role to the domcc user, 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>
Create the file loncapa/loncom/workshop.pm using your
favourite unix text editor and type in example 1
</li>
<li>
Add example 2 to the file /etc/httpd/conf/loncapa_apache.conf
</li>
<li>
Copy the workshop.pm file to /home/httpd/lib/perl/Apache, and
restart the webserver. You will need to do this after every
change of the workshop.pm file.
</li>
<li>
Point netscape at "http://cc313-pc-XX.cl.msu.edu/adm/workshop". You
should see the simple message the handler prints out.
</li>
<li>
Change workshop.pm to be what is in Example 3, the
italicised line is the only one that changed.
</li>
<li>
In netscape reload
"http://cc313-pc-XX.cl.msu.edu/adm/workshop". You should see the
output of the handler should now have your lon-capa name, which it
got from the session environment.
</li>
<li>
Next in netscape goto
"http://cc313-pc-XX.cl.msu.edu/~domcc/a.workshop". You should
see the same output as before.
</li>
<li>
Using the terminal edit the file ~/public_html/a.workshop and
put in it Example 7 using your favourite unix text editor.
</li>
<li>
Change ~/workshop.pm to be what is in Example 4, the
italicised lines are changed and the bold lines should be
added.
</li>
<li>
In netscape reload
"http://cc313-pc-XX.cl.msu.edu/~domcc/a.workshop". You should
see the output of the handler contains the contents of the file
that you created along with the name of the file.
</li>
<li>
Change ~/workshop.pm to be what is in Example 5, the
bold line should be added.
</li>
<li>
In netscape reload
"http://cc313-pc-XX.cl.msu.edu/~domcc/a.workshop". You should
see the output of the handler contains the contents of the
file that you created along with the name of the file, except
that this time all instances of the word "simple" have been
replaced with the word "complex", this includes the one in the
title and the one in the body of the file.
</li>
<li>
<ol>
<li>
Change what is in ~/workshop.pm to be what is in Example
6. The bold section of code needs to be added.
</li>
<li>
Change what is in ~/public_html/a.workshop to be what is
in Example 8. The bold section needs to be added
</li>
<li>
In netscape reload
"http://cc313-pc-XX.cl.msu.edu/~domcc/a.workshop". The web
page should now contain a form, and say that an error
occurred.
</li>
<li>
Type something into the form field and click the submit button.
</li>
<li>
The handler should still report an error, but also echo
back what you typed into the error handler.
</li>
<li>
Type in the terminal
<pre>
ls -l /home/httpd/lonUsers/pcXX/d/o/m/domcc
</pre>
Notice that there is a workshop.db file and a
workshop.hist file.
</li>
<li>
Type in the terminal
<pre>
cat /home/httpd/lonUsers/pcXX/d/o/m/workshop.hist
</pre>
You should see the information that you submitted.
</li>
<li>
In netscape revisit
"http://cc313-pc-XX.cl.msu.edu/~domcc/a.workshop". (Do
this by hitting return in the URL field of netscape, Don't
use the reload button.) Notice that the handler no longer
has an error. Also notice that the handler tells you what
you said last time.
</li>
<li>
Type something new into the text field and hit submit. The
handler should tell you the first submission and the last
submission.
</li>
</ol>
</li>
<!--
<li>
Extra credit: convert Example 5 to use store/restore instead
of the get/put. You will need to publish a .workshop file and
include it into a map. (Note that violin.sequence is the
toplevel map for you course.
</li>
<li>
Extra credit: Use Apache::lonxml::xmlparse to properly process the html file.
Use <window></window> in your example .workshop file.
</li>
-->
</ol>
<h2>Helpful Notes</h2>
<ul>
<li>
Remember that Apache::lonnet::put and Apache::lonnet::get
store data that is user wide. I use them for simplicity sake
here. Every .workshop file will read and write to the same
data location in the last example. Use store/restore if you
want to have data stored per unique resource instance in a
specific course. However this means that store/restore will
throw errors if you attempt to use them in a context in which
a resource isn't published or isn't uniquely identified
(i.e. browsing resources.)
</li>
</ul>
<hr />
<address><a href="mailto:albertel@msu.edu">Guy Albertelli</a></address>
<!-- Created: Wed May 23 02:34:54 EDT 2001 -->
<!-- hhmts start -->
Last modified: Tue Jun 11 14:18:30 EDT 2002
<!-- hhmts end -->
</body>
</html>
Index: doc/techtips/worktime.html
+++ doc/techtips/worktime.html
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>Worktime Program</title>
</head>
<body>
<h1>Worktime Program</h1>
<p>
In the examples below <i>italicized</i> lines are lines of code
that changed from the previous example, <b>bold</b> lines are
lines that have been added to the example, and any time
"username" appears it should be replaced by your specific
username.
</p>
<h3>Example 1</h3>
<pre>
package Apache::username;
use strict;
use Apache::Constants qw(:common :http);
sub handler {
my $r=@_[0];
$r->content_type('text/html');
$r->send_http_header;
return OK if $r->header_only;
$r->print("The username handler");
return OK;
}
1;
__END__
</pre>
<h3>Example 2</h3>
<pre>
package Apache::username;
use strict;
use Apache::Constants qw(:common :http);
sub handler {
my $r=@_[0];
$r->content_type('text/html');
$r->send_http_header;
return OK if $r->header_only;
<i>$r->print("The username handler is in use by $ENV{'user.name'}");</i>
return OK;
}
1;
__END__
</pre>
<h3>Example 3</h3>
<pre>
package Apache::username;
use strict;
use Apache::Constants qw(:common :http);
<b>use Apache::lonnet;</b>
sub handler {
my $r=@_[0];
$r->content_type('text/html');
$r->send_http_header;
return OK if $r->header_only;
<i>$r->print("The username handler is in use by $ENV{'user.name'} looking for "
.$r->uri."<br>");</i>
<b>my $file=&Apache::lonnet::filelocation("",$r->uri);</b>
<b>my $contents=&Apache::lonnet::getfile($file);</b>
<b>$r->print($contents);</b>
return OK;
}
1;
__END__
</pre>
<h3>Example 4</h3>
<pre>
package Apache::username;
use strict;
use Apache::Constants qw(:common :http);
use Apache::lonnet;
sub handler {
my $r=@_[0];
$r->content_type('text/html');
$r->send_http_header;
return OK if $r->header_only;
$r->print("The username handler is in use by $ENV{'user.name'} looking for "
.$r->uri."<br>");
my $file=&Apache::lonnet::filelocation("",$r->uri);
my $contents=&Apache::lonnet::getfile($file);
<b>$contents=~s/simple/complex/g;</b>
$r->print($contents);
return OK;
}
1;
__END__
</pre>
<h3>Example 5</h3>
<pre>
package Apache::username;
use strict;
use Apache::Constants qw(:common :http);
use Apache::lonnet;
sub handler {
my $r=@_[0];
$r->content_type('text/html');
$r->send_http_header;
return OK if $r->header_only;
$r->print("The username handler is in use by $ENV{'user.name'} looking for "
.$r->uri."<br>");
my $file=&Apache::lonnet::filelocation("",$r->uri);
my $contents=&Apache::lonnet::getfile($file);
$contents=~s/simple/complex/g;
$r->print($contents);
<b>my %hash=&Apache::lonnet::get('username',('info'));
#handle any errors
if ($hash{'info'} =~ m/^error:.*/) {
$r->print("<br>An error -$hash{'info'}- occured");
} else {
$r->print("<br>Last time you said $hash{'info'}");
}
if ($ENV{'form.info'}) {
$r->print("<br>Now you say $ENV{'form.info'}");
$hash{'info'}=$ENV{'form.info'};
&Apache::lonnet::put('username',%hash);
}</b>
return OK;
}
1;
__END__
</pre>
<h3>Example 6</h3>
<pre>
<html>
<head><title> A simple file </title></head>
<body>
This is a simple file
</body>
</html>
</pre>
<h3>Example 7</h3>
<pre>
<html>
<head><title> A simple file </title></head>
<body>
This is a simple file
<b><form method="POST" action="/~username/a.username">
<input type="text" name="info"></input>
<input type="submit" name="Submit"></input>
</form></b>
</body>
</html>
</pre>
<ol>
<li>
login
<ol>
<li>
First login to the CSE machine using the username guest__
and the password CAPA4all.
</li>
<li>
Bring up a terminal by clicnking on the monitor icon with
a foot at the bottom of the screen.
</li>
<li>
Type the following in the terminal.
<pre>
xhost +data.lite.msu.edu
</pre>
<li>
Start up a netscape by typing netscape& in the terminal.
</li>
<li>
telnet from the terminal to data.lite.msu.edu, login using
your username and the password guts
</li>
<li>
Login into LON-CAPA in netscape by pointing the browser at
http://data.lite.msu.edu and typing in your username and
guts
</li>
</ol>
</li>
<li>
Using the terminal edit the file ~/username.pm using your
favorite unix text editor and type in example 1
</li>
<li>
Point netscape at "http://data.lite.msu.edu/adm/username". You
should see a the simple message the handler prints out.
</li>
<li>
Change ~/username.pm to be what is in Example 2, the
italicized line is the only one that changed.
</li>
<li>
In netscape reload
"http://data.lite.msu.edu/adm/username". You should see the
output of the handler should now have your username, which it
got from the session enviroment.
</li>
<li>
Next in netscape goto
"http://data.lite.msu.edu/~username/a.username". You should
see the same output as before.
</li>
<li>
Using the terminal edit the file ~/public_html/a.username and
put in it example5 using your favorite unix text editor.
</li>
<li>
Change ~/username.pm to be what is in Example 3, the
italicized lines are changed and the bold lines should be
added.
</li>
<li>
In netscape reload
"http://data.lite.msu.edu/~username/a.username". You should
see the output of the handler contains the contents of the file
that you created along with the name of the file.
</li>
<li>
Change ~/username.pm to be what is in Example 4, the
bold line should be added.
</li>
<li>
In netscape reload
"http://data.lite.msu.edu/~username/a.username". You should
see the output of the handler contains the contents of the
file that you created along with the name of the file, except
that this time all instances of the word "simple" have been
replaced with the word "complex", this includes the one in the
title and the one in the body of the file.
</li>
<li>
<ol>
<li>
Change what is in ~/username.pm to be what is in Example
5. The bold section of code needs to be added.
</li>
<li>
Change what is in ~/public_html/a.username to be what is
in Example 7. The bold section needs to be added
</li>
<li>
In netscape reload
"http://data.lite.msu.edu/~username/a.username". The web
page should now contain a form, and say that an error
occured.
</li>
<li>
Type someting into the form field and click the submit button.
</li>
<li>
The handler should still report an error, but also echo
back what you typed into the error handler.
</li>
<li>
Type in the terminal
<pre>
ls -l /home/httpd/lonUsers/msu/u/s/e/username/
</pre>
Notice that there is a username.db file and a
username.hist file.
</li>
<li>
Type in the terminal
<pre>
cat /home/httpd/lonUsers/msu/u/s/e/username/username.hist
</pre>
You should see the information that you submitted.
</li>
<li>
In netscape revisit
"http://data.lite.msu.edu/~username/a.username". (Do
this by hitting return in the URL field of netscape, Don't
use the reload button.) Notice that the handler no longer
has an error. Also notice that the handler tells you what
you said last time.
</li>
<li>
Type something new into the text field and hit submit. The
handler should tell you the first submission and the last
submission.
</li>
</ol>
</li>
<li>
Extra credit: convert Example 5 to use store/restore instead
of the get/put. You will need to publish a .username file and
include it into a map. (Note that violin.sequence is the
toplevel map for you course.
</li>
<li>
Extra credit: Use Apache::lonxml::xmlparse to properly process the html file.
Use <window></window> in your example .username file.
</li>
</ol>
<h2>Helpful Notes</h2>
<ul>
<li>
If you the error handler does come up, the first bold line
will indicate what error the server process detected.
</li>
<li>
Remember that Apache::lonnet::put and Apache::lonnet::get
store data that is user wide. I use them for simplicity sake
here. Every .username file will read and write to the same
data location in the last example. Use store/restore if you
want to have data stored per unique resource instance in a
specific course. However this means that store/restore will
through errors if you attempt to use them in a context in
which a resource isn't published or isn't uniquely identified
(i.e. browsing resources.)
</li>
</ul>
<hr>
<address><a href="mailto:albertel@msu.edu">Guy Albertelli</a></address>
<!-- Created: Wed May 23 02:34:54 EDT 2001 -->
<!-- hhmts start -->
Last modified: Thu May 24 08:16:55 EDT 2001
<!-- hhmts end -->
</body>
</html>
--albertel1025297810--