(no commit message)
authorCindy Li <cli@ocad.ca>
Wed, 9 Jun 2010 17:21:25 +0000 (17:21 -0000)
committerCindy Li <cli@ocad.ca>
Wed, 9 Jun 2010 17:21:25 +0000 (17:21 -0000)
docs/home/classes/ContentManager.class.php
docs/home/editor/editor_tabs/tests.inc.php
docs/home/ims/ims_import.php
docs/home/imscc/include/ims_template.inc.php
docs/include/classes/Utility.class.php

index be0fea8..a25b351 100644 (file)
@@ -1293,11 +1293,11 @@ initContentMenu();
         * @return      true if 'allow_test_export'==1 || is instructor
         */
        function allowTestExport($content_id){
-//             if (isset($_SESSION['is_admin'])){      
-//                     return true;
-//             }
+               include_once(TR_INCLUDE_PATH.'classes/Utility.class.php');
+               
                $row = $this->contentDAO->get($content_id);
-               if ($row['allow_test_export'] == 1){
+               
+               if ($row['allow_test_export'] == 1 || Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE)){
                        return true;
                }
                return false;
index c0f99ef..47a1514 100644 (file)
@@ -78,7 +78,7 @@ else {
 </div>
 
 <?php 
-print_test_table($results, $_POST['tid']);
+if (is_array($results)) print_test_table($results, $_POST['tid']);
 
 function print_test_table($results, $post_tids, $id_prefix='') {?>
        <div>
@@ -91,6 +91,7 @@ function print_test_table($results, $post_tids, $id_prefix='') {?>
        </tr>
        </thead>
        <tbody>
+       <?php if (is_array($results)) { ?>
        <?php foreach ($results as $row) { ?>
        <?php
                $checkMe = '';
@@ -103,6 +104,7 @@ function print_test_table($results, $post_tids, $id_prefix='') {?>
                <td><?php echo $row['title']; ?></td>
        </tr>
        <?php } ?>
+       <?php } ?>
        </tbody>
        </table>
        </div>
index 346d6cc..b0c265c 100644 (file)
@@ -144,7 +144,7 @@ function check_available_size($course_id)
                        echo "error=".urlencode('Empty OAuth token');
                }
                else {
-                       header('Location: ../create_course.php');
+                       header('Location: '.$_SERVER['HTTP_REFERER']);
                }
                exit;
        }
@@ -776,12 +776,12 @@ function rehash($items){
 if (!isset($_POST['submit']) && !isset($_POST['cancel']) && !isset($_GET['oauth_token'])) {
        /* just a catch all */
        $msg->addError('NO_PRIV');
-       header('Location: ../create_course.php');
+       header('Location: '.$_SERVER['HTTP_REFERER']);
        exit;
 } else if (isset($_POST['cancel'])) {
        $msg->addFeedback('IMPORT_CANCELLED');
 
-       header('Location: ../create_course.php');
+       header('Location: '.$_SERVER['HTTP_REFERER']);
        exit;
 }
 
@@ -834,7 +834,7 @@ if ($msg->containsErrors()) {
        } else if ($oauth_import) {
                echo "error=".urlencode('Invalid imported file');
        } else {
-               header('Location: ../create_course.php');
+               header('Location: '.$_SERVER['HTTP_REFERER']);
        }
        exit;
 }
@@ -866,7 +866,7 @@ if ($msg->containsErrors()) {
        } else if ($oauth_import) {
                echo "error=".urlencode('Cannot create import directory');
        } else {
-               header('Location: ../create_course.php');
+               header('Location: '.$_SERVER['HTTP_REFERER']);
        }
        exit;
 }
@@ -880,7 +880,7 @@ if ($archive->extract(      PCLZIP_OPT_PATH,        $import_path,
        $msg->addError('IMPORT_FAILED');
        echo 'Error : '.$archive->errorInfo(true);
        FileUtility::clr_dir($import_path);
-       header('Location: ../create_course.php');
+       header('Location: '.$_SERVER['HTTP_REFERER']);
        exit;
 }
 //error_reporting(AT_ERROR_REPORTING);
@@ -949,7 +949,7 @@ if ($ims_manifest_xml === false) {
        } else if ($oauth_import) {
                echo "error=".urlencode('IMS manifest file does not appear to be valid');
        } else {
-               header('Location: ../create_course.php');
+               header('Location: '.$_SERVER['HTTP_REFERER']);
        }
        exit;
 }
@@ -1011,7 +1011,7 @@ if ($msg->containsErrors()) {
        } else if ($oauth_import) {
                echo "error=".urlencode('Error at parsing IMS manifest file');
        } else {
-               header('Location: ../create_course.php');
+               header('Location: '.$_SERVER['HTTP_REFERER']);
        }
        exit;
 }
index 73a216b..83a1c18 100644 (file)
@@ -224,27 +224,29 @@ function print_organizations($parent_id,
                                $content_test_rs = $contentManager->getContentTestsAssoc($content['content_id']);       
                                $test_ids = array();            //reset test ids
                                //$my_files = array();          //reset myfiles.
-                               while ($content_test_row = mysql_fetch_assoc($content_test_rs)){
-                                       //export
-                                       $test_ids[] = $content_test_row['test_id'];
-                                       //the 'added_files' is for adding into the manifest file in this zip
-                                       $added_files = test_qti_export($content_test_row['test_id'], '', $zipfile);
-                                       foreach($added_files as $xml_file=>$chunk){
-                                               foreach ($chunk as $xml_filename){
-                                                       $added_files_xml .= str_replace('{FILE}', 'QTI/'.$xml_filename, $ims_template_xml['xml']);
+                               if (is_array($content_test_rs)) {
+                                       foreach ($content_test_rs as $content_test_row){
+                                               //export
+                                               $test_ids[] = $content_test_row['test_id'];
+                                               //the 'added_files' is for adding into the manifest file in this zip
+                                               $added_files = test_qti_export($content_test_row['test_id'], '', $zipfile);
+                                               foreach($added_files as $xml_file=>$chunk){
+                                                       foreach ($chunk as $xml_filename){
+                                                               $added_files_xml .= str_replace('{FILE}', 'QTI/'.$xml_filename, $ims_template_xml['xml']);
+                                                       }
+                                               }
+                                               //Save all the xml files in this array, and then print_organizations will add it to the manifest file.
+                                               $resources .= str_replace(      array('{TEST_ID}', '{PATH}', '{FILES}'),
+                                                                                                       array($content_test_row['test_id'], 'tests_'.$content_test_row['test_id'].'.xml', $added_files_xml),
+                                                                                                       $ims_template_xml['resource_test']); 
+       /*      Taken out since we are gonna use dependency instead
+                                               $test_xml_items .= str_replace( array('{TEST_ID}'),
+                                                                                                       array($content_test_row['test_id']),
+                                                                                                       $ims_template_xml['test']); 
+       */
+                                               foreach($test_files as $filename=>$realfilepath){
+                                                       $zipfile->add_file(@file_get_contents($realfilepath), 'QTI/'.$filename, filemtime($realfilepath));
                                                }
-                                       }
-                                       //Save all the xml files in this array, and then print_organizations will add it to the manifest file.
-                                       $resources .= str_replace(      array('{TEST_ID}', '{PATH}', '{FILES}'),
-                                                                                               array($content_test_row['test_id'], 'tests_'.$content_test_row['test_id'].'.xml', $added_files_xml),
-                                                                                               $ims_template_xml['resource_test']); 
-/*     Taken out since we are gonna use dependency instead
-                                       $test_xml_items .= str_replace( array('{TEST_ID}'),
-                                                                                               array($content_test_row['test_id']),
-                                                                                               $ims_template_xml['test']); 
-*/
-                                       foreach($test_files as $filename=>$realfilepath){
-                                               $zipfile->add_file(@file_get_contents($realfilepath), 'QTI/'.$filename, filemtime($realfilepath));
                                        }
                                }
                        }
index 2f114fe..75b01f8 100644 (file)
@@ -193,11 +193,11 @@ class Utility {
                                include(TR_INCLUDE_PATH.'footer.inc.php');\r
                                exit;\r
                        }\r
-                       else\r
+                       else {\r
                                return false;\r
+                       }\r
                }\r
-               \r
-               if (!$printMsg) return true;\r
+               return true;\r
        }\r
        \r
        /**\r