--- loncom/homework/inputtags.pm 2012/09/24 10:34:19 1.310
+++ loncom/homework/inputtags.pm 2014/01/13 15:29:10 1.323
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# input definitons
#
-# $Id: inputtags.pm,v 1.310 2012/09/24 10:34:19 foxr Exp $
+# $Id: inputtags.pm,v 1.323 2014/01/13 15:29:10 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -216,7 +216,16 @@ sub start_textfield {
}
}
unless ($newvariation) {
- $oldresponse = $Apache::lonhomework::history{"resource.$partid.$resid.submission"};
+ if ((($env{'form.grade_username'} eq '') && ($env{'form.grade_domain'} eq '')) ||
+ (($env{'form.grade_username'} eq $env{'user.name'}) &&
+ ($env{'form.grade_domain'} eq $env{'user.domain'}))) {
+ $oldresponse = $Apache::lonhomework::history{"resource.$partid.$resid.submission"};
+ } elsif (($Apache::lonhomework::history{"resource.$partid.type"} eq 'anonsurvey') ||
+ ($Apache::lonhomework::history{"resource.$partid.type"} eq 'anonsurveycred')) {
+ $oldresponse = '* '.&mt('(only shown to submitter)').' *';
+ } else {
+ $oldresponse = $Apache::lonhomework::history{"resource.$partid.$resid.submission"};
+ }
}
if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
my $cols = &Apache::lonxml::get_param('cols',$parstack,$safeeval);
@@ -245,7 +254,8 @@ sub start_textfield {
&& &Apache::londefdef::is_inside_of($tagstack,
'essayresponse') ) {
$result='
';
+ &HTML::Entities::encode($oldresponse,'"<>&').
+ '';
}
#get rid of any startup text
&Apache::lonxml::get_all_text("/textfield",$parser,$style);
@@ -266,10 +276,13 @@ sub start_textfield {
my $bodytext=&Apache::lonxml::get_all_text("/textfield",$parser,
$style);
$result.=&Apache::edit::editfield($token->[1],$bodytext,'Text you want to appear by default:',80,2);
+ my $spell_langs = &spelling_languages();
+ $result .= &Apache::edit::select_arg('Spellcheck for:', 'spellcheck',
+ $spell_langs, $token);
} elsif ($target eq 'modified') {
my $constructtag=&Apache::edit::get_new_args($token,$parstack,
$safeeval,'rows','cols',
- 'addchars');
+ 'addchars', 'spellcheck');
if ($constructtag) {
$result = &Apache::edit::rebuild_tag($token);
} else {
@@ -284,12 +297,18 @@ sub start_textfield {
for (my $i=0;$i[$#Apache::inputtags::inputlist];
@@ -453,12 +483,15 @@ sub start_textline {
'addchars',$token,10);
$result.=&Apache::edit::select_arg('Readonly:','readonly',
['no','yes'],$token);
+ my $spell_langs = &spelling_languages();
+ $result.=&Apache::edit::select_arg('Spellcheck for:', 'spellcheck',
+ $spell_langs, $token);
$result.=&Apache::edit::end_row();
$result.=&Apache::edit::end_table();
} elsif ($target eq 'modified') {
my $constructtag=&Apache::edit::get_new_args($token,$parstack,
$safeeval,'size',
- 'addchars','readonly');
+ 'addchars','readonly', 'spellcheck');
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
} elsif ($target eq 'tex'
&& $Apache::lonhomework::type ne 'exam') {
@@ -615,7 +648,7 @@ sub file_selector {
&mt('Allowed filetypes: [_1]',''.$uploadedfiletypes.'').'
';
}
if ($maxfilesize) {
- $constraints .= &mt('Combined size of all files not to exceed: [_1] MB[_2].',
+ $constraints .= &mt('Combined size of all files not to exceed: [_1] MB.',
''.$maxfilesize.'').'
';
}
if ($constraints) {
@@ -659,7 +692,8 @@ sub current_file_submissions {
my $uploadedfile=$Apache::lonhomework::history{"resource.$part.$id.uploadedfile"};
my $portfiles=$Apache::lonhomework::history{"resource.$part.$id.portfiles"};
return if (($uploadedfile eq '') && ($portfiles !~/[^\s]/));
- my $header = &Apache::loncommon::start_data_table().
+ my $header = &portpath_popup_js().
+ &Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row();
if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
$header .= ''.&mt('Delete?').' | ';
@@ -725,13 +759,24 @@ sub current_file_submissions {
' value="'.$portfile.'" id="HWFILE'.$jspart.'_'.$id.'_'.$num.'_delete" />'."\n";
$num ++;
}
- my $showname = $rows{$url}{path}.$name;
+ my $pathid = 'HWFILE'.$jspart.'_'.$id.'_'.$num.'_path';
+ my $pathidtext = $pathid.'text';
+ my ($showname,$showpath);
if ($legacy{$url}) {
$showname = $name.' '.&mt('not in portfolio');
+ } else {
+ $showname = $name;
+ $showpath = '
'.
+ ''.
+ ''.
+ &mt('(Show path)').''.
+ ''.$rows{$url}{path}.$name.
+'
';
}
$result .=
''.$showname.' | '."\n".
+ '" border="0" alt="" />'.$showname.''.$showpath.''."\n".
''.$rows{$url}{size}.' | '."\n".
''.$rows{$url}{lastmodified}.' | '."\n".
&Apache::loncommon::end_data_table_row();
@@ -786,6 +831,43 @@ sub current_file_info {
return ($status,\%info,$error);
}
+sub portpath_popup_js {
+ my %lt = &Apache::lonlocal::texthash(
+ show => '(Show path)',
+ hide => '(Hide)',
+ );
+ return <<"END";
+
+
+END
+}
+
sub valid_award {
my ($award) =@_;
foreach my $possibleaward ('EXTRA_ANSWER','MISSING_ANSWER', 'ERROR',
@@ -1056,7 +1138,7 @@ sub decideoutput {
$css_class=$possible_class{'not_charged_try'};
$button=1;
} elsif ($award eq 'EXCESS_FILESIZE') {
- $message = &mt('Submission won\'t be graded. The combined size of submitted files exceeded the amount allowed.');
+ $message = &mt("Submission won't be graded. The combined size of submitted files exceeded the amount allowed.");
$css_class=$possible_class{'not_charged_try'};
$button=1;
} elsif ($award eq 'FILENAME_INUSE') {
@@ -1066,7 +1148,7 @@ sub decideoutput {
} else {
$message .= '
';
}
- $message .= &mt('Please use a different file name.');
+ $message .= &mt('Please use a different filename.');
$css_class=$possible_class{'not_charged_try'};
$button=1;
} elsif ($award eq 'INVALID_FILETYPE') {
@@ -1626,6 +1708,7 @@ sub previous_tries {
my $count;
my %count_lookup;
my $lastrndseed;
+ my $numstamps = 0;
foreach my $i (1..$Apache::lonhomework::history{'version'}) {
my $prefix = $i.":resource.$id";
@@ -1682,10 +1765,17 @@ sub previous_tries {
$message =~ s{()}{};
- $output.=' | ';
- $output.=''.$count.' | ';
- $output.=$message;
-
+ $output .= '
'.
+ ''.$count.' | '.$message;
+ if ((!$is_anon) && ($Apache::lonhomework::history{"$prefix.tries"}) &&
+ ($Apache::lonhomework::history{"$prefix.award"} ne 'ASSIGNED_SCORE') &&
+ ($Apache::lonhomework::history{$i.':timestamp'})) {
+ $output .= ''.&Apache::lonlocal::locallocaltime(
+ $Apache::lonhomework::history{$i.':timestamp'}).' | ';
+ $numstamps ++;
+ } else {
+ $output .= ' | ';
+ }
foreach my $resid (@Apache::inputtags::response) {
my $prefix = $prefix.".$resid";
if (exists($Apache::lonhomework::history{"$prefix.submission"})) {
@@ -1708,10 +1798,20 @@ sub previous_tries {
$lastrndseed = $curr_rndseed;
}
return if ($output eq '');
- my $headers =
- '
'.''.&mt('Submission #').' | '.&mt('Try').
- ' | '.
- &mt('Submitted Answer').' | ';
+ my $headers = '
'.
+ ''.&mt('Submission #').' | '.
+ ''.&mt('Try').' | ';
+ if ($numstamps) {
+ $headers .= &mt('When');
+ }
+ $headers .= ' | ';
+ my $colspan = scalar(@Apache::inputtags::response);
+ if ($colspan > 1) {
+ $headers .= '';
+ } else {
+ $headers .= ' | ';
+ }
+ $headers .= &mt('Submitted Answer').' |
';
$output ='';
my $tries_text = &get_tries_text('link');
@@ -1745,6 +1845,21 @@ sub get_tries_text {
return $tries_text;
}
+sub spelling_languages {
+ my %langchoices;
+ foreach my $id (&Apache::loncommon::languageids()) {
+ my $code = &Apache::loncommon::supportedlanguagecode($id);
+ if ($code ne '') {
+ $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
+ }
+ }
+ my @spelllangs = ('none');
+ foreach my $code ('en','de','he','es','fr','pt','tr') {
+ push(@spelllangs,[$code,$langchoices{$code}]);
+ }
+ return \@spelllangs;
+}
+
1;
__END__