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

raeburn raeburn@source.lon-capa.org
Sun, 01 Mar 2009 03:23:18 -0000


raeburn		Sun Mar  1 03:23:18 2009 EDT

  Modified files:              
    /loncom/interface	slotrequest.pm 
  Log:
  - Bug 5822. Work in progress.
    - Log slot reservation transactions in nohist_slotreservationslog.db in course
      using lonnet::instructor_log().  
  
  
Index: loncom/interface/slotrequest.pm
diff -u loncom/interface/slotrequest.pm:1.88 loncom/interface/slotrequest.pm:1.89
--- loncom/interface/slotrequest.pm:1.88	Mon Feb  2 18:20:15 2009
+++ loncom/interface/slotrequest.pm	Sun Mar  1 03:23:18 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler for requesting to have slots added to a students record
 #
-# $Id: slotrequest.pm,v 1.88 2009/02/02 18:20:15 bisitz Exp $
+# $Id: slotrequest.pm,v 1.89 2009/03/01 03:23:18 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -239,9 +239,7 @@
 }
 
 sub make_reservation {
-    my ($slot_name,$slot,$symb)=@_;
-
-    my ($cnum,$cdom)=&get_course();
+    my ($slot_name,$slot,$symb,$cnum,$cdom)=@_;
 
     my $value=&Apache::lonnet::EXT("resource.0.availablestudent",$symb,
 				   $env{'user.domain'},$env{'user.name'});
@@ -315,13 +313,7 @@
 	if ($value) {
 	    $new_value=$value.':'.$new_value;
 	}
-	my $result=&Apache::lonparmset::storeparm_by_symb($symb,
-						      '0_availablestudent',
-						       $parm_level, $new_value,
-						       'string',
-						       $env{'user.name'},
-					               $env{'user.domain'});
-	&Apache::lonxml::debug("hrrm $result");
+        &store_slot_parm($symb,$slot_name,$parm_level,$new_value,$cnum,$cdom);
 	return $wanted;
     }
 
@@ -329,6 +321,28 @@
     return undef;
 }
 
+sub store_slot_parm {
+    my ($symb,$slot_name,$parm_level,$new_value,$cnum,$cdom) = @_;
+    my $result=&Apache::lonparmset::storeparm_by_symb($symb,
+                                                  '0_availablestudent',
+                                                   $parm_level, $new_value,
+                                                   'string',
+                                                   $env{'user.name'},
+                                                   $env{'user.domain'});
+    &Apache::lonxml::debug("hrrm $result");
+    my %storehash = (
+                       symb    => $symb,
+                       slot    => $slot_name,
+                       action  => 'reserve',
+                       context => $env{'form.context'},
+                    );
+
+    &Apache::lonnet::instructor_log('slotreservationslog',\%storehash,
+                                    '',$env{'user.name'},$env{'user.domain'},
+                                    $cnum,$cdom);
+    return;
+}
+
 sub remove_registration {
     my ($r) = @_;
     if ($env{'form.entry'} ne 'remove all') {
@@ -354,7 +368,7 @@
     my $names = join(' ',@names);
 
     my $msg = &mt('Remove all of [_1] from slot [_2]?',$names,$slot_name);
-    &remove_registration_confirmation($r,$msg,['entry','slotname']);
+    &remove_registration_confirmation($r,$msg,['entry','slotname','context']);
 }
 
 sub remove_registration_user {
@@ -371,7 +385,7 @@
 		  $name,$slot_name,$title);
     
     &remove_registration_confirmation($r,$msg,['uname','udom','slotname',
-					       'entry','symb']);
+					       'entry','symb','context']);
 }
 
 sub remove_registration_confirmation {
@@ -510,6 +524,14 @@
 	if ( $consumed{$entry}->{'name'} eq ($uname.':'.$udom) ) {
 	    &Apache::lonnet::del('slot_reservations',[$entry],
 				 $cdom,$cnum);
+            my %storehash = (
+                               symb    => $symb,
+                               slot    => $slot_name,
+                               action  => 'release',
+                               context => $env{'form.context'},
+                        );
+            &Apache::lonnet::instructor_log('slotreservationslog',\%storehash,
+                                        1,$uname,$udom,$cnum,$cdom);
 	}
     }
 
@@ -530,7 +552,6 @@
 						      '0_availablestudent',
 						      $parm_level, $new_param,
 						      'string', $uname, $udom);
-
     my $msg;
     if ($mgr eq 'F') {
 	$msg = &mt('Released Reservation for user: [_1]',"$uname:$udom");
@@ -624,8 +645,9 @@
 	return 0;
     }
 
+    my ($cnum,$cdom)=&get_course();
     my $reserved=&make_reservation($env{'form.slotname'},
-				   \%slot,$symb);
+				   \%slot,$symb,$cnum,$cdom);
     my $description=&get_description($env{'form.slotname'},\%slot);
     if (defined($reserved)) {
 	my $retvalue = 0;
@@ -850,6 +872,7 @@
      <input type="hidden" name="symb" value="$escsymb" />
      <input type="hidden" name="slotname" value="$slot" />
      <input type="hidden" name="command" value="$command" />
+     <input type="hidden" name="context" value="user" />
    </form>
 STUFF
 	}
@@ -950,7 +973,7 @@
     $symb      = &escape($symb);
 
     return <<"END_LINK";
- <a href="/adm/slotrequest?command=remove_registration&amp;slotname=$slotname&amp;entry=$entry&amp;uname=$uname&amp;udom=$udom&amp;symb=$symb"
+ <a href="/adm/slotrequest?command=remove_registration&amp;slotname=$slotname&amp;entry=$entry&amp;uname=$uname&amp;udom=$udom&amp;symb=$symb&amp;context=manage"
    >($remove)</a>
 END_LINK