[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Fri, 03 Dec 2004 05:15:30 -0000


raeburn		Fri Dec  3 00:15:30 2004 EDT

  Modified files:              
    /loncom/auth	lonroles.pm 
  Log:
  Eliminate display of "Recent courses visited by DC" - use Recent Roles instead. Recent roles display will now retrieve role info for recently visited CC roles created on the fly for a DC, if not yet visited this session.
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.112 loncom/auth/lonroles.pm:1.113
--- loncom/auth/lonroles.pm:1.112	Tue Nov 23 02:29:24 2004
+++ loncom/auth/lonroles.pm	Fri Dec  3 00:15:30 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.112 2004/11/23 07:29:24 raeburn Exp $
+# $Id: lonroles.pm,v 1.113 2004/12/03 05:15:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -84,10 +84,6 @@
     my $envkey;
     my %dcroles = ();
     my $numdc = &check_fordc(\%dcroles,$then);
-    my %recentroles;
-    if ($numdc > 0) {
-        %recentroles = &Apache::lonnet::dump(&recent_filename('roles'));
-    }
 
 # ================================================================== Roles Init
     if ($ENV{'form.selectrole'}) {
@@ -117,16 +113,6 @@
             }
         }
 
-# Check if user is a DC with courses in the recent list which need privs.
-#        if ($numdc > 0) {
-#            %recentroles = &Apache::lonnet::dump(&recent_filename('recent_roles'));
-#            foreach my $rolekey (keys %recentroles) {
-#                if ($rolekey =~ m-^user\.role.cc\./\w+/\w+$-) {
-#                    &check_privs($rolekey,$then,$now);
-#                }
-#            }
-#        }
-
         foreach $envkey (keys %ENV) {
             next if ($envkey!~/^user\.role\./);
             my ($where,$trolecode,$role,$tstatus,$tend,$tstart);
@@ -276,16 +262,6 @@
 							  '.course.helper.not.run'}) {
 				$furl = "/adm/helper/course.initialization.helper";
 			    }
-                            # Check to see if the user is a DC selecting a course
-                            if (($numdc > 0) && ($role eq 'cc')) {
-                                my $formaction = '/adm/roles/';
-                                my ($dcdom,$pickedcourse) = split/_/,$courseid;
-                                if ($ENV{'user.role.dc./'.$dcdom.'/'}) {
-                                    &Apache::lonhtmlcommon::store_recent('roles',
-                                    $envkey,$formaction);
-                                }
-                            }
-                            #
                             # Send the user to the course they selected
                             &redirect_user($r,&mt('Entering Course'),
                                            $furl,$msg,
@@ -618,7 +594,11 @@
 	foreach (sort(keys(%recent_roles))) {
 	    if (defined($roletext{'user.role.'.$_})) {
 		$output.=$roletext{'user.role.'.$_};
-	    }
+	    } elsif ($numdc > 0) {
+                unless ($_ =~/^error\:/) {
+                    $output.=&display_cc_role('user.role.'.$_);
+                }
+            } 
 	}
 	if ($output) {
 	    $r->print("<tr bgcolor='#BBffBB'><td align='center' colspan='7'>".
@@ -629,7 +609,6 @@
     }
 
     if ($numdc > 0) {
-        &display_recent_roles($r,\%roletext,\%recentroles);
         $r->print(&coursepick_jscript());
         $r->print(&Apache::loncommon::coursebrowser_javascript());
     }
@@ -923,46 +902,34 @@
     return $process_pick;
 }
 
-sub display_recent_roles {
-    my ($r,$roletext,$recentroles)=@_;
+sub display_cc_role {
+    my $rolekey = shift;
+    my $roletext;
     my $advanced = $ENV{'user.adv'};
     my $tryagain = $ENV{'form.tryagain'};
-    my $numrecent = 0;
-    my $roledisplay = '<tr bgcolor="#BBffBB">'.
-                   '<td align="center" colspan="7">'.
-                   &mt('Recent courses accessed by DC').
-                    '</td></tr>'."\n";
-    foreach my $rolekey (sort keys %{$recentroles}) {
-        unless ($rolekey =~/^error\:/) {
-            unless ($$roletext{$rolekey}) {
-                if ($rolekey =~ m-^user\.role.cc\./(\w+)/(\w+)$-) {
-                    my $tcourseid = $1.'_'.$2;
-                    my $trolecode = 'cc./'.$1.'/'.$2;
-                    my $trole = Apache::lonnet::plaintext('cc');
-                    my $twhere;
-                    my $tbg='#77FF77';
-                    my $tfont='#003300';
-                    my %newhash=&Apache::lonnet::coursedescription($tcourseid);
-                    if (%newhash) {
-                        $twhere=$newhash{'description'}.
-                               ' <font size="-2">'.
-                               &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1,$tfont).
-                               '</font>';
-                    } else {
-                        $twhere=&mt('Currently not available');
-                        $ENV{'course.'.$tcourseid.'.description'}=$twhere;
-                    }
-                    $twhere.="<br />".&mt('Domain').":".$1;
-                    $$roletext{$rolekey} = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$tfont,$trole,&mt('Course'),$twhere,'','','',1,'');
-                }
+    unless ($rolekey =~/^error\:/) {
+        if ($rolekey =~ m-^user\.role.cc\./(\w+)/(\w+)$-) {
+            my $tcourseid = $1.'_'.$2;
+            my $trolecode = 'cc./'.$1.'/'.$2;
+            my $trole = Apache::lonnet::plaintext('cc');
+            my $twhere;
+            my $tbg='#77FF77';
+            my $tfont='#003300';
+            my %newhash=&Apache::lonnet::coursedescription($tcourseid);
+            if (%newhash) {
+                $twhere=$newhash{'description'}.
+                        ' <font size="-2">'.
+                        &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1,$tfont).
+                        '</font>';
+            } else {
+                $twhere=&mt('Currently not available');
+                $ENV{'course.'.$tcourseid.'.description'}=$twhere;
             }
-            $roledisplay.=$$roletext{$rolekey};
-            $numrecent ++;
+            $twhere.="<br />".&mt('Domain').":".$1;
+            $roletext = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$tfont,$trole,&mt('Course'),$twhere,'','','',1,'');
         }
     }
-    if ($numrecent > 0) {
-        $r->print("$roledisplay\n");
-    }
+    return $roletext;
 }
 
 sub allcourses_row {