[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonwhatsnew.pm

raeburn raeburn at source.lon-capa.org
Mon Sep 1 19:00:18 EDT 2025


raeburn		Mon Sep  1 23:00:18 2025 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonwhatsnew.pm 
  Log:
  - For 2.11
    Backport 1.131
  
  
-------------- next part --------------
Index: loncom/interface/lonwhatsnew.pm
diff -u loncom/interface/lonwhatsnew.pm:1.105.2.19 loncom/interface/lonwhatsnew.pm:1.105.2.20
--- loncom/interface/lonwhatsnew.pm:1.105.2.19	Fri Jan  1 15:29:14 2021
+++ loncom/interface/lonwhatsnew.pm	Mon Sep  1 23:00:18 2025
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # What's New in a course
 #
-# $Id: lonwhatsnew.pm,v 1.105.2.19 2021/01/01 15:29:14 raeburn Exp $
+# $Id: lonwhatsnew.pm,v 1.105.2.20 2025/09/01 23:00:18 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -118,7 +118,23 @@
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
 
-    $r->print(&display_header($command,\%checkallowed));
+    my $udom = $env{'user.domain'};
+    my $uname = $env{'user.name'};
+    my $cid = $env{'request.course.id'};
+    my $store_result = &store_display_settings($uname,$udom,$cid,\%checkallowed);
+    my $store_error;
+
+    unless ($store_result eq 'ok') {
+        my $lctype = lc(&Apache::loncommon::course_type());
+        &Apache::lonnet::logthis('Error saving whatsnew settings: '.
+            $store_result.' for '.'user '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
+        $store_error = '<span class="LC_error">'
+                  .&mt('Unable to save visibility settings due to [_1]',
+                       $store_result)
+                  .'</span>';
+    }
+
+    $r->print(&display_header($command,$uname,$udom,$cid,\%checkallowed));
 
     &Apache::lonhtmlcommon::clear_breadcrumbs();
     &Apache::lonhtmlcommon::add_breadcrumb
@@ -185,7 +201,7 @@
             ("What's New?",#'Course_Action_Items_Display'
 	     ));
     }
-    &display_main_box($r,$command,$refpage,\%checkallowed,$cdom,$crs);
+    &display_main_box($r,$command,$refpage,\%checkallowed,$cdom,$crs,$store_error);
     return OK;
 }
 
@@ -196,7 +212,7 @@
 #------------------------------
                                                                                 
 sub display_main_box {
-    my ($r,$command,$refpage,$checkallowed,$cdom,$crs) = @_;
+    my ($r,$command,$refpage,$checkallowed,$cdom,$crs,$store_error) = @_;
     my $domain=&Apache::loncommon::determinedomain();
     my $function = &Apache::loncommon::get_users_function();
     my $lctype = lc(&Apache::loncommon::course_type());
@@ -245,7 +261,7 @@
         crslogin => \%crslogins,
         sessions => \%sessions,
     );
-    my %initpage = &Apache::lonlocal::texthash (
+    my %initpage = (
                      firstres => "first resource in the $lctype",
                      whatsnew => "What's New Page",
                      userpref => 'your general user preferences',
@@ -277,7 +293,8 @@
         &display_interval_config($r,$refpage,\%interval_titles,'sessions');
     } else {
         &display_actions_box($r,$command,$refpage,\%threshold_titles,
-                        \%interval_titles,\%initpage,$cdom,$crs,$checkallowed);
+                        \%interval_titles,\%initpage,$cdom,$crs,
+                        $checkallowed,$store_error);
     }
     my $end_page = &Apache::loncommon::end_page();
     $r->print(<<END_OF_BLOCK);
@@ -296,13 +313,48 @@
 #-------------------------------
 
 sub display_header {
-    my ($command,$checkallowed) = @_;
-    
+    my ($command,$uname,$udom,$cid,$checkallowed) = @_;
+
     my $scripttag;
-    unless ($command eq 'chgthreshold' || $command eq 'chginterval' || 
-            $command eq 'chgoldroleinterval' ||
-            $command eq 'chgnewroleinterval' || $command eq 'chgcrslogininterval') {
-       $scripttag = <<"END";
+    my $args = {};
+    my %loadentries;
+
+    if ($command eq 'courseinit') {
+        $scripttag = <<"END";
+<script type="text/javascript">
+// <![CDATA[
+function toggleCourseInit(form) {
+    if (document.getElementById('courseinit_by_course')) {
+        var radioelem = form.elements['courseinit_control'];
+        if (radioelem.length) {
+            for (var i=0; i<radioelem.length; i++) {
+                if (radioelem[i].checked) {
+                    if (radioelem[i].value == 'coursespecific') {
+                        document.getElementById('courseinit_by_course').style.display = 'inline';
+                    } else {
+                         document.getElementById('courseinit_by_course').style.display = 'none';
+                    }
+                    break;
+                }
+            }
+        }
+    }
+    return;
+}
+// ]]>
+</script>
+END
+        $loadentries{'onload'} = 'toggleCourseInit(document.courseinitswitch);';
+    } else {
+        unless (($command eq 'chgthreshold' && $checkallowed->{'abovethreshold'}) ||
+                ($command eq 'chginterval' && $checkallowed->{'versionchanges'}) ||
+                ($command eq 'chgdisc' && $checkallowed->{'coursediscussion'}) ||
+                ($command eq 'chgoldroleinterval' && $checkallowed->{'oldroles'}) ||
+                ($command eq 'chgnewroleinterval' && $checkallowed->{'newroles'}) ||
+                ($command eq 'chgcrslogininterval' && $checkallowed->{'crslogin'}) ||
+                ($command eq 'chgsessionlimit' && $checkallowed->{'sessions'})) {
+            my %display_settings = &get_display_settings($uname,$udom,$cid);
+            $scripttag = <<"END";
 <script type="text/javascript">
 // <![CDATA[
 function change_display(caller,change) {
@@ -312,14 +364,14 @@
 
 function changeAll(change) {
 END
-        foreach my $item (keys(%{$checkallowed})) {
-	    if ($item =~ /_section$/) { next; }
-            if ($$checkallowed{$item}) {
-                $scripttag.='document.visible.display_'.$item.'.value=change'.
-                            "\n";
+            foreach my $item (keys(%{$checkallowed})) {
+	        if ($item =~ /_section$/) { next; }
+                if ($$checkallowed{$item}) {
+                    $scripttag.='document.visible.display_'.$item.'.value=change'.
+                                "\n";
+                }
             }
-        }
-        $scripttag.=<<"ENDTOGG";
+            $scripttag.=<<"ENDTOGG";
     document.visible.submit();
 }
 
@@ -375,10 +427,20 @@
 // ]]>
 </script>
 ENDTOGG
+            if (($checkallowed->{'crslogin'}) && ($display_settings{$cid.':crslogin'} ne 'hide')) {
+                $loadentries{'onload'} = "toggledetails('login');";
+            }
+            if (($checkallowed->{'sessions'}) && ($display_settings{$cid.':sessions'} ne 'hide')) {
+                $loadentries{'onload'} .= "toggledetails('session');";
+            }
+        }
     }
     my $course_type=&Apache::loncommon::course_type();
+    if (keys(%loadentries)) {
+        $args->{'add_entries'} = \%loadentries;
+    }
     return &Apache::loncommon::start_page("What's New?",
-					  $scripttag);
+					  $scripttag,$args);
 }
 
 #-------------------------------
@@ -390,7 +452,7 @@
                                                                                 
 sub display_actions_box {
     my ($r,$command,$refpage,$threshold_titles,$interval_titles,$initpage,
-        $cdom,$crs,$checkallowed) = @_;
+        $cdom,$crs,$checkallowed,$store_error) = @_;
     my $udom = $env{'user.domain'};
     my $uname = $env{'user.name'};
     my $cid = $env{'request.course.id'};
@@ -467,7 +529,7 @@
     }
     $header .= &mt('Page set to be displayed after you have selected a role in this '.$lctype).'.'
               .' <span class="LC_nobreak">'
-              .&mt('Currently: [_1].','<i>'.$currinit.'</i>')
+              .&mt('Currently: [_1].','<span class="LC_cusr_emph">'.$currinit.'</span>')
               .'  '
               .&mt('[_1]Change[_2] for just [_3]this '.$lctype.'[_4] or for [_5]all your courses/communities[_6].'
                   ,'<b>'
@@ -490,15 +552,8 @@
         $result = &store_discussion_setting($uname,$udom,$cid);
     }
 
-    my $store_result=&store_display_settings($uname,$udom,$cid,$checkallowed);
-
-    unless ($store_result eq 'ok') { 
-        &Apache::lonnet::logthis('Error saving whatsnew settings: '.
-            $store_result.' for '.'user '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
-        $result .= '<span class="LC_error">'
-                  .&mt('Unable to save visibility settings due to [_1]',
-                       $store_result)
-                  .'</span>';
+    if ($store_error) {
+        $result = $store_error;
     }
 
     if ($result) {
@@ -690,9 +745,13 @@
     if ($show{'sessions'}) {
         $sessioncount = &getsessions($cdom,$crs,\%sessions,$timediff{'sessions'},$classlist);
     }
-    $r->print(qq|<a href="javascript:changeAll('hide');">$lt{'hial'}</a>
-       <a href="javascript:changeAll('show');">$lt{'shal'}</a>
-     <form method="post" name="visible" action="/adm/whatsnew">\n|);
+    my $showhideall = <<"END";
+<span class="LC_nobreak"><a href="javascript:changeAll('hide');">$lt{'hial'}</a>
+  <a href="javascript:changeAll('show');">$lt{'shal'}</a></span>
+END
+    $r->print(&Apache::loncommon::head_subbox($showhideall));
+    $r->print(qq|<form method="post" name="visible" action="/adm/whatsnew">\n|);
+
     foreach my $item (keys(%{$checkallowed})) {
 	if ($item =~ /_section$/) { next; }
         if ($$checkallowed{$item}) {
@@ -917,46 +976,49 @@
     my ($control,$current) = &curr_courseinit();
     my @chgstate = ('userpref','coursespecific');
     my @chgentry = ('firstres','whatsnew');
+    my $courseinitsty = 'display:none;';
+    if ($control eq 'coursespecific') {
+        $courseinitsty = 'display:inline;';
+    }
     my $lctype = lc(&Apache::loncommon::course_type());
     my %lt = &Apache::lonlocal::texthash(
                              'chwp' => "Choose which page will be displayed when you enter this $lctype after selecting a role.",
-                             'cuva' => 'Current value is determined by',
-                             'anis' => 'and is set to display',
                              'padc' => 'Page display controlled by',
-                             'chce' => 'Choose '.$lctype.' entry',
+                             'chce' => "Choose $lctype entry",
                              'moce' => 'Save',
     );
-    $r->print(<<"END"); 
+    $lt{'cuva'} = &mt('Current value is determined by[_1]'.$initpage->{$control}.'[_2] and is set to display[_1]'.$initpage->{$current}.'[_2].',
+                      ': <span class="LC_cusr_emph">','</span>');
+    $r->print(<<"END");
 <br />$lt{'chwp'}
-<br />$lt{'cuva'}: <b>
-$$initpage{$control}</b> $lt{'anis'} <b>
-$$initpage{$current}</b>.<br /><br />
+<br />$lt{'cuva'}
+<br /><br />
 <form method="post" name="courseinitswitch" action="/adm/whatsnew">
 <input type="hidden" name="command" value="newcourseinit" />
 <input type="hidden" name="refpage" value="$refpage" />
-$lt{'padc'}:  
+<fieldset style="display:inline"><legend>$lt{'padc'}</legend>
 END
     foreach my $choice (@chgstate) {
         my $chkstring;
         if ($choice eq $control) {
             $chkstring = ' checked="checked" ';
-        }  
+        }
         $r->print('<span class="LC_nobreak"><label><input type="radio" name="courseinit_control" value="'.
-                   $choice.'"'.$chkstring.'/>'.$$initpage{$choice}.
+                   $choice.'"'.$chkstring.' onclick="toggleCourseInit(this.form);"/>'.&mt($initpage->{$choice}).
                    '  </label></span>');
     }
-    $r->print('<br /><br />'.&mt('If').' '.$$initpage{'coursespecific'}.
-              ' - <br />'.$lt{'chce'}.": \n");
+    $r->print('</fieldset><fieldset id="courseinit_by_course" style="'.$courseinitsty.'">'.
+              '<legend>'.$lt{'chce'}.'</legend>'."\n");
     foreach my $choice (@chgentry) {
         my $chkstring;
         if (($choice eq $current) && ($control eq 'coursespecific')) {
             $chkstring = ' checked="checked" ';
         }
         $r->print('<span class="LC_nobreak"><label><input type="radio" name="courseinit_page" value="'.
-                  $choice.'"'.$chkstring.'/>'.$$initpage{$choice}.
-                  '  </label></span>');
+                  $choice.'"'.$chkstring.'/>'.&mt($initpage->{$choice}).
+                  '  </label></span> ');
     }
-    $r->print('<br /><br /><input type="submit" name="display" value="'.
+    $r->print('</fieldset><br /><br /><input type="submit" name="display" value="'.
                $lt{'moce'}.'" /></form>');
     return;
 }
@@ -1917,10 +1979,10 @@
             $r->print('<tr'.$css_class.'>'.
 		      '<td class="LC_first_item" '.$rowspan.'><a href="'.$linkurl.'">'.
 		      $$triggered{$res}{title}.'</a></td>');
-                      if (ref($$triggered{$res}{text}) eq 'ARRAY') {
-		          $r->print($$triggered{$res}{text}[0]);
-                      }
-                      $r->print('</tr>');
+            if (ref($$triggered{$res}{text}) eq 'ARRAY') {
+                $r->print($$triggered{$res}{text}[0]);
+            }
+            $r->print('</tr>');
             if (ref($$triggered{$res}{text}) eq 'ARRAY') {
                 if (@{$$triggered{$res}{text}} > 1) {
                     for (my $i=1; $i<@{$$triggered{$res}{text}}; $i++) {
@@ -2382,7 +2444,7 @@
                     $result = &Apache::lonhtmlcommon::confirm_success(&mt("Page displayed after role selection in $lctype now set by [_1]user's global preferences[_2].",'<b>','</b>'));
                 } else {
                     $result = &Apache::lonhtmlcommon::confirm_success(&mt('Page displayed after role selection in this '.$lctype.' set to [_1].'
-                                 ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>'));
+                                 ,'<b>'.&mt($initpage->{$env{'form.courseinit_page'}}).'</b>'));
                 }
             } else {
                 &Apache::lonnet::logthis('Error saving whatsnew courseinit '.
@@ -2395,7 +2457,7 @@
                          '<tt>'.$outcome.'</tt>'),1);
                 } else {
                     $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set page display, after role selection, for this '.$lctype.' to [_1] due to [_2].'
-                                 ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>'
+                                 ,'<b>'.&mt($initpage->{$env{'form.courseinit_page'}}).'</b>'
                                  ,'<tt>'.$outcome.'</tt>'),1);
                 }
             }


More information about the LON-CAPA-cvs mailing list