[LON-CAPA-cvs] cvs: loncom /interface lonparmset.pm

amueller amueller@source.lon-capa.org
Fri, 31 Jul 2009 16:09:04 -0000


amueller		Fri Jul 31 16:09:04 2009 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  -changes in sub  mapmenu: 
          new possiblity to select maps in table mode.
          The mapmenu shows now the hierachy of the maps of your course
  -added some comments
          
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.467 loncom/interface/lonparmset.pm:1.468
--- loncom/interface/lonparmset.pm:1.467	Tue Jul 14 13:53:03 2009
+++ loncom/interface/lonparmset.pm	Fri Jul 31 16:09:03 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.467 2009/07/14 13:53:03 amueller Exp $
+# $Id: lonparmset.pm,v 1.468 2009/07/31 16:09:03 amueller Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1244,6 +1244,10 @@
     return (($type=~/^date/) && (!($type eq 'date_interval')));
 }
 
+#
+# This function prints a list of parameters, which were selected. It also display a link from which you can
+# hide or show the complete parameter list, from which you can choose your parameters. 
+#
 sub parmmenu {
     my ($r,$allparms,$pscat,$keyorder)=@_;
     my $tempkey;
@@ -1330,7 +1334,6 @@
     function checkboxChecked(id) {
         var li = "_li";
         var id_li = id.concat(li);
-
         if (document.getElementById(id_li).style.display == "none") {
             document.getElementById(id_li).style.display = "";
         }
@@ -1532,6 +1535,9 @@
     #&shortCuts($r,$allparms,$pscat,$keyorder);
     $r->print('</fieldset>');
 }
+#
+# This function offers some links on the parameter section to get with one click a group a parameters
+#
 sub shortCuts {
     my ($r,$allparms,$pscat,$keyorder)=@_;
 
@@ -1696,6 +1702,9 @@
                  ,$chooseopt));
 }
 
+#
+# This function shows on table Mode the available Parameters for the selected Resources
+#
 sub displaymenu {
     my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_;
     $r->print(&Apache::lonhtmlcommon::topic_bar (2,&mt('Select Parameters')));
@@ -1711,7 +1720,8 @@
 }
 
 sub mapmenu {
-    my ($r,$allmaps,$pschp,$maptitles)=@_;
+    my ($r,$allmaps,$pschp,$maptitles, $symbp)=@_;
+    my %allmaps_inverted = reverse %$allmaps;
     my $navmap = Apache::lonnavmaps::navmap->new();
     my $tree=[];
     my $treeinfo={};
@@ -1719,34 +1729,45 @@
         my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
         my $curRes;
         my $depth = 0;
-
+        my %parent = ();
+        my $startcount = 5;
+        my $lastcontainer = $startcount;
+# preparing what is to show ...
         while ($curRes = $it->next()) {
             if ($curRes == $it->BEGIN_MAP()) {
                 $depth++;
+                $parent{$depth}= $lastcontainer;
             }
             if ($curRes == $it->END_MAP()) {
                 $depth--;
+                $lastcontainer = $parent{$depth};
             }
             if (ref($curRes)) {
+                my $symb = $curRes->symb();
+                my $ressymb = $symb;
                 if (($curRes->is_sequence()) || ($curRes->is_page())) {
                     my $type = 'sequence';
                     if ($curRes->is_page()) {
                         $type = 'page';
                     }
                     my $id= $curRes->id();
-                    my ($mapid,$resid)=split(/\./,$id);
-                    if(!exists($treeinfo->{$mapid})) {
-                        push(@$tree,$mapid);	    
-                        $treeinfo->{$mapid} = {
+                    my $srcf = $curRes->src();
+                    my $resource_name = &Apache::lonnet::gettitle($srcf);
+                    if(!exists($treeinfo->{$id})) {
+                        push(@$tree,$id);
+                        my $enclosing_map_folder = &Apache::lonnet::declutter($curRes->enclosing_map_src());	    
+                        $treeinfo->{$id} = {
                                     depth => $depth,
                                     type  => $type,
+                                    name  => $resource_name,
+                                    enclosing_map_folder => $enclosing_map_folder,
                                     };
                     }
                 }
             }
         }
     }
-	
+# Show it ...	
     $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Enclosing Map or Folder')));
     if ((ref($tree) eq 'ARRAY') && (ref($treeinfo) eq 'HASH')) {
         my $icon = '<img src="/adm/lonIcons/navmap.folder.open.gif" alt="" />';
@@ -1762,27 +1783,48 @@
         my $whitespace = '<img src="'
                         .&Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace_21.gif")
                         .'" alt="" />';
-        foreach my $mapid (@{$tree}) {
+        if (exists($$allmaps{1})) {
+            $r->print(&Apache::loncommon::start_data_table_row()
+                .'<td>'.$icon
+                .'<label>&nbsp;'
+                .'<input type="radio" name="pschp" value="1"'
+            );
+            if ($pschp eq 1) {
+                $r->print(' checked="checked"');
+            }
+            $r->print('/>'
+                .$$maptitles{1}
+                .($$allmaps{1} !~/^uploaded/?' ['.$$allmaps{1}.']':'')
+                .'</label>'
+                .'</td>'
+                .&Apache::loncommon::end_data_table_row()
+            );
+        }
+        foreach my $id (@{$tree}) {
+            my ($mapid,$resid)=split(/\./,$id);
             # Indentation
-            my $depth = $treeinfo->{$mapid}->{'depth'};
+            my $depth = $treeinfo->{$id}->{'depth'};
             my $indent;
             for (my $i = 0; $i < $depth; $i++) {
                 $indent.= $whitespace;
             }
             $icon =  '<img src="/adm/lonIcons/navmap.folder.open.gif" alt="" />';
-            if ($treeinfo->{$mapid}->{'type'} eq 'page') {
+            if ($treeinfo->{$id}->{'type'} eq 'page') {
                 $icon = '<img src="/adm/lonIcons/navmap.page.open.gif" alt="" />';
             }
+            my $symb_name = $$symbp{$id};
+            my ($front, $tail) = split (/___${resid}___/, $symb_name);
+            $symb_name = $tail;
             $r->print(&Apache::loncommon::start_data_table_row()
                      .'<td>'.$indent.$icon
                      .'<label>&nbsp;'
-                     .'<input type ="radio" name="pschp" value="'.$mapid.'"'
+                     .'<input type ="radio" name="pschp" value="'.$allmaps_inverted{$symb_name}.'"'
             );
-            if ($pschp eq $mapid) {
+            if ($pschp eq $allmaps_inverted{$symb_name}) {
                 $r->print(' checked="checked"');
             }
             $r->print('/>'
-                     .$$maptitles{$mapid}
+                     .$treeinfo->{$id}->{name}
                      .($$allmaps{$mapid}!~/^uploaded/?' ['.$$allmaps{$mapid}.']':'')
                      .'</label>'
                      .'</td>'
@@ -1970,6 +2012,7 @@
     } else {
 	$udom=$r->dir_config('lonDefDomain');
     }
+    
 
     my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
     my $pschp=$env{'form.pschp'};
@@ -2151,7 +2194,7 @@
         $r->print('<div id="parmsel">');
     }
 
-    # Display parameter selection boxes
+    # Display Unit 1 "General Parameters"
     if (!$pssymb) {
         $r->print(&Apache::lonhtmlcommon::topic_bar (1,&mt('General Parameters')));
         $r->print(&Apache::lonhtmlcommon::start_pick_box());
@@ -2160,12 +2203,12 @@
 
 	if ($parmlev ne 'general') {
             $r->print(&Apache::lonhtmlcommon::row_closure());
-	    &mapmenu($r,\%allmaps,$pschp,\%maptitles);
+	    &mapmenu($r,\%allmaps,$pschp,\%maptitles, \%symbp);
 	}
 
         $r->print(&Apache::lonhtmlcommon::row_closure(1));
         $r->print(&Apache::lonhtmlcommon::end_pick_box());
-       
+    #Display Unit 2 "Select Parameter"   
 	&displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder);
     } else {
         my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);