Source for file CourseOffering.class.php

Documentation is available at CourseOffering.class.php

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

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