version 1.130.2.1.2.8, 2003/10/13 22:36:59
|
version 1.130.2.1.2.9, 2003/10/14 00:05:16
|
Line 3146 sub getSequenceDropDown {
|
Line 3146 sub getSequenceDropDown {
|
} |
} |
|
|
sub scantron_uploads { |
sub scantron_uploads { |
#FIXME need to support scantron files put in another location, |
|
# maybe the course directory? a scantron dir in the course directory? |
|
if (!-e $Apache::lonnet::perlvar{'lonScansDir'}) { return ''}; |
if (!-e $Apache::lonnet::perlvar{'lonScansDir'}) { return ''}; |
my $result= '<select name="scantron_selectfile">'; |
my $result= '<select name="scantron_selectfile">'; |
opendir(DIR,$Apache::lonnet::perlvar{'lonScansDir'}); |
my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; |
my @files=sort(readdir(DIR)); |
my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
|
my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname, |
|
&Apache::loncreatecourse::propath($cdom,$cname)); |
foreach my $filename (@files) { |
foreach my $filename (@files) { |
if ($filename eq '.' or $filename eq '..') { next; } |
($filename)=split(/&/,$filename); |
|
if ($filename!~/^scantron_orig_/) { next ; } |
|
$filename=~s/^scantron_orig_//; |
$result.="<option>$filename</option>\n"; |
$result.="<option>$filename</option>\n"; |
} |
} |
closedir(DIR); |
|
$result.="</select>"; |
$result.="</select>"; |
return $result; |
return $result; |
} |
} |
Line 3921 SCANTRONFORM
|
Line 3922 SCANTRONFORM
|
sub scantron_upload_scantron_data { |
sub scantron_upload_scantron_data { |
my ($r)=@_; |
my ($r)=@_; |
$r->print(&Apache::loncommon::coursebrowser_javascript($ENV{'request.role.domain'})); |
$r->print(&Apache::loncommon::coursebrowser_javascript($ENV{'request.role.domain'})); |
$r->print(&Apache::loncommon::selectcourse_link('rules', |
my $select_link=&Apache::loncommon::selectcourse_link('rules','courseid', |
'courseid','domain')); |
'domainid'); |
$r->print("Course: <input name='courseid' type='text'/>"); |
my $domsel=&Apache::loncommon::select_dom_form($ENV{'request.role.domain'}, |
$r->print("Domain: <input name='domain' type='text'/>"); |
'domainid'); |
|
$r->print(<<UPLOAD); |
|
<script type="text/javascript" language="javascript"> |
|
function checkUpload(formname) { |
|
if (formname.upfile.value == "") { |
|
alert("Please use the browse button to select a file from your local directory."); |
|
return false; |
|
} |
|
formname.submit(); |
|
} |
|
</script> |
|
|
|
<form enctype='multipart/form-data' action='/adm/grades' name='rules' method='post'> |
|
Course: <input name='courseid' type='text' /> |
|
Domain: $domsel $select_link |
|
<br /> |
|
<input name='command' value='scantronupload_save' type='hidden' /> |
|
File to upload:<input type="file" name="upfile" size="50" /> |
|
<br /> |
|
<input type="button" onClick="javascript:checkUpload(this.form);" value="Upload Scantron Data" /> |
|
</form> |
|
UPLOAD |
return ''; |
return ''; |
|
} |
|
|
|
sub scantron_upload_scantron_data_save { |
|
my($r)=@_; |
|
$r->print("Doing upload to ".$ENV{'form.courseid'}); |
|
my $home=&Apache::lonnet::homeserver($ENV{'form.courseid'}, |
|
$ENV{'form.domainid'}); |
|
my $fname='scantron_orig_'.$ENV{'form.upfile.filename'}; |
|
$r->print(&Apache::lonnet::finishuserfileupload($ENV{'form.courseid'}, |
|
$ENV{'form.domainid'}, |
|
$home,'upfile',$fname)); |
|
return ''; |
} |
} |
|
|
|
|
#-------- end of section for handling grading scantron forms ------- |
#-------- end of section for handling grading scantron forms ------- |
# |
# |
#------------------------------------------------------------------- |
#------------------------------------------------------------------- |
Line 4115 sub handler {
|
Line 4149 sub handler {
|
$url = $ENV{'form.url'}; |
$url = $ENV{'form.url'}; |
} |
} |
&send_header($request); |
&send_header($request); |
if ($url eq '' && $symb eq '') { |
if ($url eq '' && $symb eq '' && $command eq '') { |
if ($ENV{'user.adv'}) { |
if ($ENV{'user.adv'}) { |
if (($ENV{'form.codeone'}) && ($ENV{'form.codetwo'}) && |
if (($ENV{'form.codeone'}) && ($ENV{'form.codetwo'}) && |
($ENV{'form.codethree'})) { |
($ENV{'form.codethree'})) { |
Line 4199 sub handler {
|
Line 4233 sub handler {
|
$request->print(&scantron_validate_file($request)); |
$request->print(&scantron_validate_file($request)); |
} elsif ($command eq 'scantron_process' && $perm{'mgr'}) { |
} elsif ($command eq 'scantron_process' && $perm{'mgr'}) { |
$request->print(&scantron_process_students($request)); |
$request->print(&scantron_process_students($request)); |
} elsif ($command eq 'scantronupload' && &Apache::lonnet::allowed('usc',$ENV{'request.role.domain'})) { |
} elsif ($command eq 'scantronupload' && |
|
&Apache::lonnet::allowed('usc',$ENV{'request.role.domain'})) { |
$request->print(&scantron_upload_scantron_data($request)); |
$request->print(&scantron_upload_scantron_data($request)); |
|
|
|
} elsif ($command eq 'scantronupload_save' && |
|
&Apache::lonnet::allowed('usc',$ENV{'request.role.domain'})) { |
|
$request->print(&scantron_upload_scantron_data_save($request)); |
} elsif ($command) { |
} elsif ($command) { |
$request->print("Access Denied"); |
$request->print("Access Denied"); |
} |
} |