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

raeburn lon-capa-cvs@mail.lon-capa.org
Mon, 06 Jun 2005 22:40:02 -0000


raeburn		Mon Jun  6 18:40:02 2005 EDT

  Modified files:              
    /loncom/auth	lonroles.pm 
    /loncom/interface	lonwhatsnew.pm lonpreferences.pm 
  Log:
  Default is now to display "What's New?" screen to Course Coordinators, unless they have set preference to go to start of course, whenever a course is accessed from roles screen.
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.121 loncom/auth/lonroles.pm:1.122
--- loncom/auth/lonroles.pm:1.121	Sun Jun  5 03:57:28 2005
+++ loncom/auth/lonroles.pm	Mon Jun  6 18:39:59 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.121 2005/06/05 07:57:28 albertel Exp $
+# $Id: lonroles.pm,v 1.122 2005/06/06 22:39:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -262,9 +262,16 @@
 				$furl = "/adm/helper/course.initialization.helper";
 			    }
                             # Send the user to the course they selected
-                            &redirect_user($r,&mt('Entering Course'),
+                            if (($env{'request.course.fn'}) && ($role eq 'cc' && ($env{'environment.course_init_display'} ne 'firstres'))  {
+                                $msg = &mt('Entering course ....');
+                                &redirect_user($r,&mt('New in course'),
+                                      '/adm/whatsnew',$msg,
+                                      $env{'environment.remotenavmap'});
+                            } else {
+                                &redirect_user($r,&mt('Entering Course'),
                                            $furl,$msg,
 					   $env{'environment.remotenavmap'});
+                            }
                             return OK;
 			}
 		    }
Index: loncom/interface/lonwhatsnew.pm
diff -u loncom/interface/lonwhatsnew.pm:1.17 loncom/interface/lonwhatsnew.pm:1.18
--- loncom/interface/lonwhatsnew.pm:1.17	Fri Jun  3 23:36:36 2005
+++ loncom/interface/lonwhatsnew.pm	Mon Jun  6 18:39:59 2005
@@ -1,5 +1,5 @@
 #
-# $Id: lonwhatsnew.pm,v 1.17 2005/06/04 03:36:36 albertel Exp $
+# $Id: lonwhatsnew.pm,v 1.18 2005/06/06 22:39:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -35,6 +35,7 @@
 use Apache::lonlocal;
 use Apache::loncoursedata();
 use Apache::lonnavmaps();
+use Apache::lonuserstate;
 use Apache::Constants qw(:common :http);
 use Time::Local;
 
@@ -186,10 +187,14 @@
     my $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain);
 
     unless ($env{'request.course.id'}) {
-        $r->print('<br /><b><center>You are accessing an invalid course</center></b><br /><br />');
+        $r->print('<br /><b><center>You are accessing an invalid course.</center></b><br /><br />');
         return;
     }
 
+    my ($furl,$ferr)=
+           &Apache::lonuserstate::readmap($cdom.'/'.$crs);
+    $r->print('<font size="+1"><a href="'.$furl.'">Go to first resource</a></font><a href="/adm/preferences?action=changecourseinit"></font><br />Change your preferences</a> to suppress display of this screen when accessing courses as Course Coordinator in the future.<br /><hr />');
+
     my $result;
 
     if ($command eq 'reset') {
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.62 loncom/interface/lonpreferences.pm:1.63
--- loncom/interface/lonpreferences.pm:1.62	Mon Jun  6 12:23:55 2005
+++ loncom/interface/lonpreferences.pm	Mon Jun  6 18:39:59 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Preferences
 #
-# $Id: lonpreferences.pm,v 1.62 2005/06/06 16:23:55 raeburn Exp $
+# $Id: lonpreferences.pm,v 1.63 2005/06/06 22:39:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -973,6 +973,74 @@
 ENDVCSCREEN
 }
 
+################################################################
+# Subroutines for page display on course access (Course Coordinators)
+################################################################
+sub coursedisplaychanger {
+    my $r = shift;
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
+    my %userenv = &Apache::lonnet::get
+        ('environment',['course_init_display']);
+
+    my $firstselect='checked="checked"';
+    my $whatsnewselect='';
+    if ($userenv{'course_init_display'} eq 'firstres') {
+        $firstselect='';
+        $whatsnewselect='checked="checked"';
+    }
+    my $whatsnew_off=&mt('Display the first resource in the course.');
+    my $whatsnew_on=&mt('Display a summary of items in the course which require action from the course coordinator.');
+
+    $r->print('<br /><b>'.&mt('Set the page to be displayed when you select the role of Course Coordinator').':</b>');
+    $r->print(<<ENDLSCREEN);
+<form name="server" action="/adm/preferences" method="post">
+<input type="hidden" name="action" value="verify_and_change_coursepage" />
+<input type="radio" name="newdisp" value="firstres" $firstselect /> $whatsnew_off<br />
+<input type="radio" name="newdisp" value="whatsnew" $whatsnewselect /> $whatsnew_on
+ENDLSCREEN
+    $r->print('<br /><input type="submit" value="'.&mt('Change').'" />
+</form>');
+}
+
+sub verify_and_change_coursepage {
+    my $r = shift;
+    my $message='';
+    my %lt = &Apache::lonlocal::texthash(
+        'when' => 'Whenever you select the Course Coordinator role from the roles screen',
+        'ywbt' => 'you will be taken to the start of the course.',
+        'apwb' => 'a page will be displayed that lists items in the course that may require action from you.',
+        'gtts' => 'Go to the start of the course',
+        'dasp' => 'Display a summary page listing course action items', 
+    );
+    my $newdisp  = $env{'form.newdisp'};
+    if ($newdisp eq 'firstres') {
+        $message .= $lt{'when'}.', '.$lt{'ywbt'}.'<br/>';
+        &Apache::lonnet::put('environment',{'course_init_display' => $newdisp});
+        &Apache::lonnet::appenv('environment.course_init_display' => $newdisp);
+    } else {
+        $message .= $lt{'when'}.', '.$lt{'apwb'}.'<br/>';
+        &Apache::lonnet::del('environment',['course_init_display']);
+        &Apache::lonnet::delenv('environment\.course_init_display');
+    }
+    if (($env{'request.course.fn'}) && ($env{'request.course.id'})) {
+        if ($newdisp eq 'firstres') {
+            my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+            my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; 
+            my ($furl,$ferr)=
+                &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
+            $message .= '<br /><font size="+1"><a href="'.$furl.'">'.$lt{'gtts'}.' <i>'.&mt('now').'</i></a></font>';
+        } else {
+            $message .= '<br /><font size="+1"><a href="/adm/whatsnew">'.$lt{'dasp'}.'</a></font>';
+        }
+    }
+    $r->print(<<ENDVCSCREEN);
+$message
+<br /><br />
+ENDVCSCREEN
+}
+
+
 ######################################################
 #            other handler subroutines               #
 ######################################################
@@ -1153,7 +1221,22 @@
                             text => 'Change Math Preferences'},
                       printmenu => 'yes',
                       }));
-
+    if($env{'request.role'} =~ /^cc\.\//) {
+        push (@Options,({ action => 'changecourseinit',
+                          linktext => 'Change Course Initialization Preference',
+                          href => '/adm/preferences',
+                          subroutine => \&coursedisplaychanger,
+                          breadcrumb =>
+                              { href => '/adm/preferences?action=changecourseinit',
+                                text => 'Change Course Init. Pref.'},
+                          },
+                        { action => 'verify_and_change_coursepage',
+                          breadcrumb =>
+                          { href => '/adm/preferences?action=changecourseinit',                               text => 'Change Course Initialization Preference'},
+                        printmenu => 'yes',
+                        subroutine => \&verify_and_change_coursepage,
+                       }));
+    }
 
     if ($env{'user.name'} =~ /^(albertel|fox|foxr|koretemey|korte|hallmat3|turtle|raeburn)$/) {
         push (@Options,({ action => 'debugtoggle',