Diff for /modules/gci/londocsgci.pm between versions 1.2 and 1.3

version 1.2, 2009/10/03 03:11:30 version 1.3, 2009/11/27 23:48:25
Line 50  my %probcat; Line 50  my %probcat;
 my %prereqs;  my %prereqs;
 my @defchosen;  my @defchosen;
 my @chosen;  my @chosen;
   my %mandatory;
   
 sub setdefaults {  sub setdefaults {
    $path='/res/gci/gci';     $path='/res/gci/gci';
Line 88  sub setdefaults { Line 89  sub setdefaults {
               '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');                '2004_73' => 'M4');
      %mandatory=('01' => 1 ,'02' => 1,'37' => 1,'2004_73' => 1);
    %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');     @defchosen=('01','02','03','07','12','18','26','32','37','38','47','54','63','66','2004_73');
 }  }
Line 106  sub checkvalid { Line 108  sub checkvalid {
    }     }
    foreach my $cat (@categories) {     foreach my $cat (@categories) {
       unless ($covered{$cat}) {        unless ($covered{$cat}) {
          push(@errors,&mt('Category [_1] not covered.',$cat));           push(@errors,&mt('Bin [_1] not covered.',$cat));
       }        }
    }     }
    foreach my $item (@chosen) {     foreach my $item (@chosen) {
Line 125  sub fullurl { Line 127  sub fullurl {
    return $path.'/'.$version.'/GCI'.$item.'.problem';     return $path.'/'.$version.'/GCI'.$item.'.problem';
 }  }
   
 sub listresources {  sub validcheck {
    my ($r)=@_;     my ($r)=@_;
    my @errors=&checkvalid();     my @errors=&checkvalid();
    if ($#errors>-1) {     if ($#errors>-1) {
Line 134  sub listresources { Line 136  sub listresources {
          $r->print('<li>'.$message.'</li>');           $r->print('<li>'.$message.'</li>');
       }        }
       $r->print('</ul></p>');        $r->print('</ul></p>');
         return 0;
      }
      return 1;
   }
   
   sub listresources {
      my ($r)=@_;
      if ((!&validcheck($r)) || ($env{'form.editmyown'})) {
         &editor($r);
      } else {
         $r->print('<p><form name="choices" method="post">');
         $r->print('<input type="submit" name="editmyown" value="'.&mt('Create Your Own Test').'" />');
         $r->print('</form></p><p><form name="defaulting" method="post">');
         $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').'" />');
         $r->print('</form><p>');
    }     }
   }
   
   sub editor {
      my ($r)=@_;
    my %chosen=();     my %chosen=();
    foreach my $item (@chosen) {     foreach my $item (@chosen) {
       $chosen{$item}=1;        $chosen{$item}=1;
    }     }
    $r->print('<form name="selecteditems" method="post" action="/adm/coursedocs">');     $r->print('<form name="selecteditems" method="post" action="/adm/coursedocs">');
    $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>');      $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>');
      $r->print('<p>'.&mt('Tests should have at least one item from each bin and [_1] items total.',$reqnum).'</p>'); 
    $r->print(&Apache::loncommon::start_data_table().     $r->print(&Apache::loncommon::start_data_table().
              &Apache::loncommon::start_data_table_header_row().               &Apache::loncommon::start_data_table_header_row().
              '<th>'.&mt('Select').'</th><th>'.&mt('Problem').'</th><th>'.&mt('Category').'</th><th>'.&mt('Preview').'</th>'.               '<th>'.&mt('Select').'</th><th>'.&mt('Problem').'</th><th>'.&mt('Bin').'</th><th>'.&mt('Preview').'</th>'.
              &Apache::loncommon::end_data_table_header_row());               &Apache::loncommon::end_data_table_header_row());
    foreach my $item (@allprobs) {     foreach my $item (@allprobs) {
       $r->print(&Apache::loncommon::start_data_table_row());        $r->print(&Apache::loncommon::start_data_table_row());
       $r->print('<td><font size="+3">');        $r->print('<td><font size="+3">');
       $r->print('<input type="checkbox" name="item'.$item.'"');        if ($mandatory{$item}) {
       if ($chosen{$item}) { $r->print(' checked="checked"'); }           $r->print('<input type="hidden" name="item'.$item.'" value="checked"');
         } else {
            $r->print('<input type="checkbox" name="item'.$item.'"');
            if ($chosen{$item}) { $r->print(' checked="checked"'); }
         }
       $r->print(' /></font></td>');        $r->print(' /></font></td>');
       $r->print('<td><font size="+3">'.$item.'</font></td><td><font size="+3">'.$probcat{$item}.'</font></td>');        $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 $output=&Apache::lonindexer::showpreview(&fullurl($item));
Line 220  sub store { Line 250  sub store {
    if ($#errors>1) { return; }     if ($#errors>1) { return; }
    &chosen_to_map();     &chosen_to_map();
    &storemap_gci();     &storemap_gci();
    unless ($#errors>-1) {     if ($env{'form.phase'} eq 'storemap') {
       $r->print('<p>'.&mt('You have successfully assembled a valid test.').        unless ($#errors>-1) {
            $r->print('<p>'.&mt('You have successfully assembled a valid test.').
                 '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.                  '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
                 '<input type="hidden" name="orgurl" value="/adm/navmaps" /><input type="hidden" name="selectrole" value="1" />'.                  '<input type="hidden" name="orgurl" value="/adm/navmaps" /><input type="hidden" name="selectrole" value="1" />'.
                 '<input type="hidden" name="'.$env{'request.role'}.'" value="1" /><input type="submit" value="'.                  '<input type="hidden" name="'.$env{'request.role'}.'" value="1" /><input type="submit" value="'.
                  &mt('Activate Current Test').'" /></form></p>');                   &mt('Activate Current Test').'" /></form></p>');
         }
    }     }
 }  }
   

Removed from v.1.2  
changed lines
  Added in v.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>