--- modules/gci/londocsgci.pm 2009/12/20 04:32:03 1.5
+++ modules/gci/londocsgci.pm 2010/11/16 02:28:10 1.15
@@ -2,7 +2,7 @@
# Custom Edit Course Routines for Assembly of Valid Concept Tests from
# Geoscience Concept Inventory.
#
-# $Id: londocsgci.pm,v 1.5 2009/12/20 04:32:03 gci Exp $
+# $Id: londocsgci.pm,v 1.15 2010/11/16 02:28:10 gci Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -44,10 +44,13 @@ use LONCAPA qw(:DEFAULT :match);
my $path;
my $version;
my $reqnum;
+my @mandcats;
+my @bincats;
my @categories;
my @allprobs;
my %probcat;
my %prereqs;
+my %revreqs;
my @defchosen;
my @chosen;
my @mandprobs;
@@ -55,7 +58,6 @@ my @bins;
my @optional;
my %mandatory;
my @development;
-my %developmentitems;
sub setdefaults {
$path='/res/gci/gci';
@@ -90,10 +92,10 @@ sub setdefaults {
['63','64','65'],
['66','67','68','69','70','71']);
@optional = ('05','11','29','31');
-
- @categories=('M1','M2','M3','M4',
- 'A','B','C','D','E','F','G','H','I','J','K');
- %probcat =('01' => 'M1' ,'02' => 'M2' ,'37' => 'M3' ,'2004_73' => 'M4' ,
+ @mandcats = ('M1','M2','M3','M4');
+ @bincats = ('A','B','C','D','E','F','G','H','I','J','K');
+ @categories=(@mandcats,@bincats);
+ %probcat =('01' => 'M1' ,'02' => 'M2' ,'37' => 'M3' ,'2004_73' => 'M4' ,
'03' => 'A' ,'04' => 'A','05' => '' ,'06' => 'A' ,'07' => 'B' ,
'08' => 'B' ,'09' => 'B' ,'10' => 'C' ,'11' => '' ,'12' => 'C' ,
'13' => 'C' ,'14' => 'C' ,'15' => 'C' ,'16' => 'C' ,'17' => 'C' ,'18' => 'D' ,'19' => 'D' ,'20' => 'D' ,
@@ -106,12 +108,14 @@ sub setdefaults {
'60' => 'I' ,
'61' => 'I' ,'62' => 'I' ,'63' => 'J' ,'64' => 'J' ,'65' => 'J' ,'66' => 'K' ,'67' => 'K' ,'68' => 'K' ,'69' => 'K' ,'70' => 'K' ,
'71' => 'K');
- %mandatory=('01' => 1 ,'02' => 1,'37' => 1, '2004_73' => 1);
- @mandprobs = ('01','02','37','2004_73');
- %prereqs=('10' => '08', '57' => '52', '69' => '18');
- @defchosen=('01','02','03','07','12','18','26','32','37','38','47','54','63','66','2004_73');
- @development = ('100','101','102');
- %developmentitems = ('100' => 1, '101' => '1', '102' => '1');
+ %mandatory=('01' => 1 ,'02' => 1,'37' => 1, '2004_73' => 1);
+ @mandprobs = ('01','02','37','2004_73');
+ %prereqs=('10' => '08', '57' => '52', '69' => '18');
+ foreach my $item (keys(%prereqs)) {
+ $revreqs{$prereqs{$item}} = $item;
+ }
+ @defchosen=('01','02','03','07','12','18','26','32','37','38','47','54','63','66','2004_73');
+ @development = ('001','002','003','004','005','006','007','008','009','010','011','012','013','014','015','016','017','018','019','020','021','022','023','024','025','026','027');
}
sub checkvalid {
@@ -134,7 +138,11 @@ sub checkvalid {
foreach my $item (@chosen) {
if ($prereqs{$item}) {
unless ($chosenproblems{$prereqs{$item}}) {
- push(@errors,&mt('Problem [_1] requires problem [_2].',$item,$prereqs{$item}));
+ my $url = &fullurl($item);
+ my $title = &Apache::lonnet::metadata($url,'title');
+ my $prerequrl = &fullurl($prereqs{$item});
+ my $prereqtitle = &Apache::lonnet::metadata($prerequrl,'title');
+ push(@errors,&mt('[_1] requires [_2].',"'$title'","'$prereqtitle'"));
}
}
}
@@ -142,11 +150,21 @@ sub checkvalid {
}
sub fullurl {
- my ($item)=@_;
+ my ($item,$catname)=@_;
unless ($item=~/\_/) { $item='_'.$item; }
+ if ($catname eq 'development') {
+ return $path.'/pilot/pilot'.$item.'.problem';
+ }
return $path.'/'.$version.'/GCI'.$item.'.problem';
}
+sub item_from_url {
+ my ($url)=@_;
+ if ($url =~ m{\Q$path\E/\Q$version\E/GCI_?([^.]+)\.problem$}) {
+ return $1;
+ }
+}
+
sub validcheck {
my ($r)=@_;
my @errors=&checkvalid();
@@ -164,6 +182,21 @@ sub validcheck {
sub listresources {
my ($r,$context,$cdom,$cnum)=@_;
my $numchosen = scalar(@chosen);
+ my $multipart = 0;
+ my $composites;
+ if ($numchosen > 0) {
+ foreach my $key (keys(%prereqs)) {
+ if (grep(/^\Q$key\E/,@chosen)) {
+ $multipart ++;
+ $numchosen --;
+ }
+ }
+ if ($multipart) {
+ $composites = &mt(' (of which [quant,_1,is a combination question,are combination questions] in which students select both an answer, and the reasoning used).',$multipart).'
';
+ } else {
+ $composites = '. ';
+ }
+ }
unless ($numchosen > 0) {
$r->print('
'.&mt('Choose how the test should be built:').'
'.
@@ -179,7 +212,7 @@ sub listresources {
} else {
my $numsub = &get_submissions_count($cdom,$cnum);
unless ($env{'form.phase'} eq 'storemap') {
- $r->print('
'.&mt('This course contains a valid concept test which includes [quant,_1,question].',$numchosen).' '.&mt('Display Contents').'
');
+ $r->print('
'.&mt('This course contains a valid concept test which includes [quant,_1,question]',$numchosen).$composites.''.&mt('Display Contents').'
');
}
if ($numsub > 0) {
$r->print(&mt('As there are existing student submissions, modification of the [_1]contents[_2] of the Concept Test will result in loss of student performance data, and is [_3]not[_4] permitted.','','','','').'
'.&mt('Modification of open and close dates [_1]is[_2] permitted.','','').'