http://atutor.ca/atutor/mantis/view.php?id=4503
authorharris wong <hwong@ocad.ca>
Tue, 24 Aug 2010 20:18:03 +0000 (20:18 -0000)
committerharris wong <hwong@ocad.ca>
Tue, 24 Aug 2010 20:18:03 +0000 (20:18 -0000)
http://atutor.ca/atutor/mantis/view.php?id=4510

docs/include/classes/ContentManager.class.php
docs/include/lib/html_resource_parser.inc.php
docs/mods/_core/editor/edit_content_folder.php
docs/mods/_core/editor/editor_tab_functions.inc.php
docs/mods/_standard/tests/classes/testQuestions.class.php

index 96c840e..7204647 100644 (file)
@@ -301,7 +301,7 @@ class ContentManager
        
        function editContent($content_id, $title, $text, $keywords,$related, $formatting, 
                             $release_date, $head, $use_customized_head, $test_message, 
-                            $allow_test_export) {
+                            $allow_test_export, $content_type) {
                if (!authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN)) {
                        return FALSE;
                }
@@ -311,7 +311,8 @@ class ContentManager
                              SET title='$title', head='$head', use_customized_head=$use_customized_head, 
                                  text='$text', keywords='$keywords', formatting=$formatting, 
                                  revision=revision+1, last_modified=NOW(), release_date='$release_date', 
-                                 test_message='$test_message', allow_test_export=$allow_test_export 
+                                 test_message='$test_message', allow_test_export=$allow_test_export, 
+                          content_type=$content_type
                            WHERE content_id=$content_id AND course_id=$_SESSION[course_id]";
                $result = mysql_query($sql, $this->db);
 
index 309aa3d..8f362ce 100644 (file)
 /****************************************************************/
 // $Id$
 
-function get_html_resources($text) {
-       $resources = array();
+/**
+ * @param 
+ * @param   int     course id, which should be in $_SESSION, but during export to AContent,
+ *                  SESSION is not available, thus we will have to use parameters
+ */
+function get_html_resources($text, $course_id=0) {
+       $resources = array();    
+    if ($course_id == 0){
+        $course_id = $_SESSION['course_id'];
+    }
 
        $handler = new XML_HTMLSax_Handler();
 
@@ -38,12 +46,11 @@ function get_html_resources($text) {
                }
 
                // make sure this resource exists in this course's content directory:
-               $resource_server_path = realpath(AT_CONTENT_DIR . $_SESSION['course_id']. '/' . $resource);
+               $resource_server_path = realpath(AT_CONTENT_DIR . $course_id. '/' . $resource);
                if (file_exists($resource_server_path) && is_file($resource_server_path)) {
                        $resources[$resource] = $resource_server_path;
                }
        }
-
        return $resources;
 }
 
index 68235f8..86a2a9a 100644 (file)
@@ -57,7 +57,8 @@ if ($_POST['submit'])
                                                            '', 
                                                            $content_row['use_customized_head'], 
                                                            '', 
-                                                           $content_row['allow_test_export']);
+                                                           $content_row['allow_test_export'],
+                                                CONTENT_TYPE_FOLDER);
                }
                else
                { // add new content
index a2e5a7a..1ace631 100644 (file)
@@ -140,7 +140,7 @@ function save_changes($redir, $current_tab) {
                        $err = $contentManager->editContent($_POST['cid'], $_POST['title'], $_POST['body_text'], 
                                                            $_POST['keywords'], $_POST['related'], $_POST['formatting'], 
                                                            $release_date, $_POST['head'], $_POST['use_customized_head'], 
-                                                           $_POST['test_message'], $_POST['allow_test_export']);
+                                                           $_POST['test_message'], $_POST['allow_test_export'], $content_type_pref);
                        $cid = $_POST['cid'];
                } else {
                        /* insert new */
index 7b0b631..8909e5c 100644 (file)
@@ -332,7 +332,7 @@ function test_qti_export($tid, $test_title='', $zipfile = null){
                $local_dependencies = array();
 
                $text_blob = implode(' ', $row);
-               $local_dependencies = get_html_resources($text_blob);
+               $local_dependencies = get_html_resources($text_blob, $course_id);
                $dependencies = array_merge($dependencies, $local_dependencies);
 
                $xml = $xml . "\n\n" . $local_xml;