1. http://www.atutor.ca/atutor/mantis/view.php?id=4284
authorCindy Li <cli@ocad.ca>
Tue, 11 May 2010 17:19:33 +0000 (17:19 -0000)
committerCindy Li <cli@ocad.ca>
Tue, 11 May 2010 17:19:33 +0000 (17:19 -0000)
2. remove "create course" link from content pages

docs/include/classes/DAO/CoursesDAO.class.php
docs/include/page_constants.inc.php

index 2b4ca9a..e675786 100644 (file)
@@ -140,6 +140,8 @@ class CoursesDAO extends DAO {
        public function Delete($courseID)
        {
                require_once(TR_INCLUDE_PATH.'classes/FileUtility.class.php');
+               require_once(TR_INCLUDE_PATH.'classes/DAO/ContentDAO.class.php');
+               $contentDAO = new ContentDAO();
                
                unset($_SESSION['s_cid']);
                
@@ -155,10 +157,6 @@ class CoursesDAO extends DAO {
                $sql = "DELETE FROM ".TABLE_PREFIX."tests_questions_categories WHERE course_id = ".$courseID;
                $this->execute($sql);
                
-               $sql = "DELETE FROM ".TABLE_PREFIX."tests_results 
-                        WHERE test_id in (SELECT test_id FROM ".TABLE_PREFIX."tests WHERE course_id = ".$courseID.")";
-               $this->execute($sql);
-               
                $sql = "DELETE FROM ".TABLE_PREFIX."tests_questions_assoc 
                         WHERE test_id in (SELECT test_id FROM ".TABLE_PREFIX."tests WHERE course_id = ".$courseID.")";
                $this->execute($sql);
@@ -167,17 +165,19 @@ class CoursesDAO extends DAO {
                         WHERE test_id in (SELECT test_id FROM ".TABLE_PREFIX."tests WHERE course_id = ".$courseID.")";
                $this->execute($sql);
                
-               $sql = "DELETE FROM ".TABLE_PREFIX."tests_answers 
-                        WHERE question_id in (SELECT question_id FROM ".TABLE_PREFIX."tests WHERE course_id = ".$courseID.")";
-               $this->execute($sql);
-               
                $sql = "DELETE FROM ".TABLE_PREFIX."tests_questions WHERE course_id = ".$courseID;
                $this->execute($sql);
                                
                $sql = "DELETE FROM ".TABLE_PREFIX."tests WHERE course_id = ".$courseID;
                $this->execute($sql);
                
-               // delete content
+               // loop thru content to delete using ContentDAO->Delete(), which deletes a4a objects as well
+               $content_rows = $contentDAO->getContentByCourseID($courseID);
+               if (is_array($content_rows)) {
+                       foreach ($content_rows as $content) {
+                               $contentDAO->Delete($content['content_id']);
+                       }
+               }
                $sql = "DELETE FROM ".TABLE_PREFIX."content WHERE course_id = ".$courseID;
                $this->execute($sql);
                
index f3420b8..d79ef18 100644 (file)
@@ -26,7 +26,7 @@
  Because the Utility::authenticate on the following each page section \r
  messes up the oauth user authentication. \r
 */\r
-global $oauth_import;\r
+global $oauth_import, $_course_id, $_content_id;\r
 if ($oauth_import) return;\r
 \r
 // constants to map privileges.privilege_id, used to load constant pages\r
@@ -114,11 +114,13 @@ if (array_key_exists(TR_PRIV_HOME, $privs) && Utility::authenticate($privs[TR_PR
        \r
        if (isset($_current_user) && $_current_user->isAuthor())\r
        {\r
-               $_pages['home/index.php']['children']  = array_merge(array('home/create_course.php'), isset($_pages['home/index.php']['children']) ? $_pages['home/index.php']['children'] : array());\r
-               \r
-               $_pages['home/create_course.php']['title_var'] = 'create_course';\r
-               $_pages['home/create_course.php']['parent']    = 'home/index.php';\r
-               $_pages['home/create_course.php']['guide']    = 'TR_HELP_CREATE_COURSE';\r
+               if (!isset($_course_id) || $_course_id == 0) {\r
+                       $_pages['home/index.php']['children']  = array_merge(array('home/create_course.php'), isset($_pages['home/index.php']['children']) ? $_pages['home/index.php']['children'] : array());\r
+                       \r
+                       $_pages['home/create_course.php']['title_var'] = 'create_course';\r
+                       $_pages['home/create_course.php']['parent']    = 'home/index.php';\r
+                       $_pages['home/create_course.php']['guide']    = 'TR_HELP_CREATE_COURSE';\r
+               }\r
 \r
                $_pages['home/course/del_course.php']['title_var'] = 'del_course';\r
                $_pages['home/course/del_course.php']['parent']    = 'home/index.php';\r