'.&mt('Choose how the test should be built:').' '.
+ '
');
+ 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.','','').'
');
+ } else {
+ $r->print('');
+ }
+ 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('');
}
}
sub editor {
- my ($r)=@_;
- my %chosen=();
- foreach my $item (@chosen) {
- $chosen{$item}=1;
- }
- $r->print('');
+ 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('');
+ &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 +377,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,12 +401,21 @@ sub chosen_to_map {
}
@LONCAPA::map::order=();
@LONCAPA::map::resources=();
+ my $counter = 0;
for (my $idx=0;$idx<=$#allprobs;$idx++) {
my $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'));
}
}
@@ -240,32 +424,292 @@ sub chosen_to_map {
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 .= '