[LON-CAPA-cvs] cvs: loncom /html/adm/helper parameter.helper /interface lonhelper.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Tue, 22 Nov 2005 12:49:56 -0000


raeburn		Tue Nov 22 07:49:56 2005 EDT

  Modified files:              
    /loncom/interface	lonhelper.pm 
    /loncom/html/adm/helper	parameter.helper 
  Log:
  Add support for setting of parameters for course groups.  Work stll needed to deal with the case where no course groups exist.
  
  
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.127 loncom/interface/lonhelper.pm:1.128
--- loncom/interface/lonhelper.pm:1.127	Mon Oct 17 17:17:59 2005
+++ loncom/interface/lonhelper.pm	Tue Nov 22 07:49:50 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.127 2005/10/17 21:17:59 albertel Exp $
+# $Id: lonhelper.pm,v 1.128 2005/11/22 12:49:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2980,6 +2980,73 @@
 }    
 1;
 
+package Apache::lonhelper::group;
+
+=pod
+ 
+=head2 Element: groupX<group, helper element>
+ 
+<section> allows the user to choose one or more groups from the current course.
+
+It takes the standard attributes "variable", "multichoice", and "nextstate", meaning what they do for most other elements.
+ 
+=cut
+
+no strict;
+@ISA = ("Apache::lonhelper::choices");
+use strict;
+
+BEGIN {
+    &Apache::lonhelper::register('Apache::lonhelper::group',
+                                 ('group'));
+}
+
+sub new {
+    my $ref = Apache::lonhelper::choices->new();
+    bless($ref);
+}
+ 
+sub start_group {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ 
+    if ($target ne 'helper') {
+        return '';
+    }
+
+    $paramHash->{CHOICES} = [];
+
+    $paramHash->{'variable'} = $token->[2]{'variable'};
+    $helper->declareVar($paramHash->{'variable'});
+    $paramHash->{'multichoice'} = $token->[2]{'multichoice'};
+    if (defined($token->[2]{'nextstate'})) {
+        $paramHash->{NEXTSTATE} = $token->[2]{'nextstate'};
+    }
+
+    # Populate the CHOICES element
+    my %choices;
+
+    my $numgroups;
+    my %curr_groups;
+    if (&Apache::loncommon::coursegroups(\%curr_groups)) {
+        foreach my $group_name (keys %curr_groups) {
+            $choices{$group_name} = $group_name;
+        }
+    }
+    foreach my $group_name (sort(keys(%choices))) {
+        push @{$paramHash->{CHOICES}}, [$group_name, $group_name];
+    }
+}
+                                                                                    
+sub end_group {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+
+    if ($target ne 'helper') {
+        return '';
+    }
+    Apache::lonhelper::group->new();
+}
+1;
+
 package Apache::lonhelper::string;
 
 =pod
@@ -3566,6 +3633,11 @@
         $result .= '<li>'.&mt('for section [_1]',"<b>$section</b>").'</li>';
 	$result .= "<input type='hidden' name='csec' value='" .
             HTML::Entities::encode($section,"'<>&\"") . "' />\n";
+    } elsif ($vars->{TARGETS} eq 'group') {
+        my $group = $vars->{GROUP_NAME};
+        $result .= '<li>'.&mt('for group [_1]',"<b>$group</b>").'</li>';
+        $result .= "<input type='hidden' name='cgroup' value='" .
+            HTML::Entities::encode($group,"'<>&\"") . "' />\n";
     } else {
         # FIXME: This is probably wasteful! Store the name!
         my $classlist = Apache::loncoursedata::get_classlist();
Index: loncom/html/adm/helper/parameter.helper
diff -u loncom/html/adm/helper/parameter.helper:1.14 loncom/html/adm/helper/parameter.helper:1.15
--- loncom/html/adm/helper/parameter.helper:1.14	Tue Jun  7 17:19:57 2005
+++ loncom/html/adm/helper/parameter.helper	Tue Nov 22 07:49:55 2005
@@ -148,6 +148,8 @@
          . . . for <b>all students</b> in the course</choice>
       <choice computer="section" nextstate="CHOOSE_SECTION">
          . . . for a particular <b>section</b></choice>
+      <choice computer="group" nextstate="CHOOSE_GROUP">
+         . . . for a particular <b>group</b></choice>
       <choice computer="student" nextstate="CHOOSE_STUDENT">
          . . . for an individual <b>student</b></choice>
       </choices>
@@ -161,6 +163,15 @@
     <section variable="SECTION_NAME" nextstate="FINISH" />
     </state>
 
+  <state name="CHOOSE_GROUP" title="Select Group">
+    <eval>
+      return 'Please select the group you wish to set the ' .
+       &{$helper->{DATA}->{'dateType'}}() .
+         ' for:<br />';</eval>
+    <group variable="GROUP_NAME" nextstate="FINISH" />
+    </state>
+
+
   <state name="CHOOSE_STUDENT" title="Select Student">
     <eval>
       return 'Please select the student you wish to set the ' .