[LON-CAPA-cvs] cvs: loncom /homework response.pm
raeburn
raeburn at source.lon-capa.org
Mon Feb 23 14:46:19 EST 2015
raeburn Mon Feb 23 19:46:19 2015 EDT
Modified files:
/loncom/homework response.pm
Log:
- Modify how information from user agent is used to determine whether pop-up
dragmath applet (java) or inline math preview (javascript) should be
offered. Work in progress.
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.240 loncom/homework/response.pm:1.241
--- loncom/homework/response.pm:1.240 Sun Feb 22 01:34:48 2015
+++ loncom/homework/response.pm Mon Feb 23 19:46:19 2015
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# various response type definitons response definition
#
-# $Id: response.pm,v 1.240 2015/02/22 01:34:48 raeburn Exp $
+# $Id: response.pm,v 1.241 2015/02/23 19:46:19 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -578,15 +578,40 @@
sub edit_mathresponse_button {
my ($partid,$id)=@_;
my $field = 'HWVAL_'.$partid.'_'.$id;
- my $btype = $env{'browser.type'};
- my $bversion = $env{'browser.version'};
- if (($btype eq 'explorer' && $bversion < 9) || ($btype eq 'safari' && $bversion < 3) ||
- ($btype eq 'mozilla' && $bversion < 3)) {
- # DragMath applet
- my $button=&mt('Edit Answer');
-# my $helplink=&Apache::loncommon::help_open_topic('Formula_Editor');
- my $iconpath=$Apache::lonnet::perlvar{'lonIconsURL'};
- return(<<ENDFORMULABUTTON);
+ my $eqneditor = 'lcmath';
+ if ($env{'browser.type'} eq 'safari') {
+ if ($env{'browser.os'} eq 'mac') {
+ my ($prefix,$version) = ($env{'browser.version'} =~ /^(\d*)(\d{3})\./);
+ if ($env{'browser.mobile'}) {
+ if (($version < 531) || (($prefix eq '') && ($version < 533))) {
+ $eqneditor = '';
+ }
+ } elsif ($version < 522) {
+ $eqneditor = 'dragmath';
+ }
+ }
+ } elsif ($env{'browser.type'} eq 'explorer') {
+ if ($env{'browser.version'} < 9) {
+ $eqneditor = 'dragmath';
+ }
+ } elsif ($env{'browser.type'} eq 'mozilla') {
+ if ($env{'browser.version'} < 3) {
+ $eqneditor = 'dragmath';
+ } else {
+ if ($env{'browser.info'} =~ /^firefox\-([\d\.]+)/) {
+ my $firefox = $1;
+ if ($firefox < 3) {
+ $eqneditor = 'dragmath';
+ }
+ }
+ }
+ }
+ if ($eqneditor eq 'dragmath') {
+ # DragMath applet
+ my $button=&mt('Edit Answer');
+# my $helplink=&Apache::loncommon::help_open_topic('Formula_Editor');
+ my $iconpath=$Apache::lonnet::perlvar{'lonIconsURL'};
+ return(<<ENDFORMULABUTTON);
<script type="text/javascript" language="JavaScript">
function LC_mathedit_${field} (LCtextline) {
thenumber = LCtextline;
@@ -599,8 +624,7 @@
</script>
<a href="javascript:LC_mathedit_${field}('${field}');void(0);"><img class="stift" src="$iconpath/stift.gif" alt="$button" title="$button" /></a>
ENDFORMULABUTTON
-
- } else {
+ } elsif ($eqneditor eq 'lcmath') {
# LON-CAPA math equation editor
my $mathjaxjs;
unless (lc(&Apache::lontexconvert::tex_engine()) eq 'mathjax') {
More information about the LON-CAPA-cvs
mailing list