finish "create course" page and bug fixes
authorCindy Li <cli@ocad.ca>
Fri, 11 Jun 2010 19:38:39 +0000 (19:38 -0000)
committerCindy Li <cli@ocad.ca>
Fri, 11 Jun 2010 19:38:39 +0000 (19:38 -0000)
16 files changed:
docs/home/classes/ContentManager.class.php
docs/home/course/course_property.php
docs/home/course/course_start.php [new file with mode: 0644]
docs/home/course/index.php
docs/home/editor/edit_content.php
docs/home/ims/ims_export.php
docs/images/tree/Thumbs.db
docs/include/classes/DAO/CoursesDAO.class.php
docs/include/page_constants.inc.php
docs/include/sidemenus/my_courses.inc.php
docs/install/db/language_text_temp.sql
docs/themes/default/home/course/course_start.tmpl.php [new file with mode: 0644]
docs/themes/default/home/create_course_tmpl.tmpl.php
docs/themes/default/home/index_course.tmpl.php
docs/themes/default/images/export_cc.png [new file with mode: 0644]
docs/themes/default/language/index.tmpl.php

index dbe7ea6..1ccc36f 100644 (file)
@@ -117,7 +117,9 @@ class ContentManager
                }
 
                // generate array of all the content ids in the same order that they appear in "content navigation"
-               $this->_menu_in_order[] = $next_content_id = $this->getNextContentID(0);
+               if ($this->getNextContentID(0) > 0) {
+                       $this->_menu_in_order[] = $next_content_id = $this->getNextContentID(0);
+               }
                while ($next_content_id > 0)
                {
                        $next_content_id = $this->getNextContentID($next_content_id);
index 36b5f3f..03c6647 100644 (file)
@@ -19,7 +19,11 @@ global $_course_id;
 
 $coursesDAO = new CoursesDAO();
 
-Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE);
+if ($_course_id > 0) {
+       Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE);
+} else {
+       Utility::authenticate(TR_PRIV_ISAUTHOR);
+}
 
 if (isset($_POST['cancel'])) {
        $msg->addFeedback('CANCELLED');
@@ -27,23 +31,37 @@ if (isset($_POST['cancel'])) {
        exit;
 }
 else if($_POST['submit']){
-       $coursesDAO->UpdateField($_course_id, 'title', $_POST['title']);
-       $coursesDAO->UpdateField($_course_id, 'category_id', $_POST['category_id']);
-       $coursesDAO->UpdateField($_course_id, 'primary_language', $_POST['pri_lang']);
-       $coursesDAO->UpdateField($_course_id, 'description', $_POST['description']);
-       $coursesDAO->UpdateField($_course_id, 'copyright', $_POST['copyright']);
-       
-       if (isset($_POST['hide_course']))
-               $access = 'private';
-       else
-               $access = 'public';
-       
-       $coursesDAO->UpdateField($_course_id, 'access', $access);
-       $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
+               if (isset($_POST['hide_course']))
+                       $access = 'private';
+               else
+                       $access = 'public';
+               
+       if ($_course_id > 0) { // update an existing course
+               $coursesDAO->UpdateField($_course_id, 'title', $_POST['title']);
+               $coursesDAO->UpdateField($_course_id, 'category_id', $_POST['category_id']);
+               $coursesDAO->UpdateField($_course_id, 'primary_language', $_POST['pri_lang']);
+               $coursesDAO->UpdateField($_course_id, 'description', $_POST['description']);
+               $coursesDAO->UpdateField($_course_id, 'copyright', $_POST['copyright']);
+               
+               $coursesDAO->UpdateField($_course_id, 'access', $access);
+               $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
+       }
+       else { // create a new course
+               if ($course_id = $coursesDAO->Create($_SESSION['user_id'], 'top', $access, $_POST['title'], $_POST['description'], 
+                                   null, null, null, $_POST['copyright'], $_POST['pri_lang'], null, null))
+               {
+                       $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
+                       header('Location: '.TR_BASE_HREF.'home/course/index.php?_course_id='.$course_id);
+                       exit;
+               }
+       }
 }
 
-$savant->assign('course_id', $_course_id);
-$savant->assign('course_row', $coursesDAO->get($_course_id));
+// display
+if ($_course_id > 0) {
+       $savant->assign('course_id', $_course_id);
+       $savant->assign('course_row', $coursesDAO->get($_course_id));
+}
 
 global $onload;
 $onload = "document.form.title.focus();";
diff --git a/docs/home/course/course_start.php b/docs/home/course/course_start.php
new file mode 100644 (file)
index 0000000..34a8818
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+/************************************************************************/
+/* Transformable                                                        */
+/************************************************************************/
+/* Copyright (c) 2009                                                   */
+/* Adaptive Technology Resource Centre / University of Toronto          */
+/*                                                                      */
+/* This program is free software. You can redistribute it and/or        */
+/* modify it under the terms of the GNU General Public License          */
+/* as published by the Free Software Foundation.                        */
+/************************************************************************/
+
+define('TR_INCLUDE_PATH', '../../include/');
+require_once(TR_INCLUDE_PATH.'vitals.inc.php');
+require_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
+
+global $msg, $contentManager, $_course_id;
+
+if ($_course_id <= 0)
+{
+       $msg->addError('MISSING_COURSE_ID');
+       header('Location: '.TR_BASE_HREF.'home/index.php');
+       exit;
+}
+
+$coursesDAO = new CoursesDAO();
+
+require(TR_INCLUDE_PATH.'header.inc.php'); 
+
+$savant->assign('course_id', $_course_id);
+$savant->display('home/course/course_start.tmpl.php');
+
+require(TR_INCLUDE_PATH.'footer.inc.php'); 
+?>
\ No newline at end of file
index 4c3c2b7..3cc8884 100644 (file)
@@ -11,7 +11,8 @@
 /************************************************************************/
 
 define('TR_INCLUDE_PATH', '../../include/');
-require(TR_INCLUDE_PATH.'vitals.inc.php');
+require_once(TR_INCLUDE_PATH.'vitals.inc.php');
+require_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
 
 global $msg, $contentManager, $_course_id;
 
@@ -28,7 +29,7 @@ else if (isset($_sequence_links['first']['url']))
        $url = $_sequence_links['first']['url'];
 else
 {
-       // go to content wizard
+       $url = TR_BASE_HREF.'home/course/course_start.php?_course_id='.$_course_id;
 }
 
 header('Location: '.$url);
index 81c4194..ffd66bd 100644 (file)
@@ -140,7 +140,7 @@ if ($cid) {
 if (($current_tab == 0) || ($current_tab == 2)) {
     if ($_POST['formatting'] == null){ 
         // this is a fresh load from just logged in
-           if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 0) {
+           if (isset($_SESSION['prefs']['PREF_CONTENT_EDITOR']) && $_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 0) {
                        $_POST['formatting'] = 0;
                } else {
                        $_POST['formatting'] = 1;
index 912e981..55dcc7f 100644 (file)
@@ -55,8 +55,8 @@ if (isset($_REQUEST['to_tile']) && !isset($_POST['cancel'])) {
        require_once(TR_INCLUDE_PATH.'vitals.inc.php');
        global $_course_id, $_content_id;
 
-       $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;
 }
 
index 39a20af..9ba9f87 100644 (file)
Binary files a/docs/images/tree/Thumbs.db and b/docs/images/tree/Thumbs.db differ
index 7780309..ce8d608 100644 (file)
@@ -80,7 +80,12 @@ class CoursesDAO extends DAO {
                        }
                        else
                        {
-                               return mysql_insert_id();
+                               $course_id = mysql_insert_id();
+                               // create the user and course relationship
+                               $sql = "INSERT INTO ".TABLE_PREFIX."user_courses (user_id, course_id, role, last_cid)
+                                       VALUES (".$user_id.", ".$course_id.", ".TR_USERROLE_AUTHOR.", 0)";
+                               $this->execute($sql);
+                               return $course_id;
                        }
                }
                else
index 91bf7a9..56ed724 100644 (file)
@@ -126,6 +126,10 @@ if (array_key_exists(TR_PRIV_HOME, $privs) && Utility::authenticate($privs[TR_PR
                        $_pages['home/create_course.php']['guide']    = 'TR_HELP_CREATE_COURSE';\r
                }\r
 \r
+               $_pages['home/course/course_start.php']['title_var'] = 'course_start';\r
+               $_pages['home/course/course_start.php']['parent']    = 'home/index.php';\r
+               $_pages['home/course/course_start.php']['guide']    = 'TR_HELP_CONTENT_WIZARD';\r
+               \r
                $_pages['home/course/del_course.php']['title_var'] = 'del_course';\r
                $_pages['home/course/del_course.php']['parent']    = 'home/index.php';\r
                \r
index 939b1cf..52e9f34 100644 (file)
@@ -54,9 +54,14 @@ if (!is_array($my_courses)) {
                        $output .= '      <img src="'. TR_BASE_HREF.'themes/'. $_SESSION['prefs']['PREF_THEME'].'/images/add.gif" alt="'. htmlspecialchars(_AT('add_into_list')).'" title="'. htmlspecialchars(_AT('add_into_list')).'" border="0" />'."\n";
                        $output .= '    </a>'."\n";
                }
-               $output .= '    <a href="'. TR_BASE_HREF.'home/imscc/ims_export.php?course_id='. $row['course_id'].'">'."\n";
-               $output .= '      <img src="'. TR_BASE_HREF.'themes/'. $_SESSION['prefs']['PREF_THEME'].'/images/export.png" alt="'. _AT('export').'" title="'. _AT('export').'" border="0" />'."\n";
+               $output .= '    <a href="'. TR_BASE_HREF.'home/ims/ims_export.php?course_id='. $row['course_id'].'">'."\n";
+               $output .= '      <img src="'. TR_BASE_HREF.'themes/'. $_SESSION['prefs']['PREF_THEME'].'/images/export.png" alt="'. _AT('download_content_package').'" title="'. _AT('download_content_package').'" border="0" />'."\n";
                $output .= '    </a>'."\n";
+               if ($row['role'] == TR_USERROLE_AUTHOR) {
+                       $output .= '    <a href="'. TR_BASE_HREF.'home/imscc/ims_export.php?course_id='. $row['course_id'].'">'."\n";
+                       $output .= '      <img src="'. TR_BASE_HREF.'themes/'. $_SESSION['prefs']['PREF_THEME'].'/images/export_cc.png" alt="'. _AT('download_common_cartridge').'" title="'. _AT('download_common_cartridge').'" border="0" />'."\n";
+                       $output .= '    </a>'."\n";
+               }
                $output .= '  </li>'."\n";                              
        } // end of foreach; 
     $output .= '</ol>'."\n";
index b952ee3..a757ed5 100644 (file)
@@ -458,18 +458,19 @@ INSERT INTO `TR_language_text` VALUES ('en', '_template', 'import_content_packag
 INSERT INTO `TR_language_text` VALUES ('en', '_template', 'test_import_package', 'Import available tests.', now(), '');\r
 INSERT INTO `TR_language_text` VALUES ('en', '_template', 'a4a_import_package', 'Import available AccessForAll adapted content.', now(), '');\r
 INSERT INTO `TR_language_text` VALUES ('en', '_template', 'upload_content_package', 'Upload a Content Package or Common Cartridge', now(), '');\r
-\r
 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', '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
-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', 'download_content_package', 'Download Content Package', now(), '');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template', 'download_common_cartridge', 'Download Common Cartridge', now(), '');\r
+\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template', 'course_start', 'How to create course content', now(), '');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template','create_content_1','<span style="font-weight:bold">Method 1</span>: Use',now(),'');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template','create_content_2','<span style="font-weight:bold">Method 2</span>: Manually <a href="%1s">create a content</a> or <a href="%2s">create a content folder</a>. These tools are also available as "Add top page" or "Add top folder" links in "Content Navigation" side menu.',now(),'');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template', 'create_content', 'Create Content', now(), '');\r
+INSERT INTO `TR_language_text` VALUES ('en', '_template', 'content_wizard', '"Create Content" Wizard', 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
diff --git a/docs/themes/default/home/course/course_start.tmpl.php b/docs/themes/default/home/course/course_start.tmpl.php
new file mode 100644 (file)
index 0000000..893c86c
--- /dev/null
@@ -0,0 +1,28 @@
+<?php 
+/************************************************************************/
+/* Transformable                                                        */
+/************************************************************************/
+/* Copyright (c) 2009                                                   */
+/* Adaptive Technology Resource Centre / University of Toronto          */
+/*                                                                      */
+/* This program is free software. You can redistribute it and/or        */
+/* modify it under the terms of the GNU General Public License          */
+/* as published by the Free Software Foundation.                        */
+/************************************************************************/
+
+?>
+       <div class="input-form">
+       <fieldset class="group_form"><legend class="group_form"><?php echo _AT('create_content'); ?></legend>
+               <table class="form_data">
+               <tr><td>
+               <?php echo _AT('create_content_1'); ?>
+               <a href="home/course/content_wizard.php"><?php echo _AT('content_wizard'); ?></a><br /><br />
+               </td></tr>
+
+               <tr><td>
+               <?php echo _AT('create_content_2', TR_BASE_HREF.'home/editor/edit_content.php?_course_id='.$this->course_id, TR_BASE_HREF.'home/editor/edit_content_folder.php?_course_id='.$this->course_id); ?>
+               </td></tr>
+               </table>
+       </fieldset>
+       </div>
+
index a0c0b8f..b746044 100644 (file)
@@ -23,7 +23,7 @@ if (isset($_current_user) && $_current_user->isAuthor())
                <table class="form_data">
                <tr><td>
                <?php echo _AT('create_course_1'); ?>
-               <a href="course_wizard.php"><?php echo htmlentities(_AT('course_wizard')); ?></a><br /><br />
+               <a href="home/course/course_property.php"><?php echo htmlentities(_AT('course_wizard')); ?></a><br /><br />
                </td></tr>
 
                <tr><td>
index a9cb54f..ac3dab5 100644 (file)
@@ -110,9 +110,14 @@ if (isset($this->search_text)) $keywords = explode(' ', $this->search_text);
             <img src="<?php echo TR_BASE_HREF; ?>themes/<?php echo $_SESSION['prefs']['PREF_THEME']; ?>/images/add.gif" alt="<?php echo htmlspecialchars(_AT('add_into_list')); ?>" title="<?php echo htmlspecialchars(_AT('add_into_list')); ?>" border="0" />
           </a>
 <?php }?>
+          <a href="<?php echo TR_BASE_HREF; ?>home/ims/ims_export.php?course_id=<?php echo $row['course_id']; ?>">
+            <img src="<?php echo TR_BASE_HREF; ?>themes/<?php echo $_SESSION['prefs']['PREF_THEME']; ?>/images/export.png" alt="<?php echo _AT('download_content_package'); ?>" title="<?php echo _AT('download_content_package'); ?>" border="0" />
+          </a>
+<?php if ($user_role['role'] == TR_USERROLE_AUTHOR) {?>
           <a href="<?php echo TR_BASE_HREF; ?>home/imscc/ims_export.php?course_id=<?php echo $row['course_id']; ?>">
-            <img src="<?php echo TR_BASE_HREF; ?>themes/<?php echo $_SESSION['prefs']['PREF_THEME']; ?>/images/export.png" alt="<?php echo _AT('export'); ?>" title="<?php echo _AT('export'); ?>" border="0" />
+            <img src="<?php echo TR_BASE_HREF; ?>themes/<?php echo $_SESSION['prefs']['PREF_THEME']; ?>/images/export_cc.png" alt="<?php echo _AT('download_common_cartridge'); ?>" title="<?php echo _AT('download_common_cartridge'); ?>" border="0" />
           </a>
+<?php }?>
         </h3>
         <div><?php echo $description; ?></div>
       </li>                            
diff --git a/docs/themes/default/images/export_cc.png b/docs/themes/default/images/export_cc.png
new file mode 100644 (file)
index 0000000..8175898
Binary files /dev/null and b/docs/themes/default/images/export_cc.png differ
index 616ff63..73b6b83 100644 (file)
@@ -20,7 +20,7 @@ include(TR_INCLUDE_PATH.'header.inc.php');
 <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
 \r
-<table class="data" rules="rows">\r
+<table class="data" rules="rows" id="editable_table">\r
 <thead>\r
        <tr>\r
                <th scope="col">&nbsp;</th>\r