--- loncom/homework/grades.pm 2002/05/16 00:01:09 1.25 +++ loncom/homework/grades.pm 2002/05/21 02:29:22 1.26 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.25 2002/05/16 00:01:09 albertel Exp $ +# $Id: grades.pm,v 1.26 2002/05/21 02:29:22 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -322,17 +322,49 @@ sub submission { return $result; } -sub viewgrades { - my ($request) = @_; - my $result=''; - - #get resource reference +sub get_symb_and_url { + my ($request) = @_; my $url=$ENV{'form.url'}; $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; my $symb=$ENV{'form.symb'}; if (!$symb) { $symb=&Apache::lonnet::symbread($url); } 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='
+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(<Uploading Class Grades for resource $url
+
+Identify fields
+Total number of records found in file: $distotal
+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.
+
+
+
+
+
+
+
+
+
+
+
+
+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
+}
+
+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 {
my ($request)= @_;
$request->print(&Apache::lontexconvert::header());
@@ -465,16 +616,34 @@ sub handler {
}
}
} else {
+ &Apache::lonhomework::showhashsubset(\%ENV,'^form');
$Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});
if ($command eq 'submission') {
&listStudents($request) if ($ENV{'form.student'} eq '');
$request->print(&submission($request)) if ($ENV{'form.student'} ne '');
+ } elsif ($command eq 'gradingmenu') {
+ $request->print(&gradingmenu($request));
} elsif ($command eq 'viewgrades') {
$request->print(&viewgrades($request));
} elsif ($command eq 'editgrades') {
$request->print(&editgrades($request));
} elsif ($command eq 'verify') {
$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 {
$request->print("Unknown action: $command:");
}