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

raeburn raeburn at source.lon-capa.org
Fri Feb 15 16:18:34 EST 2019


raeburn		Fri Feb 15 21:18:34 2019 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	domainprefs.pm 
  Log:
  - For 2.11
    Backport 1.314, 1.349
  
  
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.160.6.89 loncom/interface/domainprefs.pm:1.160.6.90
--- loncom/interface/domainprefs.pm:1.160.6.89	Sat Sep 15 15:15:32 2018
+++ loncom/interface/domainprefs.pm	Fri Feb 15 21:18:32 2019
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.160.6.89 2018/09/15 15:15:32 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.90 2019/02/15 21:18:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3492,6 +3492,7 @@
         coursecredits        => 'Credits can be specified for courses',
         uselcmath            => 'Math preview uses LON-CAPA previewer (javascript) in place of DragMath (Java)',
         usejsme              => 'Molecule editor uses JSME (HTML5) in place of JME (Java)',
+        texengine            => 'Default method to display mathematics',
         postsubmit           => 'Disable submit button/keypress following student submission',
         canclone             => "People who may clone a course (besides course's owner and coordinators)",
         mysqltables          => 'Lifetime (s) of "Temporary" MySQL tables (student performance data) on homeserver',
@@ -3509,8 +3510,36 @@
                             'canclone'        => 'none',
                           );
         @toggles = ('uselcmath','usejsme');
+        my $deftex = $Apache::lonnet::deftex;
+        if (ref($settings) eq 'HASH') {
+            if ($settings->{'texengine'}) {
+                if ($settings->{'texengine'} =~ /^(MathJax|mimetex|tth)$/) {
+                    $deftex = $settings->{'texengine'};
+                }
+            }
+        }
+        $css_class = $itemcount%2?' class="LC_odd_row"':'';
+        my $mathdisp = '<tr'.$css_class.'><td style="vertical-align: top">'.
+                       '<span class="LC_nobreak">'.$choices{'texengine'}.
+                       '</span></td><td class="LC_right_item">'.
+                       '<select name="texengine">'."\n";
+        my %texoptions = (
+                            MathJax  => 'MathJax',
+                            mimetex  => &mt('Convert to Images'),
+                            tth      => &mt('TeX to HTML'),
+                         );
+        foreach my $renderer ('MathJax','mimetex','tth') {
+            my $selected = '';
+            if ($renderer eq $deftex) {
+                $selected = ' selected="selected"';
+            }
+            $mathdisp .= '<option value="'.$renderer.'"'.$selected.'>'.$texoptions{$renderer}.'</option>'."\n";
+        }
+        $mathdisp .= '</select></td></tr>'."\n";
+        $itemcount ++;
         ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
                                                      \%choices,$itemcount);
+        $datatable = $mathdisp.$datatable;
         $css_class = $itemcount%2?' class="LC_odd_row"':'';
         $datatable .=
             '<tr'.$css_class.'><td valign="top">'.
@@ -11682,7 +11711,11 @@
                            postsubmit           => 60,
                            mysqltables          => 172800,
                          );
-
+    my %texoptions = (
+                        MathJax  => 'MathJax',
+                        mimetex  => &mt('Convert to Images'),
+                        tth      => &mt('TeX to HTML'),
+                     );
     $defaultshash{'coursedefaults'} = {};
 
     if (ref($domconfig{'coursedefaults'}) ne 'HASH') {
@@ -11729,7 +11762,6 @@
                 $defaultshash{'coursedefaults'}{$setting}{$type} = $newdef;
             }
             if ($currdef ne $newdef) {
-                my $staticdef;
                 if ($item eq 'anonsurvey_threshold') {
                     unless (($currdef eq '') && ($newdef == $staticdefaults{$item})) {
                         $changes{$item} = 1;
@@ -11742,6 +11774,21 @@
                 }
             }
         }
+        my $texengine;
+        if ($env{'form.texengine'} =~ /^(MathJax|mimetex|tth)$/) {
+            $texengine = $env{'form.texengine'};
+            my $currdef = $domconfig{'coursedefaults'}{'texengine'};
+            if ($currdef eq '') {
+                unless ($texengine eq $Apache::lonnet::deftex) {
+                    $changes{'texengine'} = 1;
+                }
+            } elsif ($currdef ne $texengine) {
+                $changes{'texengine'} = 1;
+            }
+        }
+        if ($texengine ne '') {
+            $defaultshash{'coursedefaults'}{'texengine'} = $texengine;
+        }
         my $currclone = $domconfig{'coursedefaults'}{'canclone'};
         my @currclonecode;
         if (ref($currclone) eq 'HASH') {
@@ -11862,8 +11909,8 @@
             my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
             if (($changes{'uploadquota'}) || ($changes{'postsubmit'}) ||
                 ($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'}) ||
-                ($changes{'canclone'}) || ($changes{'mysqltables'})) {
-                foreach my $item ('uselcmath','usejsme') {
+                ($changes{'canclone'}) || ($changes{'mysqltables'}) || ($changes{'texengine'})) {
+                foreach my $item ('uselcmath','usejsme','texengine') {
                     if ($changes{$item}) {
                         $domdefaults{$item}=$defaultshash{'coursedefaults'}{$item};
                     }
@@ -11926,6 +11973,11 @@
                     } else {
                         $resulttext .= '<li>'.&mt('Molecule editor uses JME (Java), if supported by client OS.').'</li>';
                     }
+                } elsif ($item eq 'texengine') {
+                    if ($defaultshash{'coursedefaults'}{'texengine'} ne '') {
+                        $resulttext .= '<li>'.&mt('Default method to display mathematics set to: "[_1]"',
+                                                  $texoptions{$defaultshash{'coursedefaults'}{'texengine'}}).'</li>';
+                    }
                 } elsif ($item eq 'anonsurvey_threshold') {
                     $resulttext .= '<li>'.&mt('Responder count required for display of anonymous survey submissions set to [_1].',$defaultshash{'coursedefaults'}{'anonsurvey_threshold'}).'</li>';
                 } elsif ($item eq 'uploadquota') {




More information about the LON-CAPA-cvs mailing list