--- loncom/homework/essayresponse.pm 2010/09/13 04:23:00 1.101.10.2
+++ loncom/homework/essayresponse.pm 2010/08/22 19:00:15 1.109
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# essay (ungraded) style responses
#
-# $Id: essayresponse.pm,v 1.101.10.2 2010/09/13 04:23:00 raeburn Exp $
+# $Id: essayresponse.pm,v 1.109 2010/08/22 19:00:15 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -58,25 +58,27 @@ sub start_essayresponse {
if (!defined($maxfilesize)) {
$maxfilesize = 10.0; #FIXME This should become a domain configuration
}
- if ( $Apache::lonhomework::type eq 'survey' ) {
- $result.= ' ';
+ if (($Apache::lonhomework::type eq 'survey') ||
+ ($Apache::lonhomework::type eq 'surveycred') ||
+ ($Apache::lonhomework::type eq 'anonsurvey') ||
+ ($Apache::lonhomework::type eq 'anonsurveycred')) {
+ $result.= '';
}
my $status_text = &mt('Submission type');
if ($Apache::lonhomework::history{"resource.$part.award"} eq 'DRAFT') {
$status_text .= '
'.&mt('(Currently -- draft)');
}
- $result.= '
'.&Apache::lonhtmlcommon::start_pick_box(); - if ( $Apache::lonhomework::type ne 'survey' ) { - if ($env{'request.uri'} eq '/res/gci/gci/internal/submission.problem') { - - $result .= ''; - } else { - $result .= &Apache::lonhtmlcommon::row_title($status_text); - my $closure; - unless ($ncol || $uploadedfiletypes) { - $closure = 1; - } - $result.= + $result.= '
'.&Apache::lonhtmlcommon::start_pick_box().
+ &Apache::lonhtmlcommon::row_title($status_text);
+ if (($Apache::lonhomework::type ne 'survey') &&
+ ($Apache::lonhomework::type ne 'surveycred') &&
+ ($Apache::lonhomework::type ne 'anonsurvey') &&
+ ($Apache::lonhomework::type ne 'anonsurveycred')) {
+ my $closure;
+ unless ($ncol || $uploadedfiletypes) {
+ $closure = 1;
+ }
+ $result.=
''.
- &Apache::lonhtmlcommon::row_closure($closure);
- }
+ &Apache::lonhtmlcommon::row_closure($closure);
}
+
if ($ncol > 0) {
$result.= &Apache::lonhtmlcommon::row_title(&mt('Collaborators')).
'
';
$result .= &check_collaborators($ncol,$coll) if ($coll =~ /\w+/);
- $result .= &Apache::lonhtmlcommon::row_closure();
+ $result .= &Apache::lonhtmlcommon::row_closure();
}
my $filesfrom = 'both';
my $stuname = &Apache::lonnet::EXT('user.name');
@@ -141,22 +143,22 @@ sub end_essayresponse {
my $increment = &Apache::response::repetition();
my $result;
if ( $target eq 'grade' ) {
- my $collaborators = $env{'form.HWCOL'.$part.'_'.$id};
- if ($collaborators =~ /[^\s]/) {
- my $previous_list= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.collaborators"},'<>&"');
- $Apache::lonhomework::results{"resource.$part.$id.collaborators"}=$collaborators
- if ($collaborators ne $previous_list);
- }
+# Deal with collaborators
+ my $collaborators = $env{'form.HWCOL'.$part.'_'.$id};
+ my $previous_list= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.collaborators"},'<>&"');
+ if ($collaborators ne $previous_list) {
+# &Apache::lonnet::logthis("New collaborators [$collaborators] [$previous_list]");
+ $Apache::lonhomework::results{"resource.$part.$id.collaborators"}=$collaborators;
+ }
+# Scantron
if ( &Apache::response::submitted('scantron') ) {
$increment=&Apache::response::scored_response($part,$id);
} elsif ( &Apache::response::submitted() ) {
my $response = $env{'form.HWVAL_'.$id};
- my $jspart=$part;
- $jspart=~s/\./_/g;
- my $filename = $env{'form.HWFILE'.$jspart.'_'.$id.'.filename'} ||
+ my $filename = $env{'form.HWFILE'.$part.'_'.$id.'.filename'} ||
$env{'form.HWFILETOOBIG'.$part.'_'.$id};
- my $portfiles = $env{'form.HWPORT'.$jspart.'_'.$id};
- my @deletions = &Apache::loncommon::get_env_multiple('form.HWFILE'.$jspart.'_'.$id.'_delete');
+ my $portfiles = $env{'form.HWPORT'.$part.'_'.$id};
+ my @deletions = &Apache::loncommon::get_env_multiple('form.HWFILE'.$part.'_'.$id.'_delete');
my ($is_submit,$was_draft);
if ($env{'form.HWDRAFT'.$part.'_'.$id} eq 'yes') {
$is_submit = 1;
@@ -166,9 +168,17 @@ sub end_essayresponse {
}
if (($response =~ /[^\s]/) || ($filename =~ /[^\s]/) || ($portfiles =~ /[^\s]/) ||
(@deletions > 0) || ($was_draft && $is_submit)) {
- my $award='DRAFT';
+ my $award='DRAFT';
if ($env{'form.HWDRAFT'.$part.'_'.$id} eq 'yes') {
- $award='SUBMITTED';
+ if ($Apache::lonhomework::type eq 'anonsurvey') {
+ $award='ANONYMOUS';
+ } elsif ($Apache::lonhomework::type eq 'anonsurveycred') {
+ $award='ANONYMOUS_CREDIT';
+ } elsif ($Apache::lonhomework::type eq 'surveycred') {
+ $award='SUBMITTED_CREDIT';
+ } else {
+ $award='SUBMITTED';
+ }
}
my $uploadedflag=0;
my $totalsize=0;
@@ -202,7 +212,7 @@ sub end_essayresponse {
{ $akey => $response },$adom,$aname);
}
}
- }
+ }
}
} elsif ($target eq 'edit') {
$result.=&Apache::edit::end_table();
@@ -295,9 +305,7 @@ sub file_submission {
if (grep(/^\Q$file\E$/,@portfiles)) {
$port_delete{$file} = 1;
} elsif ($file =~ m{^/uploaded/\Q$udom\E/\Q$uname\E/essayresponse/\Q$cdom\E/\Q$cnum\E/}) {
- $uploaded_delete = $file;
- } elsif ($file =~ m{^/uploaded/\Q$udom\E/\Q$uname\E/essayresponse/[^/]+$}) {
- $uploaded_delete = $file;
+ $uploaded_delete = $file;
}
}
}
@@ -308,12 +316,8 @@ sub file_submission {
}
}
if ($uploaded_delete) {
- if ($uploaded_delete eq $uploadedurl) {
- $Apache::lonhomework::results{"resource.$part.$id.uploadedfile"} = "";
- $Apache::lonhomework::results{"resource.$part.$id.uploadedurl"} = "";
- } else {
- undef($uploaded_delete);
- }
+ $Apache::lonhomework::results{"resource.$part.$id.uploadedfile"} = "";
+ $Apache::lonhomework::results{"resource.$part.$id.uploadedurl"} = "";
}
}
if ($env{'form.HWPORT'.$jspart.'_'.$id} ne '') {
@@ -327,7 +331,7 @@ sub file_submission {
}
}
}
- if ($env{'form.HWFILETOOBIG'.$part.'_'.$id} ne '') {
+ if ($env{'form.HWFILETOOBIG'.$jspart.'_'.$id} ne '') {
$$award = 'EXCESS_FILESIZE';
} elsif ($env{'form.HWFILE'.$jspart.'_'.$id.'.filename'} ne '') {
my $newfile = $env{'form.HWFILE'.$jspart.'_'.$id.'.filename'};
@@ -387,7 +391,7 @@ sub file_submission {
if (ref($dirlist{$fullpath}) eq 'ARRAY') {
foreach my $dir_line (@{$dirlist{$fullpath}}) {
my ($fname,$dom,undef,$testdir,undef,undef,undef,undef,
- $size,undef,$mtime,undef,undef,undef,$obs,undef) =
+ $size,undef,$mtime,undef,undef,undef,$obs,undef) =
split(/\&/,$dir_line,16);
if ($filename eq $fname) {
my $mbsize = $size/(1024.0*1024.0);
@@ -479,7 +483,8 @@ sub file_submission {
push(@pathitems,$restitle);
$path .= join('/',@pathitems);
my $formelement = 'HWFILE'.$jspart.'_'.$id;
- my $fname = &Apache::lonnet::clean_filename($env{'form.'.$formelement.'.filename'});
+ my $fname = $env{'form.'.$formelement.'.filename'};
+ &Apache::lonnet::clean_filename($fname);
my $url = '/uploaded/'.$udom.'/'.$uname.'/'.$prefix.$path.'/'.$fname;
my @stat = &Apache::lonnet::stat_file($url);
if (@stat && $stat[0] ne 'no_such_dir') {
@@ -493,9 +498,9 @@ sub file_submission {
$Apache::lonhomework::results{"resource.$part.$id.portfiles"} = $stored_upload;
push(@tolock,$stored_upload);
} else {
- $$award = 'INTERNAL_ERROR';
+ $$award = 'INTERNAL_ERROR';
}
- }
+ }
delete($env{'form.HWFILE'.$jspart.'_'.$id});
}
if (@accepted_portfiles) {
@@ -510,9 +515,7 @@ sub file_submission {
$Apache::lonhomework::results{"resource.$part.$id.portfiles"} = "";
}
}
- if (($Apache::lonhomework::history{"resource.$part.$id.portfiles"} ne
- $Apache::lonhomework::results{"resource.$part.$id.portfiles"}) ||
- ($uploaded_delete)) {
+ if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"} ne $Apache::lonhomework::results{"resource.$part.$id.portfiles"}) {
if (ref($uploadedflag)) {
$$uploadedflag=1;
}