Source for file CanonicalCourse.class.php

Documentation is available at CanonicalCourse.class.php

  1. <?php
  2.  
  3. require_once(OKI2."/osid/coursemanagement/CanonicalCourse.php");
  4. require_once(HARMONI."oki2/coursemanagement/CanonicalCourseIterator.class.php");
  5. require_once(HARMONI."oki2/shared/HarmoniStringIterator.class.php");
  6.  
  7.  
  8. /**
  9. * CanonicalCourse contains general information about a course. This is in
  10. * contrast to the CourseOffering which contains information about a concrete
  11. * offering of this course in a specific term and with identified people and
  12. * roles. The CourseSection is the third and most specific course-related
  13. * object. The section includes information about the location of the class
  14. * as well as the roster of students. CanonicalCourses can contain other
  15. * CanonicalCourses and may be organized hierarchically, in schools,
  16. * departments, for majors, and so on. For each CanonicalCourse, there are
  17. * zero or more offerings and for each offering, zero or more sections. All
  18. * three levels have separate data for Title, Number, Description, and Id.
  19. * This information can be the same or different as implementations choose and
  20. * applications require.
  21. *
  22. * <p>
  23. * OSID Version: 2.0
  24. * </p>
  25. *
  26. * @package harmoni.osid_v2.coursemanagement
  27. *
  28. * @copyright Copyright &copy; 2005, Middlebury College
  29. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  30. *
  31. * @version $Id: CanonicalCourse.class.php,v 1.29 2007/09/04 20:25:39 adamfranco Exp $
  32. */
  33. class HarmoniCanonicalCourse
  34. extends CanonicalCourse
  35. {
  36. /**
  37. * @variable object $_node the node in the hierarchy.
  38. * @access private
  39. * @variable object $_id the unique id for the canonical course.
  40. * @access private
  41. * @variable object $_table the canonical course table.
  42. * @access private
  43. * @variable object Id $_canonicalCoursesId the hierarchy
  44. * @access private
  45. ***/
  46. var $_node;
  47. var $_id;
  48. var $_table;
  49. var $_hierarchy;
  50. /**
  51. * The constructor.
  52. *
  53. * @param object Id $id
  54. * @param object Node $node
  55. *
  56. * @access public
  57. * @return void
  58. */
  59. function HarmoniCanonicalCourse($id, $node)
  60. {
  61. $this->_id =$id;
  62. $this->_node =$node;
  63. $this->_table = 'cm_can';
  64. $cm = Services::getService("CourseManagement");
  65. $this->_hierarchy =$cm->_hierarchy;
  66. }
  67.  
  68. /**
  69. * Get the title for this CanonicalCourse.
  70. *
  71. * @return string
  72. *
  73. * @throws object CourseManagementException An exception
  74. * with one of the following messages defined in
  75. * org.osid.coursemanagement.CourseManagementException may be
  76. * thrown: {@link }
  77. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  78. * OPERATION_FAILED}, {@link }
  79. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  80. * PERMISSION_DENIED}, {@link }
  81. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  82. * CONFIGURATION_ERROR}, {@link }
  83. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  84. * UNIMPLEMENTED}
  85. *
  86. * @access public
  87. */
  88. function getTitle () {
  89. return $this->_getField('title');
  90. }
  91.  
  92. /**
  93. * Update the title for this CanonicalCourse.
  94. *
  95. * @param string $title
  96. *
  97. * @throws object CourseManagementException An exception
  98. * with one of the following messages defined in
  99. * org.osid.coursemanagement.CourseManagementException may be
  100. * thrown: {@link }
  101. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  102. * OPERATION_FAILED}, {@link }
  103. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  104. * PERMISSION_DENIED}, {@link }
  105. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  106. * CONFIGURATION_ERROR}, {@link }
  107. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  108. * UNIMPLEMENTED}, {@link }
  109. * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  110. * NULL_ARGUMENT}
  111. *
  112. * @access public
  113. */
  114. function updateTitle ( $title ) {
  115.  
  116. $this->_setField('title',$title);
  117. }
  118.  
  119. /**
  120. * Get the number for this CanonicalCourse.
  121. *
  122. * @return string
  123. *
  124. * @throws object CourseManagementException An exception
  125. * with one of the following messages defined in
  126. * org.osid.coursemanagement.CourseManagementException may be
  127. * thrown: {@link }
  128. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  129. * OPERATION_FAILED}, {@link }
  130. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  131. * PERMISSION_DENIED}, {@link }
  132. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  133. * CONFIGURATION_ERROR}, {@link }
  134. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  135. * UNIMPLEMENTED}
  136. *
  137. * @access public
  138. */
  139. function getNumber () {
  140. return $this->_getField('number');
  141. }
  142.  
  143. /**
  144. * Update the number for this CanonicalCourse.
  145. *
  146. * @param string $number
  147. *
  148. * @throws object CourseManagementException An exception
  149. * with one of the following messages defined in
  150. * org.osid.coursemanagement.CourseManagementException may be
  151. * thrown: {@link }
  152. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  153. * OPERATION_FAILED}, {@link }
  154. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  155. * PERMISSION_DENIED}, {@link }
  156. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  157. * CONFIGURATION_ERROR}, {@link }
  158. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  159. * UNIMPLEMENTED}, {@link }
  160. * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  161. * NULL_ARGUMENT}
  162. *
  163. * @access public
  164. */
  165. function updateNumber ( $number ) {
  166. $this->_setField('number',$number);
  167. }
  168.  
  169. /**
  170. * Get the description for this CanonicalCourse. Returns null if no description exists
  171. *
  172. * @return string
  173. *
  174. * @throws object CourseManagementException An exception
  175. * with one of the following messages defined in
  176. * org.osid.coursemanagement.CourseManagementException may be
  177. * thrown: {@link }
  178. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  179. * OPERATION_FAILED}, {@link }
  180. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  181. * PERMISSION_DENIED}, {@link }
  182. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  183. * CONFIGURATION_ERROR}, {@link }
  184. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  185. * UNIMPLEMENTED}
  186. *
  187. * @access public
  188. */
  189. function getDescription () {
  190. return $this->_node->getDescription();
  191. }
  192.  
  193. /**
  194. * Update the description for this CanonicalCourse.
  195. *
  196. * @param string $description
  197. *
  198. * @throws object CourseManagementException An exception
  199. * with one of the following messages defined in
  200. * org.osid.coursemanagement.CourseManagementException may be
  201. * thrown: {@link }
  202. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  203. * OPERATION_FAILED}, {@link }
  204. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  205. * PERMISSION_DENIED}, {@link }
  206. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  207. * CONFIGURATION_ERROR}, {@link }
  208. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  209. * UNIMPLEMENTED}, {@link }
  210. * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  211. * NULL_ARGUMENT}
  212. *
  213. * @access public
  214. */
  215. function updateDescription ( $description ) {
  216. $this->_node->updateDescription($description);
  217. }
  218. /**
  219. * Get the display name for this CanonicalCourse.
  220. *
  221. * @return string
  222. *
  223. * @throws object CourseManagementException An exception
  224. * with one of the following messages defined in
  225. * org.osid.coursemanagement.CourseManagementException may be
  226. * thrown: {@link }
  227. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  228. * OPERATION_FAILED}, {@link }
  229. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  230. * PERMISSION_DENIED}, {@link }
  231. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  232. * CONFIGURATION_ERROR}, {@link }
  233. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  234. * UNIMPLEMENTED}
  235. *
  236. * @access public
  237. */
  238. function getDisplayName () {
  239. return $this->_node->getDisplayName();
  240. }
  241. /**
  242. * Update the display name for this CanonicalCourse.
  243. *
  244. * @param string $displayName
  245. *
  246. * @throws object CourseManagementException An exception
  247. * with one of the following messages defined in
  248. * org.osid.coursemanagement.CourseManagementException may be
  249. * thrown: {@link }
  250. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  251. * OPERATION_FAILED}, {@link }
  252. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  253. * PERMISSION_DENIED}, {@link }
  254. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  255. * CONFIGURATION_ERROR}, {@link }
  256. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  257. * UNIMPLEMENTED}, {@link }
  258. * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  259. * NULL_ARGUMENT}
  260. *
  261. * @access public
  262. */
  263. function updateDisplayName ( $displayName ) {
  264. $this->_node->updateDisplayName($displayName);
  265. }
  266.  
  267. /**
  268. * Get the unique Id for this CanonicalCourse.
  269. *
  270. * @return object Id
  271. *
  272. * @throws object CourseManagementException An exception
  273. * with one of the following messages defined in
  274. * org.osid.coursemanagement.CourseManagementException may be
  275. * thrown: {@link }
  276. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  277. * OPERATION_FAILED}, {@link }
  278. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  279. * PERMISSION_DENIED}, {@link }
  280. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  281. * CONFIGURATION_ERROR}, {@link }
  282. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  283. * UNIMPLEMENTED}
  284. *
  285. * @access public
  286. */
  287. function getId () {
  288. return $this->_id;
  289. }
  290.  
  291. /**
  292. * Get the Course Type for this CanonicalCourse. This Type is meaningful
  293. * to the implementation and applications and are not specified by the
  294. * OSID.
  295. *
  296. * @return object Type
  297. *
  298. * @throws object CourseManagementException An exception
  299. * with one of the following messages defined in
  300. * org.osid.coursemanagement.CourseManagementException may be
  301. * thrown: {@link }
  302. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  303. * OPERATION_FAILED}, {@link }
  304. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  305. * PERMISSION_DENIED}, {@link }
  306. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  307. * CONFIGURATION_ERROR}, {@link }
  308. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  309. * UNIMPLEMENTED}
  310. *
  311. * @access public
  312. */
  313. function getCourseType () {
  314. return $this->_getType('can');
  315. }
  316.  
  317. /**
  318. * Create a new CanonicalCourse. The display name defaults to the title, but this can be changed later.
  319. *
  320. * @param string $title
  321. * @param string $number
  322. * @param string $description
  323. * @param object Type $courseType
  324. * @param object Type $courseStatusType
  325. * @param float $credits
  326. *
  327. * @return object CanonicalCourse
  328. *
  329. * @throws object CourseManagementException An exception
  330. * with one of the following messages defined in
  331. * org.osid.coursemanagement.CourseManagementException may be
  332. * thrown: {@link }
  333. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  334. * OPERATION_FAILED}, {@link }
  335. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  336. * PERMISSION_DENIED}, {@link }
  337. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  338. * CONFIGURATION_ERROR}, {@link }
  339. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  340. * UNIMPLEMENTED}, {@link }
  341. * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  342. * NULL_ARGUMENT}, {@link }
  343. * org.osid.coursemanagement.CourseManagementException#UNKNOWN_TYPE
  344. * UNKNOWN_TYPE}
  345. *
  346. * @access public
  347. */
  348. function createCanonicalCourse ( $title, $number, $description, $courseType, $courseStatusType, $credits ) {
  349. $idManager = Services::getService("IdManager");
  350. $id=$idManager->createId();
  351.  
  352.  
  353. $type = new Type("CourseManagement","edu.middlebury", "CanonicalCourse");
  354. $node=$this->_hierarchy->createNode($id,$this->_id,$type,$title,$description);
  355.  
  356. $dbManager= Services::getService("DatabaseManager");
  357. $query= new InsertQuery;
  358.  
  359. $query->setTable('cm_can');
  360.  
  361. $query->setColumns(array('id','number','credits','equivalent','fk_cm_can_type','title','fk_cm_can_stat_type'));
  362.  
  363. $values[]="'".addslashes($id->getIdString())."'";
  364. $values[]="'".addslashes($number)."'";
  365. $values[]="'".addslashes($credits)."'";
  366. $values[]="'".addslashes($id->getIdString())."'";
  367. $values[]="'".$this->_typeToIndex('can',$courseType)."'";
  368. $values[]="'".addslashes($title)."'";
  369. $values[]="'".$this->_typeToIndex('can_stat',$courseStatusType)."'";
  370. $query->addRowOfValues($values);
  371.  
  372.  
  373.  
  374. $dbManager->query($query);
  375.  
  376. $ret = new HarmoniCanonicalCourse($id, $node);
  377. return $ret;
  378. }
  379.  
  380. /**
  381. * Get all CanonicalCourses.
  382. *
  383. * @return object CanonicalCourseIterator
  384. *
  385. * @throws object CourseManagementException An exception
  386. * with one of the following messages defined in
  387. * org.osid.coursemanagement.CourseManagementException may be
  388. * thrown: {@link }
  389. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  390. * OPERATION_FAILED}, {@link }
  391. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  392. * PERMISSION_DENIED}, {@link }
  393. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  394. * CONFIGURATION_ERROR}, {@link }
  395. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  396. * UNIMPLEMENTED}
  397. *
  398. * @access public
  399. */
  400. function getCanonicalCourses () {
  401. $cm = Services::getService("CourseManagement");
  402. //get the children
  403. $node =$this->_node;
  404. $nodeType =$node->getType();
  405. $children =$node->getChildren();
  406. //iterate throught the children
  407. $array = array();
  408. while($children->hasNextNode()){
  409. $child =$children->nextNode();
  410. $currNodeType =$child->getType();
  411. //If this node is also a CanonicalCourse
  412. if($currNodeType->isEqual($nodeType)){
  413. $id =$child->getId();
  414. $array[] =$cm->getCanonicalCourse($id);
  415. }
  416. }
  417. //convert to an iterator and return
  418. $ret = new HarmoniCanonicalCourseIterator($array);
  419. return $ret;
  420. }
  421.  
  422. /**
  423. * Get all CanonicalCourses of the specified Type.
  424. *
  425. * @param object Type $courseType
  426. *
  427. * @return object CanonicalCourseIterator
  428. *
  429. * @throws object CourseManagementException An exception
  430. * with one of the following messages defined in
  431. * org.osid.coursemanagement.CourseManagementException may be
  432. * thrown: {@link }
  433. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  434. * OPERATION_FAILED}, {@link }
  435. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  436. * PERMISSION_DENIED}, {@link }
  437. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  438. * CONFIGURATION_ERROR}, {@link }
  439. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  440. * UNIMPLEMENTED}, {@link }
  441. * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  442. * NULL_ARGUMENT}, {@link }
  443. * org.osid.coursemanagement.CourseManagementException#UNKNOWN_TYPE
  444. * UNKNOWN_TYPE}
  445. *
  446. * @access public
  447. */
  448. function getCanonicalCoursesByType ( $courseType ) {
  449. $cm = Services::getService("CourseManagement");
  450. //get the children
  451. $node =$this->_node;
  452. $nodeType =$node->getType();
  453. $children =$node->getChildren();
  454. //iterate throught the children
  455. $array = array();
  456. while($children->hasNextNode()){
  457. $child =$children->nextNode();
  458. $currNodeType =$child->getType();
  459. //If this node is also a CanonicalCourse
  460. if($currNodeType->isEqual($nodeType)){
  461. $id =$child->getId();
  462. $course =$cm->getCanonicalCourse($id);
  463. if($courseType->isEqual($course->getCourseType())){
  464. $array[] =$cm->getCanonicalCourse($id);
  465. }
  466. }
  467. }
  468. //convert to an iterator and return
  469. $ret = new HarmoniCanonicalCourseIterator($array);
  470. return $ret;
  471. }
  472.  
  473. /**
  474. * Create a new CourseOffering. The default display name is the title of the course.
  475. *
  476. * The display name defaults to the title. If the title,
  477. * number or displayName are left null, they default to the values of the creating agent.
  478. * Niether of these defaults are in the OSID, however.
  479. *
  480. * @param string $title
  481. * @param string $number
  482. * @param string $description
  483. * @param object Id $termId
  484. * @param object Type $offeringType
  485. * @param object Type $offeringStatusType
  486. * @param object Type $courseGradeType
  487. *
  488. * @return object CourseOffering
  489. *
  490. * @throws object CourseManagementException An exception
  491. * with one of the following messages defined in
  492. * org.osid.coursemanagement.CourseManagementException may be
  493. * thrown: {@link }
  494. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  495. * OPERATION_FAILED}, {@link }
  496. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  497. * PERMISSION_DENIED}, {@link }
  498. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  499. * CONFIGURATION_ERROR}, {@link }
  500. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  501. * UNIMPLEMENTED}, {@link }
  502. * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  503. * NULL_ARGUMENT}, {@link }
  504. * org.osid.coursemanagement.CourseManagementException#UNKNOWN_TYPE
  505. * UNKNOWN_TYPE}
  506. *
  507. * @access public
  508. */
  509. function createCourseOffering ( $title, $number, $description, $termId, $offeringType, $offeringStatusType, $courseGradeType ) {
  510. //set any defaults
  511. if(is_null($title)){
  512. $title = $this->getTitle();
  513. }
  514. if(is_null($number)){
  515. $number = $this->getNumber();
  516. }
  517. if(is_null($description)){
  518. $description = $this->getDescription();
  519. }
  520. $idManager = Services::getService("IdManager");
  521. $id=$idManager->createId();
  522.  
  523.  
  524. $type = new Type("CourseManagement","edu.middlebury", "CourseOffering");
  525. $node=$this->_hierarchy->createNode($id,$this->_id,$type,$title,$description);
  526.  
  527. $dbManager= Services::getService("DatabaseManager");
  528. $query= new InsertQuery;
  529.  
  530. $query->setTable('cm_offer');
  531.  
  532. $query->setColumns(array('id','fk_gr_grade_type','fk_cm_term',
  533. 'fk_cm_offer_stat_type','fk_cm_offer_type','title','number'));
  534. $values[]="'".addslashes($id->getIdString())."'";
  535. $gm = Services::getService('Grading');
  536. $typeIndex = $gm->_typeToIndex('grade',$courseGradeType);
  537. $values[]="'".addslashes($typeIndex)."'";
  538. $values[]="'".addslashes($termId->getIdString())."'";
  539. $values[]="'".addslashes($this->_typeToIndex('offer_stat',$offeringStatusType))."'";
  540. $values[]="'".addslashes($this->_typeToIndex('offer',$offeringType))."'";
  541. $values[]="'".addslashes($title)."'";
  542. $values[]="'".addslashes($number)."'";
  543. $query->addRowOfValues($values);
  544.  
  545. $dbManager->query($query);
  546.  
  547. $ret = new HarmoniCourseOffering($id, $node);
  548. return $ret;
  549.  
  550. }
  551. /**
  552. * Delete a CourseOffering.
  553. *
  554. * @param object Id $courseOfferingId
  555. *
  556. * @throws object CourseManagementException An exception
  557. * with one of the following messages defined in
  558. * org.osid.coursemanagement.CourseManagementException may be
  559. * thrown: {@link }
  560. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  561. * OPERATION_FAILED}, {@link }
  562. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  563. * PERMISSION_DENIED}, {@link }
  564. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  565. * CONFIGURATION_ERROR}, {@link }
  566. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  567. * UNIMPLEMENTED}, {@link }
  568. * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  569. * NULL_ARGUMENT}, {@link }
  570. * org.osid.coursemanagement.CourseManagementException#UNKNOWN_ID
  571. * UNKNOWN_ID}
  572. *
  573. * @access public
  574. */
  575. function deleteCourseOffering ( $courseOfferingId ) {
  576. $node =$this->_hierarchy->getNode($courseOfferingId);
  577.  
  578. $iterator =$node->getChildren();
  579. if($iterator->hasNextNode()){
  580. print "<b>Warning!</b> Can't delete CourseOfferings without deleting their CourseSections";
  581. return;
  582. }
  583. $this->_hierarchy->deleteNode($courseOfferingId);
  584.  
  585.  
  586.  
  587. $dbManager = Services::getService("DatabaseManager");
  588. $query= new DeleteQuery;
  589.  
  590.  
  591. $query->setTable('cm_offer');
  592.  
  593. $query->addWhere("id=".addslashes($courseOfferingId->getIdString()));
  594. $dbManager->query($query);
  595. }
  596.  
  597. /**
  598. * Get all CourseOfferings that belong to this CanonicalCourse.
  599. *
  600. * @return object CourseOfferingIterator
  601. *
  602. * @throws object CourseManagementException An exception
  603. * with one of the following messages defined in
  604. * org.osid.coursemanagement.CourseManagementException may be
  605. * thrown: {@link }
  606. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  607. * OPERATION_FAILED}, {@link }
  608. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  609. * PERMISSION_DENIED}, {@link }
  610. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  611. * CONFIGURATION_ERROR}, {@link }
  612. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  613. * UNIMPLEMENTED}
  614. *
  615. * @access public
  616. */
  617. function getCourseOfferings () {
  618.  
  619. $nodeIterator =$this->_node->getChildren();
  620. $array = array();
  621. $idManager= Services::getService("IdManager");
  622. $cm= Services::getService("CourseManagement");
  623. while($nodeIterator->hasNextNode()){
  624. $childNode =$nodeIterator->nextNode();
  625. $nodeType =$childNode->getType();
  626. if($nodeType->getKeyWord()!="CourseOffering"){
  627. continue;
  628. }
  629. $id =$childNode->getId();
  630. $courseOffering =$cm->getCourseOffering($id);
  631. $array[] =$courseOffering;
  632. }
  633. $ret = new HarmoniCourseOfferingIterator($array);
  634. return $ret;
  635. }
  636.  
  637. /**
  638. * Get all CourseOfferings of the specified Type that belong to this CanonicalCourse.
  639. *
  640. * @param object Type $offeringType
  641. *
  642. * @return object CourseOfferingIterator
  643. *
  644. * @throws object CourseManagementException An exception
  645. * with one of the following messages defined in
  646. * org.osid.coursemanagement.CourseManagementException may be
  647. * thrown: {@link }
  648. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  649. * OPERATION_FAILED}, {@link }
  650. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  651. * PERMISSION_DENIED}, {@link }
  652. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  653. * CONFIGURATION_ERROR}, {@link }
  654. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  655. * UNIMPLEMENTED}, {@link }
  656. * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  657. * NULL_ARGUMENT}, {@link }
  658. * org.osid.coursemanagement.CourseManagementException#UNKNOWN_TYPE
  659. * UNKNOWN_TYPE}
  660. *
  661. * @access public
  662. */
  663. function getCourseOfferingsByType ( $offeringType ) {
  664. $nodeIterator =$this->_node->getChildren();
  665. $array = array();
  666. $idManager= Services::getService("IdManager");
  667. $cm= Services::getService("CourseManagement");
  668. $typeIndex=$cm->_typeToIndex('offer',$offeringType);
  669. while($nodeIterator->hasNextNode()){
  670. $childNode =$nodeIterator->nextNode();
  671. $nodeType =$childNode->getType();
  672. if($nodeType->getKeyWord()!="CourseOffering"){
  673. continue;
  674. }
  675. $courseOffering =$cm->getCourseOffering($childNode->getId());
  676. if($typeIndex == $courseOffering->_getField('fk_cm_offer_type')){
  677. $array[] =$courseOffering;
  678. }
  679. }
  680. $ret = new HarmoniCourseOfferingIterator($array);
  681. return $ret;
  682.  
  683. }
  684.  
  685. /**
  686. * Add an equivalent course which are for mapping courses across
  687. * departments, schools, or institutions as well as for providing new
  688. * courses that map to previous ones. This can be used for
  689. * cross-listening. Note that if course A is equivalent to course B it
  690. * does not necessarily follow that course B is equivalent to course A.
  691. * Course A could cover a superset of the mateiral in course B.
  692. *
  693. * @param object Id $canonicalCourseId
  694. *
  695. * @throws object CourseManagementException An exception
  696. * with one of the following messages defined in
  697. * org.osid.coursemanagement.CourseManagementException may be
  698. * thrown: {@link }
  699. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  700. * OPERATION_FAILED}, {@link }
  701. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  702. * PERMISSION_DENIED}, {@link }
  703. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  704. * CONFIGURATION_ERROR}, {@link }
  705. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  706. * UNIMPLEMENTED}, {@link }
  707. * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  708. * NULL_ARGUMENT}, {@link }
  709. * org.osid.coursemanagement.CourseManagementException#ALREADY_ADDED
  710. * ALREADY_ADDED}
  711. *
  712. * @access public
  713. */
  714. function addEquivalentCourse ( $canonicalCourseId ) {
  715. //Courses are equivalent if they have the same id in the equivalent field
  716. //The id chosen is the lowest of the ids
  717. //getField()
  718.  
  719. $cm = Services::getService("CourseManagement");
  720. $course =$cm->getCanonicalCourse($canonicalCourseId);
  721. $courseEquivalent = $course->_getField('equivalent');
  722. $thisEquivalent = $this->_getField('equivalent');
  723. $comp = strcasecmp($courseEquivalent,$thisEquivalent);
  724. if($comp==0){
  725. return;
  726. } elseif ($comp > 0){
  727. $min = $thisEquivalent;
  728. $courseIterator =$course->getEquivalentCourses();
  729. $course->_setField('equivalent',$min);
  730. }else{
  731. $min = $courseEquivalent;
  732. $courseIterator =$this->getEquivalentCourses();
  733. $this->_setField('equivalent',$min);
  734. }
  735. while($courseIterator->hasNextCanonicalCourse()){
  736. $course = $courseIterator->nextCanonicalCourse();
  737. $course->_setField('equivalent', $min);
  738. }
  739. }
  740.  
  741. /**
  742. * Assures that the course passed in as a parameter is no longer
  743. * equivalent to any other courses. It does not matter which course
  744. * calls the function. In fact, it may make the most sense for courses to
  745. * call the function on themselves.
  746. *
  747. * @param object Id $canonicalCourseId
  748. *
  749. * @throws object CourseManagementException An exception
  750. * with one of the following messages defined in
  751. * org.osid.coursemanagement.CourseManagementException may be
  752. * thrown: {@link }
  753. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  754. * OPERATION_FAILED}, {@link }
  755. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  756. * PERMISSION_DENIED}, {@link }
  757. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  758. * CONFIGURATION_ERROR}, {@link }
  759. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  760. * UNIMPLEMENTED}, {@link }
  761. * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  762. * NULL_ARGUMENT}, {@link }
  763. * org.osid.coursemanagement.CourseManagementException#UNKNOWN_ID
  764. * UNKNOWN_ID}
  765. *
  766. * @access public
  767. */
  768. function removeEquivalentCourse ( $canonicalCourseId ) {
  769. $cm = Services::getService("CourseManagement");
  770. $course =$cm->getCanonicalCourse($canonicalCourseId);
  771. $courseIterator =$course->getEquivalentCourses();
  772.  
  773. if(!$courseIterator->hasNextCanonicalCourse()){
  774. return;
  775. }
  776. $courseEquivalent = $course->_getField('equivalent');
  777. $idString=$canonicalCourseId->getIdString();
  778. if($courseEquivalent!=$idString){
  779. $course->_setField('equivalent',$idString);
  780. return;
  781. }
  782. //Hahahahaa! I crack myself up.
  783. $first =true;
  784. while($courseIterator->hasNextCanonicalCourse()){
  785. $currCourse =$courseIterator->nextCanonicalCourse();
  786. $currId =$currCourse->getId();
  787. $currIdString = $currId->getIdString();
  788. if($first || strcasecmp($currIdString,$minSoFar) < 0){
  789. $minSoFar = $currIdString;
  790. $first=false;
  791. }
  792. }
  793. $courseIterator =$course->getEquivalentCourses();
  794. while($courseIterator->hasNextCanonicalCourse()){
  795. $course =$courseIterator->nextCanonicalCourse();
  796. $course->_setField('equivalent',$minSoFar);
  797. }
  798. }
  799.  
  800. /**
  801. * Get all equivalent courses for this CanonicalCourse.
  802. *
  803. * @return object CanonicalCourseIterator
  804. *
  805. * @throws object CourseManagementException An exception
  806. * with one of the following messages defined in
  807. * org.osid.coursemanagement.CourseManagementException may be
  808. * thrown: {@link }
  809. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  810. * OPERATION_FAILED}, {@link }
  811. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  812. * PERMISSION_DENIED}, {@link }
  813. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  814. * CONFIGURATION_ERROR}, {@link }
  815. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  816. * UNIMPLEMENTED}
  817. *
  818. * @access public
  819. */
  820. function getEquivalentCourses () {
  821. $dbManager = Services::getService("DatabaseManager");
  822. $cm = Services::getService("CourseManagement");
  823. $query= new SelectQuery;
  824. $query->addTable($this->_table);
  825. $query->addColumn('id');
  826. $query->addWhere("equivalent ='".$this->_getField('equivalent')."'");
  827. $res=$dbManager->query($query);
  828. $array=array();
  829. $idManager= Services::getService('IdManager');
  830. $myIdString = $this->_id->getIdString();
  831. while($res->hasMoreRows()){
  832. $row = $res->getCurrentRow();
  833. $res->advanceRow();
  834. if($row['id']==$myIdString){
  835. continue;
  836. }
  837. $array[] = $cm->getCanonicalCourse($idManager->getId($row['id']));
  838. }
  839. $ret = new HarmoniCanonicalCourseIterator($array);
  840. return $ret;
  841. }
  842.  
  843. /**
  844. * Add a Topic for this CanonicalCourse.
  845. *
  846. * @param string $topic
  847. *
  848. * @throws object CourseManagementException An exception
  849. * with one of the following messages defined in
  850. * org.osid.coursemanagement.CourseManagementException may be
  851. * thrown: {@link }
  852. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  853. * OPERATION_FAILED}, {@link }
  854. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  855. * PERMISSION_DENIED}, {@link }
  856. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  857. * CONFIGURATION_ERROR}, {@link }
  858. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  859. * UNIMPLEMENTED}, {@link }
  860. * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  861. * NULL_ARGUMENT}, {@link }
  862. * org.osid.coursemanagement.CourseManagementException#ALREADY_ADDED
  863. * ALREADY_ADDED}
  864. *
  865. * @access public
  866. */
  867. function addTopic ( $topic ) {
  868. $dbManager = Services::getService("DatabaseManager");
  869. $query= new SelectQuery;
  870. $query->addTable('cm_topics');
  871. $query->addWhere("fk_cm_can='".$this->_id->getIdString()."'");
  872. $query->addWhere("topic='".addslashes($topic)."'");
  873. //not really needed, but it keeps this from crashing.
  874. $query->addColumn('topic');
  875. $res=$dbManager->query($query);
  876.  
  877.  
  878.  
  879. if($res->getNumberOfRows()==0){
  880. $query= new InsertQuery;
  881. $query->setTable('cm_topics');
  882. $values[]="'".addslashes($this->_id->getIdString())."'";
  883. $values[]="'".addslashes($topic)."'";
  884. $query->setColumns(array('fk_cm_can','topic'));
  885. $query->addRowOfValues($values);
  886. $result =$dbManager->query($query);
  887. }elseif($res->getNumberOfRows()==1){
  888. //do nothing
  889. }else{
  890. print "\n<b>Warning!<\b> The Topic with course ".$this->getDisplayName()." and description ".$topic." is not unique--there are ".$res->getNumberOfRows()." copies.\n";
  891.  
  892. }
  893. }
  894.  
  895. /**
  896. * Remove a Topic for this CanonicalCourse.
  897. *
  898. * @param string $topic
  899. *
  900. * @throws object CourseManagementException An exception
  901. * with one of the following messages defined in
  902. * org.osid.coursemanagement.CourseManagementException may be
  903. * thrown: {@link }
  904. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  905. * OPERATION_FAILED}, {@link }
  906. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  907. * PERMISSION_DENIED}, {@link }
  908. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  909. * CONFIGURATION_ERROR}, {@link }
  910. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  911. * UNIMPLEMENTED}, {@link }
  912. * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  913. * NULL_ARGUMENT}
  914. *
  915. * @access public
  916. */
  917. function removeTopic ( $topic ) {
  918. $dbManager = Services::getService("DatabaseManager");
  919. $query= new DeleteQuery;
  920. $query->setTable('cm_topics');
  921. $query->addWhere("fk_cm_can='".$this->_id->getIdString()."'");
  922. $query->addWhere("topic='".addslashes($topic)."'");
  923. $dbManager->query($query);
  924.  
  925. }
  926.  
  927. /**
  928. * Get all Topics for this CanonicalCourse.
  929. *
  930. * @return object StringIterator
  931. *
  932. * @throws object CourseManagementException An exception
  933. * with one of the following messages defined in
  934. * org.osid.coursemanagement.CourseManagementException may be
  935. * thrown: {@link }
  936. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  937. * OPERATION_FAILED}, {@link }
  938. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  939. * PERMISSION_DENIED}, {@link }
  940. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  941. * CONFIGURATION_ERROR}, {@link }
  942. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  943. * UNIMPLEMENTED}
  944. *
  945. * @access public
  946. */
  947. function getTopics () {
  948. $dbManager = Services::getService("DatabaseManager");
  949. $query= new SelectQuery;
  950. $query->addTable('cm_topics');
  951. $query->addWhere("fk_cm_can='".$this->_id->getIdString()."'");
  952. $query->addColumn('topic');
  953. $res=$dbManager->query($query);
  954. $array=array();
  955. while($res->hasMoreRows()){
  956. $row = $res->getCurrentRow();
  957. $res->advanceRow();
  958. $array[]=$row['topic'];
  959. }
  960. $ret = new HarmoniStringIterator($array);
  961. return $ret;
  962. }
  963.  
  964. /**
  965. * Get the credits for this CanonicalCourse.
  966. *
  967. * @return float
  968. *
  969. * @throws object CourseManagementException An exception
  970. * with one of the following messages defined in
  971. * org.osid.coursemanagement.CourseManagementException may be
  972. * thrown: {@link }
  973. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  974. * OPERATION_FAILED}, {@link }
  975. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  976. * PERMISSION_DENIED}, {@link }
  977. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  978. * CONFIGURATION_ERROR}, {@link }
  979. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  980. * UNIMPLEMENTED}
  981. *
  982. * @access public
  983. */
  984. function getCredits () {
  985. return $this->_getField('credits');
  986. }
  987.  
  988. /**
  989. * Update the credits for this CanonicalCourse.
  990. *
  991. * @param float $credits
  992. *
  993. * @throws object CourseManagementException An exception
  994. * with one of the following messages defined in
  995. * org.osid.coursemanagement.CourseManagementException may be
  996. * thrown: {@link }
  997. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  998. * OPERATION_FAILED}, {@link }
  999. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  1000. * PERMISSION_DENIED}, {@link }
  1001. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  1002. * CONFIGURATION_ERROR}, {@link }
  1003. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  1004. * UNIMPLEMENTED}, {@link }
  1005. * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  1006. * NULL_ARGUMENT}
  1007. *
  1008. * @access public
  1009. */
  1010. function updateCredits ( $credits ) {
  1011. $this->_setField('credits',$credits);
  1012. }
  1013.  
  1014. /**
  1015. * Get the Status for this CanonicalCourse.
  1016. *
  1017. * @return object Type
  1018. *
  1019. * @throws object CourseManagementException An exception
  1020. * with one of the following messages defined in
  1021. * org.osid.coursemanagement.CourseManagementException may be
  1022. * thrown: {@link }
  1023. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  1024. * OPERATION_FAILED}, {@link }
  1025. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  1026. * PERMISSION_DENIED}, {@link }
  1027. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  1028. * CONFIGURATION_ERROR}, {@link }
  1029. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  1030. * UNIMPLEMENTED}
  1031. *
  1032. * @access public
  1033. */
  1034. function getStatus () {
  1035. return $this->_getType('can_stat');
  1036. }
  1037.  
  1038. /**
  1039. * Update the Status for this CanonicalCourse.
  1040. *
  1041. * @param object Type $statusType
  1042. *
  1043. * @throws object CourseManagementException An exception
  1044. * with one of the following messages defined in
  1045. * org.osid.coursemanagement.CourseManagementException may be
  1046. * thrown: {@link }
  1047. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  1048. * OPERATION_FAILED}, {@link }
  1049. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  1050. * PERMISSION_DENIED}, {@link }
  1051. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  1052. * CONFIGURATION_ERROR}, {@link }
  1053. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  1054. * UNIMPLEMENTED}, {@link }
  1055. * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  1056. * NULL_ARGUMENT}, {@link }
  1057. * org.osid.coursemanagement.CourseManagementException#UNKNOWN_TYPE
  1058. * UNKNOWN_TYPE}
  1059. *
  1060. * @access public
  1061. */
  1062. function updateStatus ( $statusType ) {
  1063.  
  1064. $index = $this->_typeToIndex('can_stat',$statusType);
  1065. $this->_setField('fk_cm_can_stat_type',$index);
  1066. }
  1067. /**
  1068. * Get all the Property Types for CanonicalCourse. There is is only
  1069. * One type of property associated with each course object.
  1070. *
  1071. * @return object TypeIterator
  1072. *
  1073. * @throws object CourseManagementException An exception
  1074. * with one of the following messages defined in
  1075. * org.osid.coursemanagement.CourseManagementException may be
  1076. * thrown: {@link }
  1077. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  1078. * OPERATION_FAILED}, {@link }
  1079. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  1080. * PERMISSION_DENIED}, {@link }
  1081. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  1082. * CONFIGURATION_ERROR}, {@link }
  1083. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  1084. * UNIMPLEMENTED}
  1085. *
  1086. * @access public
  1087. */
  1088. function getPropertyTypes () {
  1089. $courseType =$this->getCourseType();
  1090. $propertiesType = new Type("PropertiesType", $courseType->getAuthority(), "properties");
  1091. $array = array($propertiesType);
  1092. $typeIterator = new HarmoniTypeIterator($array);
  1093. return $typeIterator;
  1094. }
  1095.  
  1096. /**
  1097. * Get the Properties associated with this CanonicalCourse. There is is only
  1098. * One type of property associated with each course object.
  1099. *
  1100. * @return object PropertiesIterator
  1101. *
  1102. * @throws object CourseManagementException An exception
  1103. * with one of the following messages defined in
  1104. * org.osid.coursemanagement.CourseManagementException may be
  1105. * thrown: {@link }
  1106. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  1107. * OPERATION_FAILED}, {@link }
  1108. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  1109. * PERMISSION_DENIED}, {@link }
  1110. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  1111. * CONFIGURATION_ERROR}, {@link }
  1112. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  1113. * UNIMPLEMENTED}
  1114. *
  1115. * @access public
  1116. */
  1117. function getProperties () {
  1118. $array = array($this->_getProperties());
  1119. $ret = new HarmoniPropertiesIterator($array);
  1120. return $ret;//return the iterator
  1121. }
  1122. /**
  1123. * Get the Properties of this Type associated with this CanonicalCourse. There is is only
  1124. * One type of property associated with each course object.
  1125. *
  1126. * @param object Type $propertiesType
  1127. *
  1128. * @return object Properties
  1129. *
  1130. * @throws object CourseManagementException An exception
  1131. * with one of the following messages defined in
  1132. * org.osid.coursemanagement.CourseManagementException may be
  1133. * thrown: {@link }
  1134. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  1135. * OPERATION_FAILED}, {@link }
  1136. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  1137. * PERMISSION_DENIED}, {@link }
  1138. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  1139. * CONFIGURATION_ERROR}, {@link }
  1140. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  1141. * UNIMPLEMENTED}, {@link }
  1142. * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  1143. * NULL_ARGUMENT}, {@link }
  1144. * org.osid.coursemanagement.CourseManagementException#UNKNOWN_TYPE
  1145. * UNKNOWN_TYPE}
  1146. *
  1147. * @access public
  1148. */
  1149. function getPropertiesByType ( $propertiesType ) {
  1150. $courseType =$this->getCourseType();
  1151. $propType = new Type("PropertiesType", $courseType->getAuthority(), "properties");
  1152. if($propertiesType->isEqualTo($propType)){
  1153. return $this->_getProperties();
  1154. }
  1155. return null;
  1156. }
  1157. /**
  1158. * Get a Properties object with the information about this object.
  1159. *
  1160. * @return object Properties
  1161. *
  1162. * @access private
  1163. */
  1164. function _getProperties(){
  1165. $dbManager = Services::getService("DatabaseManager");
  1166. //get the record
  1167. $query = new SelectQuery();
  1168. $query->addTable('cm_can');
  1169. $query->addColumn("*");
  1170. $query->addWhere("id='".addslashes($this->_id->getIdString())."'");
  1171. $res=$dbManager->query($query);
  1172. //make sure we can find that course
  1173. if(!$res->hasMoreRows()){
  1174. print "<b>Warning!</b> Can't get Properties of Course with id ".$this->_id." since that id wasn't found in the database.";
  1175. return null;
  1176. }
  1177. $row = $res->getCurrentRow();//grab (hopefully) the only row
  1178. //make a type
  1179. $courseType =$this->getCourseType();
  1180. $propertiesType = new Type("PropertiesType", $courseType->getAuthority(), "properties");
  1181. //create a custom Properties object
  1182. $idManager = Services::getService("Id");
  1183. $property = new HarmoniProperties($propertiesType);
  1184. $property->addProperty('display_name', $this->_node->getDisplayName());
  1185. $property->addProperty('title', $row['title']);
  1186. $property->addProperty('description', $this->_node->getDescription());
  1187. $property->addProperty('id', $idManager->getId($row['id']));
  1188. $property->addProperty('number', $row['number']);
  1189. $property->addProperty('credits', $row['credits']);
  1190. $property->addProperty('equivalent_id', $idManager->getId($row['equivalent']));
  1191. $property->addProperty('type', $courseType);
  1192.  
  1193. $statusType =$this->getStatus();
  1194. $property->addProperty('status_type', $statusType);
  1195.  
  1196. $res->free();
  1197. return $property;
  1198. }
  1199. function _typeToIndex($typename, $type)
  1200. {
  1201. $cm=Services::getService("CourseManagement");
  1202. return $cm->_typeToIndex($typename, $type);
  1203. }
  1204. function _getTypes($typename)
  1205. {
  1206. $cm=Services::getService("CourseManagement");
  1207. return $cm->_getTypes($typename);
  1208. }
  1209. function _getField($key)
  1210. {
  1211. $cm=Services::getService("CourseManagement");
  1212. return $cm->_getField($this->_id,$this->_table,$key);
  1213. }
  1214. function _getType($typename){
  1215. $cm=Services::getService("CourseManagement");
  1216. return $cm->_getType($this->_id,$this->_table,$typename);
  1217. }
  1218. function _setField($key, $value)
  1219. {
  1220. $cm=Services::getService("CourseManagement");
  1221. return $cm->_setField($this->_id,$this->_table,$key, $value);
  1222. }
  1223. }
  1224.  
  1225. ?>

Documentation generated on Wed, 19 Sep 2007 10:21:59 -0400 by phpDocumentor 1.3.0RC3