version 1.1, 2001/02/07 00:29:30
|
version 1.3, 2001/02/13 18:41:00
|
Line 1
|
Line 1
|
# The LON-CAPA Grading handler |
# The LON-CAPA Grading handler |
# Guy Albertelli |
# 2/9 Guy Albertelli |
# 11/30 Gerd Kortemeyer |
|
# 6/1 Gerd Kortemeyer |
|
|
|
package Apache::grades; |
package Apache::grades; |
use strict; |
use strict; |
use Apache::style; |
use Apache::style; |
use Apache::lonxml; |
use Apache::lonxml; |
use Apache::lonnet; |
use Apache::lonnet; |
|
use Apache::loncommon; |
use Apache::lonhomework; |
use Apache::lonhomework; |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
|
|
|
sub moreinfo { |
|
my ($request,$reason) = @_; |
|
$request->print("Unable to process request: $reason"); |
|
$request->print('<form action="/adm/grades" method="post">'."\n"); |
|
$request->print('<input type="hidden" name="url" value="'.$ENV{'form.url'}.'"></input>'."\n"); |
|
$request->print('<input type="hidden" name="command" value="'.$ENV{'form.command'}.'"></input>'."\n"); |
|
$request->print("Student:".'<input type="text" name="student" value="'.$ENV{'form.student'}.'"></input>'."<br />\n"); |
|
$request->print("Domain:".'<input type="text" name="domain" value="'.$ENV{'user.domain'}.'"></input>'."<br />\n"); |
|
$request->print('<input type="submit" name="submit" value="ReSubmit"></input>'."<br />\n"); |
|
$request->print('</form>'); |
|
} |
|
|
|
|
|
#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="<h2> Submission Record </h2> $uname:$udom for $url".$answer; |
|
return $result; |
|
} |
|
|
|
sub send_header { |
|
my ($request)= @_; |
|
$request->print(&Apache::lontexconvert::header()); |
|
$request->print('<body bgcolor="#FFFFFF">'); |
|
} |
|
|
|
sub send_footer { |
|
my ($request)= @_; |
|
$request->print('</body>'); |
|
$request->print(&Apache::lontexconvert::footer()); |
|
} |
|
|
sub handler { |
sub handler { |
my $request=$_[0]; |
my $request=$_[0]; |
|
|
Line 24 sub handler {
|
Line 70 sub handler {
|
$request->send_http_header; |
$request->send_http_header; |
return OK if $request->header_only; |
return OK if $request->header_only; |
my $url=$ENV{'form.url'}; |
my $url=$ENV{'form.url'}; |
|
my $command=$ENV{'form.command'}; |
|
|
|
&send_header($request); |
if ($url eq '') { |
if ($url eq '') { |
$request->print("Non-Contextual Access Unsupported"); |
$request->print("Non-Contextual Access Unsupported:$command:$url:"); |
} else { |
} else { |
$Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$url); |
$Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$url); |
|
if ($command eq 'submission') { |
|
$request->print(&submission($request)); |
|
} else { |
|
$request->print("Unknown action:$command:"); |
|
} |
} |
} |
|
&send_footer($request); |
return OK; |
return OK; |
} |
} |
|
|