--- loncom/homework/grades.pm 2003/11/21 22:59:42 1.161 +++ loncom/homework/grades.pm 2003/11/25 21:44:45 1.162 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.161 2003/11/21 22:59:42 albertel Exp $ +# $Id: grades.pm,v 1.162 2003/11/25 21:44:45 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -3379,7 +3379,7 @@ sub scantron_uploads { my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'}; my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname, - &Apache::locommon::propath($cdom,$cname)); + &Apache::loncommon::propath($cdom,$cname)); foreach my $filename (@files) { ($filename)=split(/&/,$filename); if ($filename!~/^scantron_orig_/) { next ; } @@ -3416,12 +3416,12 @@ sub scantron_selectphase { #FIXME allow instructor to be able to download the scantron file # and to upload it, $result.= < - - $default_form_data - +
+ +SCANTRONFORM + + $r->print($result); + + if (&Apache::lonnet::allowed('usc',$ENV{'request.role.domain'}) || + &Apache::lonnet::allowed('usc',$ENV{'request.course.id'})) { + + $r->print(< + +SCANTRONFORM + } + + $r->print(< - $grading_menu_button SCANTRONFORM - return $result; + return } sub get_scantron_config { @@ -4112,6 +4148,7 @@ sub scantron_upload_scantron_data { 'domainid'); my $domsel=&Apache::loncommon::select_dom_form($ENV{'request.role.domain'}, 'domainid'); + my $default_form_data=&defaultFormData(&get_symb_and_url($r)); $r->print(< function checkUpload(formname) { @@ -4124,6 +4161,7 @@ sub scantron_upload_scantron_data {
+$default_form_data Course: Domain: $domsel $select_link
@@ -4138,7 +4176,14 @@ UPLOAD sub scantron_upload_scantron_data_save { my($r)=@_; - $r->print("Doing upload to ".$ENV{'form.courseid'}); + 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))); + return ''; + } + $r->print("Doing upload to ".$ENV{'form.courseid'}."
"); my $home=&Apache::lonnet::homeserver($ENV{'form.courseid'}, $ENV{'form.domainid'}); my $fname=$ENV{'form.upfile.filename'}; @@ -4156,10 +4201,10 @@ sub scantron_upload_scantron_data_save { # See if there is anything left unless ($fname) { return 'error: no uploaded file'; } $fname='scantron_orig_'.$fname; - &Apache::lonnet::logthis("fname is $fname"); $r->print(&Apache::lonnet::finishuserfileupload($ENV{'form.courseid'}, $ENV{'form.domainid'}, $home,'upfile',$fname)); + $r->print(&show_grading_menu_form(&get_symb_and_url($r))); return ''; } @@ -4446,12 +4491,16 @@ sub handler { } elsif ($command eq 'scantron_process' && $perm{'mgr'}) { $request->print(&scantron_process_students($request)); } elsif ($command eq 'scantronupload' && - &Apache::lonnet::allowed('usc',$ENV{'request.role.domain'})) { - $request->print(&scantron_upload_scantron_data($request)); - + (&Apache::lonnet::allowed('usc',$ENV{'request.role.domain'})|| + &Apache::lonnet::allowed('usc',$ENV{'request.course.id'}))) { + $request->print(&scantron_upload_scantron_data($request)); } elsif ($command eq 'scantronupload_save' && - &Apache::lonnet::allowed('usc',$ENV{'request.role.domain'})) { + (&Apache::lonnet::allowed('usc',$ENV{'request.role.domain'})|| + &Apache::lonnet::allowed('usc',$ENV{'request.course.id'}))) { $request->print(&scantron_upload_scantron_data_save($request)); + } elsif ($command eq 'scantrondownload' && + &Apache::lonnet::allowed('usc',$ENV{'request.course.id'})) { + $request->print(&scantron_download_scantron_data($request)); } elsif ($command) { $request->print("Access Denied ($command)"); }
+
+ + $default_form_data + + + +
@@ -3450,16 +3450,52 @@ sub scantron_selectphase {
+ +
+
+
+ + + + + +
+ Specify a Scantron data file to upload. +
+SCANTRONFORM + &scantron_upload_scantron_data($r); + + $r->print(< +