[LON-CAPA-cvs] cvs: loncom /homework inputtags.pm structuretags.pm /xml scripttag.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 23 May 2003 16:26:28 -0000
albertel Fri May 23 12:26:28 2003 EDT
Modified files:
/loncom/xml scripttag.pm
/loncom/homework inputtags.pm structuretags.pm
Log:
- fixes BUG#1364, produces an error messages if a duplicated id is seen while in CSTR space and viewing a problem.
- now tracks all part numbers seen, and tracks all import ids seen
- properly use @Apace::inputtags::response for the list of response ids in this part
and responselist for all ids in the problem
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.89 loncom/xml/scripttag.pm:1.90
--- loncom/xml/scripttag.pm:1.89 Thu May 22 17:05:01 2003
+++ loncom/xml/scripttag.pm Fri May 23 12:26:28 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# <script> definiton
#
-# $Id: scripttag.pm,v 1.89 2003/05/22 21:05:01 albertel Exp $
+# $Id: scripttag.pm,v 1.90 2003/05/23 16:26:28 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -311,6 +311,7 @@
my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
if (!$id) { $id=$Apache::lonxml::curdepth; }
push(@Apache::inputtags::import,$id);
+ push(@Apache::inputtags::importlist,$id);
&Apache::lonxml::newparser($parser,\$file,$dir);
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.102 loncom/homework/inputtags.pm:1.103
--- loncom/homework/inputtags.pm:1.102 Fri May 23 03:04:44 2003
+++ loncom/homework/inputtags.pm Fri May 23 12:26:28 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# input definitons
#
-# $Id: inputtags.pm,v 1.102 2003/05/23 07:04:44 albertel Exp $
+# $Id: inputtags.pm,v 1.103 2003/05/23 16:26:28 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -52,6 +52,8 @@
@Apache::inputtags::previous_version=();
# id of current part, 0 means that no part is current (inside <problem> only
$Apache::inputtags::part='';
+ # list of all part ids seen
+ @Apache::inputtags::partlist=();
# list of problem date statuses, the first element is for <problem>
# if there is a second element it is for the current <part>
@Apache::inputtags::status=();
@@ -59,6 +61,26 @@
%Apache::inputtags::params=();
# list of all ids, for <import>, these get join()ed and prepended
@Apache::inputtags::import=();
+ # list of all import ids seen
+ @Apache::inputtags::importlist=();
+}
+
+sub check_for_duplicate_ids {
+ my %check;
+ foreach my $id (@Apache::inputtags::partlist,
+ @Apache::inputtags::responselist,
+ @Apache::inputtags::importlist) {
+ $check{$id}++;
+ }
+ my @duplicates;
+ foreach my $id (sort(keys(%check))) {
+ if ($check{$id} > 1) {
+ push(@duplicates,$id);
+ }
+ }
+ if (@duplicates) {
+ &Apache::lonxml::error("Duplicated ids found, problem will operate incorrectly. Duplicated ids seen: ",join(', ',@duplicates));
+ }
}
sub start_input {
@@ -429,10 +451,9 @@
$Apache::lonhomework::history{"resource.$id.tries"} + 1;
$Apache::lonhomework::results{"resource.$id.solved"} =
$solvemsg;
- my $numawards=scalar(@Apache::inputtags::responselist);
- &Apache::lonxml::debug("Whaaa!");
+ my $numawards=scalar(@Apache::inputtags::response);
$Apache::lonhomework::results{"resource.$id.awarded"} = 0;
- foreach my $res (@Apache::inputtags::responselist) {
+ foreach my $res (@Apache::inputtags::response) {
$Apache::lonhomework::results{"resource.$id.awarded"}+=
$Apache::lonhomework::results{"resource.$id.$res.awarded"};
}
@@ -503,7 +524,7 @@
my $response='';
if ( defined $ENV{'form.submitted'}) {
my @awards = ();
- foreach $response (@Apache::inputtags::responselist) {
+ foreach $response (@Apache::inputtags::response) {
&Apache::lonxml::debug("looking for response.$id.$response.awarddetail");
my $value=$Apache::lonhomework::results{"resource.$id.$response.awarddetail"};
&Apache::lonxml::debug("keeping $value from $response for $id");
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.176 loncom/homework/structuretags.pm:1.177
--- loncom/homework/structuretags.pm:1.176 Mon May 19 17:05:23 2003
+++ loncom/homework/structuretags.pm Fri May 23 12:26:28 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.176 2003/05/19 21:05:23 albertel Exp $
+# $Id: structuretags.pm,v 1.177 2003/05/23 16:26:28 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -274,7 +274,9 @@
}
#initialize globals
$Apache::inputtags::part='0';
+ @Apache::inputtags::partlist=('0');
@Apache::inputtags::responselist = ();
+ @Apache::inputtags::importlist = ();
@Apache::inputtags::previous=();
@Apache::inputtags::previous_version=();
$Apache::structuretags::printanswer='No';
@@ -529,6 +531,9 @@
$result = &problem_edit_footer();
}
+ if ($ENV{'request.state'} eq 'construct' && $target eq 'web') {
+ &Apache::inputtags::check_for_duplicate_ids();
+ }
undef(%Apache::lonhomework::history);
undef(%Apache::lonhomework::results);
undef($Apache::inputtags::part);
@@ -854,7 +859,8 @@
my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
if ($id eq '') { $id = $Apache::lonxml::curdepth; }
$Apache::inputtags::part=$id;
- @Apache::inputtags::responselist = ();
+ push(@Apache::inputtags::partlist,$id);
+ @Apache::inputtags::response=();
@Apache::inputtags::previous=();
@Apache::inputtags::previous_version=();
$Apache::lonhomework::problemstatus=