Source for file createcoursesection.act.php

Documentation is available at createcoursesection.act.php

  1. <?php
  2.  
  3. /**
  4. * This action is the central page for viewing and modifying course section information.
  5. *
  6. * @package polyphony.coursemanagement
  7. *
  8. *
  9. * @since 7/28/06
  10. *
  11. * @copyright Copyright &copy; 2006, Middlebury College
  12. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  13. *
  14. * @version $Id: createcoursesection.act.php,v 1.18 2007/09/19 14:04:54 adamfranco Exp $
  15. */
  16.  
  17. require_once(POLYPHONY."/main/library/AbstractActions/MainWindowAction.class.php");
  18. require_once(HARMONI."GUIManager/Components/Blank.class.php");
  19.  
  20. class createcoursesectionAction
  21. extends MainWindowAction
  22. {
  23. /**
  24. * Check Authorizations
  25. *
  26. * @return boolean
  27. * @access public
  28. * @since 4/26/05
  29. */
  30. function isAuthorizedToExecute () {
  31. // Check for authorization
  32. // Check that the user can create an asset here.
  33. $authZ = Services::getService("AuthZ");
  34. $idManager = Services::getService("Id");
  35. return $authZ->isUserAuthorized(
  36. $idManager->getId("edu.middlebury.authorization.add_children"),
  37. $idManager->getId("edu.middlebury.coursemanagement")
  38. );
  39. }
  40.  
  41. /**
  42. * Return the heading text for this action, or an empty string.
  43. *
  44. * @return string
  45. * @access public
  46. * @since 4/26/05
  47. */
  48. function getHeadingText () {
  49. return _("Add or remove a course section.");
  50. }
  51.  
  52. /**
  53. * Build the content for this action
  54. *
  55. * @return void
  56. * @access public
  57. * @since 4/26/05
  58. */
  59. function buildContent () {
  60. $defaultTextDomain = textdomain("polyphony");
  61. $idManager = Services::getService("Id");
  62. $cmm = Services::getService("CourseManagement");
  63. $harmoni = Harmoni::instance();
  64. $harmoni->request->startNamespace("polyphony-agents");
  65. $harmoni->request->passthrough("courseId");
  66. $courseIdString = $harmoni->request->get("courseId");
  67. $courseId =$idManager->getId($courseIdString);
  68. $cm = Services::getService("CourseManagement");
  69. $offering =$cmm->getCourseOffering($courseId);
  70. $offeringName = $offering->getDisplayName();
  71. // Process any changes and add or remove courses as necessary
  72. if (RequestContext::value("sectionType") && RequestContext::value("sectionStatus") &&
  73. RequestContext::value("sectionLocation"))
  74. $this->addSection($offering, RequestContext::value("sectionType"), RequestContext::value("sectionStatus"),
  75. RequestContext::value("sectionLocation"));
  76. // Print out the add form and course list
  77. $actionRows =$this->getActionRows();
  78. $actionRows->add(new Heading(_("Add or remove course sections in ".$offeringName."."), 2), "100%", null, LEFT, CENTER);
  79. $actionRows->add($this->getAddForm($offering), "100%", null, LEFT, CENTER);
  80. $harmoni->request->endNamespace();
  81.  
  82. textdomain($defaultTextDomain);
  83. }
  84.  
  85. /***************************FUNCTIONS***************************************/
  86.  
  87.  
  88. /*******************************************************
  89. * The form to add information for adding course sections
  90. *********************************************************/
  91.  
  92. /**
  93. * Build a form to add information to add course sections.
  94. *
  95. * @return void
  96. * @access public
  97. * @since 8/29/05
  98. */
  99. function getAddForm($offering) {
  100. $harmoni = Harmoni::instance();
  101. $cmm = Services::getService("CourseManagement");
  102. $idManager = Services::getService("Id");
  103. $am = Services::GetService("AgentManager");
  104. ob_start();
  105. $offeringName = $offering->getDisplayName();
  106. $offeringId =$offering->getId();
  107. $offeringIdString = $offeringId->getIdString();
  108. print _("<h3>Course offering: ".$offeringName."</h3>")."";
  109. print _("<h4>Please enter the following information to add a course section in ".$offeringName.".</h4>")."";
  110. // Search header
  111. $self = $harmoni->request->quickURL("coursemanagement", "createcoursesection",
  112. array("sectionType", "sectionStatus", "sectionLocation"));
  113. $last_type = $harmoni->request->get("sectionType");
  114. $section_type = RequestContext::name("sectionType");
  115. $last_status = $harmoni->request->get("sectionStatus");
  116. $section_status = RequestContext::name("sectionStatus");
  117. $last_location = $harmoni->request->get("sectionLocation");
  118. $section_location = RequestContext::name("sectionLocation");
  119. print "<form action='$self' method='post'>
  120. <div>
  121. <p>Section Type: <br/><input type='text' name='$section_type' value='$last_type' /></p>
  122. <p>Section Status: <br/><input type='text' name='$section_status' value='$last_type' /></p>
  123. <p>Section Location: <br/><input type='text' name='$section_location' value='$last_location' /></p>";
  124. print "\n\t<input type='submit' value='"._("Add")."' />";
  125. print "\n\t<a href='".$harmoni->request->quickURL()."'>";
  126. print "<input type='button' value='"._("Clear")."' /></a>";
  127. print "\n</div>\n</form>\n";
  128. $link = $harmoni->request->quickURL("coursemanagement", "edit_offering_details",
  129. array("courseId"=>$offeringIdString));
  130. print _("<h4><a href='$link'>Click here to return to offering details.</a></h4>")."";
  131. $output = new Block(ob_get_clean(), STANDARD_BLOCK);
  132. return $output;
  133. }
  134. /**
  135. * Process any changes in the form to add a section.
  136. *
  137. * @param string offering
  138. * @param string type
  139. * @param string status
  140. * &param string location
  141. * @return void
  142. * @access public
  143. * @since 8/29/05
  144. */
  145. function addSection($offering, $type, $status, $location) {
  146. $actionRows =$this->getActionRows();
  147. $pageRows = new Container(new YLayout(), OTHER, 1);
  148. $harmoni = Harmoni::instance();
  149. $cmm = Services::getService("CourseManagement");
  150. $idManager = Services::getService("Id");
  151. $everyoneId =$idManager->getId("edu.middlebury.agents.everyone");
  152. $usersId =$idManager->getId("edu.middlebury.agents.users");
  153. $sectionType = new Type("CourseManagement", "edu.middlebury", $type);
  154. $sectionStatus = new Type("CourseManagement", "edu.middlebury", $status);
  155. $section =$offering->createCourseSection($offering->getTitle(), $offering->getNumber(),
  156. $offering->getDescription(), $sectionType,
  157. $sectionStatus, $sectionLocation);
  158. // Update display name with the section type
  159. $displayName = $section->getDisplayName();
  160. $newDisplayName = $displayName.$type;
  161. $section->updateDisplayName($newDisplayName);
  162. ob_start();
  163. print "<h3>Section ".$newDisplayName." added.</h3>";
  164. $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), "100%", null, LEFT, CENTER);
  165. }
  166. }

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