[LON-CAPA-cvs] cvs: loncom /html/adm/help/tex Domain_Configuration_Course_Defaults.tex /interface domainprefs.pm /lonnet/perl lonnet.pm /xml lontexconvert.pm

raeburn raeburn at source.lon-capa.org
Fri Oct 6 20:51:01 EDT 2017


raeburn		Sat Oct  7 00:51:01 2017 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm 
    /loncom/lonnet/perl	lonnet.pm 
    /loncom/xml	lontexconvert.pm 
    /loncom/html/adm/help/tex	Domain_Configuration_Course_Defaults.tex 
  Log:
  - Bug 6867
    - Domain configuration to set default math renderer for <m> tag content.
    - Default renderer for unconfigured domains changed from tth to MathJax.
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.313 loncom/interface/domainprefs.pm:1.314
--- loncom/interface/domainprefs.pm:1.313	Fri Aug 25 00:33:14 2017
+++ loncom/interface/domainprefs.pm	Sat Oct  7 00:50:47 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.313 2017/08/25 00:33:14 raeburn Exp $
+# $Id: domainprefs.pm,v 1.314 2017/10/07 00:50:47 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4073,11 +4073,13 @@
         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',
     );
     my %staticdefaults = (
+                           texengine            => 'MathJax',
                            anonsurvey_threshold => 10,
                            uploadquota          => 500,
                            postsubmit           => 60,
@@ -4091,8 +4093,36 @@
                             'canclone'        => 'none',
                           );
         @toggles = ('canuse_pdfforms','uselcmath','usejsme');
+        my $deftex = $staticdefaults{'texengine'};
+        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 style="vertical-align: top">'.
@@ -13663,7 +13693,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') {
@@ -13723,6 +13757,20 @@
                 }
             }
         }
+        my $texengine;
+        if ($env{'form.texengine'} =~ /^(MathJax|mimetex|tth)$/) {
+            $texengine = $env{'form.texengine'};
+            if ($defaultshash{'coursedefaults'}{'texengine'} eq '') {
+                unless ($texengine eq 'MathJax') {
+                    $changes{'texengine'} = 1;
+                }
+            } elsif ($defaultshash{'coursedefaults'}{'texengine'} ne $texengine) {
+                $changes{'texengine'} = 1;
+            }
+        }
+        if ($texengine ne '') {
+            $defaultshash{'coursedefaults'}{'texengine'} = $texengine;
+        }
         my $currclone = $domconfig{'coursedefaults'}{'canclone'};
         my @currclonecode;
         if (ref($currclone) eq 'HASH') {
@@ -13843,8 +13891,8 @@
             my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
             if (($changes{'canuse_pdfforms'}) || ($changes{'uploadquota'}) || ($changes{'postsubmit'}) ||
                 ($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'}) ||
-                ($changes{'canclone'}) || ($changes{'mysqltables'})) {
-                foreach my $item ('canuse_pdfforms','uselcmath','usejsme') { 
+                ($changes{'canclone'}) || ($changes{'mysqltables'}) || ($changes{'texengine'})) {
+                foreach my $item ('canuse_pdfforms','uselcmath','usejsme','texengine') {
                     if ($changes{$item}) {
                         $domdefaults{$item}=$defaultshash{'coursedefaults'}{$item};
                     }
@@ -13913,6 +13961,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') {
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1355 loncom/lonnet/perl/lonnet.pm:1.1356
--- loncom/lonnet/perl/lonnet.pm:1.1355	Mon Sep 25 00:36:35 2017
+++ loncom/lonnet/perl/lonnet.pm	Sat Oct  7 00:50:52 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1355 2017/09/25 00:36:35 raeburn Exp $
+# $Id: lonnet.pm,v 1.1356 2017/10/07 00:50:52 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2453,6 +2453,9 @@
         } elsif ($domconfig{'coursedefaults'}{'canclone'}) {
             $domdefaults{'canclone'}=$domconfig{'coursedefaults'}{'canclone'};
         }
+        if ($domconfig{'coursedefaults'}{'texengine'}) {
+            $domdefaults{'texengine'} = $domconfig{'coursedefaults'}{'texengine'};
+        } 
     }
     if (ref($domconfig{'usersessions'}) eq 'HASH') {
         if (ref($domconfig{'usersessions'}{'remote'}) eq 'HASH') {
Index: loncom/xml/lontexconvert.pm
diff -u loncom/xml/lontexconvert.pm:1.119 loncom/xml/lontexconvert.pm:1.120
--- loncom/xml/lontexconvert.pm:1.119	Sat Apr  9 14:48:13 2016
+++ loncom/xml/lontexconvert.pm	Sat Oct  7 00:50:57 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # TeX Conversion Module
 #
-# $Id: lontexconvert.pm,v 1.119 2016/04/09 14:48:13 raeburn Exp $
+# $Id: lontexconvert.pm,v 1.120 2017/10/07 00:50:57 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -331,7 +331,12 @@
         }
 	return $env{'environment.texengine'};
     }
-    return 'tth';
+    my $dom = $env{'request.role.domain'} || $env{'user.domain'};
+    my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+    if ($domdefaults{'texengine'} ne '') {
+        return $domdefaults{'texengine'};
+    }
+    return 'MathJax';
 }
 
 sub init_math_support {
Index: loncom/html/adm/help/tex/Domain_Configuration_Course_Defaults.tex
diff -u loncom/html/adm/help/tex/Domain_Configuration_Course_Defaults.tex:1.7 loncom/html/adm/help/tex/Domain_Configuration_Course_Defaults.tex:1.8
--- loncom/html/adm/help/tex/Domain_Configuration_Course_Defaults.tex:1.7	Mon Sep 19 13:12:18 2016
+++ loncom/html/adm/help/tex/Domain_Configuration_Course_Defaults.tex	Sat Oct  7 00:51:01 2017
@@ -4,10 +4,22 @@
 \begin{itemize}
 \item \textbf{Defaults that can be overridden in an individual course by a Course Coordinator} 
 
-Currently, there are three domain defaults of this type (which can be overridden
+Currently, there are four domain defaults of this type (which can be overridden
 using Settings $>$ Course Settings $>$ Display with ``Display of resources'' checked).
 
 \begin{itemize}
+\item Default method to display mathematics expressions included between $<$m$>$ and $<$/m$>$ tags.
+
+Starting with LON-CAPA 2.12 the default renderer used to display math can be set to one of: 
+\textit{MathJax}, \textit{Convert to Images (mimetex)}, or \textit{TeX to HTML (tth)}.
+The domain default in effect for a user will be for the domain of the user's current role.
+However, if a user has selected a renderer from the \textit{Math display settings} in 
+User Preferences that will take precedence over the domain default.
+Furthermore, if the course setting: \textit{Force use of a specific math rendering engine}
+has been set, that will take precedence (in course context) over both the user preference 
+and the domain default.  If no default renderer has been set, MathJax is used in 
+LON-CAPA 2.12 and later, whereas TeX to HTML (tth) is used in LON-CAPA 2.11 and earlier.
+  
 \item Student formula entry uses inline preview, not DragMath pop-up
 
 For problems that require a formula input via a textbox, the default is to


More information about the LON-CAPA-cvs mailing list