[LON-CAPA-cvs] cvs: loncom /homework default_homework.lcpm /homework/caparesponse caparesponse.pm /interface loncommon.pm
raeburn
raeburn@source.lon-capa.org
Thu, 16 Dec 2010 16:01:14 -0000
This is a MIME encoded message
--raeburn1292515274
Content-Type: text/plain
raeburn Thu Dec 16 16:01:14 2010 EDT
Modified files:
/loncom/homework default_homework.lcpm
/loncom/homework/caparesponse caparesponse.pm
/loncom/interface loncommon.pm
Log:
- Bug 5531.
caparesponse.pm
- For stringresponse: (case (in)sensitive) computer's answer available
in detailed submission display.
- Student username in warnings on control characters etc. renamed $sname
instead of $name (already in use in different scope) to improve code
readability
- computer answer available for legacy stringresponse submission (e.g.,
for bug 5531 detection script -see neutrinohavest.pl)
if grade_retrieveanswers included in form for answer target.
default_homework.pm
- fix detection of control characters in answers - answers will be in
an array
- computer's answer returned by &caparesponse_check_list()
loncommon.pm
- &format_previous_attempt_value() handles display of computer's answer.
- fix typo in phrase for localization (no current translations in
localize/*.pm to update).
--raeburn1292515274
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20101216160114.txt"
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.150 loncom/homework/default_homework.lcpm:1.151
--- loncom/homework/default_homework.lcpm:1.150 Mon Oct 18 19:47:31 2010
+++ loncom/homework/default_homework.lcpm Thu Dec 16 16:01:01 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run()
#
-# $Id: default_homework.lcpm,v 1.150 2010/10/18 19:47:31 raeburn Exp $
+# $Id: default_homework.lcpm,v 1.151 2010/12/16 16:01:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -359,11 +359,25 @@
my $allow_control_char = 0;
my $control_chars_removed = 0;
+ my $ansstring;
if ($type eq 'cs' || $type eq 'ci') {
if (ref($LONCAPA::CAPAresponse_answer->{'answers'}) eq 'ARRAY') {
foreach my $strans (@{$LONCAPA::CAPAresponse_answer->{'answers'}}) {
- if ($strans =~ /[\000-\037]/) {
- $allow_control_char = 1;
+ if (ref($strans) eq 'ARRAY') {
+ foreach my $item (@{$strans}) {
+ if ($item =~ /[\000-\037]/) {
+ $allow_control_char = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (($type eq 'cs') || ($type eq 'ci')) {
+ if (ref($LONCAPA::CAPAresponse_answer->{'answers'}) eq 'ARRAY') {
+ foreach my $answer (@{ $LONCAPA::CAPAresponse_answer->{'answers'} }) {
+ if (ref($answer) eq 'ARRAY') {
+ $ansstring = join("\0",@{$answer});
}
}
}
@@ -476,7 +490,7 @@
&LONCAPA_INTERNAL_DEBUG(" all final_awards ".join(':',@final_awards));
my ($final_award,$final_msg) =
&LONCAPA_INTERNAL_FINALIZEAWARDS(\@final_awards,\@final_msg,undef,1);
- return ($final_award,$final_msg,$error,$control_chars_removed);
+ return ($final_award,$final_msg,$error,$control_chars_removed,$ansstring);
}
sub verify_stringresponse {
Index: loncom/homework/caparesponse/caparesponse.pm
diff -u loncom/homework/caparesponse/caparesponse.pm:1.242 loncom/homework/caparesponse/caparesponse.pm:1.243
--- loncom/homework/caparesponse/caparesponse.pm:1.242 Mon Oct 18 19:47:39 2010
+++ loncom/homework/caparesponse/caparesponse.pm Thu Dec 16 16:01:08 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# caparesponse definition
#
-# $Id: caparesponse.pm,v 1.242 2010/10/18 19:47:39 raeburn Exp $
+# $Id: caparesponse.pm,v 1.243 2010/12/16 16:01:08 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -451,6 +451,7 @@
my ($result,@msgs) =
&Apache::run::run("&caparesponse_check_list()",$safeeval);
&Apache::lonxml::debug("checking $name $result with $response took ".&Time::HiRes::tv_interval($t0));
+
&Apache::lonxml::debug('msgs are '.join(':',@msgs));
my ($awards)=split(/:/,$result);
my @awards= split(/,/,$awards);
@@ -1223,17 +1224,20 @@
$$args_ref{'type'} = 'ci';
}
&add_in_tag_answer($parstack,$safeeval);
- my (@final_awards,@final_msgs,@names);
+ my (@final_awards,@final_msgs,@names,%ansstring);
foreach my $name (keys(%answer)) {
&Apache::lonxml::debug(" doing $name with ".join(':',@{ $answer{$name}{'answers'} }));
${$safeeval->varglob('LONCAPA::CAPAresponse_answer')}=dclone($answer{$name});
my ($result, @msgs)=&Apache::run::run("&caparesponse_check_list()",$safeeval);
if ($$args_ref{'type'} =~ /^c[si]$/) {
+ $ansstring{$name} = pop(@msgs);
+ }
+ if ($$args_ref{'type'} =~ /^c[si]$/) {
my $control_chars_removed = pop(@msgs);
my $error = pop(@msgs);
if (($error ne '') ||
($control_chars_removed ne '')) {
- my ($symb,$courseid,$domain,$name) =
+ my ($symb,$courseid,$sdomain,$sname) =
&Apache::lonnet::whichuser();
if ($control_chars_removed ne '') {
my $showresponse = $response;
@@ -1244,11 +1248,11 @@
my @lines = split(/[\r\n\f]+/,$showresponse);
$showresponse = join('\\n',@lines);
}
- &Apache::lonnet::logthis("Stringresponse grading: control characters stripped from submission ".$showresponse." for $name:$domain in $courseid for part: $part response: $id and symb: $symb");
+ &Apache::lonnet::logthis("Stringresponse grading: control characters stripped from submission ".$showresponse." for $sname:$sdomain in $courseid for part: $part response: $id and symb: $symb");
$Apache::lonhomework::results{"resource.$part.$id.submission"} = $response;
}
if ($error ne '') {
- &Apache::lonnet::logthis("Stringresponse grading error: $error for $name:$domain in $courseid for part: $part response: $id and symb: $symb");
+ &Apache::lonnet::logthis("Stringresponse grading error: $error for $sname:$sdomain in $courseid for part: $part response: $id and symb: $symb");
}
}
}
@@ -1266,6 +1270,9 @@
&Apache::inputtags::finalizeawards(\@final_awards,
\@final_msgs,
\@names,1);
+ if (keys(%ansstring) > 0) {
+ $Apache::lonhomework::results{"resource.$part.$id.answerstring"} = &Apache::lonnet::hash2str(%ansstring);
+ }
}
if (($ad eq 'INCORRECT' || $ad eq 'APPROX_ANS' ||
$ad eq 'EXACT_ANS')) {
@@ -1317,6 +1324,9 @@
if ($target eq 'answer') {
$result.=&Apache::response::answer_part('stringresponse',
$element);
+ if ($env{'form.grade_retrieveanswers'}) {
+ $env{'form.grade_answers.resource.'.$part.'.'.$id} = $element;
+ }
} elsif ($target eq 'analyze') {
push (@{ $Apache::lonhomework::analyze{"$part.$id.answer"}{$name}[$i] },
$element);
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.987 loncom/interface/loncommon.pm:1.988
--- loncom/interface/loncommon.pm:1.987 Sun Nov 28 00:04:05 2010
+++ loncom/interface/loncommon.pm Thu Dec 16 16:01:14 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.987 2010/11/28 00:04:05 raeburn Exp $
+# $Id: loncommon.pm,v 1.988 2010/12/16 16:01:14 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3551,6 +3551,29 @@
$value = &Apache::lonlocal::locallocaltime($value);
} elsif (ref($value) eq 'ARRAY') {
$value = '('.join(', ', @{ $value }).')';
+ } elsif ($key =~ /answerstring$/) {
+ my %answers = &Apache::lonnet::str2hash($value);
+ my @anskeys = sort(keys(%answers));
+ if (@anskeys == 1) {
+ my $answer = $answers{$anskeys[0]};
+ if ($answer =~ m{\Q\0\E}) {
+ $answer =~ s{\Q\0\E}{, }g;
+ }
+ my $tag_internal_answer_name = 'INTERNAL';
+ if ($anskeys[0] eq $tag_internal_answer_name) {
+ $value = $answer;
+ } else {
+ $value = $anskeys[0].'='.$answer;
+ }
+ } else {
+ foreach my $ans (@anskeys) {
+ my $answer = $answers{$ans};
+ if ($answer =~ m{\Q\0\E}) {
+ $answer =~ s{\Q\0\E}{, }g;
+ }
+ $value .= $ans.'='.$answer.'<br />';;
+ }
+ }
} else {
$value = &unescape($value);
}
@@ -8730,7 +8753,7 @@
if ($context eq 'portfolio') {
$output .= '<p>'.&mt('or').'</p>';
} elsif ($context eq 'testbank') {
- $output .= '<p>'.&mt('Or [_1]continue[_2] the testbank import without modifying the references(s).','<a href="javascript:document.testbankForm.submit();">','</a>').'</p>';
+ $output .= '<p>'.&mt('Or [_1]continue[_2] the testbank import without modifying the reference(s).','<a href="javascript:document.testbankForm.submit();">','</a>').'</p>';
$returnflag = 'modify_orightml';
}
}
--raeburn1292515274--