--- modules/gci/londocsgci.pm 2009/10/03 03:11:30 1.2 +++ modules/gci/londocsgci.pm 2009/11/27 23:48:25 1.3 @@ -2,7 +2,7 @@ # Custom Edit Course Routines for Assembly of Valid Concept Tests from # Geoscience Concept Inventory. # -# $Id: londocsgci.pm,v 1.2 2009/10/03 03:11:30 gci Exp $ +# $Id: londocsgci.pm,v 1.3 2009/11/27 23:48:25 gci Exp $ # # Copyright Michigan State University Board of Trustees # @@ -50,6 +50,7 @@ my %probcat; my %prereqs; my @defchosen; my @chosen; +my %mandatory; sub setdefaults { $path='/res/gci/gci'; @@ -88,6 +89,7 @@ sub setdefaults { '61' => 'I' ,'62' => 'I' ,'63' => 'J' ,'64' => 'J' ,'65' => 'J' ,'66' => 'K' ,'67' => 'K' ,'68' => 'K' ,'69' => 'K' ,'70' => 'K' , '71' => 'K' , '2004_73' => 'M4'); + %mandatory=('01' => 1 ,'02' => 1,'37' => 1,'2004_73' => 1); %prereqs=('10' => '08', '57' => '52', '69' => '18'); @defchosen=('01','02','03','07','12','18','26','32','37','38','47','54','63','66','2004_73'); } @@ -106,7 +108,7 @@ sub checkvalid { } foreach my $cat (@categories) { unless ($covered{$cat}) { - push(@errors,&mt('Category [_1] not covered.',$cat)); + push(@errors,&mt('Bin [_1] not covered.',$cat)); } } foreach my $item (@chosen) { @@ -125,7 +127,7 @@ sub fullurl { return $path.'/'.$version.'/GCI'.$item.'.problem'; } -sub listresources { +sub validcheck { my ($r)=@_; my @errors=&checkvalid(); if ($#errors>-1) { @@ -134,22 +136,50 @@ sub listresources { $r->print('
  • '.$message.'
  • '); } $r->print('

    '); + return 0; + } + return 1; +} + +sub listresources { + my ($r)=@_; + if ((!&validcheck($r)) || ($env{'form.editmyown'})) { + &editor($r); + } else { + $r->print('

    '); + $r->print(''); + $r->print('

    '); + $r->print(''); + foreach my $item (@defchosen) { + $r->print('print(''); + $r->print('

    '); } +} + +sub editor { + my ($r)=@_; my %chosen=(); foreach my $item (@chosen) { $chosen{$item}=1; } $r->print('

    '); - $r->print('

    '.&mt('You may select test items from the list below and then press "Store Problem Selection" at the bottom of the screen.').'

    '); + $r->print('

    '.&mt('You may select test items from the list below and then press "Store Problem Selection" at the bottom of the screen.').'

    '); + $r->print('

    '.&mt('Tests should have at least one item from each bin and [_1] items total.',$reqnum).'

    '); $r->print(&Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). - ''.&mt('Select').''.&mt('Problem').''.&mt('Category').''.&mt('Preview').''. + ''.&mt('Select').''.&mt('Problem').''.&mt('Bin').''.&mt('Preview').''. &Apache::loncommon::end_data_table_header_row()); foreach my $item (@allprobs) { $r->print(&Apache::loncommon::start_data_table_row()); $r->print(''); - $r->print('print(' checked="checked"'); } + if ($mandatory{$item}) { + $r->print('print('print(' checked="checked"'); } + } $r->print(' />'); $r->print(''.$item.''.$probcat{$item}.''); my $output=&Apache::lonindexer::showpreview(&fullurl($item)); @@ -220,12 +250,14 @@ sub store { if ($#errors>1) { return; } &chosen_to_map(); &storemap_gci(); - unless ($#errors>-1) { - $r->print('

    '.&mt('You have successfully assembled a valid test.'). + if ($env{'form.phase'} eq 'storemap') { + unless ($#errors>-1) { + $r->print('

    '.&mt('You have successfully assembled a valid test.'). ''. ''. '

    '); + } } }