Diff for /modules/gci/londocsgci.pm between versions 1.7 and 1.15

version 1.7, 2009/12/25 00:49:35 version 1.15, 2010/11/16 02:28:10
Line 58  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 116  sub setdefaults { Line 115  sub setdefaults {
         $revreqs{$prereqs{$item}} = $item;          $revreqs{$prereqs{$item}} = $item;
     }      }
     @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');
     @development = ('100','101','102');      @development = ('001','002','003','004','005','006','007','008','009','010','011','012','013','014','015','016','017','018','019','020','021','022','023','024','025','026','027');
     %developmentitems = ('100' => 1, '101' => '1', '102' => '1');  
 }  }
   
 sub checkvalid {  sub checkvalid {
Line 152  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';
 }  }
   
Line 181  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 = '.&nbsp;';
          }
      }
    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 196  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).'&nbsp;<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 227  sub listresources { Line 243  sub listresources {
                 &Apache::lonhtmlcommon::row_closure(1).                  &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 265  sub editor { Line 282  sub editor {
     $r->print(&display_questions(\@devitems,'development',$devleg,\%chosenitems));      $r->print(&display_questions(\@devitems,'development',$devleg,\%chosenitems));
     $r->print('<input type="hidden" name="phase" value="storemap" />'.      $r->print('<input type="hidden" name="phase" value="storemap" />'.
               '<input type="hidden" name="context" value="'.$context.'" />'.                '<input type="hidden" name="context" value="'.$context.'" />'.
                 '<input type="hidden" name="concepttest" value="'.$env{'form.concepttest'}.'" />'.
               '<input type="submit" value="'.&mt('Store Problem Selection').'" />'.                '<input type="submit" value="'.&mt('Store Problem Selection').'" />'.
               '</form>');                '</form>');
     &Apache::lonnet::delenv('request.gcicontext');      &Apache::lonnet::delenv('request.gcicontext');
Line 293  sub display_questions { Line 311  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.'">'.
               '<a href="javascript:showQuestions('."'$fieldid','$titleid'".')">'.                '<a href="javascript:showQuestions('."'$fieldid','$titleid'".')">'.
               &mt('Show').'</a> ...</span><br />'.                &mt('Show').'</a> ...</span><br />'.
               '<div id="'.$fieldid.'">'.                '<div id="'.$fieldid.'" style="display: none">'.
               &Apache::loncommon::start_data_table().                &Apache::loncommon::start_data_table().
               &Apache::loncommon::start_data_table_header_row();                &Apache::loncommon::start_data_table_header_row();
     unless (($catname eq 'development') || ($catname eq 'mandatory')) {      unless (($catname eq 'development') || ($catname eq 'mandatory')) {
Line 309  sub display_questions { Line 327  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="countChecked('."'$catname'".');';              $output .= ' onclick="countChecked('."'$catname'".');';
             my $binname;              my $binname;
Line 342  sub display_questions { Line 362  sub display_questions {
         }          }
         $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 '' ? '&nbsp;':$content).' </td>'."\n".          $output .= '<td> '.($content eq '' ? '&nbsp;':$content).' </td>'."\n".
                    &Apache::loncommon::end_data_table_row();                     &Apache::loncommon::end_data_table_row();
     }      }
Line 402  sub chosen_to_map { Line 426  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]));            my $url  = &LONCAPA::map::qtunescape(&fullurl($allprobs[$idx]));
           if (($revreqs{$allprobs[$idx]}) &&             if (($revreqs{$allprobs[$idx]}) && 
Line 419  sub chosen_to_map { Line 444  sub chosen_to_map {
   $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 {
Line 577  sub builder_javascript { Line 612  sub builder_javascript {
     my $prereqjs = "      my $prereqjs = "
 function checkPrereqs(caller,item,prereq,binname) {  function checkPrereqs(caller,item,prereq,binname) {
     var changedPrereq = 0;      var changedPrereq = 0;
     if (document.selecteditems.elements['item'+item].checked == false) {      element = document.getElementById('item'+item);
       if (element.checked == false) {
         return;          return;
     } else {      } else {
         if (!document.selecteditems.elements['item'+prereq].checked) {          prereqelement = document.getElementById('item'+prereq);
             document.selecteditems.elements['item'+prereq].checked = true;          if (!prereqelement.checked) {
               prereqelement.checked = true;
             changedPrereq = 1;              changedPrereq = 1;
             countChecked(binname);              countChecked(binname);
         }          }
Line 639  function hideQuestions(content,title) { Line 676  function hideQuestions(content,title) {
     return;      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) {  function countChecked(binname) {
     var count = 0;      var count = 0;
     for (var i=0; i<document.selecteditems.elements.length; i++) {      for (var i=0; i<document.selecteditems.elements.length; i++) {
Line 666  function countChecked(binname) { Line 683  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 680  function validTestCheck() { Line 699  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 697  function setDocsPhase() { Line 717  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);  
   
                 }                  }
             }              }
         }          }

Removed from v.1.7  
changed lines
  Added in v.1.15


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