/** * Change the Enrollment Status Type for the student on the roster. * * @param object Id $agentId * @param object Type $enrollmentStatusType * * @throws object CourseManagementException An exception * with one of the following messages defined in * org.osid.coursemanagement.CourseManagementException may be * thrown: {@link * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED * UNIMPLEMENTED}, {@link * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.coursemanagement.CourseManagementException#UNKNOWN_TYPE * UNKNOWN_TYPE} * * @access public */ function changeStudent(Id $agentId, Type $enrollmentStatusType) { $dbManager = Services::getService("DatabaseManager"); $query = new SelectQuery(); $query->addTable('cm_enroll'); $query->addWhere("fk_cm_section='" . addslashes($this->_id->getIdString()) . "'"); $query->addWhere("fk_student_id='" . addslashes($agentId->getIdString()) . "'"); //I don't need Id, but I need to select something for the query to work $query->addColumn('id'); $res = $dbManager->query($query); if ($res->getNumberOfRows() == 0) { throwError(new Error("Cannot change status of student [" . $agentId->getIDString() . "] because that student in not enrolled in the course[" . $this->_id->getIdString() . "]", "CourseManagement", true)); } else { if ($res->getNumberOfRows() > 1) { print "<b>Warning!</b> Student with id " . $agentId->getIdString() . " is already enrolled in section " . $this->getDisplayName() . " twice."; } } $typeIndex = $this->_typeToIndex('enroll_stat', $enrollmentStatusType); $query = new UpdateQuery(); $query->setTable('cm_enroll'); $query->addWhere("fk_cm_section='" . addslashes($this->_id->getIdString()) . "'"); $query->addWhere("fk_student_id='" . addslashes($agentId->getIdString()) . "'"); $query->setColumns(array('fk_cm_enroll_stat_type')); $query->setValues(array("'" . addslashes($typeIndex) . "'")); $dbManager->query($query); }