@@ -45,8 +45,7 @@ class WebServiceDataProvider extends StudentDataProvider {
4545 /**
4646 * @param string $currentUserName - Username of the user currently logged in. Will be sent to web service
4747 */
48- public function __construct ($ currentUserName )
49- {
48+ public function __construct ($ currentUserName ){
5049 $ this ->currentUserName = $ currentUserName ;
5150
5251 // Get the WSDL URI from module's settings
@@ -58,8 +57,7 @@ public function __construct($currentUserName)
5857 * Returns a Student object with hard-coded data
5958 * @return \Intern\Student
6059 */
61- public function getStudent ($ studentId )
62- {
60+ public function getStudent ($ studentId ){
6361 if ($ studentId === null || $ studentId == '' ){
6462 throw new \InvalidArgumentException ('Missing student ID. ' );
6563 }
@@ -93,20 +91,22 @@ public function getStudent($studentId)
9391 // Log the request
9492 $ this ->logRequest ('getStudent ' , 'success ' , $ params );
9593
96- // Create the Student object and plugin the values
97- $ student = new Student ();
98- $ this ->plugStudentValues ($ student , $ result );
99-
94+ // Create the Student object and plugin the values, Full check for missing data
95+ try {
96+ $ student = new Student ();
97+ $ this ->plugStudentValues ($ student , $ result );
98+ }
99+ catch (\Exception $ e ) {
100+ throw new \Intern \Exception \StudentNotFoundException ("Missing student data: $ studentId " );
101+ }
100102 return $ student ;
101103 }
102104
103- protected function sendRequest (Array $ params )
104- {
105+ protected function sendRequest (Array $ params ){
105106 return $ this ->client ->GetInternInfo ($ params );
106107 }
107108
108- public function getCreditHours (string $ studentId , string $ term )
109- {
109+ public function getCreditHours (string $ studentId , string $ term ){
110110 if ($ studentId === null || $ studentId == '' ){
111111 throw new \InvalidArgumentException ('Missing student ID. ' );
112112 }
@@ -139,8 +139,7 @@ public function getCreditHours(string $studentId, string $term)
139139 }
140140 }
141141
142- public function getFacultyMember ($ facultyId )
143- {
142+ public function getFacultyMember ($ facultyId ){
144143 if ($ facultyId === null || $ facultyId == '' ){
145144 throw new \InvalidArgumentException ('Missing student ID. ' );
146145 }
@@ -181,33 +180,35 @@ public function getFacultyMember($facultyId)
181180 * @param Student $student
182181 * @param stdClass $data
183182 */
184- protected function plugStudentValues (&$ student , \stdClass $ data )
185- {
183+ protected function plugStudentValues (&$ student , \stdClass $ data ){
186184 /**********************
187185 * Basic Demographics *
188186 **********************/
189187 $ student ->setStudentId ($ data ->bannerID );
190188 $ student ->setUsername ($ data ->userName );
191-
192189 $ student ->setFirstName ($ data ->firstName );
193- $ student ->setMiddleName ($ data ->middleName );
190+ if (isset ($ data ->middleName )){
191+ $ student ->setMiddleName ($ data ->middleName );
192+ }
194193 $ student ->setLastName ($ data ->lastName );
195- $ student ->setPreferredName ($ data ->preferredName );
194+ if (isset ($ data ->preferredName )){
195+ $ student ->setPreferredName ($ data ->preferredName );
196+ }
196197
197- if ($ data ->confidential === 'N ' ) {
198+ if (isset ( $ data -> confidential ) && $ data ->confidential === 'N ' ) {
198199 $ student ->setConfidentialFlag (false );
199200 } else {
200201 $ student ->setConfidentialFlag (true );
201202 }
202203
203204 // Person type flags
204- if ($ data ->isStudent == 1 ){
205+ if (isset ( $ data -> isStudent ) && $ data ->isStudent == 1 ){
205206 $ student ->setStudentFlag (true );
206207 } else {
207208 $ student ->setStudentFlag (false );
208209 }
209210
210- if ($ data ->isStaff == 1 ){
211+ if (isset ( $ data -> isStaff ) && $ data ->isStaff == 1 ){
211212 $ student ->setStaffFlag (true );
212213 } else {
213214 $ student ->setStaffFlag (false );
@@ -218,10 +219,10 @@ protected function plugStudentValues(&$student, \stdClass $data)
218219 *****************/
219220
220221 // Campus
221- if ($ data ->campusDescription == WebServiceDataProvider::MAIN_CAMPUS ) {
222+ if (isset ( $ data -> campusDescription ) && $ data ->campusDescription == WebServiceDataProvider::MAIN_CAMPUS ) {
222223 // If campus is 'Main Campus', then we know it's a main campus student
223224 $ student ->setCampus (Student::MAIN_CAMPUS );
224- } else if ($ data ->campusDescription != '' ) {
225+ } else if (isset ( $ data -> campusDescription ) && $ data ->campusDescription != '' ) {
225226 // If the campus is set, but is not 'Main Campus', then we know it's some other campus name (e.g. "Catawba EdD EdLead")
226227 // We're not going to check for every possible campus name; as long as there's *something* there, we'll assume it's distance ed
227228 $ student ->setCampus (Student::DISTANCE_ED );
@@ -233,9 +234,9 @@ protected function plugStudentValues(&$student, \stdClass $data)
233234 }
234235
235236 // Check if level exist, if not add it
236- if (LevelFactory::checkLevelExist ($ data ->studentLevel ) && $ student ->getStudentFlag ()){
237+ if (isset ( $ data -> studentLevel ) && LevelFactory::checkLevelExist ($ data ->studentLevel ) && $ student ->getStudentFlag ()){
237238 $ student ->setLevel ($ data ->studentLevel );
238- } else if ($ student ->getStudentFlag ()) {
239+ } else if (isset ( $ data -> studentLevel ) && $ student ->getStudentFlag ()) {
239240 $ newLevel = LevelFactory::saveNewCode ($ data ->studentLevel );
240241 $ student ->setLevel ($ newLevel );
241242 }
@@ -255,12 +256,14 @@ protected function plugStudentValues(&$student, \stdClass $data)
255256 // Grad date, if available
256257 if (isset ($ data ->gradDate ) && $ data ->gradDate != '' ) {
257258 $ student ->setGradDateFromString ($ data ->gradDate );
258- } else if (isset ($ data ->gradYear ) && $ data ->gradYear != '' ) {
259+ } /* else if(isset($data->gradYear) && $data->gradYear != '') {
259260 $student->setGradDateFromString($data->gradYear);
260- }
261+ }*/
261262
262263 // Contact info
263- $ student ->setPhone ($ data ->phoneNumber );
264+ if (isset ($ data ->phoneNumber )){
265+ $ student ->setPhone ($ data ->phoneNumber );
266+ }
264267 }
265268
266269 /**
@@ -289,8 +292,7 @@ protected function plugFacultyValues(\stdClass $data) {
289292 /**
290293 * Logs this request to PHPWS' curlapi.log file
291294 */
292- private function logRequest ($ functionName , $ result , Array $ params )
293- {
295+ private function logRequest ($ functionName , $ result , Array $ params ) {
294296 $ args = implode (', ' , $ params );
295297 $ msg = "$ functionName( $ args) result: $ result " ;
296298 \PHPWS_Core::log ($ msg , 'curlapi.log ' , 'CURLAPI ' );
0 commit comments