--- loncom/homework/grades.pm 2001/02/07 00:29:30 1.1 +++ loncom/homework/grades.pm 2001/02/13 19:43:44 1.4 @@ -1,16 +1,67 @@ # The LON-CAPA Grading handler -# Guy Albertelli -# 11/30 Gerd Kortemeyer -# 6/1 Gerd Kortemeyer +# 2/9,2/13 Guy Albertelli package Apache::grades; use strict; use Apache::style; use Apache::lonxml; use Apache::lonnet; +use Apache::loncommon; use Apache::lonhomework; use Apache::Constants qw(:common); +sub moreinfo { + my ($request,$reason) = @_; + $request->print("Unable to process request: $reason"); + $request->print('
'); +} + + +#FIXME - needs to be much smarter +sub finduser { + my ($name) = @_; + return ($name,$ENV{'user.domain'}); +} + +sub submission { + my ($request) = @_; + my $url=$ENV{'form.url'}; + $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; + if ($ENV{'form.student'} eq '') { &moreinfo($request,"Need student login id"); return ''; } + my ($uname,$udom) = &finduser($ENV{'form.student'}); + if ($uname eq '') { &moreinfo($request,"Unable to find student"); return ''; } + my $symb=&Apache::lonnet::symbread($url); + if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; } + my $home=&Apache::lonnet::homeserver($uname,$udom); + my $answer=&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,$home, + $ENV{'request.course.id'}); + my $result="