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

raeburn raeburn at source.lon-capa.org
Wed Sep 14 13:59:30 EDT 2016


raeburn		Wed Sep 14 17:59:30 2016 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonpreferences.pm 
  Log:
  - For 2.11
    - Backport 1.215, 1.216.
  
  
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.196.4.19 loncom/interface/lonpreferences.pm:1.196.4.20
--- loncom/interface/lonpreferences.pm:1.196.4.19	Wed Aug 10 23:50:07 2016
+++ loncom/interface/lonpreferences.pm	Wed Sep 14 17:59:30 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Preferences
 #
-# $Id: lonpreferences.pm,v 1.196.4.19 2016/08/10 23:50:07 raeburn Exp $
+# $Id: lonpreferences.pm,v 1.196.4.20 2016/09/14 17:59:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1860,6 +1860,58 @@
     &print_main_menu($r,$message);
 }
 
+sub author_space_settings {
+    my $r = shift;
+    &Apache::lonhtmlcommon::add_breadcrumb(
+            {   href => '/adm/preferences?action=authorsettings',
+                text => 'Authoring Space Settings'});
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
+    my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au','ca','aa']);
+    if (keys(%author_roles) > 0) {
+            $r->print(Apache::loncommon::start_page('Authoring Space Settings'));
+            $r->print(Apache::lonhtmlcommon::breadcrumbs('Authoring Space Settings'));
+            my %userenv = &Apache::lonnet::get('environment',['nocodemirror']);
+            my $constchecked='';
+            if ($env{'environment.nocodemirror'}) {
+               $constchecked=' checked="checked"';
+            }
+            my $text=&mt('By default, CodeMirror an editor with advanced functionality for editing code is activated for authors.');
+            my $cmoff=&mt('Deactivate CodeMirror. This can improve performance on slow computers and accessibility.');
+            my $change=&mt('Save');
+            $r->print(<<ENDSCREEN);
+        <form name="prefs" action="/adm/preferences" method="post">
+        <input type="hidden" name="action" value="change_authoring_settings" />
+        $text<br />
+        <label><input type="checkbox" name="cmoff"$constchecked />$cmoff</label><br />
+        <input type="submit" value="$change" />
+        </form>
+ENDSCREEN
+    }
+}
+
+sub change_authoring_settings {
+    my $r = shift;
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
+    my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au','ca','aa']);
+    if (keys(%author_roles) > 0) {
+            my %ausettings=('environment.nocodemirror' => '');
+            if ($env{'form.cmoff'}) { $ausettings{'environment.nocodemirror'}='yes'; }
+            &Apache::lonnet::put('environment',\%ausettings);
+            &Apache::lonnet::appenv({'environment.nocodemirror' => $ausettings{'environment.nocodemirror'}});
+            my $status='';
+            if ($ausettings{'environment.nocodemirror'} eq 'yes') {
+                $status=&mt('on');
+            } else {
+                $status=&mt('off');
+            }
+            my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]','<i>'.&mt('Deactivate CodeMirror in Authoring Space').'</i>','<tt>'.$status.'</tt>'));
+            $message=&Apache::loncommon::confirmwrapper($message);
+            &print_main_menu($r,$message);
+    }
+}
+
 sub lockednameschanger {
     my $r = shift;
     &Apache::lonhtmlcommon::add_breadcrumb(
@@ -2228,6 +2280,10 @@
         &coursedisplaychanger($r);
     }elsif($env{'form.action'} eq 'verify_and_change_coursepage'){
         &verify_and_change_coursepage($r);
+    }elsif($env{'form.action'} eq 'authorsettings'){
+        &author_space_settings($r);
+    }elsif($env{'form.action'} eq 'change_authoring_settings'){
+        &change_authoring_settings($r);
     }elsif($env{'form.action'} eq 'debugtoggle'){
         if (&can_toggle_debug()) {
             &toggle_debug();




More information about the LON-CAPA-cvs mailing list