[LON-CAPA-cvs] cvs: loncom /homework lonhomework.pm structuretags.pm /xml lonxml.pm

raeburn raeburn at source.lon-capa.org
Mon Nov 27 17:44:21 EST 2023


raeburn		Mon Nov 27 22:44:21 2023 EDT

  Modified files:              
    /loncom/homework	structuretags.pm lonhomework.pm 
    /loncom/xml	lonxml.pm 
  Log:
  - Move &setmode_javascript() from structuretags.pm to lonxml.pm to facilitate
    reuse.
  
  
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.580 loncom/homework/structuretags.pm:1.581
--- loncom/homework/structuretags.pm:1.580	Fri Nov 17 17:02:21 2023
+++ loncom/homework/structuretags.pm	Mon Nov 27 22:44:20 2023
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.580 2023/11/17 17:02:21 raeburn Exp $
+# $Id: structuretags.pm,v 1.581 2023/11/27 22:44:20 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -297,7 +297,7 @@
     }
     return &Apache::loncommon::resize_textarea_js().
                 &Apache::loncommon::colorfuleditor_js().
-           &setmode_javascript().
+           &Apache::lonxml::setmode_javascript().
 	<<"JS";
 <script type="text/javascript">
 // <![CDATA[
@@ -409,21 +409,6 @@
 JS
 }
 
-sub setmode_javascript {
-    return <<"ENDSCRIPT";
-<script type="text/javascript">
-// <![CDATA[
-function setmode(form,probmode) {
-    var initial = form.problemmode.value;
-    form.problemmode.value = probmode;
-    form.submit();
-    form.problemmode.value = initial;
-}
-// ]]>
-</script>
-ENDSCRIPT
-}
-
 sub page_start {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$name,
 	$extra_head)=@_;
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.380 loncom/homework/lonhomework.pm:1.381
--- loncom/homework/lonhomework.pm:1.380	Fri Nov 17 17:02:21 2023
+++ loncom/homework/lonhomework.pm	Mon Nov 27 22:44:20 2023
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.380 2023/11/17 17:02:21 raeburn Exp $
+# $Id: lonhomework.pm,v 1.381 2023/11/27 22:44:20 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -949,7 +949,7 @@
 
 sub analyze_header {
     my ($request) = @_;
-    my $js = &Apache::structuretags::setmode_javascript();
+    my $js = &Apache::lonxml::setmode_javascript();
 
     # Breadcrumbs
     my $text = 'Authoring Space';
@@ -1198,7 +1198,7 @@
 	my $js =
 	    &Apache::edit::js_change_detection(). 
 	    &Apache::loncommon::resize_textarea_js().
-            &Apache::structuretags::setmode_javascript().
+            &Apache::lonxml::setmode_javascript().
             &Apache::lonhtmlcommon::dragmath_js("EditMathPopup");
 
     # Breadcrumbs
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.562 loncom/xml/lonxml.pm:1.563
--- loncom/xml/lonxml.pm:1.562	Sat Jul 22 22:41:45 2023
+++ loncom/xml/lonxml.pm	Mon Nov 27 22:44:21 2023
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.562 2023/07/22 22:41:45 raeburn Exp $
+# $Id: lonxml.pm,v 1.563 2023/11/27 22:44:21 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1664,6 +1664,26 @@
       return ($editfooter,$add_to_onload,$add_to_onresize);;
 }
 
+sub setmode_javascript {
+    return <<"ENDSCRIPT";
+<script type="text/javascript">
+// <![CDATA[
+function setmode(form,probmode) {
+    if (probmode == 'daxe') {
+        var url = new URL(document.location.href);
+        window.location = url.protocol+'//'+url.hostname+'/daxepage'+url.pathname;
+    } else {
+        var initial = form.problemmode.value;
+        form.problemmode.value = probmode;
+        form.submit();
+        form.problemmode.value = initial;
+    }
+}
+// ]]>
+</script>
+ENDSCRIPT
+}
+
 sub get_target {
   my $viewgrades=&Apache::lonnet::allowed('vgr',$env{'request.course.id'});
   if ( $env{'request.state'} eq 'published') {




More information about the LON-CAPA-cvs mailing list