dokeos-admin
[ class tree: dokeos-admin ] [ index: dokeos-admin ] [ all elements ]

Source for file course_add.php

Documentation is available at course_add.php

  1. <?php
  2. // $Id: course_add.php 14291 2008-02-14 08:17:23Z elixir_inter $
  3. /*
  4. ==============================================================================
  5.     Dokeos - elearning and course management software
  6.  
  7.     Copyright (c) 2004 Dokeos S.A.
  8.     Copyright (c) 2003 Ghent University (UGent)
  9.     Copyright (c) 2001 Universite catholique de Louvain (UCL)
  10.     Copyright (c) Olivier Brouckaert
  11.     Copyright (c) Bart Mollet, Hogeschool Gent
  12.  
  13.     For a full list of contributors, see "credits.txt".
  14.     The full license can be read in "license.txt".
  15.  
  16.     This program is free software; you can redistribute it and/or
  17.     modify it under the terms of the GNU General Public License
  18.     as published by the Free Software Foundation; either version 2
  19.     of the License, or (at your option) any later version.
  20.  
  21.     See the GNU General Public License for more details.
  22.  
  23.     Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  24. ==============================================================================
  25. */
  26. /**
  27. ==============================================================================
  28. *    @package dokeos.admin
  29. ==============================================================================
  30. */
  31. /*
  32. ==============================================================================
  33.         INIT SECTION
  34. ==============================================================================
  35. */
  36.  
  37. // name of the language file that needs to be included 
  38. $language_file array('admin','create_course');
  39. $cidReset true;
  40. require_once ('../inc/global.inc.php');
  41. $this_section=SECTION_PLATFORM_ADMIN;
  42.  
  43. require_once (api_get_path(LIBRARY_PATH).'fileManage.lib.php');
  44. require_once (api_get_path(CONFIGURATION_PATH).'add_course.conf.php');
  45. require_once (api_get_path(LIBRARY_PATH).'add_course.lib.inc.php');
  46. require_once (api_get_path(LIBRARY_PATH).'course.lib.php');
  47. require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  48. $tool_name get_lang('AddCourse');
  49. $interbreadcrumb[array ("url" => 'index.php'"name" => get_lang('PlatformAdmin'));
  50.  
  51. /*
  52. ==============================================================================
  53.         MAIN CODE
  54. ==============================================================================
  55. */
  56.  
  57.  
  58.  
  59. // Get all possible teachers
  60. $table_user Database :: get_main_table(TABLE_MAIN_USER);
  61. $sql "SELECT user_id,lastname,firstname FROM $table_user WHERE status=1 ORDER BY lastname,firstname";
  62. $res api_sql_query($sql,__FILE__,__LINE__);
  63. $teachers array();
  64. $teachers[0'-- '.get_lang('NoManager').' --';
  65. while($obj mysql_fetch_object($res))
  66. {
  67.         $teachers[$obj->user_id$obj->lastname.' '.$obj->firstname;
  68. }
  69. // Build the form
  70. $form new FormValidator('update_course');
  71. $form->add_textfield'visual_code'get_lang('CourseCode'),false,array('size'=>'20','maxlength'=>20));
  72. $form->applyFilter('visual_code','strtoupper');
  73. $form->addRule('wanted_code',get_lang('Max'),'maxlength',20);
  74. $form->addElement('select''tutor_id'get_lang('CourseTitular')$teachers);
  75. $form->addElement('select''course_teachers'get_lang('CourseTeachers')$teachers'multiple=multiple size=5');
  76. $form->add_textfield('title'get_lang('Title'),truearray ('size' => '60'));
  77. $categories_select $form->addElement('select''category_code'get_lang('CourseFaculty')$categories);
  78. $form->add_textfield('department_name'get_lang('CourseDepartment'),falsearray ('size' => '60'));
  79. $form->add_textfield('department_url'get_lang('CourseDepartmentURL'),falsearray ('size' => '60'));
  80. $form->addElement('select_language''course_language'get_lang('CourseLanguage'));
  81. $form->addElement('radio''visibility'get_lang("CourseAccess")get_lang('OpenToTheWorld')COURSE_VISIBILITY_OPEN_WORLD);
  82. $form->addElement('radio''visibility'nullget_lang('OpenToThePlatform')COURSE_VISIBILITY_OPEN_PLATFORM);
  83. $form->addElement('radio''visibility'nullget_lang('Private')COURSE_VISIBILITY_REGISTERED);
  84. $form->addElement('radio''visibility'nullget_lang('CourseVisibilityClosed')COURSE_VISIBILITY_CLOSED);
  85. $form->addElement('radio''subscribe'get_lang('Subscription')get_lang('Allowed')1);
  86. $form->addElement('radio''subscribe'nullget_lang('Denied')0);
  87. $form->addElement('radio''unsubscribe'get_lang('Unsubscription')get_lang('AllowedToUnsubscribe')1);
  88. $form->addElement('radio''unsubscribe'nullget_lang('NotAllowedToUnsubscribe')0);
  89. $form->add_textfield('disk_quota',get_lang('CourseQuota'));
  90. $form->addRule('disk_quota',get_lang('ThisFieldShouldBeNumeric'),'numeric');
  91. $form->add_progress_bar();
  92. $form->addElement('submit'nullget_lang('Ok'));
  93. // Set some default values
  94. $values['course_language'get_setting('platformLanguage');
  95. $values['disk_quota'get_setting('default_document_quotum');
  96. $values['visibility'COURSE_VISIBILITY_OPEN_PLATFORM;
  97. $values['subscribe'1;
  98. $values['unsubscribe'0;
  99. reset($teachers);
  100. $values['course_teachers'key($teachers);
  101. $form->setDefaults($values);
  102. // Validate form
  103. if$form->validate())
  104. {
  105.     $course $form->exportValues();
  106.     $code $course['visual_code'];
  107.     $tutor_name $teachers[$course['tutor_id']];
  108.     $teacher_id $course['tutor_id'];
  109.     $course_teachers $course['course_teachers'];
  110.     $test=false;
  111.     
  112.     //The course tutor has been selected in the teachers list so we must remove him to avoid double records in the database
  113.     foreach($course_teachers as $key=>$value){
  114.         if($value==$teacher_id){
  115.             unset($course_teachers[$key]);
  116.             break;
  117.         }
  118.     }
  119.  
  120.     $title $course['title'];
  121.     $category $course['category_code'];
  122.     $department_name $course['department_name'];
  123.     $department_url $course['department_url'];
  124.     $course_language $course['course_language'];
  125.     $disk_quota $course['disk_quota'];
  126.     if (!stristr($department_url'http://'))
  127.     {
  128.         $department_url 'http://'.$department_url;
  129.     }
  130.     if(trim($code== ''){
  131.         $code generate_course_code(substr($title,0,20));
  132.     }
  133.     $keys define_course_keys($code""$_configuration['db_prefix']);
  134.     if (sizeof($keys))
  135.     {
  136.         $currentCourseCode $keys["currentCourseCode"];
  137.         $currentCourseId $keys["currentCourseId"];
  138.         $currentCourseDbName $keys["currentCourseDbName"];
  139.         $currentCourseRepository $keys["currentCourseRepository"];
  140.         $expiration_date time($firstExpirationDelay;
  141.         prepare_course_repository($currentCourseRepository$currentCourseId);
  142.         update_Db_course($currentCourseDbName);
  143.         $pictures_array=fill_course_repository($currentCourseRepository);
  144.         fill_Db_course($currentCourseDbName$currentCourseRepository$course_language,$pictures_array);
  145.         register_course($currentCourseId$currentCourseCode$currentCourseRepository$currentCourseDbName$tutor_name$category$title$course_language$teacher_id$expiration_date,$course_teachers);
  146.         $sql "UPDATE $table_course SET disk_quota = '".$disk_quota."', visibility = '".mysql_real_escape_string($course['visibility'])."', subscribe = '".mysql_real_escape_string($course['subscribe'])."', unsubscribe='".mysql_real_escape_string($course['unsubscribe'])."' WHERE code = '".$currentCourseId."'";
  147.         api_sql_query($sql,__FILE__,__LINE__);
  148.         header('Location: course_list.php');
  149.         exit ();
  150.     }
  151. }
  152. Display::display_header($tool_name);
  153.  
  154. // Display the form
  155. $form->display();
  156. /*
  157. ==============================================================================
  158.         FOOTER
  159. ==============================================================================
  160. */
  161. ?>

Documentation generated on Thu, 12 Jun 2008 13:14:13 -0500 by phpDocumentor 1.4.1