File:  [LON-CAPA] / loncom / homework / essayresponse.pm
Revision 1.9: download - view: text, annotated - select for diffs
Fri Jul 19 20:43:11 2002 UTC (21 years, 9 months ago) by ng
Branches: MAIN
CVS tags: HEAD
put the collaborator field in. Needs to check whether it is greater than 0.

    1: # The LearningOnline Network with CAPA
    2: # essay (ungraded) style responses
    3: #
    4: # $Id: essayresponse.pm,v 1.9 2002/07/19 20:43:11 ng Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: # 4/3 Guy
   29: package Apache::essayresponse;
   30: use strict;
   31: 
   32: BEGIN {
   33:   &Apache::lonxml::register('Apache::essayresponse',('essayresponse'));
   34: }
   35: 
   36: sub start_essayresponse {
   37:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   38:   my $result;
   39:   my $id = &Apache::response::start_response($parstack,$safeeval);
   40:   if ($target eq 'meta') {
   41:     $result=&Apache::response::meta_package_write('essayresponse');
   42:   }
   43:   if ($target eq 'web') {
   44:       my $id  = $Apache::inputtags::response['-1'];
   45:       my $part= $Apache::inputtags::part;
   46:       my $symb= &Apache::lonnet::symbread($ENV{'form.url'});
   47: #      my $ncol= &Apache::lonnet::EXT('parameter\_$part\_$id\_maxcollaborators',$symb);
   48:       my $ncol= &Apache::lonnet::get($symb,['parameter\_$part\_$id\_maxcollaborators']);
   49:       $result ='<br />Collaborators: <input type="text" size="40" max="70" name="HWCOL'.
   50:               $Apache::inputtags::response['-1'].'" /><br />'.$ncol.':<br>'.
   51: 	      '(Enter collaborators using username or username@domain, e.g. smithje or doej@msu or smithje@fsu.)';
   52:   }
   53:   return $result;
   54: }
   55: 
   56: sub end_essayresponse {
   57:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   58:   if ( $target eq 'grade' ) {
   59:     if ( defined $ENV{'form.submitted'}) {
   60:       my $id            = $Apache::inputtags::response['-1'];
   61:       my $response      = $ENV{'form.HWVAL'.$id};
   62:       my $collaborators = $ENV{'form.HWCOL'.$id};
   63: #      my $response = $ENV{'form.HWVAL'.$Apache::inputtags::response['-1']};
   64: #      my $collaborators = $ENV{'form.HWCOL'.$Apache::inputtags::response['-1']};
   65:       if ( $response =~ /[^\s]/) {
   66: 	my $part=$Apache::inputtags::part;
   67: 	$Apache::lonhomework::results{"resource.$part.$id.submission"}=$response;
   68: 	$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}="SUBMITTED";
   69: 	$Apache::lonhomework::results{"resource.$part.$id.collaborators"}=$collaborators;
   70: 	my %previous=&Apache::response::check_for_previous($response,$part,$id);
   71: 	&Apache::response::handle_previous(\%previous,'SUBMITTED');
   72:       }
   73:     }
   74:   }
   75:   &Apache::response::end_response;
   76:   return '';
   77: }
   78: 
   79: 1;
   80: __END__

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