[LON-CAPA-cvs] cvs: loncom /interface lonmenu.pm lonviewclasslist.pm /lonnet/perl lonnet.pm

raeburn raeburn at source.lon-capa.org
Mon Dec 31 09:29:21 EST 2012


raeburn		Mon Dec 31 14:29:21 2012 EDT

  Modified files:              
    /loncom/interface	lonviewclasslist.pm lonmenu.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Edit link for /adm/classlists (student-viewable roster) in Course Editor
    and in inline Functions menu.
  
  
-------------- next part --------------
Index: loncom/interface/lonviewclasslist.pm
diff -u loncom/interface/lonviewclasslist.pm:1.13 loncom/interface/lonviewclasslist.pm:1.14
--- loncom/interface/lonviewclasslist.pm:1.13	Thu Mar 25 17:38:43 2010
+++ loncom/interface/lonviewclasslist.pm	Mon Dec 31 14:29:08 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to display the classlist 
 #
-# $Id: lonviewclasslist.pm,v 1.13 2010/03/25 17:38:43 raeburn Exp $
+# $Id: lonviewclasslist.pm,v 1.14 2012/12/31 14:29:08 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -34,6 +34,7 @@
 use Apache::loncoursedata();
 use Apache::loncommon();
 use Apache::lonhtmlcommon();
+use Apache::courseprefs();
 use Apache::Constants qw(:common :http REDIRECT);
 use Apache::lonlocal;
 use Apache::lonnet;
@@ -61,7 +62,7 @@
         return OK;
     }
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
-                                            ['register']);
+                                 ['register','forceedit','action','symb','todocs']);
     if (! ($env{'request.course.fn'})) {
         $env{'user.error.msg'}=
             "/adm/viewclasslist:not in course role";
@@ -87,13 +88,95 @@
     # Get classlist view settings
     my %viewsettings = &retrieve_view_settings();
 
-    # Print classlist
-    if (keys(%viewsettings) > 0) {
-        $r->print(&html_classlist($r,\%viewsettings));
+    if (($env{'form.forceedit'}) || ($env{'form.action'} eq 'setconfig'))  {
+        if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {
+            my $crstype = &Apache::loncommon::course_type();
+            my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+            my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+            my $rosterprefs = &roster_prefs($crstype);
+            my $allitems = {};
+            if ($env{'form.action'} eq 'setconfig') {
+                my %values=&Apache::lonnet::dump('environment',$cdom,$cnum);
+                if (keys(%values) > 0) {
+                    my ($numchanged,%changes,%disallowed);
+                    my $prefs = {
+                                    classlists => $rosterprefs,
+                                };
+                    $changes{'classlists'} = {};
+                    &Apache::courseprefs::process_changes($cdom,'classlists',\%values,
+                                                          $rosterprefs,
+                                                          $changes{'classlists'},
+                                                          $allitems,\%disallowed,$crstype);
+                    my $message;
+                    if (keys(%{$changes{'classlists'}}) > 0) {
+                        my $actions = ['classlists'];
+                        $message =
+                            &Apache::courseprefs::store_changes($cdom,$cnum,$actions,
+                                                                $actions,$prefs,\%values,
+                                                                \%changes,$crstype);
+                    } else {
+                        if ($crstype eq 'Community') {
+                            $message = &mt('No changes made to community settings.');
+                        } else {
+                            $message = &mt('No changes made to course settings.');
+                        }
+                    }
+                    $r->print(&Apache::loncommon::confirmwrapper($message));
+               } else {
+                    $r->print('<div class="LC_info">'.
+                              &mt('Unable to retrieve current settings.').'<br />'.
+                              &mt('No changes saved.').
+                              '</div>');
+               }
+           } else {
+               my $current = {};
+               my @settings = ('student_classlist_view','student_classlist_opt_in',
+                               'student_classlist_portfiles');
+               foreach my $setting (@settings) {
+                   $current->{$setting} = $env{"course.$env{'request.course.id'}.$setting"};
+               }
+               my ($output,$rowtotal) =
+                   &Apache::courseprefs::print_config_box($r,$cdom,'display',
+                                                          'viewableroster',
+                                                          $rosterprefs,$current,
+                                                          $allitems,$crstype);
+               if ($output) {
+                   $r->print('<form method="post" name="display" action="/adm/viewclasslist">'."\n".
+                             '<input type="hidden" name="action" value="setconfig" />'."\n".
+                             '<input type="hidden" name="register" value="'.$env{'form.register'}.'" />'."\n".
+                             '<input type="hidden" name="forceedit" value="'.$env{'form.forceedit'}.'" />'."\n");
+                   if ($env{'form.symb'}) {
+                        $r->print('<input type="hidden" name="symb" value="'.$env{'form.symb'}.'" />'."\n");
+                   }
+                   if ($env{'form.symb'}) {
+                        $r->print('<input type="hidden" name="todocs" value="'.$env{'form.todocs'}.'" />'."\n");
+                   }
+                   $r->print('<div class="LC_left_float">'.
+                             $output.
+                             '</div><br clear="all" />'.
+                             '<input type="submit" value="'.&mt('Save').'" />'.
+                             '</form>');
+               } else {
+                   $r->print('<div class="LC_info">'.
+                             &mt('No student-viewable course roster settings available.').
+                             '</div>');
+               }
+           }
+        } else {
+            $r->print('<div class="LC_info">'.
+                      &mt('You do not have rights to modify student-viewable course roster settings.').
+                      '</div>');
+        }
     } else {
-        $r->print('<div class="LC_info">'.
-                  &mt("Display of a student-viewable course roster is not currently enabled.").
-                  '</div>');
+
+        # Print classlist
+        if (keys(%viewsettings) > 0) {
+            $r->print(&html_classlist($r,\%viewsettings));
+        } else {
+            $r->print('<div class="LC_info">'.
+                      &mt("Display of a student-viewable course roster is not currently enabled.").
+                      '</div>');
+        }
     }
     #
     # Finish up
@@ -123,6 +206,37 @@
     return %viewsettings;
 }
 
+sub roster_prefs {
+    my ($crstype) = @_;
+    my %lt;
+    if ($crstype eq 'Community') {
+        %lt = &Apache::lonlocal::texthash (
+                  stuv => 'Member-viewable membership list options',
+                  stul => 'Member agreement needed to be listed',
+        );
+    } else {
+        %lt = &Apache::lonlocal::texthash(
+                  stuv => 'Student-viewable classlist options',
+                  stul => 'Student agreement needed to be listed',
+        );
+    }
+    $lt{'incl'} = &mt('Include link to accessible portfolio files');
+
+    return 
+        { text => 'Student-viewable roster settings',
+          header => [ {col1 => 'Setting',
+                       col2 => $lt{'stuv'}}],
+          ordered => ['student_classlist_view',
+                      'student_classlist_opt_in',
+                      'student_classlist_portfiles'],
+          itemtext => {
+                       student_classlist_view        => $lt{'stuv'},
+                       student_classlist_opt_in      => $lt{'stul'},
+                       student_classlist_portfiles   => $lt{'incl'},
+                      },
+        };
+}
+
 sub html_classlist {
     my ($r,$viewsettings) = @_;
     my ($Str,$title,$secdisplay,$cid,$cdom,$cnum,$listtype,%publicroster);
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.405 loncom/interface/lonmenu.pm:1.406
--- loncom/interface/lonmenu.pm:1.405	Fri Dec 28 17:12:49 2012
+++ loncom/interface/lonmenu.pm	Mon Dec 31 14:29:08 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.405 2012/12/28 17:12:49 raeburn Exp $
+# $Id: lonmenu.pm,v 1.406 2012/12/31 14:29:08 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -875,6 +875,13 @@
                                               $forceedit,$forceview,$forcereg,
                                               $env{'form.title'},$env{'form.suppurl'});
             }
+        } elsif (($resurl =~ m{^/?adm/viewclasslist$}) &&
+                 (&Apache::lonnet::allowed('opa',$env{'request.course.id'}))) {
+            ($cfile,$home,$switchserver,$forceedit,$forceview) =
+            &Apache::lonnet::can_edit_resource($resurl,$cnum,$cdom,$resurl,
+                                               $env{'form.symb'});
+            $editbutton = &get_editbutton($cfile,$home,$switchserver,
+                                          $forceedit,$forceview,$forcereg);
         } elsif (($resurl !~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) &&
                  ($resurl ne '/cgi-bin/printout.pl')) {
             if ($env{'request.filename'}) {
@@ -930,14 +937,6 @@
                             'Add records');
                 }
             }
-        } elsif ($resurl =~ m{^/?adm/viewclasslist}) {
-# This applies to viewclasslist page for users in a course
-            if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {
-                &switch('','',6,4,'pparm.png','Settings',
-                        '',
-                        "go('/adm/courseprefs?actions=classlists&phase=display')",
-                        'Student-viewable classlist options');
-            }
         }
         if (($env{'form.folderpath'} =~ /^supplemental/) &&
             (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&
@@ -991,7 +990,7 @@
             'advtools', @funcs[61,71,72,73,74,92]);
     } elsif ($env{'request.noversionuri'} eq '/adm/viewclasslist') {
         &Apache::lonhtmlcommon::add_breadcrumb_tool(
-            'advtools', @funcs[64]);
+            'advtools', @funcs[61]);
     }
 }
 
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1207 loncom/lonnet/perl/lonnet.pm:1.1208
--- loncom/lonnet/perl/lonnet.pm:1.1207	Fri Dec 21 16:58:41 2012
+++ loncom/lonnet/perl/lonnet.pm	Mon Dec 31 14:29:21 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1207 2012/12/21 16:58:41 raeburn Exp $
+# $Id: lonnet.pm,v 1.1208 2012/12/31 14:29:21 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2716,10 +2716,14 @@
                 return;
             }
         } else {
+            if ($resurl =~ m{^/?adm/viewclasslist$}) {
+                unless (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {
+                    return;
+                }
+            } elsif (!$crsedit) {
 #
 # No edit allowed where CC has switched to student role.
 #
-            unless ($crsedit) {
                 return;
             }
         }
@@ -2766,6 +2770,14 @@
                         $forceedit = 1;
                     }
                     $cfile = $resurl;
+                } elsif ($resurl =~ m{^/?adm/viewclasslist$}) {
+                    $incourse = 1;
+                    if ($env{'form.forceedit'}) {
+                        $forceview = 1;
+                    } else {
+                        $forceedit = 1;
+                    }
+                    $cfile = ($resurl =~ m{^/} ? $resurl : "/$resurl");
                 }
             } elsif ($resurl eq '/res/lib/templates/simpleproblem.problem/smpedit') {
                 my $template = '/res/lib/templates/simpleproblem.problem';


More information about the LON-CAPA-cvs mailing list