[LON-CAPA-cvs] cvs: loncom / loncapa_apache.conf /homework daxeopen.pm daxepage.pm /homework/cleanxml html_to_xml.pm post_xml.pm pre_xml.pm xml_to_loncapa.pm /publisher lonpubdir.pm /xml londefdef.pm

damieng damieng at source.lon-capa.org
Wed Jan 6 11:44:38 EST 2016


damieng		Wed Jan  6 16:44:38 2016 EDT

  Modified files:              
    /loncom	loncapa_apache.conf 
    /loncom/homework	daxeopen.pm daxepage.pm 
    /loncom/homework/cleanxml	xml_to_loncapa.pm post_xml.pm pre_xml.pm 
                             	html_to_xml.pm 
    /loncom/publisher	lonpubdir.pm 
    /loncom/xml	londefdef.pm 
  Log:
  Added Daxe editing for HTML documents, fixed issues with case mixing in task documents
  
-------------- next part --------------
Index: loncom/loncapa_apache.conf
diff -u loncom/loncapa_apache.conf:1.237 loncom/loncapa_apache.conf:1.238
--- loncom/loncapa_apache.conf:1.237	Thu Dec 10 16:26:40 2015
+++ loncom/loncapa_apache.conf	Wed Jan  6 16:44:27 2016
@@ -2,7 +2,7 @@
 ## loncapa_apache.conf -- Apache HTTP LON-CAPA configuration file
 ##
 
-# $Id: loncapa_apache.conf,v 1.237 2015/12/10 16:26:40 damieng Exp $
+# $Id: loncapa_apache.conf,v 1.238 2016/01/06 16:44:27 damieng Exp $
 
 #
 # LON-CAPA Section (extensions to httpd.conf daemon configuration)
@@ -456,12 +456,12 @@
 ErrorDocument     500 /adm/errorhandler
 </LocationMatch>
 
-<LocationMatch "^/daxepage/priv/.*\.(task|problem|exam|quiz|assess|survey|library)$">
+<LocationMatch "^/daxepage/priv/.*\.(task|problem|exam|quiz|assess|survey|library|xml|html|htm|xhtml|xhtm)$">
 SetHandler perl-script
 PerlHandler Apache::daxepage
 </LocationMatch>
 
-<LocationMatch "^/daxeopen/priv/.*\.(task|problem|exam|quiz|assess|survey|library)$">
+<LocationMatch "^/daxeopen/priv/.*\.(task|problem|exam|quiz|assess|survey|library|xml|html|htm|xhtml|xhtm)$">
 SetHandler perl-script
 PerlHandler Apache::daxeopen
 </LocationMatch>
Index: loncom/homework/daxeopen.pm
diff -u loncom/homework/daxeopen.pm:1.3 loncom/homework/daxeopen.pm:1.4
--- loncom/homework/daxeopen.pm:1.3	Tue Dec 15 15:00:58 2015
+++ loncom/homework/daxeopen.pm	Wed Jan  6 16:44:30 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Opening converted problems and directory listings for Daxe
 #
-# $Id: daxeopen.pm,v 1.3 2015/12/15 15:00:58 damieng Exp $
+# $Id: daxeopen.pm,v 1.4 2016/01/06 16:44:30 damieng Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -49,7 +49,7 @@
     &Apache::loncommon::no_cache($request);
     if ($uri =~ /\/$/) {
         return directory_listing($uri, $request);
-    } elsif ($uri =~ /\.(task|problem|exam|quiz|assess|survey|library)$/) {
+    } elsif ($uri =~ /\.(task|problem|exam|quiz|assess|survey|library|xml|html|htm|xhtml|xhtm)$/) {
         return convert_problem($uri, $request);
     } else {
         # Apache should send other files directly
@@ -70,7 +70,13 @@
     try {
         my $warnings = 0; # no warning printed
         my $textref = &Apache::pre_xml::pre_xml($file, $warnings);
-        $textref = &Apache::html_to_xml::html_to_xml($textref, $warnings);
+        my $case_sensitive;
+        if ($uri =~ /\.(task)$/) {
+          $case_sensitive = 1;
+        } else {
+          $case_sensitive = 0;
+        }
+        $textref = &Apache::html_to_xml::html_to_xml($textref, $warnings, $case_sensitive);
         my $text = &Apache::post_xml::post_xml($textref, $file, $perlvar{'lonDocRoot'}, $warnings);
         &Apache::loncommon::content_type($request, 'text/xml', 'utf-8');
         $request->print($text);
Index: loncom/homework/daxepage.pm
diff -u loncom/homework/daxepage.pm:1.1 loncom/homework/daxepage.pm:1.2
--- loncom/homework/daxepage.pm:1.1	Thu Dec 10 16:26:43 2015
+++ loncom/homework/daxepage.pm	Wed Jan  6 16:44:30 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Page with Daxe on the left side and the preview on the right side
 #
-# $Id: daxepage.pm,v 1.1 2015/12/10 16:26:43 damieng Exp $
+# $Id: daxepage.pm,v 1.2 2016/01/06 16:44:30 damieng Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -36,7 +36,7 @@
     my $uri = $request->uri;
     $uri =~ s/^\/daxepage//;
     &Apache::loncommon::no_cache($request);
-    if ($uri !~ /\.(task|problem|exam|quiz|assess|survey|library)$/) {
+    if ($uri !~ /\.(task|problem|exam|quiz|assess|survey|library|xml|html|htm|xhtml|xhtm)$/) {
         $request->status(406);
         return OK;
     }
Index: loncom/homework/cleanxml/xml_to_loncapa.pm
diff -u loncom/homework/cleanxml/xml_to_loncapa.pm:1.4 loncom/homework/cleanxml/xml_to_loncapa.pm:1.5
--- loncom/homework/cleanxml/xml_to_loncapa.pm:1.4	Tue Jan  5 18:51:08 2016
+++ loncom/homework/cleanxml/xml_to_loncapa.pm	Wed Jan  6 16:44:32 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # convert_file takes a well-formed XML file content and converts it to LON-CAPA syntax.
 #
-# $Id: xml_to_loncapa.pm,v 1.4 2016/01/05 18:51:08 damieng Exp $
+# $Id: xml_to_loncapa.pm,v 1.5 2016/01/06 16:44:32 damieng Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -60,7 +60,10 @@
   my ($contents) = @_;
 
   my $dom_doc = XML::LibXML->load_xml(string => $contents);
-  add_outtext($dom_doc);
+  my $root = $dom_doc->documentElement();
+  if (defined $root && $root->nodeName ne 'html') {
+    add_outtext($dom_doc);
+  }
   return node_to_string($dom_doc);
 }
 
Index: loncom/homework/cleanxml/post_xml.pm
diff -u loncom/homework/cleanxml/post_xml.pm:1.4 loncom/homework/cleanxml/post_xml.pm:1.5
--- loncom/homework/cleanxml/post_xml.pm:1.4	Fri Dec 18 22:07:42 2015
+++ loncom/homework/cleanxml/post_xml.pm	Wed Jan  6 16:44:32 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Third step to clean a file.
 #
-# $Id: post_xml.pm,v 1.4 2015/12/18 22:07:42 damieng Exp $
+# $Id: post_xml.pm,v 1.5 2016/01/06 16:44:32 damieng Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -150,7 +150,7 @@
   # the root element has already been added in pre_xml
   my $root = $doc->documentElement;
   # inside the root, replace html, problem and library elements by their content
-  my @toreplace = ('html','problem','library');
+  my @toreplace = ('html','problem','library','Task');
   foreach my $name (@toreplace) {
     my @elements = $root->getElementsByTagName($name);
     foreach my $element (@elements) {
@@ -1812,7 +1812,7 @@
 sub fix_paragraphs_inside {
   my ($node, $all_block) = @_;
   # blocks in which paragrahs will be added:
-  my @blocks_with_p = ('loncapa','library','problem','part','problemtype','window','block','while','postanswerdate','preduedate','solved','notsolved','languageblock','instructorcomment','togglebox','standalone','form');
+  my @blocks_with_p = ('loncapa','library','problem','part','problemtype','window','block','while','postanswerdate','preduedate','solved','notsolved','languageblock','instructorcomment','togglebox','standalone','body','form');
   my @fix_p_if_br_or_p = (@responses,'foil','item','text','label','hintgroup','hintpart','hint','web','windowlink','div','li','dd','td','th','blockquote');
   if ((string_in_array(\@blocks_with_p, $node->nodeName) && paragraph_needed($node)) ||
       (string_in_array(\@fix_p_if_br_or_p, $node->nodeName) && paragraph_inside($node))) {
Index: loncom/homework/cleanxml/pre_xml.pm
diff -u loncom/homework/cleanxml/pre_xml.pm:1.1 loncom/homework/cleanxml/pre_xml.pm:1.2
--- loncom/homework/cleanxml/pre_xml.pm:1.1	Thu Dec  3 20:40:31 2015
+++ loncom/homework/cleanxml/pre_xml.pm	Wed Jan  6 16:44:32 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # First step to clean a file.
 #
-# $Id: pre_xml.pm,v 1.1 2015/12/03 20:40:31 damieng Exp $
+# $Id: pre_xml.pm,v 1.2 2016/01/06 16:44:32 damieng Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -357,6 +357,8 @@
     $root_name = 'library';
   } elsif ($filepath =~ /\.html?$/i) {
     $root_name = 'html';
+  } elsif ($filepath =~ /\.task?$/i) {
+    $root_name = 'Task';
   } else {
     $root_name = 'problem';
   }
Index: loncom/homework/cleanxml/html_to_xml.pm
diff -u loncom/homework/cleanxml/html_to_xml.pm:1.1 loncom/homework/cleanxml/html_to_xml.pm:1.2
--- loncom/homework/cleanxml/html_to_xml.pm:1.1	Thu Dec  3 20:40:31 2015
+++ loncom/homework/cleanxml/html_to_xml.pm	Wed Jan  6 16:44:32 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Second step to clean a file.
 #
-# $Id: html_to_xml.pm,v 1.1 2015/12/03 20:40:31 damieng Exp $
+# $Id: html_to_xml.pm,v 1.2 2016/01/06 16:44:32 damieng Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -51,8 +51,11 @@
 
 # This takes non-well-formed UTF-8 LC+HTML and returns well-formed but non-valid XML LC+XHTML.
 sub html_to_xml {
-  my($textref, $warn) = @_;
+  my($textref, $warn, $case_sensitive) = @_;
   $warnings = $warn;
+  if (!defined $case_sensitive) {
+    $case_sensitive = 0;
+  }
   $result = '';
   @stack = ();
   $close_warning = '';
@@ -65,6 +68,10 @@
                           process_h  => [\&process, "token0"],
                         );
   # NOTE: by default, the HTML parser turns all attribute and elements names to lowercase
+  # This is a problem with the Task elements, so it is disabled in that case
+  if ($case_sensitive) {
+    $p->case_sensitive(1);
+  }
   $p->empty_element_tags(1);
   $result .= "<?xml version='1.0' encoding='UTF-8'?>\n";
   $p->parse($$textref);
Index: loncom/publisher/lonpubdir.pm
diff -u loncom/publisher/lonpubdir.pm:1.166 loncom/publisher/lonpubdir.pm:1.167
--- loncom/publisher/lonpubdir.pm:1.166	Thu Dec 10 16:26:59 2015
+++ loncom/publisher/lonpubdir.pm	Wed Jan  6 16:44:35 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Authoring Space Directory Lister
 #
-# $Id: lonpubdir.pm,v 1.166 2015/12/10 16:26:59 damieng Exp $
+# $Id: lonpubdir.pm,v 1.167 2016/01/06 16:44:35 damieng Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -914,6 +914,8 @@
     if ($filename=~/$LONCAPA::assess_re/) {
 	$editlink=' (<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=editxml">'.&mt('EditXML').'</a>)';
 	$editlink2=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=edit">'.&mt('Edit').'</a>)';
+    }
+    if ($filename=~/\.(xml|html|htm|xhtml|xhtm)$/ || $filename=~/$LONCAPA::assess_re/) {
         if ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9) {
             my $daxeurl = '/daxepage'.$linkdir.'/'.$filename;
             $editlink .= ' (<a href="'.$daxeurl.'" target="_blank">Daxe</a>)';
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.456 loncom/xml/londefdef.pm:1.457
--- loncom/xml/londefdef.pm:1.456	Mon Mar  9 19:05:33 2015
+++ loncom/xml/londefdef.pm	Wed Jan  6 16:44:37 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.456 2015/03/09 19:05:33 raeburn Exp $
+# $Id: londefdef.pm,v 1.457 2016/01/06 16:44:37 damieng Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -638,6 +638,12 @@
     }
     $result .= '
 <div><input type="submit" name="editmode" accesskey="e" value="'.&mt('Edit').'" />';
+    if ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9) {
+        my $uri = $env{'request.uri'};
+        my $daxeurl = '/daxepage'.$uri;
+        $result .= '<input type="button" value="'.&mt('Edit with Daxe').'" '.
+                  'onclick="window.open(\''.$daxeurl.'\',\'_blank\');" />';
+    }
     if (($env{'request.course.id'}) && ($env{'form.forceedit'})) {
         my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'});
         if ($url =~ /\.html?$/i) {


More information about the LON-CAPA-cvs mailing list