当前位置: 首页>>代码示例>>PHP>>正文


PHP StudentFactory类代码示例

本文整理汇总了PHP中StudentFactory的典型用法代码示例。如果您正苦于以下问题:PHP StudentFactory类的具体用法?PHP StudentFactory怎么用?PHP StudentFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了StudentFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'search')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to lookup student names!');
     }
     $student = null;
     $error = new JsonError(403);
     $username = $context->get('username');
     $banner_id = (int) $context->get('banner_id');
     try {
         if ($banner_id) {
             $student = StudentFactory::getStudentByBannerID($banner_id, Term::getSelectedTerm());
         } elseif (!empty($username)) {
             $student = StudentFactory::getStudentByUsername($username, Term::getSelectedTerm());
         } else {
             $error->setMessage('Did not receive Banner ID or user name.');
             $context->setContent(json_encode($error));
         }
         $student->gender_string = HMS_Util::formatGender($student->gender);
         $context->setContent(json_encode($student));
     } catch (\StudentNotFoundException $e) {
         $error->setMessage($e->getMessage());
         $context->setContent(json_encode($error));
     }
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:26,代码来源:JSONGetStudentCommand.php

示例2: execute

 /**
  * (non-PHPdoc)
  * @see Command::execute()
  */
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php');
     $term = $context->get('term');
     if (!isset($term)) {
         throw new InvalidArgumentException('Missing term.');
     }
     $user = UserStatus::getUsername();
     $student = StudentFactory::getStudentByUsername($user, $term);
     // Load the student's application. Should be a lottery application.
     $application = HousingApplicationFactory::getAppByStudent($student, $term);
     // If there isn't a valid application in the DB, then we have a problem.
     if (!isset($application) || !$application instanceof LotteryApplication) {
         throw new InvalidArgumentException('Null application object.');
     }
     // Check to make sure the date isn't already set
     $time = $application->getWaitingListDate();
     if (isset($time)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You have already applied for the waiting list.');
         $cmd = CommandFactory::getCommand('ShowStudentMenu');
         $cmd->redirect();
     }
     // Set the date
     $application->setWaitingListDate(time());
     // Save the application again
     $application->save();
     // Log it to the activity log
     HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_REAPP_WAITINGLIST_APPLY, UserStatus::getUsername());
     // Success command
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $cmd->redirect();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:37,代码来源:WaitingListSignupCommand.php

示例3: execute

 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'assign_by_floor')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to assign students by floor.');
     }
     $username = $context->get('username');
     $banner_id = (int) $context->get('banner_id');
     $reason = $context->get('reason');
     $meal_plan = $context->get('meal_plan');
     $bed_id = $context->get('bed_id');
     $term = Term::getSelectedTerm();
     try {
         if ($banner_id) {
             $student = StudentFactory::getStudentByBannerID($banner_id, Term::getSelectedTerm());
         } elseif (!empty($username)) {
             $student = StudentFactory::getStudentByUsername($username, Term::getSelectedTerm());
         } else {
             $context->setContent(json_encode(array('status' => 'failure', 'message' => 'Did not receive Banner ID or user name.')));
             return;
         }
         try {
             HMS_Assignment::assignStudent($student, $term, null, $bed_id, $meal_plan, null, null, $reason);
         } catch (AssignmentException $e) {
             $context->setContent(json_encode(array('status' => 'failure', 'message' => $e->getMessage())));
             return;
         }
         $message = $student->first_name . ' ' . $student->last_name;
         $context->setContent(json_encode(array('status' => 'success', 'message' => $message, 'student' => $student)));
     } catch (\StudentNotFoundException $e) {
         $context->setContent(json_encode(array('status' => 'failure', 'message' => $e->getMessage())));
     }
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:33,代码来源:JSONAssignStudentCommand.php

示例4: execute

 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'approve_rlc_applications')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to approve RLC applications.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     # Foreach rlc assignment made
     # $app_id is the 'id' column in the 'learning_community_applications' table, tells which student we're assigning
     # $rlc_id is the 'id' column in the 'learning_communitites' table, and refers to the RLC selected for the student
     foreach ($_REQUEST['final_rlc'] as $app_id => $rlc_id) {
         if ($rlc_id <= 0) {
             continue;
         }
         $app = HMS_RLC_Application::getApplicationById($app_id);
         $student = StudentFactory::getStudentByUsername($app->username, $app->term);
         # Insert a new assignment in the 'learning_community_assignment' table
         $assign = new HMS_RLC_Assignment();
         $assign->rlc_id = $rlc_id;
         $assign->gender = $student->getGender();
         $assign->assigned_by = UserStatus::getUsername();
         $assign->application_id = $app->id;
         $assign->state = 'new';
         $assign->save();
         # Log the assignment
         PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
         HMS_Activity_Log::log_activity($app->username, ACTIVITY_ASSIGN_TO_RLC, UserStatus::getUsername(), "New Assignment");
     }
     // Show a success message
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Successfully assigned RLC applicant(s).');
     $context->goBack();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:34,代码来源:AssignRlcApplicantsCommand.php

示例5: show

 public function show()
 {
     $tpl = array();
     // Check for an empty array of requests
     if (sizeof($this->requests) == 0) {
         $tpl['NO_REQUESTS'] = 'No pending requests found.';
         return PHPWS_Template::process($tpl, 'hms', 'admin/roomChangeListView.tpl');
     }
     javascriptMod('hms', 'livestamp');
     $tpl['REQUESTS'] = array();
     foreach ($this->requests as $request) {
         $row = array();
         $participants = $request->getParticipants();
         $participantNames = array();
         foreach ($participants as $p) {
             $student = StudentFactory::getStudentByBannerId($p->getBannerId(), $this->term);
             $participantNames[] = $student->getName();
         }
         $row['participants'] = implode(', ', $participantNames);
         $mgmtCmd = CommandFactory::getCommand('ShowManageRoomChange');
         $mgmtCmd->setRequestId($request->getId());
         $row['manage'] = $mgmtCmd->getURI();
         $row['last_updated_timestamp'] = $request->getLastUpdatedTimestamp();
         $row['last_updated_date'] = date("M j @ g:ia", $request->getLastUpdatedTimestamp());
         $tpl['REQUESTS'][] = $row;
     }
     return PHPWS_Template::process($tpl, 'hms', 'admin/roomChangeListView.tpl');
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:28,代码来源:RoomChangeListView.php

示例6: execute

 public function execute(CommandContext $context)
 {
     $id = $context->get('roommateId');
     if (is_null($id)) {
         throw new InvalidArgumentException('Must set roommateId');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
     $roommate = new HMS_Roommate($id);
     if ($roommate->id == 0) {
         throw new InvalidArgumentException('Invalid roommateId ' . $id);
     }
     if (UserStatus::getUsername() != $roommate->requestee) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException("{$username} tried to reject roommate pairing {$roommate->id}");
     }
     $requestor = StudentFactory::getStudentByUsername($roommate->requestor, $roommate->term);
     $name = $requestor->getFullName();
     $username = $requestor->getUsername();
     $roommate->delete();
     HMS_Activity_Log::log_activity($roommate->requestor, ACTIVITY_REJECTED_AS_ROOMMATE, $roommate->requestee, "{$roommate->requestee} rejected {$roommate->requestor}'s request");
     HMS_Activity_Log::log_activity($roommate->requestee, ACTIVITY_REJECTED_AS_ROOMMATE, $roommate->requestor, "{$roommate->requestee} rejected {$roommate->requestor}'s request");
     // Email both parties
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     HMS_Email::send_reject_emails($roommate);
     NQ::Simple('hms', hms\NotificationView::SUCCESS, "<b>You rejected the roommate request from {$name}.</b>  If this was an error, you may re-request using their username, <b>{$username}</b>.");
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $cmd->redirect();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:28,代码来源:RoommateRejectCommand.php

示例7: __construct

 public function __construct($username)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     $student = StudentFactory::getStudentByUsername($username, Term::getCurrentTerm());
     $this->student = $student;
     $this->term = $student->getApplicationTerm();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:7,代码来源:VerifyAssignmentView.php

示例8: execute

 public function execute()
 {
     $db = PdoFactory::getPdoInstance();
     $query = "SELECT hms_assignment.banner_id, hms_hall_structure.room_number, hms_hall_structure.hall_name\n              FROM hms_assignment\n              JOIN hms_hall_structure\n                  ON hms_assignment.bed_id = hms_hall_structure.bedid\n              WHERE\n                hms_assignment.term = :term and\n                roomid IN (SELECT room_id\n                            FROM hms_learning_community_assignment\n                            JOIN hms_learning_community_applications\n                                ON hms_learning_community_assignment.application_id = hms_learning_community_applications.id\n                            JOIN hms_assignment\n                                ON (hms_learning_community_applications.username = hms_assignment.asu_username AND hms_learning_community_applications.term = hms_assignment.term)\n                            JOIN hms_bed\n                                ON hms_assignment.bed_id = hms_bed.id\n                            JOIN hms_room\n                                ON hms_bed.room_id = hms_room.id\n                            WHERE\n                                hms_learning_community_applications.term = :term)\n              ORDER BY roomid";
     $stmt = $db->prepare($query);
     $params = array('term' => $this->term);
     $stmt->execute($params);
     $queryResult = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $results = array();
     $i = 0;
     $count = 0;
     foreach ($queryResult as $result) {
         $tplVals = array();
         $tplVals['BANNER'] = $result['banner_id'];
         $student = StudentFactory::getStudentByBannerID($result['banner_id'], $this->term);
         $tplVals['USERNAME'] = $student->getUsername();
         $tplVals['FIRST_NAME'] = $student->getFirstName();
         $tplVals['LAST_NAME'] = $student->getLastName();
         $membership = RlcMembershipFactory::getMembership($student, $this->term);
         if ($membership) {
             $tplVals['COMMUNITY'] = $membership->getRlcName();
             $count++;
         } else {
             $tplVals['COMMUNITY'] = '';
         }
         $tplVals['HALL'] = $result['hall_name'];
         $tplVals['ROOM'] = $result['room_number'];
         $results[$i] = $tplVals;
         $i++;
     }
     $this->memberCount = $count;
     $this->data = $results;
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:33,代码来源:RlcRoster.php

示例9: createPairing

 protected function createPairing(HousingApplication $a, HousingApplication $b)
 {
     // Determine lifestyle option
     $option = LO_COED;
     if ($a->lifestyle_option == LO_SINGLE_GENDER || $b->lifestyle_option == LO_SINGLE_GENDER) {
         $option = LO_SINGLE_GENDER;
     }
     try {
         $studentA = StudentFactory::getStudentByUsername($a->username, $this->term);
     } catch (StudentNotFoundException $e) {
         echo 'StudentNotFoundException: ' . $a->username . ' Could not pair ' . $a->username . ', ' . $b->username . "\n";
         return null;
     }
     try {
         $studentB = Studentfactory::getStudentByUsername($b->username, $this->term);
     } catch (StudentNotFoundException $e) {
         echo 'StudentNotFoundException: ' . $b->username . ' Could not pair ' . $a->username . ', ' . $b->username . "\n";
         return null;
     }
     if ($a->getCreatedOn() < $b->getCreatedOn()) {
         $earliestTime = $a->getCreatedOn();
     } else {
         $earliestTime = $b->getCreatedOn();
     }
     // Looks like there is no problem here.
     return new AssignmentPairing($studentA, $studentB, $option, $earliestTime);
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:27,代码来源:RoommatePairingStrategy.php

示例10: execute

 public function execute()
 {
     PHPWS_Core::initModClass('hms', 'PdoFactory.php');
     $db = PdoFactory::getInstance()->getPdo();
     $query = "SELECT requestor, requestee from hms_roommate\n                  LEFT OUTER JOIN\n                    (select asu_username, hms_room.id as rmid\n                      FROM hms_assignment\n                      JOIN hms_bed ON hms_assignment.bed_id = hms_bed.id\n                      JOIN hms_room ON hms_bed.room_id = hms_room.id\n                      WHERE hms_assignment.term = :term)\n                as requestor_room_id ON requestor_room_id.asu_username = requestor\n                  LEFT OUTER JOIN\n                    (select asu_username, hms_room.id as rmid\n                      FROM hms_assignment\n                      JOIN hms_bed ON hms_assignment.bed_id = hms_bed.id\n                      JOIN hms_room ON hms_bed.room_id = hms_room.id\n                      WHERE hms_assignment.term = :term)\n                AS requestee_room_id ON requestee_room_id.asu_username = requestee\n                  WHERE hms_roommate.term = :term and confirmed = 1 AND\n                  requestor_room_id.rmid != requestee_room_id.rmid";
     // $query = "SELECT hms_assignment.term, hms_assignment.banner_id, hms_hall_structure.banner_building_code, hms_hall_structure.banner_id
     //             as bed_code, hms_new_application.meal_plan FROM hms_assignment
     //               JOIN hms_hall_structure ON
     //                 hms_assignment.bed_id = hms_hall_structure.bedid
     //               LEFT OUTER JOIN hms_new_application ON
     //                 (hms_assignment.banner_id = hms_new_application.banner_id
     //                 AND hms_assignment.term = hms_new_application.term)
     //               WHERE hms_assignment.term IN (:term) ORDER BY hms_assignment.term";
     $stmt = $db->prepare($query);
     $stmt->execute(array('term' => $this->term));
     $queryResult = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $result = array();
     $i = 0;
     foreach ($queryResult as $row) {
         $requestee = StudentFactory::getStudentByUsername($row['requestee'], $this->term);
         $requestor = StudentFactory::getStudentByUsername($row['requestor'], $this->term);
         $row['requestee_banner'] = $requestee->getBannerId();
         $row['requestor_banner'] = $requestor->getBannerId();
         $row['requestee_name'] = $requestee->getFullName();
         $row['requestor_name'] = $requestor->getFullName();
         $result[$i] = $row;
         $i++;
     }
     $this->data = $result;
     $this->mismatchCount = $i;
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:31,代码来源:MismatchedRoommates.php

示例11: __construct

 /**
  *
  * @param RoomChangeParticipant $participant The RoomChangeParticipant this view represents
  * @param RoomChangeRequest $request
  * @param array<RoomChangeParticipant> $participants All participants on this request
  */
 public function __construct(RoomChangeParticipant $participant, RoomChangeRequest $request, array $participants)
 {
     $this->participant = $participant;
     $this->request = $request;
     $this->participants = $participants;
     $this->student = StudentFactory::getStudentByBannerId($this->participant->getBannerId(), Term::getSelectedTerm());
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:13,代码来源:RoomChangeParticipantView.php

示例12: doSearch

 /**
  * Main searching function. Does the database lookup and then checks each student though the various functions.
  */
 public function doSearch()
 {
     // Clear all the caches
     StudentDataProvider::clearAllCache();
     $term = $this->term;
     $query = "select DISTINCT * FROM (select hms_new_application.username from hms_new_application WHERE term={$term} AND cancelled != 1 UNION select hms_assignment.asu_username from hms_assignment WHERE term={$term}) as foo";
     $result = PHPWS_DB::getCol($query);
     if (PHPWS_Error::logIfError($result)) {
         throw new Exception($result->toString());
     }
     foreach ($result as $username) {
         $student = null;
         try {
             $student = StudentFactory::getStudentByUsername($username, $term);
         } catch (Exception $e) {
             $this->actions[$username][] = 'WARNING!! Unknown student!';
             // Commenting out the NQ line, since this doesn't work when the search is run from cron/Pulse
             //NQ::simple('hms', hms\NotificationView::WARNING, 'Unknown student: ' . $username);
             continue;
         }
         if ($student->getType() != TYPE_WITHDRAWN && $student->getAdmissionDecisionCode() != ADMISSION_WITHDRAWN_PAID && $student->getAdmissionDecisionCode() != ADMISSION_RESCIND) {
             continue;
         }
         $this->actions[$username][] = $student->getBannerId() . ' (' . $student->getUsername() . ')';
         $this->withdrawnCount++;
         $this->handleApplication($student);
         $this->handleAssignment($student);
         $this->handleRoommate($student);
         $this->handleRlcAssignment($student);
         $this->handleRlcApplication($student);
     }
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:35,代码来源:WithdrawnSearch.php

示例13: execute

 public function execute(CommandContext $context)
 {
     $term = $context->get('term');
     if (!isset($term) || is_null($term) || empty($term)) {
         throw new InvalidArgumentException('Missing term.');
     }
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $feature = ApplicationFeature::getInstanceByNameAndTerm('RlcApplication', $term);
     // Make sure the RLC application feature is enabled
     if (is_null($feature) || !$feature->isEnabled()) {
         NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, RLC applications are not avaialable for this term.");
         $cmd->redirect();
     }
     // Check feature's deadlines
     if ($feature->getStartDate() > time()) {
         NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, it is too soon to fill out an RLC application.");
         $cmd->redirect();
     } else {
         if ($feature->getEndDate() < time()) {
             NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, the RLC application deadline has already passed. Please contact University Housing if you are interested in applying for a RLC.");
             $cmd->redirect();
         }
     }
     // Get the Student object
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), Term::getCurrentTerm());
     $view = new RlcApplicationPage1View($context, $student);
     $context->setContent($view->show());
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:28,代码来源:ShowRlcApplicationViewCommand.php

示例14: execute

 public function execute()
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     if (!isset($this->term) || is_null($this->term)) {
         throw new InvalidArgumentException('Missing term.');
     }
     $db = new PHPWS_DB('hms_new_application');
     $db->addColumn('banner_id');
     $db->addColumn('username');
     $db->addWhere('term', $this->term);
     $results = $db->select();
     if (empty($results)) {
         return;
     } elseif (PEAR::isError($results)) {
         throw new DatabaseException($results->toString());
     }
     $twentyFiveYearsAgo = strtotime("-25 years");
     foreach ($results as $student) {
         try {
             $sf = StudentFactory::getStudentByBannerId($student['banner_id'], $this->term);
             $dob = $sf->getDOB();
             if (strtotime($dob) > $twentyFiveYearsAgo) {
                 continue;
             }
             $student['dob'] = $dob;
             $student['full_name'] = $sf->getFullName();
             $this->all_rows[] = $student;
         } catch (Exception $e) {
             $student['dob'] = $student['full_name'] = null;
             $this->problems[] = $student['banner_id'];
         }
     }
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:33,代码来源:TwentyFive.php

示例15: execute

 public function execute(CommandContext $context)
 {
     $id = $context->get('roommateId');
     if (is_null($id)) {
         throw new InvalidArgumentException('Must set roommateId');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
     $roommate = new HMS_Roommate($id);
     if ($roommate->id = 0) {
         throw new InvalidArgumentException('Invalid roommateId ' . $id);
     }
     $username = UserStatus::getUsername();
     if ($username != $roommate->requestor && $username != $roommate->requestee) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException("{$username} tried to break roommate pairing {$roommate->id}");
     }
     PHPWS_Core::initCoreClass('Captcha.php');
     // get other roommate
     $other = StudentFactory::getStudentByUsername($roommate->get_other_guy($username), $roommate->term);
     $form = new PHPWS_Form();
     $cmd = CommandFactory::getCommand('RoommateBreak');
     $cmd->setRoommateId($id);
     $cmd->initForm($form);
     $form->addTplTag('CAPTCHA_IMAGE', Captcha::get());
     $form->addTplTag('NAME', $other->getFullName());
     $form->addSubmit('Confirm');
     $form->addCssClass('submit', 'btn btn-danger');
     $context->setContent(PHPWS_Template::process($form->getTemplate(), 'hms', 'student/roommate_break_confirm.tpl'));
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:29,代码来源:ShowRoommateBreakCommand.php


注:本文中的StudentFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。