- Done
");
+ $r->print("");
$r->print(&show_grading_menu_form($symb,$url));
return '';
}
@@ -4190,7 +4583,8 @@ sub scantron_upload_scantron_data {
my ($r)=@_;
$r->print(&Apache::loncommon::coursebrowser_javascript($ENV{'request.role.domain'}));
my $select_link=&Apache::loncommon::selectcourse_link('rules','courseid',
- 'domainid');
+ 'domainid',
+ 'coursename');
my $domsel=&Apache::loncommon::select_dom_form($ENV{'request.role.domain'},
'domainid');
my $default_form_data=&defaultFormData(&get_symb_and_url($r,1));
@@ -4207,12 +4601,14 @@ sub scantron_upload_scantron_data {
$default_form_data
-Course:
-Domain: $domsel $select_link
-
+
-File to upload:
-
UPLOAD
@@ -4221,11 +4617,21 @@ UPLOAD
sub scantron_upload_scantron_data_save {
my($r)=@_;
+ my ($symb,$url)=&get_symb_and_url($r,1);
+ my $doanotherupload=
+ ''."\n".
+ ' '."\n".
+ ' '."\n".
+ ' '."\n";
if (!&Apache::lonnet::allowed('usc',$ENV{'form.domainid'}) &&
!&Apache::lonnet::allowed('usc',
$ENV{'form.domainid'}.'_'.$ENV{'form.courseid'})) {
$r->print("You are not allowed to upload Scantron data to the requested course. ");
- $r->print(&show_grading_menu_form(&get_symb_and_url($r)));
+ if ($symb) {
+ $r->print(&show_grading_menu_form($symb,$url));
+ } else {
+ $r->print($doanotherupload);
+ }
return '';
}
$r->print("Doing upload to ".$ENV{'form.courseid'}." ");
@@ -4246,21 +4652,68 @@ sub scantron_upload_scantron_data_save {
# See if there is anything left
unless ($fname) { return 'error: no uploaded file'; }
$fname='scantron_orig_'.$fname;
- $r->print(&Apache::lonnet::finishuserfileupload($ENV{'form.courseid'},
- $ENV{'form.domainid'},
- $home,'upfile',$fname));
- my ($symb,$url)=&get_symb_and_url($r);
+ if (length($ENV{'form.upfile'}) < 2) {
+ $r->print("Error: The file you attempted to upload, ".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"')." , contained no information. Please check that you entered the correct filename.");
+ } else {
+ my $result=&Apache::lonnet::finishuserfileupload($ENV{'form.courseid'},$ENV{'form.domainid'},$home,'upfile',$fname);
+ if ($result =~ m|^/uploaded/|) {
+ $r->print("Success: Successfully uploaded ".(length($ENV{'form.upfile'})-1)." bytes of data into location ".$result." ");
+ } else {
+ $r->print("Error: An error (".$result.") occured when attempting to upload the file, ".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"')." ");
+ }
+ }
if ($symb) {
- $r->print(&show_grading_menu_form(&get_symb_and_url($r)));
+ $r->print(&show_grading_menu_form($symb,$url));
} else {
- $r->print(''."\n".
- ' '."\n".
- ' '."\n".
- ' '."\n");
+ $r->print($doanotherupload);
}
return '';
}
+sub valid_file {
+ my ($requested_file)=@_;
+ foreach my $filename (sort(&scantron_filenames())) {
+ &Apache::lonnet::logthis("$requested_file $filename");
+ if ($requested_file eq $filename) { return 1; }
+ }
+ return 0;
+}
+
+sub scantron_download_scantron_data {
+ my ($r)=@_;
+ my $default_form_data=&defaultFormData(&get_symb_and_url($r,1));
+ my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
+ my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
+ my $file=$ENV{'form.scantron_selectfile'};
+ if (! &valid_file($file)) {
+ $r->print(<
+ The requested file name was invalid.
+
+ERROR
+ $r->print(&show_grading_menu_form(&get_symb_and_url($r,1)));
+ return;
+ }
+ my $orig='/uploaded/'.$cdom.'/'.$cname.'/scantron_orig_'.$file;
+ my $corrected='/uploaded/'.$cdom.'/'.$cname.'/scantron_corrected_'.$file;
+ my $skipped='/uploaded/'.$cdom.'/'.$cname.'/scantron_skipped_'.$file;
+ &Apache::lonnet::allowuploaded('/adm/grades',$orig);
+ &Apache::lonnet::allowuploaded('/adm/grades',$corrected);
+ &Apache::lonnet::allowuploaded('/adm/grades',$skipped);
+ $r->print(<
+ Original file as uploaded by the scantron office.
+
+
+ Corrections , a file of corrected records that were used in grading.
+
+
+ Skipped , a file of records that were skipped.
+
+DOWNLOAD
+ $r->print(&show_grading_menu_form(&get_symb_and_url($r,1)));
+ return '';
+}
#-------- end of section for handling grading scantron forms -------
#
@@ -4411,17 +4864,18 @@ GRADINGMENUJS
$result.='