version 1.4, 2009/12/02 18:35:59
|
version 1.6, 2009/12/21 15:51:29
|
Line 44 use LONCAPA qw(:DEFAULT :match);
|
Line 44 use LONCAPA qw(:DEFAULT :match);
|
my $path; |
my $path; |
my $version; |
my $version; |
my $reqnum; |
my $reqnum; |
|
my @mandcats; |
|
my @bincats; |
my @categories; |
my @categories; |
my @allprobs; |
my @allprobs; |
my %probcat; |
my %probcat; |
my %prereqs; |
my %prereqs; |
|
my %revreqs; |
my @defchosen; |
my @defchosen; |
my @chosen; |
my @chosen; |
|
my @mandprobs; |
|
my @bins; |
|
my @optional; |
my %mandatory; |
my %mandatory; |
|
my @development; |
|
my %developmentitems; |
|
|
sub setdefaults { |
sub setdefaults { |
$path='/res/gci/gci'; |
$path='/res/gci/gci'; |
$version='GCIv2-1-1'; |
$version='GCIv2-1-1'; |
$reqnum=15; |
$reqnum=15; |
@allprobs=('01','02','03','04','05','06','07', |
@allprobs=('01','02','37','2004_73','03','04','05','06','07', |
'08','10', |
'08','10', |
'09', |
'09', |
'11','12','13','14','15','16','17', |
'11','12','13','14','15','16','17', |
'18','69', |
'18','69', |
'19','20', |
'19','20', |
'21','22','23','24','25','26','27','28','29','30', |
'21','22','23','24','25','26','27','28','29','30', |
'31','32','33','34','35','36','37','38', |
'31','32','33','34','35','36','38', |
'39A','39B', |
'39A','39B', |
'40', |
'40', |
'41','42','43','44','45','46','47','48','49','50', |
'41','42','43','44','45','46','47','48','49','50', |
Line 72 sub setdefaults {
|
Line 80 sub setdefaults {
|
'53','54','55','56','58', |
'53','54','55','56','58', |
'60', |
'60', |
'61','62','63','64','65','66','67','68','70', |
'61','62','63','64','65','66','67','68','70', |
'71', |
'71'); |
'2004_73'); |
@bins = ( ['03','04','06'], |
|
['07','08','09'], |
@categories=('M1','M2','M3','M4', |
['10','12','13','14','15','16','17'], |
'A','B','C','D','E','F','G','H','I','J','K'); |
['18','19','20','21','22','23','24','25'], |
%probcat =('01' => 'M1','02' => 'M2','03' => 'A' ,'04' => 'A' ,'05' => '' ,'06' => 'A' ,'07' => 'B' ,'08' => 'B' ,'09' => 'B' ,'10' => 'C' , |
['26','27','28','30'], |
'11' => '' ,'12' => 'C' ,'13' => 'C' ,'14' => 'C' ,'15' => 'C' ,'16' => 'C' ,'17' => 'C' ,'18' => 'D' ,'19' => 'D' ,'20' => 'D' , |
['32','33','34','35','36'], |
|
['38','39A','39B','40','41','42','43','44','45','46'], |
|
['47','48','49','50','51','52','53'], |
|
['54','55','56','57','58','60','61','62'], |
|
['63','64','65'], |
|
['66','67','68','69','70','71']); |
|
@optional = ('05','11','29','31'); |
|
@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' , |
'21' => 'D' ,'22' => 'D' ,'23' => 'D' ,'24' => 'D' ,'25' => 'D' ,'26' => 'E' ,'27' => 'E' ,'28' => 'E' ,'29' => '' ,'30' => 'E' , |
'21' => 'D' ,'22' => 'D' ,'23' => 'D' ,'24' => 'D' ,'25' => 'D' ,'26' => 'E' ,'27' => 'E' ,'28' => 'E' ,'29' => '' ,'30' => 'E' , |
'31' => '' ,'32' => 'F' ,'33' => 'F' ,'34' => 'F' ,'35' => 'F' ,'36' => 'F' ,'37' => 'M3','38' => 'G' , |
'31' => '' ,'32' => 'F' ,'33' => 'F' ,'34' => 'F' ,'35' => 'F' ,'36' => 'F' ,'38' => 'G' , |
'39A'=> 'G' ,'39B'=> 'G' , |
'39A'=> 'G' ,'39B'=> 'G' , |
'40' => 'G' , |
'40' => 'G' , |
'41' => 'G' ,'42' => 'G' ,'43' => 'G' ,'44' => 'G' ,'45' => 'G' ,'46' => 'G' ,'47' => 'H' ,'48' => 'H' ,'49' => 'H' ,'50' => 'H' , |
'41' => 'G' ,'42' => 'G' ,'43' => 'G' ,'44' => 'G' ,'45' => 'G' ,'46' => 'G' ,'47' => 'H' ,'48' => 'H' ,'49' => 'H' ,'50' => 'H' , |
'51' => 'H' ,'52' => 'H' ,'53' => 'H' ,'54' => 'I' ,'55' => 'I' ,'56' => 'I' ,'57' => 'I' ,'58' => 'I' , |
'51' => 'H' ,'52' => 'H' ,'53' => 'H' ,'54' => 'I' ,'55' => 'I' ,'56' => 'I' ,'57' => 'I' ,'58' => 'I' , |
'60' => 'I' , |
'60' => 'I' , |
'61' => 'I' ,'62' => 'I' ,'63' => 'J' ,'64' => 'J' ,'65' => 'J' ,'66' => 'K' ,'67' => 'K' ,'68' => 'K' ,'69' => 'K' ,'70' => 'K' , |
'61' => 'I' ,'62' => 'I' ,'63' => 'J' ,'64' => 'J' ,'65' => 'J' ,'66' => 'K' ,'67' => 'K' ,'68' => 'K' ,'69' => 'K' ,'70' => 'K' , |
'71' => 'K' , |
'71' => 'K'); |
'2004_73' => 'M4'); |
%mandatory=('01' => 1 ,'02' => 1,'37' => 1, '2004_73' => 1); |
%mandatory=('01' => 1 ,'02' => 1,'37' => 1,'2004_73' => 1); |
@mandprobs = ('01','02','37','2004_73'); |
%prereqs=('10' => '08', '57' => '52', '69' => '18'); |
%prereqs=('10' => '08', '57' => '52', '69' => '18'); |
@defchosen=('01','02','03','07','12','18','26','32','37','38','47','54','63','66','2004_73'); |
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 = ('100','101','102'); |
|
%developmentitems = ('100' => 1, '101' => '1', '102' => '1'); |
} |
} |
|
|
sub checkvalid { |
sub checkvalid { |
Line 114 sub checkvalid {
|
Line 140 sub checkvalid {
|
foreach my $item (@chosen) { |
foreach my $item (@chosen) { |
if ($prereqs{$item}) { |
if ($prereqs{$item}) { |
unless ($chosenproblems{$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'")); |
} |
} |
} |
} |
} |
} |
Line 123 sub checkvalid {
|
Line 153 sub checkvalid {
|
|
|
sub fullurl { |
sub fullurl { |
my ($item)=@_; |
my ($item)=@_; |
unless ($item=~/\_/) { $item='_'.$item; } |
unless ($item=~/^\_/) { $item='_'.$item; } |
return $path.'/'.$version.'/GCI'.$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 { |
sub validcheck { |
my ($r)=@_; |
my ($r)=@_; |
my @errors=&checkvalid(); |
my @errors=&checkvalid(); |
Line 142 sub validcheck {
|
Line 179 sub validcheck {
|
} |
} |
|
|
sub listresources { |
sub listresources { |
my ($r)=@_; |
my ($r,$context,$cdom,$cnum)=@_; |
if ((!&validcheck($r)) || ($env{'form.editmyown'})) { |
my $numchosen = scalar(@chosen); |
&editor($r); |
unless ($numchosen > 0) { |
|
$r->print('<h3>'.&mt('Create a Concept Test').'</h3>'. |
|
'<p>'.&mt('Choose how the test should be built:').'<br />'. |
|
'<form name="choices" method="post" action="/adm/coursedocs" onsubmit="javascript:setDocsPhase();">'. |
|
'<label><input type="radio" name="concepttest" value="defchosen" />'.&mt('Have a valid test built automatically by the WebCenter.').'</label><br />'. |
|
'<label><input type="radio" name="concepttest" value="editmyown" checked="checked" />'.&mt('Make your own selection of questions from the Geoscience Concept Inventory.').'</label><br /><br />'. |
|
'<input type="hidden" name="phase" value="" />'. |
|
'<input type="submit" name="choosetest" value="'.&mt('Next').'"></p>'); |
|
return; |
|
} |
|
if ((!&validcheck($r)) || ($env{'form.concepttest'} eq 'editmyown')) { |
|
&editor($r,$context,$cdom,$cnum); |
} else { |
} else { |
$r->print('<p><form name="choices" method="post">'); |
my $numsub = &get_submissions_count($cdom,$cnum); |
$r->print('<input type="submit" name="editmyown" value="'.&mt('Create Your Own Test').'" />'); |
unless ($env{'form.phase'} eq 'storemap') { |
$r->print('</form></p><p><form name="defaulting" method="post">'); |
$r->print('<p>'.&mt('This course contains a valid concept test which includes [quant,_1,question].',$numchosen).' <a href="/adm/navmaps" target="_coursecontents">'.&mt('Display Contents').'</a><br />'); |
$r->print('<input type="hidden" name="phase" value="storemap" />'); |
|
foreach my $item (@defchosen) { |
|
$r->print('<input type="hidden" name="item'.$item.'" value="checked"'); |
|
} |
} |
$r->print('<input type="submit" name="defchosen" value="'.&mt('Let WebCenter Create a Test for You').'" />'); |
if ($numsub > 0) { |
$r->print('</form><p>'); |
$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.','<i>','</i>','<b>','</b>').'<br />'.&mt('Modification of open and close dates [_1]is[_2] permitted.','<b>','</b>').'</p>'); |
|
} else { |
|
$r->print('<fieldset><legend>'.&mt('Modify Test').'</legend>'. |
|
&mt('Currently no student submissions have been recorded, so you may modify the contents of the Concept Test.'). |
|
'<br /><form name="changetest" method="post" action="/adm/coursedocs">'. |
|
'<input type="hidden" name="concepttest" value="editmyown" />'. |
|
'<input type="submit" name="modifytest" value="'.&mt('Edit Concept Test').'" /></form></fieldset></p>'); |
|
} |
|
my ($crsparms,$ineffect,$parmlev) = ¤t_parms($cdom,$cnum); |
|
my $formname = 'datesform'; |
|
my $datebutton = &mt('Save'); |
|
my $startform = |
|
&Apache::lonhtmlcommon::date_setter($formname,'opendate', |
|
$crsparms->{'opendate'}); |
|
my $endform = |
|
&Apache::lonhtmlcommon::date_setter($formname,'duedate', |
|
$crsparms->{'duedate'}); |
|
$r->print('<p><fieldset><legend>'.&mt('Test Availability').'</legend>'. |
|
&mt('Open and close dates for test items for the concept test are currently set as follows:'). |
|
'<br />'. |
|
'<form name="'.$formname.'" method="post" '. |
|
'action="/adm/coursedocs">'. |
|
&Apache::lonhtmlcommon::start_pick_box(). |
|
&Apache::lonhtmlcommon::row_title(&mt('Open date')). |
|
$startform. |
|
&Apache::lonhtmlcommon::row_closure(1). |
|
&Apache::lonhtmlcommon::row_title(&mt('Close date')). |
|
$endform. |
|
&Apache::lonhtmlcommon::end_pick_box().'<br />'. |
|
'<input type="hidden" name="phase" value="storeparms" />'. |
|
'<input type="submit" value="'.$datebutton.'" />'. |
|
'</form></fieldset></p>'); |
} |
} |
} |
} |
|
|
sub editor { |
sub editor { |
my ($r)=@_; |
my ($r,$context,$cdom,$cnum)=@_; |
my %chosen=(); |
my %chosenitems=(); |
foreach my $item (@chosen) { |
my $havedev = 0; |
$chosen{$item}=1; |
foreach my $item (@chosen) { |
} |
$chosenitems{$item}=1; |
&Apache::lonnet::appenv({'request.gcicontext' => 'buildtest'}); |
} |
$r->print('<form name="selecteditems" method="post" action="/adm/coursedocs">'); |
my @devitems = &get_development_questions($cdom,$cnum); |
$r->print('<p>'.&mt('You may select test items from the list below and then press "Store Problem Selection" at the bottom of the screen.').'</p>'); |
&Apache::lonnet::appenv({'request.gcicontext' => 'buildtest'}); |
$r->print('<p>'.&mt('Tests should have at least one item from each bin and [_1] items total.',$reqnum).'</p>'); |
$r->print('<form name="selecteditems" method="post" action="/adm/coursedocs" |
$r->print(&Apache::loncommon::start_data_table(). |
onsubmit="return validTestCheck()">'); |
&Apache::loncommon::start_data_table_header_row(). |
$r->print(&mt('Select test items from the numbered bins below and then press [_1]"Store Problem Selection"[_2] at the bottom of the page.','<i>','</i>').'<br />'); |
'<th>'.&mt('Select').'</th><th>'.&mt('Problem').'</th><th>'.&mt('Bin').'</th><th>'.&mt('Preview').'</th>'. |
$r->print('<ul>'. |
&Apache::loncommon::end_data_table_header_row()); |
'<li>'.&mt('Tests will contain a minimum of [_1] questions from the GCI 2 Inventory.',"<b>$reqnum</b>").'</li>'. |
foreach my $item (@allprobs) { |
'<li>'.&mt('Tests must contain [_1]four[_2] mandatory questions and at least one item from each of [_1]eleven[_2] other bins.','<b>','</b>').'</li>'. |
$r->print(&Apache::loncommon::start_data_table_row()); |
'<li>'.&mt('All tests conclude with [_1]two[_2] questions selected by the system (at random) from a pool of development questions being piloted by the GCI team.','<b>','</b>').'</li>'. |
$r->print('<td><font size="+3">'); |
'</ul>'); |
if ($mandatory{$item}) { |
my $mandleg = &mt('Mandatory Questions'); |
$r->print('<input type="hidden" name="item'.$item.'" value="checked"'); |
$r->print(&display_questions(\@mandprobs,'mandatory',$mandleg,\%chosenitems)); |
} else { |
for (my $i=0; $i<@bins; $i++) { |
$r->print('<input type="checkbox" name="item'.$item.'"'); |
my $num = $i+1; |
if ($chosen{$item}) { $r->print(' checked="checked"'); } |
my $legend = &mt('Bin [_1]',$num); |
} |
my $catname = 'bin'.$i; |
$r->print(' /></font></td>'); |
$r->print(&display_questions($bins[$i],$catname,$legend,\%chosenitems)); |
$r->print('<td><font size="+3">'.$item.'</font></td><td><font size="+3">'.$probcat{$item}.'</font></td>'); |
} |
my $output=&Apache::lonindexer::showpreview(&fullurl($item)); |
my $optleg = &mt('Optional Questions'); |
$r->print('<td> '.($output eq '' ? ' ':$output)." </td>\n"); |
$r->print(&display_questions(\@optional,'optional',$optleg,\%chosenitems)); |
|
my $devleg = &mt('Development Questions'); |
$r->print( &Apache::loncommon::end_data_table_row()); |
$r->print(&display_questions(\@devitems,'development',$devleg,\%chosenitems)); |
} |
$r->print('<input type="hidden" name="phase" value="storemap" />'. |
$r->print(&Apache::loncommon::end_data_table()); |
'<input type="hidden" name="context" value="'.$context.'" />'. |
$r->print('<input type="hidden" name="phase" value="storemap" />'); |
'<input type="submit" value="'.&mt('Store Problem Selection').'" />'. |
$r->print('<input type="submit" value="'.&mt('Store Problem Selection').'" /></form>'); |
'</form>'); |
&Apache::lonnet::delenv('request.gcicontext'); |
&Apache::lonnet::delenv('request.gcicontext'); |
|
} |
|
|
|
sub display_questions { |
|
my ($questions,$catname,$catlegend,$chosenitems) = @_; |
|
return unless((ref($questions) eq 'ARRAY') && (ref($chosenitems) eq 'HASH')); |
|
my $total = 0; |
|
foreach my $item (@{$questions}) { |
|
if ($chosenitems->{$item}) { |
|
$total ++; |
|
} |
|
} |
|
my $fieldid = 'GCI_'.$catname.'_q'; |
|
my $titleid = 'GCI_'.$catname.'_t'; |
|
my $countid = 'GCI_'.$catname.'_count'; |
|
my $output = '<fieldset>'; |
|
my %fixed = ( |
|
mandatory => 4, |
|
development => 2, |
|
); |
|
if (($catname eq 'mandatory') || ($catname eq 'development')) { |
|
$output .= '<legend>'.&mt('[_1] [_2] selected automatically',$catlegend, |
|
'<input type="text" name="'.$countid.'" size="1" '. |
|
'value="'.$fixed{$catname}.'" readonly="readonly" />').'</legend>'; |
|
} else { |
|
$output .= '<legend>'.&mt('[_1]: currently [_2] selected',$catlegend, |
|
'<input type="text" name="'.$countid.'" size="1" value="'. |
|
$total.'" readonly="readonly" />').'</legend>'; |
|
} |
|
$output .= '<span id="'.$titleid.'">'. |
|
'<a href="javascript:showQuestions('."'$fieldid','$titleid'".')">'. |
|
&mt('Show').'</a> ...</span><br />'. |
|
'<div id="'.$fieldid.'">'. |
|
&Apache::loncommon::start_data_table(). |
|
&Apache::loncommon::start_data_table_header_row(); |
|
unless (($catname eq 'development') || ($catname eq 'mandatory')) { |
|
$output .= '<th>'.&mt('Select').'</th>'; |
|
} |
|
$output .= '<th>'.&mt('Problem'). |
|
'</th><th>'.&mt('Preview').'</th>'. |
|
&Apache::loncommon::end_data_table_header_row(); |
|
foreach my $item (@{$questions}) { |
|
my $url = &fullurl($item); |
|
my $title = &Apache::lonnet::metadata($url,'title'); |
|
$output .= &Apache::loncommon::start_data_table_row().'<td>'; |
|
if (($catname eq 'mandatory') || ($catname eq 'development')) { |
|
$output .= '<input type="hidden" name="item'.$item.'" value="checked" />'; |
|
} else { |
|
$output .= '<input type="checkbox" name="item'.$item.'"'; |
|
if ($chosenitems->{$item}) { $output .= ' checked="checked"'; } |
|
$output .= ' onclick="countChecked('."'$catname'".');'; |
|
my $binname; |
|
if ($prereqs{$item}) { |
|
for (my $i=0; $i<@bincats; $i++) { |
|
if ($bincats[$i] eq $probcat{$prereqs{$item}}) { |
|
$binname = 'bin'.$i; |
|
last; |
|
} |
|
} |
|
$output .= 'checkPrereqs('."'dep','$item','$prereqs{$item}','$binname'".');'; |
|
} elsif ($revreqs{$item}) { |
|
for (my $i=0; $i<@bincats; $i++) { |
|
if ($bincats[$i] eq $probcat{$item}) { |
|
$binname = 'bin'.$i; |
|
last; |
|
} |
|
} |
|
$output .= 'checkPrereqs('."'pre','$revreqs{$item}','$item','$binname'".');'; |
|
} |
|
$output .= '" />'. |
|
'<input type="hidden" name="container'.$item.'" value="'. |
|
$catname.'"></td><td>'; |
|
} |
|
$output .= '<b>'.$title.'</b></td>'; |
|
my $content=&Apache::lonindexer::showpreview($url); |
|
$output .= '<td> '.($content eq '' ? ' ':$content).' </td>'."\n". |
|
&Apache::loncommon::end_data_table_row(); |
|
} |
|
$output .= &Apache::loncommon::end_data_table(). |
|
'</div></fieldset><br />'; |
|
return $output; |
|
} |
|
|
|
sub get_development_questions { |
|
my ($cdom,$cnum) = @_; |
|
my $cid = $cdom.'_'.$cnum; |
|
my %courseenv = &Apache::lonnet::userenvironment($cdom,$cnum, |
|
('internal.courseowner')); |
|
my $seed = $courseenv{'internal.courseowner'}; |
|
my $rndseed=&Apache::lonnet::rndseed($seed,$cid,$cdom,$cnum); |
|
&Apache::lonnet::setup_random_from_rndseed($rndseed); |
|
my @devitems = &Math::Random::random_permutation(@development); |
|
return ($devitems[0],$devitems[1]); |
} |
} |
|
|
sub evaluate { |
sub evaluate { |
Line 209 sub mapread_gci {
|
Line 377 sub mapread_gci {
|
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'}; |
return |
return |
&LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/default.sequence'); |
&LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/default_1261144274.sequence'); |
} |
} |
|
|
sub storemap_gci { |
sub storemap_gci { |
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my ($coursedom,$coursenum) = @_; |
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'}; |
if (($coursedom !~ /^$match_domain$/) || ($coursenum !~ /^$match_courseid$/)) { |
|
$coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
$coursenum=$env{'course.'.$env{'request.course.id'}.'.num'}; |
|
} |
|
return ('unauthorized',2) if (($coursedom eq '') || ($coursedom eq '') || |
|
(!&Apache::lonnet::allowed('mdc',$coursedom.'_'.$coursenum))); |
my ($outtext,$errtext)= |
my ($outtext,$errtext)= |
&LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/default.sequence',1); |
&LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/default_1261144274.sequence',1); |
if ($errtext) { return ($errtext,2); } |
if ($errtext) { return ($errtext,2); } |
return ($errtext,0); |
return ($errtext,0); |
} |
} |
Line 228 sub chosen_to_map {
|
Line 401 sub chosen_to_map {
|
} |
} |
@LONCAPA::map::order=(); |
@LONCAPA::map::order=(); |
@LONCAPA::map::resources=(); |
@LONCAPA::map::resources=(); |
|
my $counter = 0; |
for (my $idx=0;$idx<=$#allprobs;$idx++) { |
for (my $idx=0;$idx<=$#allprobs;$idx++) { |
my $residx=$idx+1; |
my $residx=$idx+1; |
if ($chosenproblems{$allprobs[$idx]}) { |
if ($chosenproblems{$allprobs[$idx]}) { |
push(@LONCAPA::map::order,$residx); |
|
my $url = &LONCAPA::map::qtunescape(&fullurl($allprobs[$idx])); |
my $url = &LONCAPA::map::qtunescape(&fullurl($allprobs[$idx])); |
my $name = &LONCAPA::map::qtunescape('Problem '.$allprobs[$idx]); |
if (($revreqs{$allprobs[$idx]}) && |
|
($chosenproblems{$revreqs{$allprobs[$idx]}})) { |
|
my $probnum = $allprobs[$idx].'_'.$revreqs{$allprobs[$idx]}; |
|
$url = &LONCAPA::map::qtunescape(&fullurl($probnum)); |
|
} elsif ($prereqs{$allprobs[$idx]}) { |
|
next; |
|
} |
|
push(@LONCAPA::map::order,$residx); |
|
$counter ++; |
|
my $name = &LONCAPA::map::qtunescape('Problem '.$counter); |
$LONCAPA::map::resources[$residx]=join(':', ($name, $url, 'false', 'normal', 'res')); |
$LONCAPA::map::resources[$residx]=join(':', ($name, $url, 'false', 'normal', 'res')); |
} |
} |
} |
} |
Line 242 sub chosen_to_map {
|
Line 424 sub chosen_to_map {
|
sub map_to_chosen { |
sub map_to_chosen { |
@chosen=(); |
@chosen=(); |
foreach my $idx (@LONCAPA::map::order) { |
foreach my $idx (@LONCAPA::map::order) { |
push(@chosen,$allprobs[$idx-1]); |
my ($title,$url)=split(':',$LONCAPA::map::resources[$idx]); |
|
my $item; |
|
unless ($url eq '') { |
|
$item = &item_from_url($url); |
|
if (($item =~ /^(\d+)_(\d+)$/) && ($prereqs{$2} eq $1)) { |
|
push(@chosen,($1,$2)); |
|
} else { |
|
push(@chosen,$item); |
|
} |
|
} |
|
} |
|
if (($env{'form.concepttest'} eq 'defchosen') || |
|
((@chosen == 0) && ($env{'form.concepttest'} eq 'editmyown'))) { |
|
@chosen = @defchosen; |
} |
} |
} |
} |
|
|
sub store { |
sub store { |
my ($r)=@_; |
my ($caller,$cdom,$cnum)=@_; |
|
if ($env{'form.concepttest'} eq 'defchosen') { |
|
@chosen = @defchosen; |
|
} |
my @errors=&checkvalid(); |
my @errors=&checkvalid(); |
if ($#errors>1) { return; } |
if (@errors > 0) { |
|
if (($caller eq 'requestcrs') && ($env{'form.concepttest'} eq 'defchosen')) { |
|
return &mt('Invalid concept test.'); |
|
} else { |
|
my $errormsg = '<span class="LC_warning">'.&mt('Invalid concept test:'); |
|
if (@errors > 1) { |
|
$errormsg .= '<ul><li>'.join('</li><li>',@errors).'</li></ul>'; |
|
} else { |
|
$errormsg .= '<br />'.$errors[0]; |
|
} |
|
$errormsg .= '</span>'; |
|
return $errormsg; |
|
} |
|
} |
&chosen_to_map(); |
&chosen_to_map(); |
&storemap_gci(); |
my ($err,$errnum) = &storemap_gci($cdom,$cnum); |
|
if ($caller eq 'requestcrs') { |
|
if ($errnum == 0) { |
|
return; |
|
} else { |
|
return 'An error occurred when storing the concept test'; |
|
} |
|
} |
if ($env{'form.phase'} eq 'storemap') { |
if ($env{'form.phase'} eq 'storemap') { |
unless ($#errors>-1) { |
if ($errnum == 0) { |
$r->print('<p>'.&mt('You have successfully assembled a valid test.'). |
&Apache::lonuserstate::readmap($cdom.'/'.$cnum); |
'<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'. |
return '<p>'.&mt('You have successfully assembled a valid test.').'</p>'. |
'<input type="hidden" name="orgurl" value="/adm/navmaps" /><input type="hidden" name="selectrole" value="1" />'. |
'<p><a href="/adm/navmaps">'.&mt('Display Table of Contents'). |
'<input type="hidden" name="'.$env{'request.role'}.'" value="1" /><input type="submit" value="'. |
'</a>'.(' ' x4).'<a href="/adm/menu">'.&mt('Return to Main Menu').'</a></p>'; |
&mt('Activate Current Test').'" /></form></p>'); |
} else { |
|
return '<div class="LC_error">'.&mt('An error occurred when storing your concept test: [_1].',$err).'</div>'; |
} |
} |
} |
} |
|
return; |
} |
} |
|
|
sub load { |
sub load { |
&mapread_gci(); |
&mapread_gci(); |
&map_to_chosen(); |
&map_to_chosen(); |
my @errors=&checkvalid(); |
if (@chosen > 0) { |
if ($#errors>1) { @chosen=@defchosen; } |
my @errors=&checkvalid(); |
|
if ($#errors>1) { @chosen=@defchosen; } |
|
} |
|
} |
|
|
|
sub current_parms { |
|
my ($cdom,$cnum) = @_; |
|
my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom); |
|
my (%crsparms,%ineffect,%parmlev); |
|
foreach my $item ('opendate','duedate') { |
|
$crsparms{$item} = $courseopt->{$env{'request.course.id'}.'.0.'.$item}; |
|
my ($result,@outpar) = |
|
&Apache::lonparmset::parmval('0.'.$item,'0.0',undef,undef, |
|
$cdom,undef,undef,$courseopt); |
|
if ($result) { |
|
$ineffect{$item} = $outpar[$result]; |
|
$parmlev{$item} = $result; |
|
} |
|
} |
|
return (\%crsparms,\%ineffect,\%parmlev); |
|
} |
|
|
|
sub store_dates_parms { |
|
my ($cdom,$cnum) = @_; |
|
my $topsymb = '___0___uploaded/'.$cdom.'/'.$cnum.'/default.sequence'; |
|
my ($opendate,$duedate) = |
|
&Apache::lonuserutils::get_dates_from_form('opendate','duedate'); |
|
my %dates = ( |
|
opendate => { |
|
value => $opendate, |
|
type => 'date_start', |
|
}, |
|
duedate => { |
|
value => $duedate, |
|
type => 'date_end', |
|
}, |
|
); |
|
my %parmresult; |
|
foreach my $date (keys(%dates)) { |
|
$parmresult{$date} = |
|
&Apache::lonparmset::storeparm_by_symb($topsymb, |
|
'0_'.$date,14,$dates{$date}{'value'}, |
|
$dates{$date}{'type'},undef,$cdom); |
|
} |
|
my $output = &mt('Open and Close dates set for test items').'<ul>'. |
|
'<li>'.&mt('Concept Test Questions open:').' '. |
|
&Apache::lonlocal::locallocaltime($opendate).'</li>'. |
|
'<li>'.&mt('Concept Test Questions close:').' '. |
|
&Apache::lonlocal::locallocaltime($duedate).'</li>'. |
|
'</ul>'; |
|
return $output; |
|
} |
|
|
|
sub get_submissions_count { |
|
my ($cdom,$cnum) = @_; |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
if (!defined($navmap)) { |
|
my $itemserror = '<span class="LC_warning">'.&mt('An error occurred retrieving information about the course.').'<br />'.&mt('It is recommended that you [_1]re-select the course[_2].','<a href="/adm/roles">','</a>').'</span>'; |
|
return $itemserror; |
|
} |
|
my @allres=$navmap->retrieveResources('/uploaded/'.$cdom.'/'.$cnum.'/default_1261144274.sequence',sub {if ($_[0]->is_problem) { $_[0]->parts();} return 1;}); |
|
my (%resourcetracker,$submissioncount); |
|
my %resourcetracker = &Apache::lonnet::dump('nohist_resourcetracker', |
|
$cdom,$cnum); |
|
foreach my $resource (@allres) { |
|
my $symb = $resource->symb(); |
|
my @parts = @{$resource->parts()}; |
|
foreach my $part (@parts) { |
|
if ($resource->handgrade($part) eq 'yes') { |
|
next; |
|
} |
|
if ($resource->is_survey($part)) { |
|
next; |
|
} |
|
if (exists($resourcetracker{$symb."\0".$part."\0users"})) { |
|
$submissioncount += $resourcetracker{$symb."\0".$part."\0users"}; |
|
} |
|
} |
|
} |
|
return $submissioncount; |
|
} |
|
|
|
sub builder_javascript { |
|
my %lt = &Apache::lonlocal::texthash( |
|
show => 'Show', |
|
hide => 'Hide', |
|
); |
|
my $prereqjs = " |
|
function checkPrereqs(caller,item,prereq,binname) { |
|
var changedPrereq = 0; |
|
if (document.selecteditems.elements['item'+item].checked == false) { |
|
return; |
|
} else { |
|
if (!document.selecteditems.elements['item'+prereq].checked) { |
|
document.selecteditems.elements['item'+prereq].checked = true; |
|
changedPrereq = 1; |
|
countChecked(binname); |
|
} |
|
} |
|
"; |
|
|
|
my ($hasdep,$prereq,$hasdeptitle,$prereqtitle) = ('','','',''); |
|
foreach my $item (sort(keys(%prereqs))) { |
|
$hasdep .= "'$item',"; |
|
$prereq .= "'$prereqs{$item}',"; |
|
my $url = &fullurl($item); |
|
$hasdeptitle .= "'".&Apache::lonnet::metadata($url,'title')."',"; |
|
my $purl = &fullurl($prereqs{$item}); |
|
$prereqtitle .= "'".&Apache::lonnet::metadata($purl,'title')."',"; |
|
} |
|
$hasdep =~ s/,$//; |
|
$prereq =~ s/,$//; |
|
$hasdeptitle =~ s/,$//; |
|
$prereqtitle =~ s/,$//; |
|
|
|
$prereqjs .= <<"ENDFN"; |
|
|
|
var hasDeps = Array($hasdep); |
|
var preReqs = Array($prereq); |
|
var hasDepTitles = Array($hasdeptitle); |
|
var preReqTitles = Array($prereqtitle); |
|
for (var i=0; i<hasDeps.length; i++) { |
|
if (hasDeps[i] == item) { |
|
var msg = hasDepTitles[i]+' question has a prerequisite: '+preReqTitles[i]+'.\\nThe two questions will appear together in a composite question.'; |
|
if (changedPrereq == 1) { |
|
msg = msg+'\\n\\nAs the prerequisite was not checked, inclusion of '+hasDepTitles[i]+' has now caused '+preReqTitles[i]+' to also be checked automatically.'; |
|
} |
|
if (caller == 'pre') { |
|
msg = msg +'\\n\\nIf you do not wish to include '+preReqTitles[i]+' you will first need to uncheck '+hasDepTitles[i]+', then uncheck '+preReqTitles[i]+' again.' |
|
} |
|
alert(msg); |
|
break; |
|
} |
|
} |
|
return; |
|
} |
|
|
|
ENDFN |
|
|
|
return <<ENDJS; |
|
function showQuestions(content,title) { |
|
document.getElementById(content).style.display = ""; |
|
document.getElementById(title).innerHTML='<a href="javascript:hideQuestions('+"'"+content+"','"+title+"'"+');">$lt{'hide'}</a> ...'; |
|
return; |
|
} |
|
|
|
function hideQuestions(content,title) { |
|
document.getElementById(content).style.display = "none"; |
|
document.getElementById(title).innerHTML='<a href="javascript:showQuestions('+"'"+content+"','"+title+"'"+')">$lt{'show'}</a> ...'; |
|
return; |
|
} |
|
|
|
function setInitialVisibility() { |
|
if (document.getElementById('GCI_mandatory_q') == null) { |
|
return; |
|
} |
|
document.getElementById('GCI_mandatory_q').style.display = "none"; |
|
document.getElementById('GCI_bin0_q').style.display = "none"; |
|
document.getElementById('GCI_bin1_q').style.display = "none"; |
|
document.getElementById('GCI_bin2_q').style.display = "none"; |
|
document.getElementById('GCI_bin3_q').style.display = "none"; |
|
document.getElementById('GCI_bin4_q').style.display = "none"; |
|
document.getElementById('GCI_bin5_q').style.display = "none"; |
|
document.getElementById('GCI_bin6_q').style.display = "none"; |
|
document.getElementById('GCI_bin7_q').style.display = "none"; |
|
document.getElementById('GCI_bin8_q').style.display = "none"; |
|
document.getElementById('GCI_bin9_q').style.display = "none"; |
|
document.getElementById('GCI_bin10_q').style.display = "none"; |
|
document.getElementById('GCI_optional_q').style.display = "none"; |
|
document.getElementById('GCI_development_q').style.display = "none"; |
|
} |
|
|
|
function countChecked(binname) { |
|
var count = 0; |
|
for (var i=0; i<document.selecteditems.elements.length; i++) { |
|
if (document.selecteditems.elements[i].type == "hidden") { |
|
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) { |
|
count ++; |
|
} |
|
} |
|
} |
|
} |
|
document.selecteditems.elements['GCI_'+binname+'_count'].value = count; |
|
} |
|
|
|
function validTestCheck() { |
|
var empty = ''; |
|
for (var i=0; i<11; i++) { |
|
var binname = 'GCI_bin'+i+'_count'; |
|
var j = i+1; |
|
if (document.selecteditems.elements[binname].value < 1) { |
|
empty = empty +' '+j; |
|
} |
|
} |
|
if (empty != "") { |
|
alert("Current test invalid - select at least one item from the following bin(s): "+empty); |
|
return false; |
|
} |
|
return true; |
|
} |
|
|
|
function setDocsPhase() { |
|
if (document.choices.concepttest.length) { |
|
for (var i=0; i<document.choices.concepttest.length; i++) { |
|
if (document.choices.concepttest[i].checked) { |
|
if (document.choices.concepttest[i].value == 'defchosen') { |
|
document.choices.phase.value = 'storemap'; |
|
alert("Setting value for phase to "+document.choices.phase.value); |
|
|
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
$prereqjs |
|
|
|
ENDJS |
|
|
} |
} |
|
|
} #end scope variables |
} #end scope variables |