version 1.25, 2002/05/16 00:01:09
|
version 1.26, 2002/05/21 02:29:22
|
Line 322 sub submission {
|
Line 322 sub submission {
|
return $result; |
return $result; |
} |
} |
|
|
sub viewgrades { |
sub get_symb_and_url { |
my ($request) = @_; |
my ($request) = @_; |
my $result=''; |
|
|
|
#get resource reference |
|
my $url=$ENV{'form.url'}; |
my $url=$ENV{'form.url'}; |
$url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; |
$url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; |
my $symb=$ENV{'form.symb'}; |
my $symb=$ENV{'form.symb'}; |
if (!$symb) { $symb=&Apache::lonnet::symbread($url); } |
if (!$symb) { $symb=&Apache::lonnet::symbread($url); } |
if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; } |
if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; } |
|
return ($symb,$url); |
|
} |
|
|
|
sub gradingmenu { |
|
my ($request) = @_; |
|
my ($symb,$url)=&get_symb_and_url($request); |
|
if (!$symb) {return '';} |
|
my $result='<h2>Select a grading method</h2><br />'; |
|
$result.='<form action="/adm/grades" method="post">'."\n". |
|
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
|
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
|
'<input type="hidden" name="command" value="viewgrades" />'."\n". |
|
'<input type="submit" name="submit" value="View/Edit Entire Class" />'."\n". |
|
'</form>'; |
|
$result.='<form action="/adm/grades" method="post">'."\n". |
|
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
|
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
|
'<input type="hidden" name="command" value="csvupload" />'."\n". |
|
'<input type="submit" name="submit" value="Upload Scores" />'."\n". |
|
'</form>'; |
|
$result.='<form action="/adm/grades" method="post">'."\n". |
|
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
|
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
|
'<input type="hidden" name="command" value="submission" />'."\n". |
|
'<input type="submit" name="submit" value="View/Edit Student" />'."\n". |
|
'</form>'; |
|
return $result; |
|
} |
|
|
|
sub viewgrades { |
|
my ($request) = @_; |
|
my $result=''; |
|
|
|
#get resource reference |
|
my ($symb,$url)=&get_symb_and_url($request); |
|
if (!$symb) {return '';} |
#get classlist |
#get classlist |
my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'}); |
my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'}); |
#print "Found $cdom:$cnum<br />"; |
#print "Found $cdom:$cnum<br />"; |
Line 398 sub editgrades {
|
Line 430 sub editgrades {
|
return $result; |
return $result; |
} |
} |
|
|
|
sub csvupload { |
|
my ($request)= @_; |
|
my $result; |
|
my ($symb,$url)=&get_symb_and_url($request); |
|
if (!$symb) {return '';} |
|
my $upfile_select=&Apache::loncommon::upfile_select_html(); |
|
$result.=<<ENDUPFORM; |
|
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="gradesupload"> |
|
<input type="hidden" name="symb" value="$symb" /> |
|
<input type="hidden" name="url" value="$url" /> |
|
<input type="hidden" name="command" value="csvuploadmap" /> |
|
<hr /> |
|
<h3>Specify a file containing the class grades for resource $url</h3> |
|
$upfile_select |
|
<p><input type="submit" name="submit" value="Upload Grades" /> |
|
ENDUPFORM |
|
return $result; |
|
} |
|
|
|
sub csvuploadmap_header { |
|
my ($request,$symb,$url,$datatoken,$distotal)= @_; |
|
my $result; |
|
my $javascript; |
|
if ($ENV{'form.upfile_associate'} eq 'reverse') { |
|
# $javascript=&csv_upload_javascript_reverse_associate(); |
|
} else { |
|
# $javascript=&csv_upload_javascript_forward_associate(); |
|
} |
|
my $javascript_validations;#=&javascript_validations($krbdefdom); |
|
$request->print(<<ENDPICK); |
|
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="gradesupload"> |
|
<h3>Uploading Class Grades for resource $url</h3> |
|
<hr> |
|
<h3>Identify fields</h3> |
|
Total number of records found in file: $distotal <hr /> |
|
Enter as many fields as you can. The system will inform you and bring you back |
|
to this page if the data selected is insufficient to run your class.<hr /> |
|
<input type="button" value="Reverse Association" onClick="javascript:this.form.associate.value='Reverse Association';submit(this.form);" /> |
|
<input type="hidden" name="associate" value="" /> |
|
<input type="hidden" name="phase" value="three" /> |
|
<input type="hidden" name="datatoken" value="$datatoken" /> |
|
<input type="hidden" name="fileupload" value="$ENV{'form.fileupload'}" /> |
|
<input type="hidden" name="upfiletype" value="$ENV{'form.upfiletype'}" /> |
|
<input type="hidden" name="upfile_associate" |
|
value="$ENV{'form.upfile_associate'}" /> |
|
<input type="hidden" name="symb" value="$symb" /> |
|
<input type="hidden" name="url" value="$url" /> |
|
<input type="hidden" name="command" value="csvuploadassign" /> |
|
<hr /> |
|
<script type="text/javascript" language="Javascript"> |
|
$javascript |
|
$javascript_validations |
|
</script> |
|
ENDPICK |
|
return ''; |
|
|
|
} |
|
|
|
sub csvupload_fields { |
|
my ($url) = @_; |
|
my (@parts) = &getpartlist($url); |
|
my @fields; |
|
foreach my $part (@parts) { |
|
my @datum; |
|
my $display=&Apache::lonnet::metadata($url,$part.'.display'); |
|
my $name=&Apache::lonnet::metadata($url,$part.'.name'); |
|
if (!$display) { $display = $name; } |
|
@datum=($name,$display); |
|
push(@fields,\@datum); |
|
} |
|
return (@fields); |
|
} |
|
|
|
sub csvuploadmap_footer { |
|
my ($request,$i,$keyfields) =@_; |
|
$request->print(<<ENDPICK); |
|
</table> |
|
<input type="hidden" name="nfields" value="$i" /> |
|
<input type="hidden" name="keyfields" value="$keyfields" /> |
|
<input type="button" onClick="javascript:verify(this.form)" value="Assign Grades" /><br /> |
|
</form> |
|
ENDPICK |
|
} |
|
|
|
sub csvuploadmap { |
|
my ($request)= @_; |
|
my ($symb,$url)=&get_symb_and_url($request); |
|
if (!$symb) {return '';} |
|
my $datatoken; |
|
if (!$ENV{'form.datatoken'}) { |
|
$datatoken=&Apache::loncommon::upfile_store($request); |
|
} else { |
|
$datatoken=$ENV{'form.datatoken'}; |
|
&Apache::loncommon::load_tmp_file($request); |
|
} |
|
my @records=&Apache::loncommon::upfile_record_sep(); |
|
&csvuploadmap_header($request,$symb,$url,$datatoken,$#records+1); |
|
my $i; |
|
my $keyfields; |
|
if (@records) { |
|
my @fields=&csvupload_fields($url); |
|
if ($ENV{'form.upfile_associate'} eq 'reverse') { |
|
&Apache::loncommon::csv_print_samples($request,\@records); |
|
$i=&Apache::loncommon::csv_print_select_table($request,\@records, |
|
\@fields); |
|
foreach (@fields) { $keyfields.=$_->[0].','; } |
|
chop($keyfields); |
|
} else { |
|
unshift(@fields,['none','']); |
|
$i=&Apache::loncommon::csv_samples_select_table($request,\@records, |
|
\@fields); |
|
my %sone=&Apache::loncommon::record_sep($records[0]); |
|
$keyfields=join(',',sort(keys(%sone))); |
|
} |
|
} |
|
&csvuploadmap_footer($request,$i,$keyfields); |
|
return ''; |
|
} |
|
|
sub send_header { |
sub send_header { |
my ($request)= @_; |
my ($request)= @_; |
$request->print(&Apache::lontexconvert::header()); |
$request->print(&Apache::lontexconvert::header()); |
Line 465 sub handler {
|
Line 616 sub handler {
|
} |
} |
} |
} |
} else { |
} else { |
|
&Apache::lonhomework::showhashsubset(\%ENV,'^form'); |
$Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'}); |
$Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'}); |
if ($command eq 'submission') { |
if ($command eq 'submission') { |
&listStudents($request) if ($ENV{'form.student'} eq ''); |
&listStudents($request) if ($ENV{'form.student'} eq ''); |
$request->print(&submission($request)) if ($ENV{'form.student'} ne ''); |
$request->print(&submission($request)) if ($ENV{'form.student'} ne ''); |
|
} elsif ($command eq 'gradingmenu') { |
|
$request->print(&gradingmenu($request)); |
} elsif ($command eq 'viewgrades') { |
} elsif ($command eq 'viewgrades') { |
$request->print(&viewgrades($request)); |
$request->print(&viewgrades($request)); |
} elsif ($command eq 'editgrades') { |
} elsif ($command eq 'editgrades') { |
$request->print(&editgrades($request)); |
$request->print(&editgrades($request)); |
} elsif ($command eq 'verify') { |
} elsif ($command eq 'verify') { |
$request->print(&verifyreceipt($request)); |
$request->print(&verifyreceipt($request)); |
|
} elsif ($command eq 'csvupload') { |
|
$request->print(&csvupload($request)); |
|
} elsif ($command eq 'csvuploadmap') { |
|
$request->print(&csvuploadmap($request)); |
|
} elsif ($command eq 'csvuploadassign') { |
|
if ($ENV{'form.associate'} ne 'Reverse Association') { |
|
$request->print(&csvuploadassign($request)); |
|
} else { |
|
if ( $ENV{'form.upfile_associate'} ne 'reverse' ) { |
|
$ENV{'form.upfile_associate'} = 'reverse'; |
|
} else { |
|
$ENV{'form.upfile_associate'} = 'forward'; |
|
} |
|
$request->print(&csvuploadmap($request)); |
|
} |
} else { |
} else { |
$request->print("Unknown action: $command:"); |
$request->print("Unknown action: $command:"); |
} |
} |