--- modules/gci/londocsgci.pm 2009/12/25 00:49:35 1.7 +++ modules/gci/londocsgci.pm 2010/01/09 01:07:56 1.10 @@ -2,7 +2,7 @@ # Custom Edit Course Routines for Assembly of Valid Concept Tests from # Geoscience Concept Inventory. # -# $Id: londocsgci.pm,v 1.7 2009/12/25 00:49:35 gci Exp $ +# $Id: londocsgci.pm,v 1.10 2010/01/09 01:07:56 gci Exp $ # # Copyright Michigan State University Board of Trustees # @@ -58,7 +58,6 @@ my @bins; my @optional; my %mandatory; my @development; -my %developmentitems; sub setdefaults { $path='/res/gci/gci'; @@ -116,8 +115,7 @@ sub setdefaults { $revreqs{$prereqs{$item}} = $item; } @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'); + @development = ('001','002','003','004','005','006','007','008','009','010','011','012','013','014'); } sub checkvalid { @@ -152,8 +150,11 @@ 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'; } @@ -181,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('Create a Concept Test').'

'. '

'.&mt('Choose how the test should be built:').'
'. @@ -196,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.','','').'

'); @@ -227,7 +243,8 @@ sub listresources { &Apache::lonhtmlcommon::row_closure(1). &Apache::lonhtmlcommon::row_title(&mt('Close date')). $endform. - &Apache::lonhtmlcommon::end_pick_box().'
'. + &Apache::lonhtmlcommon::row_closure(1). + &Apache::lonhtmlcommon::end_pick_box().'
'. ''. ''. '

'); @@ -293,7 +310,7 @@ sub display_questions { 'value="'.$fixed{$catname}.'" readonly="readonly" />').''; } else { $output .= ''.&mt('[_1]: currently [_2] selected',$catlegend, - '').''; } $output .= ''. @@ -309,13 +326,15 @@ sub display_questions { ''.&mt('Preview').''. &Apache::loncommon::end_data_table_header_row(); foreach my $item (@{$questions}) { - my $url = &fullurl($item); + my $url = &fullurl($item,$catname); my $title = &Apache::lonnet::metadata($url,'title'); $output .= &Apache::loncommon::start_data_table_row().''; - if (($catname eq 'mandatory') || ($catname eq 'development')) { + if ($catname eq 'mandatory') { $output .= ''; + } elsif ($catname eq 'development') { + $output .= ''; } else { - $output .= '{$item}) { $output .= ' checked="checked"'; } $output .= ' onclick="countChecked('."'$catname'".');'; my $binname; @@ -402,8 +421,9 @@ sub chosen_to_map { @LONCAPA::map::order=(); @LONCAPA::map::resources=(); my $counter = 0; + my $residx; for (my $idx=0;$idx<=$#allprobs;$idx++) { - my $residx=$idx+1; + $residx=$idx+1; if ($chosenproblems{$allprobs[$idx]}) { my $url = &LONCAPA::map::qtunescape(&fullurl($allprobs[$idx])); if (($revreqs{$allprobs[$idx]}) && @@ -419,6 +439,16 @@ sub chosen_to_map { $LONCAPA::map::resources[$residx]=join(':', ($name, $url, 'false', 'normal', 'res')); } } + foreach my $devitem (@development) { + if ($env{'form.pilot'.$devitem}) { + my $url = &LONCAPA::map::qtunescape(&fullurl($devitem,'development')); + $residx ++; + push(@LONCAPA::map::order,$residx); + $counter ++; + my $name = &LONCAPA::map::qtunescape('Problem '.$counter); + $LONCAPA::map::resources[$residx]=join(':', ($name, $url, 'false', 'normal', 'res')); + } + } } sub map_to_chosen { @@ -577,11 +607,13 @@ sub builder_javascript { my $prereqjs = " function checkPrereqs(caller,item,prereq,binname) { var changedPrereq = 0; - if (document.selecteditems.elements['item'+item].checked == false) { + element = document.getElementById('item'+item); + if (element.checked == false) { return; } else { - if (!document.selecteditems.elements['item'+prereq].checked) { - document.selecteditems.elements['item'+prereq].checked = true; + prereqelement = document.getElementById('item'+prereq); + if (!prereqelement.checked) { + prereqelement.checked = true; changedPrereq = 1; countChecked(binname); } @@ -666,13 +698,15 @@ function countChecked(binname) { if (document.selecteditems.elements[i].value == binname) { var itemname = document.selecteditems.elements[i].name; var itemnum = itemname.substr(9); - if (document.selecteditems.elements['item'+itemnum].checked) { + element = document.getElementById('item'+itemnum); + if (element.checked) { count ++; } } } } - document.selecteditems.elements['GCI_'+binname+'_count'].value = count; + countelement = document.getElementById('GCI_'+binname+'_count'); + countelement.value = count; } function validTestCheck() { @@ -680,7 +714,8 @@ function validTestCheck() { for (var i=0; i<11; i++) { var binname = 'GCI_bin'+i+'_count'; var j = i+1; - if (document.selecteditems.elements[binname].value < 1) { + countelement = document.getElementById(binname); + if (countelement.value < 1) { empty = empty +' '+j; } }