File:  [LON-CAPA] / loncom / homework / grades.pm
Revision 1.4: download - view: text, annotated - select for diffs
Tue Feb 13 19:43:44 2001 UTC (23 years, 3 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- closes the home work remote now

    1: # The LON-CAPA Grading handler
    2: # 2/9,2/13 Guy Albertelli
    3: 
    4: package Apache::grades;
    5: use strict;
    6: use Apache::style;
    7: use Apache::lonxml;
    8: use Apache::lonnet;
    9: use Apache::loncommon;
   10: use Apache::lonhomework;
   11: use Apache::Constants qw(:common);
   12: 
   13: sub moreinfo {
   14:   my ($request,$reason) = @_;
   15:   $request->print("Unable to process request: $reason");
   16:   $request->print('<form action="/adm/grades" method="post">'."\n");
   17:   $request->print('<input type="hidden" name="url" value="'.$ENV{'form.url'}.'"></input>'."\n");
   18:   $request->print('<input type="hidden" name="command" value="'.$ENV{'form.command'}.'"></input>'."\n");
   19:   $request->print("Student:".'<input type="text" name="student" value="'.$ENV{'form.student'}.'"></input>'."<br />\n");
   20:   $request->print("Domain:".'<input type="text" name="domain" value="'.$ENV{'user.domain'}.'"></input>'."<br />\n");
   21:   $request->print('<input type="submit" name="submit" value="ReSubmit"></input>'."<br />\n");
   22:   $request->print('</form>');
   23: }
   24: 
   25: 
   26: #FIXME - needs to be much smarter
   27: sub finduser {
   28:   my ($name) = @_;
   29:   return ($name,$ENV{'user.domain'});
   30: }
   31: 
   32: sub submission {
   33:   my ($request) = @_;
   34:   my $url=$ENV{'form.url'};
   35:   $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
   36:   if ($ENV{'form.student'} eq '') { &moreinfo($request,"Need student login id"); return ''; }
   37:   my ($uname,$udom) = &finduser($ENV{'form.student'});
   38:   if ($uname eq '') { &moreinfo($request,"Unable to find student"); return ''; }
   39:   my $symb=&Apache::lonnet::symbread($url);
   40:   if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; }
   41:   my $home=&Apache::lonnet::homeserver($uname,$udom);
   42:   my $answer=&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,$home,
   43: 						      $ENV{'request.course.id'});
   44:   my $result="<h2> Submission Record </h2>  $uname:$udom for $url".$answer;
   45:   return $result;
   46: }
   47: 
   48: sub send_header {
   49:   my ($request)= @_;
   50:   $request->print(&Apache::lontexconvert::header());
   51:   $request->print("
   52: <script>
   53: remotewindow=open('','homeworkremote');
   54: remotewindow.close();
   55: </script>"); 
   56:   $request->print('<body bgcolor="#FFFFFF">');
   57: }
   58: 
   59: sub send_footer {
   60:   my ($request)= @_;
   61:   $request->print('</body>');
   62:   $request->print(&Apache::lontexconvert::footer());
   63: }
   64: 
   65: sub handler {
   66:   my $request=$_[0];
   67: 
   68:   if ( $ENV{'user.name'} eq 'albertel' ) {$Apache::lonxml::debug=1;} else {$Apache::lonxml::debug=0;}
   69:   
   70:   if ($ENV{'browser.mathml'}) {
   71:     $request->content_type('text/xml');
   72:   } else {
   73:     $request->content_type('text/html');
   74:   }
   75:   $request->send_http_header;
   76:   return OK if $request->header_only;
   77:   my $url=$ENV{'form.url'};
   78:   my $command=$ENV{'form.command'};
   79:   
   80:   &send_header($request);
   81:   if ($url eq '') {
   82:     $request->print("Non-Contextual Access Unsupported:$command:$url:");
   83:   } else {
   84:     $Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$url);
   85:     if ($command eq 'submission') {
   86:       $request->print(&submission($request));
   87:     } else {
   88:       $request->print("Unknown action:$command:");
   89:     }
   90:   }
   91:   &send_footer($request);
   92:   return OK;
   93: }
   94: 
   95: 1;
   96: 
   97: __END__;

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