version 1.5, 2009/12/20 04:32:03
|
version 1.12, 2010/09/14 06:23:15
|
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 @mandprobs; |
Line 55 my @bins;
|
Line 58 my @bins;
|
my @optional; |
my @optional; |
my %mandatory; |
my %mandatory; |
my @development; |
my @development; |
my %developmentitems; |
|
|
|
sub setdefaults { |
sub setdefaults { |
$path='/res/gci/gci'; |
$path='/res/gci/gci'; |
Line 90 sub setdefaults {
|
Line 92 sub setdefaults {
|
['63','64','65'], |
['63','64','65'], |
['66','67','68','69','70','71']); |
['66','67','68','69','70','71']); |
@optional = ('05','11','29','31'); |
@optional = ('05','11','29','31'); |
|
@mandcats = ('M1','M2','M3','M4'); |
@categories=('M1','M2','M3','M4', |
@bincats = ('A','B','C','D','E','F','G','H','I','J','K'); |
'A','B','C','D','E','F','G','H','I','J','K'); |
@categories=(@mandcats,@bincats); |
%probcat =('01' => 'M1' ,'02' => 'M2' ,'37' => 'M3' ,'2004_73' => 'M4' , |
%probcat =('01' => 'M1' ,'02' => 'M2' ,'37' => 'M3' ,'2004_73' => 'M4' , |
'03' => 'A' ,'04' => 'A','05' => '' ,'06' => 'A' ,'07' => 'B' , |
'03' => 'A' ,'04' => 'A','05' => '' ,'06' => 'A' ,'07' => 'B' , |
'08' => 'B' ,'09' => 'B' ,'10' => 'C' ,'11' => '' ,'12' => 'C' , |
'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' , |
'13' => 'C' ,'14' => 'C' ,'15' => 'C' ,'16' => 'C' ,'17' => 'C' ,'18' => 'D' ,'19' => 'D' ,'20' => 'D' , |
Line 106 sub setdefaults {
|
Line 108 sub setdefaults {
|
'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'); |
%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'); |
@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)) { |
@development = ('100','101','102'); |
$revreqs{$prereqs{$item}} = $item; |
%developmentitems = ('100' => 1, '101' => '1', '102' => '1'); |
} |
|
@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'); |
} |
} |
|
|
sub checkvalid { |
sub checkvalid { |
Line 134 sub checkvalid {
|
Line 138 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 142 sub checkvalid {
|
Line 150 sub checkvalid {
|
} |
} |
|
|
sub fullurl { |
sub fullurl { |
my ($item)=@_; |
my ($item,$catname)=@_; |
unless ($item=~/\_/) { $item='_'.$item; } |
unless ($item=~/\_/) { $item='_'.$item; } |
|
if ($catname eq 'development') { |
|
return $path.'/pilot/pilot'.$item.'.problem'; |
|
} |
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 164 sub validcheck {
|
Line 182 sub validcheck {
|
sub listresources { |
sub listresources { |
my ($r,$context,$cdom,$cnum)=@_; |
my ($r,$context,$cdom,$cnum)=@_; |
my $numchosen = scalar(@chosen); |
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).'<br />'; |
|
} else { |
|
$composites = '. '; |
|
} |
|
} |
unless ($numchosen > 0) { |
unless ($numchosen > 0) { |
$r->print('<h3>'.&mt('Create a Concept Test').'</h3>'. |
$r->print('<h3>'.&mt('Create a Concept Test').'</h3>'. |
'<p>'.&mt('Choose how the test should be built:').'<br />'. |
'<p>'.&mt('Choose how the test should be built:').'<br />'. |
Line 179 sub listresources {
|
Line 212 sub listresources {
|
} else { |
} else { |
my $numsub = &get_submissions_count($cdom,$cnum); |
my $numsub = &get_submissions_count($cdom,$cnum); |
unless ($env{'form.phase'} eq 'storemap') { |
unless ($env{'form.phase'} eq 'storemap') { |
$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('<p>'.&mt('This course contains a valid concept test which includes [quant,_1,question]',$numchosen).$composites.'<a href="/adm/navmaps" target="_coursecontents">'.&mt('Display Contents').'</a><br />'); |
} |
} |
if ($numsub > 0) { |
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.','<i>','</i>','<b>','</b>').'<br />'.&mt('Modification of open and close dates [_1]is[_2] permitted.','<b>','</b>').'</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>'); |
Line 207 sub listresources {
|
Line 240 sub listresources {
|
&Apache::lonhtmlcommon::start_pick_box(). |
&Apache::lonhtmlcommon::start_pick_box(). |
&Apache::lonhtmlcommon::row_title(&mt('Open date')). |
&Apache::lonhtmlcommon::row_title(&mt('Open date')). |
$startform. |
$startform. |
&Apache::lonhtmlcommon::row_closure(). |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_title(&mt('Close date')). |
&Apache::lonhtmlcommon::row_title(&mt('Close date')). |
$endform. |
$endform. |
&Apache::lonhtmlcommon::end_pick_box().'<br />'. |
&Apache::lonhtmlcommon::row_closure(1). |
|
&Apache::lonhtmlcommon::end_pick_box().'<br />'. |
'<input type="hidden" name="phase" value="storeparms" />'. |
'<input type="hidden" name="phase" value="storeparms" />'. |
'<input type="submit" value="'.$datebutton.'" />'. |
'<input type="submit" value="'.$datebutton.'" />'. |
'</form></fieldset></p>'); |
'</form></fieldset></p>'); |
Line 276 sub display_questions {
|
Line 310 sub display_questions {
|
'value="'.$fixed{$catname}.'" readonly="readonly" />').'</legend>'; |
'value="'.$fixed{$catname}.'" readonly="readonly" />').'</legend>'; |
} else { |
} else { |
$output .= '<legend>'.&mt('[_1]: currently [_2] selected',$catlegend, |
$output .= '<legend>'.&mt('[_1]: currently [_2] selected',$catlegend, |
'<input type="text" name="'.$countid.'" size="1" value="'. |
'<input type="text" name="'.$countid.'" id="'.$countid.'" size="1" value="'. |
$total.'" readonly="readonly" />').'</legend>'; |
$total.'" readonly="readonly" />').'</legend>'; |
} |
} |
$output .= '<span id="'.$titleid.'">'. |
$output .= '<span id="'.$titleid.'">'. |
Line 292 sub display_questions {
|
Line 326 sub display_questions {
|
'</th><th>'.&mt('Preview').'</th>'. |
'</th><th>'.&mt('Preview').'</th>'. |
&Apache::loncommon::end_data_table_header_row(); |
&Apache::loncommon::end_data_table_header_row(); |
foreach my $item (@{$questions}) { |
foreach my $item (@{$questions}) { |
my $url = &fullurl($item); |
my $url = &fullurl($item,$catname); |
my $title = &Apache::lonnet::metadata($url,'title'); |
my $title = &Apache::lonnet::metadata($url,'title'); |
$output .= &Apache::loncommon::start_data_table_row().'<td>'; |
$output .= &Apache::loncommon::start_data_table_row().'<td>'; |
if (($catname eq 'mandatory') || ($catname eq 'development')) { |
if ($catname eq 'mandatory') { |
$output .= '<input type="hidden" name="item'.$item.'" value="checked" />'; |
$output .= '<input type="hidden" name="item'.$item.'" value="checked" />'; |
|
} elsif ($catname eq 'development') { |
|
$output .= '<input type="hidden" name="pilot'.$item.'" value="checked" />'; |
} else { |
} else { |
$output .= '<input type="checkbox" name="item'.$item.'"'; |
$output .= '<input type="checkbox" name="item'.$item.'" id="item'.$item.'"'; |
if ($chosenitems->{$item}) { $output .= ' checked="checked"'; } |
if ($chosenitems->{$item}) { $output .= ' checked="checked"'; } |
$output .= 'onclick="javascript:countChecked('."'$catname'".');" />'. |
$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="'. |
'<input type="hidden" name="container'.$item.'" value="'. |
$catname.'"></td><td>'; |
$catname.'"></td><td>'; |
} |
} |
$output .= '<b>'.$title.'</b></td>'; |
$output .= '<b>'.$title.'</b></td>'; |
my $content=&Apache::lonindexer::showpreview($url); |
my $content=&Apache::lonindexer::showpreview($url); |
|
my $startformtag = '<form name="lonhomework" enctype="multipart/form-data" method="post" action="'.$url.'?inhibitmenu=yes" >'; |
|
my $endtag = '<table><tr><td><input onmouseup="javascript:setSubmittedPart'; |
|
$content =~ s/^\Q$startformtag\E//; |
|
$content =~ s/\Q$endtag\E.+$//s; |
$output .= '<td> '.($content eq '' ? ' ':$content).' </td>'."\n". |
$output .= '<td> '.($content eq '' ? ' ':$content).' </td>'."\n". |
&Apache::loncommon::end_data_table_row(); |
&Apache::loncommon::end_data_table_row(); |
} |
} |
Line 366 sub chosen_to_map {
|
Line 425 sub chosen_to_map {
|
@LONCAPA::map::order=(); |
@LONCAPA::map::order=(); |
@LONCAPA::map::resources=(); |
@LONCAPA::map::resources=(); |
my $counter = 0; |
my $counter = 0; |
|
my $residx; |
for (my $idx=0;$idx<=$#allprobs;$idx++) { |
for (my $idx=0;$idx<=$#allprobs;$idx++) { |
my $residx=$idx+1; |
$residx=$idx+1; |
if ($chosenproblems{$allprobs[$idx]}) { |
if ($chosenproblems{$allprobs[$idx]}) { |
|
my $url = &LONCAPA::map::qtunescape(&fullurl($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); |
push(@LONCAPA::map::order,$residx); |
$counter ++; |
$counter ++; |
my $url = &LONCAPA::map::qtunescape(&fullurl($allprobs[$idx])); |
|
my $name = &LONCAPA::map::qtunescape('Problem '.$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')); |
} |
} |
} |
} |
|
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 { |
sub map_to_chosen { |
@chosen=(); |
@chosen=(); |
foreach my $idx (@LONCAPA::map::order) { |
foreach my $idx (@LONCAPA::map::order) { |
my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]); |
my ($title,$url)=split(':',$LONCAPA::map::resources[$idx]); |
|
my $item; |
unless ($url eq '') { |
unless ($url eq '') { |
push(@chosen,$allprobs[$idx-1]); |
$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') || |
if (($env{'form.concepttest'} eq 'defchosen') || |
Line 400 sub store {
|
Line 483 sub store {
|
my @errors=&checkvalid(); |
my @errors=&checkvalid(); |
if (@errors > 0) { |
if (@errors > 0) { |
if (($caller eq 'requestcrs') && ($env{'form.concepttest'} eq 'defchosen')) { |
if (($caller eq 'requestcrs') && ($env{'form.concepttest'} eq 'defchosen')) { |
return 'Invalid concept test.'; |
return &mt('Invalid concept test.'); |
} else { |
} else { |
return; |
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(); |
Line 518 sub builder_javascript {
|
Line 608 sub builder_javascript {
|
show => 'Show', |
show => 'Show', |
hide => 'Hide', |
hide => 'Hide', |
); |
); |
|
my $prereqjs = " |
|
function checkPrereqs(caller,item,prereq,binname) { |
|
var changedPrereq = 0; |
|
element = document.getElementById('item'+item); |
|
if (element.checked == false) { |
|
return; |
|
} else { |
|
prereqelement = document.getElementById('item'+prereq); |
|
if (!prereqelement.checked) { |
|
prereqelement.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; |
return <<ENDJS; |
function showQuestions(content,title) { |
function showQuestions(content,title) { |
document.getElementById(content).style.display = ""; |
document.getElementById(content).style.display = ""; |
Line 558 function countChecked(binname) {
|
Line 702 function countChecked(binname) {
|
if (document.selecteditems.elements[i].value == binname) { |
if (document.selecteditems.elements[i].value == binname) { |
var itemname = document.selecteditems.elements[i].name; |
var itemname = document.selecteditems.elements[i].name; |
var itemnum = itemname.substr(9); |
var itemnum = itemname.substr(9); |
if (document.selecteditems.elements['item'+itemnum].checked) { |
element = document.getElementById('item'+itemnum); |
|
if (element.checked) { |
count ++; |
count ++; |
} |
} |
} |
} |
} |
} |
} |
} |
document.selecteditems.elements['GCI_'+binname+'_count'].value = count; |
countelement = document.getElementById('GCI_'+binname+'_count'); |
|
countelement.value = count; |
} |
} |
|
|
function validTestCheck() { |
function validTestCheck() { |
Line 572 function validTestCheck() {
|
Line 718 function validTestCheck() {
|
for (var i=0; i<11; i++) { |
for (var i=0; i<11; i++) { |
var binname = 'GCI_bin'+i+'_count'; |
var binname = 'GCI_bin'+i+'_count'; |
var j = i+1; |
var j = i+1; |
if (document.selecteditems.elements[binname].value < 1) { |
countelement = document.getElementById(binname); |
|
if (countelement.value < 1) { |
empty = empty +' '+j; |
empty = empty +' '+j; |
} |
} |
} |
} |
Line 589 function setDocsPhase() {
|
Line 736 function setDocsPhase() {
|
if (document.choices.concepttest[i].checked) { |
if (document.choices.concepttest[i].checked) { |
if (document.choices.concepttest[i].value == 'defchosen') { |
if (document.choices.concepttest[i].value == 'defchosen') { |
document.choices.phase.value = 'storemap'; |
document.choices.phase.value = 'storemap'; |
alert("Setting value for phase to "+document.choices.phase.value); |
|
|
|
} |
} |
} |
} |
} |
} |
Line 598 function setDocsPhase() {
|
Line 743 function setDocsPhase() {
|
return; |
return; |
} |
} |
|
|
|
$prereqjs |
|
|
ENDJS |
ENDJS |
|
|
} |
} |