');
+ my ($r,$context,$cdom,$cnum)=@_;
+ my %chosenitems=();
+ my $havedev = 0;
+ foreach my $item (@chosen) {
+ $chosenitems{$item}=1;
+ }
+ my @devitems = &get_development_questions($cdom,$cnum);
+ &Apache::lonnet::appenv({'request.gcicontext' => 'buildtest'});
+ $r->print('
');
+ $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.','','').' ');
+ $r->print('
'.
+ '
'.&mt('Tests will contain a minimum of [_1] questions from the GCI 2 Inventory.',"$reqnum").'
'.
+ '
'.&mt('Tests must contain [_1]four[_2] mandatory questions and at least one item from each of [_1]eleven[_2] other bins.','','').'
'.
+ '
'.&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.','','').'
'.
+ '
');
+ my $mandleg = &mt('Mandatory Questions');
+ $r->print(&display_questions(\@mandprobs,'mandatory',$mandleg,\%chosenitems));
+ for (my $i=0; $i<@bins; $i++) {
+ my $num = $i+1;
+ my $legend = &mt('Bin [_1]',$num);
+ my $catname = 'bin'.$i;
+ $r->print(&display_questions($bins[$i],$catname,$legend,\%chosenitems));
+ }
+ my $optleg = &mt('Optional Questions');
+ $r->print(&display_questions(\@optional,'optional',$optleg,\%chosenitems));
+ my $devleg = &mt('Development Questions');
+ $r->print(&display_questions(\@devitems,'development',$devleg,\%chosenitems));
+ $r->print(''.
+ ''.
+ ''.
+ '
');
+ &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 = ' ';
+ 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 {
@@ -207,14 +380,19 @@ sub mapread_gci {
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
return
- &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/default.sequence');
+ &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/default_1261144274.sequence');
}
sub storemap_gci {
- my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
- my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
+ my ($coursedom,$coursenum) = @_;
+ 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)=
- &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/default.sequence',1);
+ &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/default_1261144274.sequence',1);
if ($errtext) { return ($errtext,2); }
return ($errtext,0);
}
@@ -226,46 +404,326 @@ 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]}) {
- push(@LONCAPA::map::order,$residx);
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'));
}
}
+ 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 {
@chosen=();
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 {
- my ($r)=@_;
+ my ($caller,$cdom,$cnum)=@_;
+ if ($env{'form.concepttest'} eq 'defchosen') {
+ @chosen = @defchosen;
+ }
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 = ''.&mt('Invalid concept test:');
+ if (@errors > 1) {
+ $errormsg .= '