[LON-CAPA-cvs] cvs: modules /raeburn/register registrations.pm

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Tue, 22 May 2007 19:19:53 -0000


raeburn		Tue May 22 15:19:53 2007 EDT

  Modified files:              
    /modules/raeburn/register	registrations.pm 
  Log:
  Adding CVS version header.
  Adding brief author information.
  Retrieval of workshop names from database replaces static definition.
  (Fix bug causing reporting of 0 requests for DonCoord workshop at conference).
  
  
Index: modules/raeburn/register/registrations.pm
diff -u modules/raeburn/register/registrations.pm:1.2 modules/raeburn/register/registrations.pm:1.3
--- modules/raeburn/register/registrations.pm:1.2	Wed Mar 21 18:38:07 2007
+++ modules/raeburn/register/registrations.pm	Tue May 22 15:19:51 2007
@@ -1,3 +1,15 @@
+##########################################################
+#
+# Session-based registration reporting for conferences/workshops
+# Data retrieval for users with administrative access for a
+# particular event.
+#
+# $Id: registrations.pm,v 1.3 2007/05/22 19:19:51 raeburn Exp $
+#
+# Stuart P Raeburn
+#
+##########################################################
+
 package Apache::LON::registrations;
 
 use strict;
@@ -131,11 +143,15 @@
             }
                                                                                                   
 # get items that should appear in workshop_registration table
-            $sth = $dbh->prepare("SELECT name FROM event_formfields WHERE event_id = '$event_id' AND tablename = 'workshop_registration'");
+            $sth = $dbh->prepare("SELECT contents FROM event_formfields WHERE event_id = '$event_id' AND tablename = 'workshop_registration'");
             $sth->execute;
-            while (my @row = $sth->fetchrow_array) {
-                if (@row > 0) {
-                    push @workshop, @row;
+            while (my($contents)  = $sth->fetchrow_array) {
+                my @items = split(/&/,$contents);
+                foreach my $item (@items) {
+                    my ($key,$value) = split(/=/,$item);
+                    if (!(grep(/$key/,@workshop))) {
+                        push(@workshop,$key);
+                    }
                 }
             }
             $sth->finish;
@@ -899,8 +915,10 @@
         }
     }
     $sth->finish;
-    my %workshops;
-    my @workshopnames = ('coord','author','portfolio','other');
+    my (%workshops,@workshopnames);
+    if (ref($workshop) eq 'ARRAY') {
+        @workshopnames = @{$workshop};
+    }
     foreach my $user_id (@users) {
         %{$workshops{$user_id}} = ();
         my $user_id_quoted = $dbh->quote($user_id);