fix the bug that importing CC from transformable into atutor doesn't include content...
authorCindy Li <cli@ocad.ca>
Thu, 10 Jun 2010 20:30:07 +0000 (20:30 -0000)
committerCindy Li <cli@ocad.ca>
Thu, 10 Jun 2010 20:30:07 +0000 (20:30 -0000)
19 files changed:
docs/home/classes/ContentManager.class.php
docs/home/editor/edit_content.php
docs/home/editor/edit_content_folder.php
docs/home/editor/editor_tab_functions.inc.php
docs/home/editor/editor_tabs/alternatives.inc.php
docs/home/editor/editor_tabs/edit.inc.php
docs/home/editor/editor_tabs/tests.inc.php
docs/home/editor/js/edit.js
docs/home/ims/include/ims_template.inc.php
docs/home/imscc/ims_export.php
docs/home/imscc/include/ims_template.inc.php
docs/include/classes/DAO/ContentDAO.class.php
docs/include/classes/DAO/ContentForumsAssocDAO.class.php
docs/include/classes/DAO/ContentTestsAssocDAO.class.php
docs/include/classes/DAO/CoursesDAO.class.php
docs/include/classes/DAO/ForumsCoursesDAO.class.php
docs/install/db/db_schema.sql
docs/install/db/language_text_temp.sql
docs/themes/default/language/index.tmpl.php

index cb15784..dbe7ea6 100644 (file)
@@ -226,7 +226,7 @@ class ContentManager
 
        function addContent($course_id, $content_parent_id, $ordering, $title, $text, $keywords, 
                            $related, $formatting, $head = '', $use_customized_head = 0, 
-                           $test_message = '', $allow_test_export = 1, $content_type = CONTENT_TYPE_CONTENT) {
+                           $test_message = '', $content_type = CONTENT_TYPE_CONTENT) {
                global $_current_user, $_course_id;
                
            if (!isset($_current_user) || !$_current_user->isAuthor($this->course_id)) {
@@ -243,13 +243,12 @@ class ContentManager
                /* main topics all have minor_num = 0 */
                $cid = $this->contentDAO->Create($_course_id, $content_parent_id, $ordering, 0, $formatting,
                                          $keywords, '', $title, $text, $head, $use_customized_head,
-                                         $test_message, $allow_test_export, $content_type);
+                                         $test_message, $content_type);
                return $cid;
        }
        
        function editContent($content_id, $title, $text, $keywords, $formatting, 
-                            $head, $use_customized_head, $test_message, 
-                            $allow_test_export) {
+                            $head, $use_customized_head, $test_message) {
            global $_current_user;
            
                if (!isset($_current_user) || !$_current_user->isAuthor($this->course_id)) {
@@ -257,7 +256,7 @@ class ContentManager
                }
 
                $this->contentDAO->Update($content_id, $title, $text, $keywords, $formatting, $head, $use_customized_head,
-                                         $test_message, $allow_test_export);
+                                         $test_message);
        }
 
        function moveContent($content_id, $new_content_parent_id, $new_content_ordering) {
@@ -1286,22 +1285,6 @@ initContentMenu();
                        }
                }
        }
-
-       /** 
-        * Return true if this content page allows export, else false.
-        * @param       int     content id
-        * @return      true if 'allow_test_export'==1 || is instructor
-        */
-       function allowTestExport($content_id){
-               include_once(TR_INCLUDE_PATH.'classes/Utility.class.php');
-               
-               $row = $this->contentDAO->get($content_id);
-               
-               if ($row['allow_test_export'] == 1 || Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE, false)){
-                       return true;
-               }
-               return false;
-       }
 }
 
 ?>
\ No newline at end of file
index c0f2282..81c4194 100644 (file)
@@ -208,7 +208,6 @@ $pid = intval($_REQUEST['pid']);
                        $_POST['weblink_text'] = $content_row['text'];
                        $_POST['keywords']   = $content_row['keywords'];
                        $_POST['test_message'] = $content_row['test_message'];
-                       $_POST['allow_test_export'] = $content_row['allow_test_export'];
 
 //                     $_POST['day']   = substr($content_row['release_date'], 8, 2);
 //                     $_POST['month'] = substr($content_row['release_date'], 5, 2);
@@ -383,22 +382,6 @@ $pid = intval($_REQUEST['pid']);
 //             }
        } 
        
-       if (!isset($_POST['allow_test_export']) && $current_tab != 3) {
-               //export flag handling.
-//             $sql = "SELECT `allow_test_export` FROM ".TABLE_PREFIX."content WHERE content_id=$_REQUEST[cid]";
-//             $result2 = mysql_query($sql, $db);
-//             if ($result2){
-//                     $c_row = mysql_fetch_assoc($result2);
-//             }
-               if (intval($content_row['allow_test_export'])==1){
-                       echo '<input type="hidden" name="allow_test_export" value="1" />';
-               } else {
-                       echo '<input type="hidden" name="allow_test_export" value="0" />';
-               }
-       } else {
-               echo '<input type="hidden" name="allow_test_export" value="'.intval($_POST['allow_test_export']).'" />';
-       }
-
        if ($do_check) {
                $changes_made = check_for_changes($content_row, $row_alternatives);
        }
index 8d81904..1f0d625 100644 (file)
@@ -52,8 +52,7 @@ if ($_POST['submit'])
                                                            $content_row['formatting'], 
                                                            '', 
                                                            $content_row['use_customized_head'], 
-                                                           '', 
-                                                           $content_row['allow_test_export']);
+                                                           '');
                }
                else
                { // add new content
index b42b17e..6c482ea 100644 (file)
@@ -29,7 +29,7 @@ function get_tabs() {
        //these are the _AT(x) variable names and their include file
        /* tabs[tab_id] = array(tab_name, file_name,                accesskey) */
        $tabs[0] = array('content',                     'edit.inc.php',          'n');
-       $tabs[1] = array('properties',                  'properties.inc.php',    'p');
+       $tabs[1] = array('metadata',                    'properties.inc.php',    'p');
        $tabs[2] = array('alternative_content', 'alternatives.inc.php',  'l');  
        $tabs[3] = array('tests',               'tests.inc.php',         't');  
        
@@ -100,7 +100,6 @@ function save_changes($redir, $current_tab) {
        $_POST['formatting'] = intval($_POST['formatting']);
        $_POST['keywords']      = trim($_POST['keywords']);
        $_POST['test_message'] = trim($_POST['test_message']);
-       $_POST['allow_test_export'] = intval($_POST['allow_test_export']);
 
        //if weblink is selected, use it
        if ($_POST['formatting']==CONTENT_TYPE_WEBLINK) {
@@ -137,11 +136,10 @@ function save_changes($redir, $current_tab) {
                        $err = $contentManager->editContent($_POST['_cid'], $_POST['title'], $_POST['body_text'], 
                                                            $_POST['keywords'], $_POST['formatting'], 
                                                            $_POST['head'], $_POST['use_customized_head'], 
-                                                           $_POST['test_message'], $_POST['allow_test_export']);
+                                                           $_POST['test_message']);
                        $cid = $_POST['_cid'];
                } else {
                        /* insert new */
-                       
                        $cid = $contentManager->addContent($_course_id,
                                                                                                  $_POST['pid'],
                                                                                                  $_POST['ordering'],
@@ -153,11 +151,11 @@ function save_changes($redir, $current_tab) {
                                                                                                  $_POST['head'],
                                                                                                  $_POST['use_customized_head'],
                                                                                                  $_POST['test_message'],
-                                                                                                 $_POST['allow_test_export'],
                                                                                                  $content_type_pref);
                        $_POST['_cid']    = $cid;
                        $_REQUEST['_cid'] = $cid;
                }
+               if ($cid == 0) return;
 //     }
 
        /* insert glossary terms */
@@ -450,9 +448,6 @@ function check_for_changes($row, $row_alternatives) {
        if ($row && isset($_POST['test_message']) && $_POST['test_message'] != $row['test_message']){
                $changes[3] = true;
        }
-       if ($row && isset($_POST['allow_test_export']) && $_POST['allow_test_export'] != $row['allow_test_export']){
-               $changes[3] = true;
-       }
        
        $content_tests = $contentManager->getContentTestsAssoc($cid);
        
index 4d432f2..6f7e120 100644 (file)
@@ -21,9 +21,14 @@ include_once(TR_INCLUDE_PATH.'classes/DAO/DAO.class.php');
 $dao = new DAO();
 $resourceTypesDAO = new ResourceTypesDAO();
 
-global $_content_id;
+global $_content_id, $content_row, $msg;
 $cid = $_content_id;
 
+if ($cid == 0) {
+       $msg->printErrors('SAVE_BEFORE_PROCEED');
+       require_once(TR_INCLUDE_PATH.'footer.inc.php');
+       exit;
+}
 /**
  * This function returns the preview link of the given file
  * @param  $file     the file location in "file manager"
@@ -90,7 +95,6 @@ function display_alternative_cell($secondary_resources, $alternative_type, $cont
 }
 
 // Main program
-global $db, $content_row;
 require(TR_INCLUDE_PATH.'lib/resources_parser.inc.php');
 
 if (count($resources)==0)
index 6f48e9c..60917d5 100644 (file)
@@ -11,6 +11,7 @@
 /************************************************************************/\r
 \r
 if (!defined('TR_INCLUDE_PATH')) { exit; }\r
+global $_course_id;\r
 ?>\r
     <script type="text/javascript" language="javascript">\r
     //<!--\r
@@ -55,6 +56,7 @@ if (!defined('TR_INCLUDE_PATH')) { exit; }
     <script type="text/javascript" language="javascript">\r
     //<!--\r
         trans.editor.content_path = "<?php if(isset($content_row['content_path'])) echo $content_row['content_path']; ?>";\r
+        trans.editor.course_id = "<?php if(isset($cid)) echo $_course_id; ?>";\r
         trans.editor.content_id = "<?php if(isset($cid)) echo $cid; ?>";\r
         trans.editor.head_enabled_title = "<?php echo _AT('customized_head_enabled_title'); ?>";\r
         trans.editor.head_disabled_title = "<?php echo _AT('customized_head_disabled_title'); ?>";\r
index 47a1514..9b64915 100644 (file)
@@ -50,28 +50,6 @@ else {
        <span style="font-weight:bold"><?php echo _AT('about_content_tests'); ?></span>
 </div>
 
-<div class="row">
-       <?php
-       //Need radio button 'cause one checkbox makes the states indeterministic
-       //@harris
-       $test_export_y_checked = '';
-       $test_export_n_checked = '';
-       if ($_POST['allow_test_export'] == 1){
-               $test_export_y_checked = ' checked="checked"';
-       } else {
-               $test_export_n_checked = ' checked="checked"';
-       }
-       
-       echo _AT('allow_test_export');
-?>
-
-       <input type="radio" name="allow_test_export" id="allow_test_export" value="1" <?php echo $test_export_y_checked; ?>/>
-       <label for="allow_test_export"><?php echo _AT('yes'); ?></label>
-       <input type="radio" name="allow_test_export" id="disallow_test_export" value="0" <?php echo $test_export_n_checked; ?>/>
-       <label for="disallow_test_export"><?php echo _AT('no'); ?></label>
-</div>
-
-
 <div class="row">
        <p><?php echo _AT('custom_test_message'); ?></p>
        <textarea name="test_message"><?php echo $_POST['test_message']; ?></textarea>
index 6900858..5c0afed 100644 (file)
@@ -94,7 +94,7 @@ trans.editor = trans.editor || {};
 \r
     //click function to launch file manager window\r
     var launchFileManager = function () {\r
-        window.open(trans.base_href + 'file_manager/index.php?framed=1&popup=1&cp=' + trans.editor.content_path + '&_cid=' + trans.editor.content_id, 'newWin1', 'menubar=0,scrollbars=1,resizable=1,width=640,height=490');\r
+        window.open(trans.base_href + 'file_manager/index.php?framed=1&popup=1&cp=' + trans.editor.content_path + '&_course_id=' + trans.editor.course_id, 'newWin1', 'menubar=0,scrollbars=1,resizable=1,width=640,height=490');\r
         return false;\r
     };\r
 \r
index e55e19c..b39e013 100644 (file)
@@ -170,31 +170,29 @@ function print_organizations($parent_id,
                        /* generate the IMS QTI resource and files */
                        global $contentManager;
                        //check if test export is allowed.
-                       if ($contentManager->allowTestExport($content['content_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);
-
-                                       //Save all the xml files in this array, and then print_organizations will add it to the manifest file.
-                                       foreach($added_files as $filename=>$file_array){
-                                               $my_files[] = $filename;
-                                               foreach ($file_array as $garbage=>$filename2){
-                                                       if (!in_array($filename2, $my_files)){
-                                                               $my_files[] = $filename2;
-                                                       }
+                       $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);
+
+                               //Save all the xml files in this array, and then print_organizations will add it to the manifest file.
+                               foreach($added_files as $filename=>$file_array){
+                                       $my_files[] = $filename;
+                                       foreach ($file_array as $garbage=>$filename2){
+                                               if (!in_array($filename2, $my_files)){
+                                                       $my_files[] = $filename2;
                                                }
                                        }
-
-                                       //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']); 
                                }
+
+                               //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']); 
                        }
 
                        /* generate the a4a files */
index 4bc96b0..f3df41f 100644 (file)
@@ -19,8 +19,8 @@ require_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
 require_once(TR_INCLUDE_PATH.'classes/DAO/ContentDAO.class.php');
 require_once(TR_INCLUDE_PATH.'classes/DAO/UsersDAO.class.php');
 
-$course_id = (isset($_REQUEST['course_id']) ? intval($_REQUEST['course_id']) : $_course_id);
-$cid = isset($_REQUEST['cid']) ? intval($_REQUEST['cid']) : $_content_id; /* content id of an optional chapter */
+$_course_id = $course_id = (isset($_REQUEST['course_id']) ? intval($_REQUEST['course_id']) : $_course_id);
+$_content_id = $cid = isset($_REQUEST['cid']) ? intval($_REQUEST['cid']) : $_content_id; /* content id of an optional chapter */
 $c   = isset($_REQUEST['c'])   ? intval($_REQUEST['c'])   : 0;
 
 if ($course_id == 0 && $cid == 0)
@@ -31,9 +31,7 @@ if ($course_id == 0 && $cid == 0)
 }
 
 if (isset($_REQUEST['to_tile']) && !isset($_POST['cancel'])) {
-       /* for TILE */
-
-       /* redirect to TILE import servlet */
+       /* export from transformable to atutor */
 
        require_once(TR_INCLUDE_PATH.'vitals.inc.php');
        if (!authenticate(TR_PRIV_ADMIN, TR_PRIV_RETURN)) {
@@ -281,6 +279,7 @@ if ($glossary_xml){
        $glossary_manifest_xml = '';
 }
 */
+
 ob_start();
 print_organizations($top_content_parent_id, $content, 0, '', array(), $toc_html);
 
index 83a1c18..f54009c 100644 (file)
@@ -220,34 +220,32 @@ function print_organizations($parent_id,
 
                        /* generate the IMS QTI resource and files */
                        //check if test export is allowed.
-                       if ($contentManager->allowTestExport($content['content_id'])){
-                               $content_test_rs = $contentManager->getContentTestsAssoc($content['content_id']);       
-                               $test_ids = array();            //reset test ids
-                               //$my_files = array();          //reset myfiles.
-                               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));
+                       $content_test_rs = $contentManager->getContentTestsAssoc($content['content_id']);       
+                       $test_ids = array();            //reset test ids
+                       //$my_files = array();          //reset myfiles.
+                       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));
+                                       }
                                }
                        }
 
index d84c21a..615b52c 100644 (file)
@@ -26,7 +26,7 @@ class ContentDAO extends DAO {
         */
        public function Create($course_id, $content_parent_id, $ordering, $revision, $formatting, $keywords, 
                               $content_path, $title, $text, $head, $use_customized_head, $test_message, 
-                              $allow_test_export, $content_type)
+                              $content_type)
        {
                global $addslashes, $msg;
 
@@ -47,7 +47,6 @@ class ContentDAO extends DAO {
                                       head,
                                       use_customized_head,
                                       test_message,
-                                      allow_test_export,
                                       content_type
                                       )
                               VALUES (".$course_id.",
@@ -63,7 +62,6 @@ class ContentDAO extends DAO {
                                       '".$addslashes($head)."',
                                       ".$use_customized_head.",
                                       '".$addslashes($test_message)."',
-                                      ".$allow_test_export.",
                                       ".$content_type.")";
 
                        if (!$this->execute($sql))
@@ -73,7 +71,14 @@ class ContentDAO extends DAO {
                        }
                        else
                        {
-                               return mysql_insert_id();
+                               $cid = mysql_insert_id();
+                               
+                               // update the courses.modified_date to the current timestamp
+                               include_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
+                               $coursesDAO = new CoursesDAO();
+                               $coursesDAO->updateModifiedDate($cid, "content_id");
+                               
+                               return $cid;
                        }
                }
                else
@@ -97,8 +102,7 @@ class ContentDAO extends DAO {
         * @author  Cindy Qi Li
         */
        public function Update($content_id, $title, $text, $keywords, $formatting, 
-                            $head, $use_customized_head, $test_message, 
-                            $allow_test_export)
+                            $head, $use_customized_head, $test_message)
        {
                global $addslashes, $msg;
 
@@ -112,11 +116,19 @@ class ContentDAO extends DAO {
                                       formatting = '".$formatting."',
                                       head = '".$addslashes($head)."',
                                       use_customized_head = ".$use_customized_head.",
-                                      test_message = '".$addslashes($test_message)."',
-                                      allow_test_export = ".$allow_test_export."
+                                      test_message = '".$addslashes($test_message)."'
                                 WHERE content_id = ".$content_id;
 
-                       return $this->execute($sql);
+                       if ($this->execute($sql)) {
+                               // update the courses.modified_date to the current timestamp
+                               include_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
+                               $coursesDAO = new CoursesDAO();
+                               $coursesDAO->updateModifiedDate($content_id, "content_id");
+                               return true;
+                       } else {
+                               $msg->addError('DB_NOT_UPDATED');
+                               return false;
+                       }
                }
                else {
                        return false;
@@ -141,7 +153,16 @@ class ContentDAO extends DAO {
                           SET ".$fieldName."='".$addslashes($fieldValue)."'
                         WHERE content_id = ".$contentID;
                
-               return $this->execute($sql);
+               if ($this->execute($sql)) {
+                       // update the courses.modified_date to the current timestamp
+                       include_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
+                       $coursesDAO = new CoursesDAO();
+                       $coursesDAO->updateModifiedDate($contentID, "content_id");
+                       return true;
+               } else {
+                       $msg->addError('DB_NOT_UPDATED');
+                       return false;
+               }
        }
        
        /**
@@ -171,7 +192,16 @@ class ContentDAO extends DAO {
                $contentForumsAssocDAO->DeleteByContentID($contentID);
                
                $sql = "DELETE FROM ".TABLE_PREFIX."content WHERE content_id = ".$contentID;
-               return $this->execute($sql);
+               if ($this->execute($sql)) {
+                       // update the courses.modified_date to the current timestamp
+                       include_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
+                       $coursesDAO = new CoursesDAO();
+                       $coursesDAO->updateModifiedDate($contentID, "content_id");
+                       return true;
+               } else {
+                       $msg->addError('DB_NOT_UPDATED');
+                       return false;
+               }
        }
 
        /**
index e9c00a2..54f7c67 100644 (file)
@@ -35,7 +35,16 @@ class ContentForumsAssocDAO extends DAO {
                $sql =  'INSERT INTO ' . TABLE_PREFIX . 'content_forums_assoc' . 
                                '(content_id, forum_id) ' .
                                'VALUES (' . $content_id . ", $forum_id)";
-           return $this->execute($sql);
+               if ($this->execute($sql)) {
+                       // update the courses.modified_date to the current timestamp
+                       include_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
+                       $coursesDAO = new CoursesDAO();
+                       $coursesDAO->updateModifiedDate($content_id, "content_id");
+                       return true;
+               } else {
+                       $msg->addError('DB_NOT_UPDATED');
+                       return false;
+               }
        }
        
        /**
@@ -49,7 +58,16 @@ class ContentForumsAssocDAO extends DAO {
        {
            $sql = "DELETE FROM ".TABLE_PREFIX."content_forums_assoc 
                     WHERE content_id = ".$contentID."";
-           return $this->execute($sql);
+               if ($this->execute($sql)) {
+                       // update the courses.modified_date to the current timestamp
+                       include_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
+                       $coursesDAO = new CoursesDAO();
+                       $coursesDAO->updateModifiedDate($contentID, "content_id");
+                       return true;
+               } else {
+                       $msg->addError('DB_NOT_UPDATED');
+                       return false;
+               }
        }
        
        /**
@@ -63,7 +81,25 @@ class ContentForumsAssocDAO extends DAO {
        {
            $sql = "DELETE FROM ".TABLE_PREFIX."content_forums_assoc 
                     WHERE forum_id = ".$forumID."";
-           return $this->execute($sql);
+               if ($this->execute($sql)) {
+                       // update the courses.modified_date to the current timestamp
+                       include_once(TR_INCLUDE_PATH.'classes/DAO/ForumsCoursesDAO.class.php');
+                       include_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
+                       
+                       $forumsCoursesDAO = new ForumsCoursesDAO();
+                       $course_rows = $forumsCoursesDAO->getByForum($forumID);
+                       
+                       if (is_array($course_rows)) {
+                               foreach ($course_rows as $row) {
+                                       $coursesDAO = new CoursesDAO();
+                                       $coursesDAO->updateModifiedDate($row['course_id']);
+                               }
+                       }
+                       return true;
+               } else {
+                       $msg->addError('DB_NOT_UPDATED');
+                       return false;
+               }
        }
        
        /**
index b9f48e6..213e132 100644 (file)
@@ -35,7 +35,16 @@ class ContentTestsAssocDAO extends DAO {
                $sql =  'INSERT INTO ' . TABLE_PREFIX . 'content_tests_assoc' . 
                                '(content_id, test_id) ' .
                                'VALUES (' . $content_id . ", $test_id)";
-           return $this->execute($sql);
+               if ($this->execute($sql)) {
+                       // update the courses.modified_date to the current timestamp
+                       include_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
+                       $coursesDAO = new CoursesDAO();
+                       $coursesDAO->updateModifiedDate($content_id, "content_id");
+                       return true;
+               } else {
+                       $msg->addError('DB_NOT_UPDATED');
+                       return false;
+               }
        }
        
        /**
@@ -49,7 +58,17 @@ class ContentTestsAssocDAO extends DAO {
        {
            $sql = "DELETE FROM ".TABLE_PREFIX."content_tests_assoc 
                     WHERE content_id = ".$contentID."";
-           return $this->execute($sql);
+               
+           if ($this->execute($sql)) {
+                       // update the courses.modified_date to the current timestamp
+                       include_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
+                       $coursesDAO = new CoursesDAO();
+                       $coursesDAO->updateModifiedDate($contentID, "content_id");
+                       return true;
+               } else {
+                       $msg->addError('DB_NOT_UPDATED');
+                       return false;
+               }
        }
        
        /**
@@ -63,7 +82,22 @@ class ContentTestsAssocDAO extends DAO {
        {
            $sql = "DELETE FROM ".TABLE_PREFIX."content_tests_assoc 
                     WHERE test_id = ".$testID."";
-           return $this->execute($sql);
+               if ($this->execute($sql)) {
+                       // update the courses.modified_date to the current timestamp
+                       include_once(TR_INCLUDE_PATH.'classes/DAO/TestsDAO.class.php');
+                       include_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
+                       $testsDAO = new TestsDAO();
+                       $test_rows = $testsDAO->get($testID);
+                       
+                       if ($test_rows['course_id'] > 0) {
+                               $coursesDAO = new CoursesDAO();
+                               $coursesDAO->updateModifiedDate($test_rows['course_id']);
+                       }
+                       return true;
+               } else {
+                       $msg->addError('DB_NOT_UPDATED');
+                       return false;
+               }
        }
        
        /**
index f5d780e..7780309 100644 (file)
@@ -123,7 +123,8 @@ class CoursesDAO extends DAO {
                        return false;
                
                $sql = "UPDATE ".TABLE_PREFIX."courses 
-                          SET ".$fieldName."='".$addslashes($fieldValue)."'
+                          SET ".$fieldName."='".$addslashes($fieldValue).",
+                              modified_date = now()
                         WHERE course_id = ".$courseID;
                
                return $this->execute($sql);
@@ -191,6 +192,27 @@ class CoursesDAO extends DAO {
                return $this->execute($sql);
        }
 
+       /**
+        * Update courses.modified_date to the current timestamp
+        * @access  public
+        * @param   id: course_id or content_id
+        *          id_type: "course_id" or "content_id", by default is "course_id"
+        * @return  true if successful, otherwise, return false
+        * @author  Cindy Qi Li
+        */
+       public function updateModifiedDate($id, $id_type = "course_id")
+       {
+               if ($id_type != "course_id" && $id_type != "content_id") return false;
+               
+               if ($id_type == "course_id") {
+                       $sql = "UPDATE ".TABLE_PREFIX."courses SET modified_date=now() WHERE course_id=".$id;
+               } else if ($id_type == "content_id") {
+                       $sql = "UPDATE ".TABLE_PREFIX."courses SET modified_date=now() 
+                                WHERE course_id=(SELECT course_id FROM ".TABLE_PREFIX."content WHERE content_id=".$id.")";
+               }
+               return $this->execute($sql);
+       }
+
        /**
         * Return course information by given course id
         * @access  public
@@ -219,7 +241,7 @@ class CoursesDAO extends DAO {
        {
                $sql = "SELECT * FROM ".TABLE_PREFIX."courses 
                         WHERE access='public'
-                        ORDER BY modified_date, created_date";
+                        ORDER BY modified_date DESC, created_date DESC";
                return $this->execute($sql);
        }
 
index e35f3e8..5cfd5e3 100644 (file)
@@ -87,5 +87,18 @@ class ForumsCoursesDAO extends DAO {
            $sql = "SELECT * FROM ".TABLE_PREFIX."forums_courses WHERE course_id = '".$course_id."'";
            return $this->execute($sql);
        }
+
+       /**
+       * Return rows by forum ID
+       * @access  public
+       * @param   name
+       * @return  table rows
+       * @author  Cindy Qi Li
+       */
+       function getByForum($forum_id)
+       {
+           $sql = "SELECT * FROM ".TABLE_PREFIX."forums_courses WHERE forum_id = '".$forum_id."'";
+           return $this->execute($sql);
+       }
 }
 ?>
\ No newline at end of file
index 2d93d99..d9798c6 100644 (file)
@@ -31,7 +31,6 @@ CREATE TABLE `content` (
   `head` TEXT NOT NULL,\r
   `use_customized_head` TINYINT(4) NOT NULL,\r
   `test_message` TEXT NOT NULL,\r
-  `allow_test_export` TINYINT(1) UNSIGNED NOT NULL,\r
   `content_type` TINYINT(1) UNSIGNED NOT NULL,\r
   PRIMARY KEY  (`content_id`),\r
   KEY `course_id` (`course_id`),\r
index 4ad452f..b952ee3 100644 (file)
@@ -462,8 +462,9 @@ INSERT INTO `TR_language_text` VALUES ('en', '_template', 'upload_content_packag
 INSERT INTO `TR_language_text` VALUES ('en', '_template', 'others_course', 'Others\' course', now(), '');\r
 INSERT INTO `TR_language_text` VALUES ('en', '_template', 'most_recent_courses', 'Most Recent Courses', now(), '');\r
 INSERT INTO `TR_language_text` VALUES ('en', '_template', 'all_categories', 'All Categories', now(), '');\r
-INSERT INTO `TR_language_text` VALUES ('en', '_template', '', '', now(), '');\r
-INSERT INTO `TR_language_text` VALUES ('en', '_template', '', '', now(), '');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template', 'ims_files_missing', 'In this package, the file, %1$s, is missing or misplaced.', now(), '');\r
+\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template', 'metadata', 'Meta-data', now(), '');\r
 INSERT INTO `TR_language_text` VALUES ('en', '_template', '', '', now(), '');\r
 INSERT INTO `TR_language_text` VALUES ('en', '_template', '', '', now(), '');\r
 INSERT INTO `TR_language_text` VALUES ('en', '_template', '', '', now(), '');\r
@@ -497,6 +498,7 @@ INSERT INTO `TR_language_text` VALUES ('en', '_msgs','TR_ERROR_FILE_NOT_SELECTED
 INSERT INTO `TR_language_text` VALUES ('en', '_msgs','TR_ERROR_BAD_FILE_TYPE', 'Unsupported file type. Plain Text or HTML files only.', now(), '');\r
 INSERT INTO `TR_language_text` VALUES ('en', '_msgs','TR_ERROR_INVALID_INPUT', 'Invalid URL: %s', now(), '');\r
 INSERT INTO `TR_language_text` VALUES ('en', '_msgs','TR_FEEDBACK_CLOSED', 'Successfully closed', now(), '');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_msgs','TR_ERROR_SAVE_BEFORE_PROCEED', 'Please save the content before proceeding to define "Adapted Content".', now(), '');\r
 \r
 INSERT INTO `TR_language_text` VALUES ('en', '_msgs','TR_', '', now(), '');\r
 INSERT INTO `TR_language_text` VALUES ('en', '_msgs','TR_', '', now(), '');\r
@@ -504,7 +506,6 @@ INSERT INTO `TR_language_text` VALUES ('en', '_msgs','TR_', '', now(), '');
 INSERT INTO `TR_language_text` VALUES ('en', '_msgs','TR_', '', now(), '');\r
 INSERT INTO `TR_language_text` VALUES ('en', '_msgs','TR_', '', now(), '');\r
 INSERT INTO `TR_language_text` VALUES ('en', '_msgs','TR_', '', now(), '');\r
-INSERT INTO `TR_language_text` VALUES ('en', '_msgs','TR_', '', now(), '');\r
 \r
 \r
 INSERT INTO `AT_language_text` VALUES ('en', '_msgs','AT_ERROR_TILE_AUTHENTICATION_FAIL','The Transformable authentication fails at:<br />%s.',now(),'');\r
index 670bb6e..616ff63 100644 (file)
@@ -19,10 +19,8 @@ include(TR_INCLUDE_PATH.'header.inc.php');
 \r
 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form1">\r
 <fieldset class="group_form"><legend class="group_form"><?php echo _AT("language"); ?></legend>\r
-<h2 align="center"><?php echo $this->title ;?></h2>\r
 \r
 <table class="data" rules="rows">\r
-\r
 <thead>\r
        <tr>\r
                <th scope="col">&nbsp;</th>\r
@@ -55,7 +53,13 @@ include(TR_INCLUDE_PATH.'header.inc.php');
                <td><span class="inlineEdits" id="<?php echo "english_name:".$row["language_code"].":".$row["charset"]; ?>"><?php echo $row['english_name']; ?></span></td>\r
                <td><?php echo $row['language_code']; ?></td>\r
                <td><?php echo $row['charset']; ?></td>\r
-               <td><?php if ($row['status']) echo _AT('enabled'); else echo _AT('disabled'); ?></td>\r
+               <td>\r
+               <?php \r
+               if ($row['status'] == TR_STATUS_ENABLED) echo _AT('enabled'); \r
+               else if ($row['status'] == TR_STATUS_DISABLED) echo _AT('disabled'); \r
+               else echo _AT('unknown'); \r
+               ?>\r
+               </td>\r
        </tr>\r
 <?php }?>\r
 </tbody>\r