Ejemplo n.º 1
0
 function majorJSONAction()
 {
     if (!isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
         return $this->redirect()->toUrl('/');
     }
     $this->layout("layout/user");
     $session = new Container('user');
     $username = $session->username;
     $uid = $session->userid;
     $major = $this->params()->fromPost('major');
     $finalMajor = $major;
     $finalMajor = $major;
     $starcount = 0;
     if ($major != '') {
         $starcount++;
     }
     $mode = $this->params()->fromPost('mode');
     $r = new RESTJSONManager();
     if ($mode == 'save') {
         $this->getPlanTable()->updateMajor($uid);
         $jsonRequest = array();
         $jsonRequest['error'] = null;
         $jsonRequest['errorCode'] = 0;
         $jsonRequest['errorLevel'] = 0;
         $jsonRequest['major'] = $finalMajor;
         $jsonRequest['starCount'] = $starcount;
         $jsonRequest['notes'] = array($this->params()->fromPost('note'));
         $jsonRequest['uid'] = $this->params()->fromPost('uid');
         $majorurl = Constants::PLAN_GET_MAJOR;
         $majorurl = str_replace("<UID>", $uid, $majorurl);
         $response = $r->PlanJSONManager('POST', $majorurl, $jsonRequest, $uid);
         $error = "";
         $ecode = "";
         $response = "";
         if ($jsonResponse->getStatusCode() == '200' || $jsonResponse->getStatusCode() == '201') {
             $response = json_decode($jsonResponse->getBody(), true);
             $ecode = isset($response['errorCode']) ? $response['errorCode'] : 0;
             $error = isset($response['error']) ? $response['error'] : "";
         } else {
             $ecode = "999";
             $error = "Backend API Error";
         }
     } elseif ($mode == 'update') {
         $jsonRequest = array();
         $jsonRequest['error'] = null;
         $jsonRequest['errorCode'] = 0;
         $jsonRequest['errorLevel'] = 0;
         $jsonRequest['major'] = $finalMajor;
         $jsonRequest['starCount'] = $starcount;
         $jsonRequest['notes'] = array($this->params()->fromPost('note'));
         $jsonRequest['uid'] = $this->params()->fromPost('uid');
         $majorurl = Constants::PLAN_GET_MAJOR;
         $majorurl = str_replace("<UID>", $uid, $majorurl);
         $response = $r->PlanJSONManager('PUT', $majorurl, $jsonRequest, $uid);
         $error = "";
         $ecode = "";
         $response = "";
         if ($jsonResponse->getStatusCode() == '200' || $jsonResponse->getStatusCode() == '201') {
             $response = json_decode($jsonResponse->getBody(), true);
             $ecode = isset($response['errorCode']) ? $response['errorCode'] : 0;
             $error = isset($response['error']) ? $response['error'] : "";
         } else {
             $ecode = "999";
             $error = "Backend API Error";
         }
     } else {
         $major = str_replace(" ", "%20", $major);
         $major = str_replace("/", '%252F', $major);
         $url = Constants::PLAN_GET_COLLEGE_BY_MAJOR;
         $url = str_replace("<MAJOR>", $major, $url);
         $jsonResponse = $r->PlanJSONManager('GET', $url, null, '');
         $error = "";
         $ecode = "";
         $response = "";
         if ($jsonResponse->getStatusCode() == '200' || $jsonResponse->getStatusCode() == '201') {
             $response = json_decode($jsonResponse->getBody(), true);
             $ecode = isset($response['errorCode']) ? $response['errorCode'] : 0;
             $error = isset($response['error']) ? $response['error'] : "";
         } else {
             $ecode = "999";
             $error = "Backend API Error";
         }
     }
     $resultret = new JsonModel(array('response' => json_decode($jsonResponse->getBody(), true), 'error' => $error, 'ecode' => $ecode, 'request' => $url));
     /*
      * $resultret = new JsonModel(array(
      *
      * 'response' =>$jsonResponse->__toString() ,'request'=>$url));
      */
     return $resultret;
 }
Ejemplo n.º 2
0
 function myuceazyAction()
 {
     $this->layout("layout/user");
     $session = new Container('user');
     $username = $session->username;
     $uid = $session->userid;
     if ($uid == '' || $uid == null) {
         return $this->redirect()->toUrl('/');
     }
     $planRow = $this->getPlanTable()->getPlanByUID($uid);
     $plangpaflag = "";
     foreach ($planRow as $plan) {
         $plangpaflag = $plan->mycounselor;
     }
     $result = array();
     $notes = "";
     $dreamschool = $this->params()->fromQuery('dreamschool');
     $r = new RESTJSONManager();
     $tmpSchoolName = str_replace(" ", "%20", $dreamschool);
     // $dreamschool=$tmpSchoolName;
     if ($dreamschool != null) {
     } else {
         if ($plangpaflag == 1) {
             $url = Constants::PLAN_MYUCEAZY_BASE_URL;
             $url = str_replace("<UID>", $uid, $url);
             $dreamresult = $r->PlanJSONManager('GET', $url, null, $uid);
             $decodeResponse = json_decode($dreamresult->getBody(), true);
             $dreamschool = $decodeResponse['dreamSchool'];
             $notes = $decodeResponse['notes'];
             $tmpSchoolName = str_replace(" ", "%20", $dreamschool);
         }
     }
     $decodeResponse = "";
     // Get School information
     $url = Constants::PLAN_SCHOOL_INFO_URL;
     $url = str_replace("<SCHOOL>", $tmpSchoolName, $url);
     // echo $url;
     $dreamresult = $r->PlanJSONManager('GET', $url, null, $uid);
     $schoolInfo = json_decode($dreamresult->getBody(), true);
     // var_dump($schoolInfo);
     $decodeResponse = "";
     $url = Constants::PLAN_MYUCEAZY_STUINFO;
     $url = str_replace("<UID>", $uid, $url);
     $result = $r->PlanJSONManager('GET', $url, null, $uid);
     $yourGPA = $result->getBody();
     $url = Constants::PLAN_GET_MAJOR;
     $url = str_replace("<UID>", $uid, $url);
     $result = $r->PlanJSONManager('GET', $url, null, $uid);
     $decodeResponse = json_decode($result->getBody(), true);
     $major = $decodeResponse['major'];
     $url = Constants::PLAN_MYUCEAZY_ELIGIBILITY;
     $url = str_replace("<UID>", $uid, $url);
     $jsonResponse = $r->PlanJSONManager('GET', $url, null, '');
     $cols = json_decode($jsonResponse->getBody(), true);
     $eligibleCourse = "";
     $url = Constants::PLAN_UCEAZY_ELIGIBLE_COURSE;
     $url = str_replace("<UID>", $uid, $url);
     $jsonResponse = $r->PlanJSONManager('GET', $url, null, '');
     $eligibleCourse = json_decode($jsonResponse->getBody(), true);
     $competitiveCourse = "";
     $url = Constants::PLAN_UCEAZY_COMPETITIVE_COURSES;
     $url = str_replace("<UID>", $uid, $url);
     $jsonResponse = $r->PlanJSONManager('GET', $url, null, '');
     $competitiveCourse = json_decode($jsonResponse->getBody(), true);
     $url = Constants::PLAN_UCEAZY_BEST_STD_TESTS;
     $url = str_replace("<UID>", $uid, $url);
     $jsonResponse = $r->PlanJSONManager('GET', $url, null, '');
     $bestScores = json_decode($jsonResponse->getBody(), true);
     $notification_data = $this->getNotifyData("all", $uid);
     $view = new ViewModel(array("competitiveCourse" => $competitiveCourse, "bestScores" => $bestScores, "dreamschool" => $dreamschool, 'schoolinfo' => $schoolInfo, 'eligibleCourse' => $eligibleCourse, 'yourgpa' => $yourGPA, 'major' => $major, 'cols' => $cols, "planflag" => $plangpaflag, 'uid' => $uid, 'note' => isset($notes[0]) ? $notes[0] : "", 'notification_data' => $notification_data));
     return $view;
 }
Ejemplo n.º 3
0
 function gpaJSONAction()
 {
     if (!isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
         return $this->redirect()->toUrl('/');
     }
     $this->layout("layout/user");
     $jsonRequest = array();
     $jsonRequest['error'] = null;
     $jsonRequest['errorCode'] = 0;
     $jsonRequest['errorLevel'] = 0;
     $mode = $this->params()->fromPost('mode');
     $uid = $this->params()->fromPost('uid');
     $jsonRequest['notes'] = array($this->params()->fromPost('note'));
     $jsonRequest['uid'] = $this->params()->fromPost('uid');
     if ($this->params()->fromPost('schoolname') == "") {
         $jsonRequest['schoolName'] = null;
     } else {
         $jsonRequest['schoolName'] = $this->params()->fromPost('schoolname');
     }
     $jsonRequest['previousSchoolNames'] = $this->params()->fromPost('previousSchoolNames');
     if ($this->params()->fromPost('county') == "-1") {
         $jsonRequest['county'] = null;
     } else {
         $jsonRequest['county'] = $this->params()->fromPost('county');
     }
     $jsonRequest['endDate'] = $this->params()->fromPost('year');
     $jsonRequest['stateName'] = $this->params()->fromPost('state');
     $jsonRequest['highSchoolCourses'] = array();
     $alla2g = $this->params()->fromPost('a2g');
     $totalSchoolInfo = count($this->params()->fromPost('a2g'));
     $i = 0;
     for ($index = 0; $index < $totalSchoolInfo; $index++) {
         $a2g = $alla2g[$index];
         $dynamicparameter9 = $alla2g[$index] . '_9_grade';
         $dynamicparameter10 = $alla2g[$index] . '_10_grade';
         $dynamicparameter11 = $alla2g[$index] . '_11_grade';
         $dynamicparameter12 = $alla2g[$index] . '_12_grade';
         // Loop for 9th grade
         for ($tmp = 0; $tmp < count($this->params()->fromPost($dynamicparameter9)); $tmp++) {
             $dynamiccname = $a2g . '_9_cname';
             $dynamicgradesem1 = $a2g . '_9_gradesem1';
             $dynamicgradesem2 = $a2g . '_9_gradesem2';
             $dynamicgradesem3 = $a2g . '_9_gradesem3';
             $dynamiclevel = $a2g . '_9_level';
             $dynamiccredit = $a2g . '_9_credit';
             $cname = $this->params()->fromPost($dynamiccname);
             $gradesem1 = $this->params()->fromPost($dynamicgradesem1);
             $gradesem2 = $this->params()->fromPost($dynamicgradesem2);
             $gradesem3 = $this->params()->fromPost($dynamicgradesem3);
             $level = $this->params()->fromPost($dynamiclevel);
             $credit = $this->params()->fromPost($dynamiccredit);
             if ($cname[$tmp] != '' || $level[$tmp] != "" || $gradesem1[$tmp] != 'Select' || $gradesem2[$tmp] != 'Select' || $gradesem3[$tmp] != 'Select' || $credit[$tmp] != '') {
                 $jsonRequest['highSchoolCourses'][$i] = array('year' => '', 'subject' => $cname[$tmp], 'a2g' => $a2g, 'grade' => '9', 'subjectCode' => '', 'level' => $level[$tmp], 'sem1Grade' => $gradesem1[$tmp], 'sem2Grade' => $gradesem2[$tmp], 'sem3Grade' => $gradesem3[$tmp], 'credit' => $credit[$tmp]);
                 $i++;
             }
         }
         // Loop for 10 grade
         for ($tmp = 0; $tmp < count($this->params()->fromPost($dynamicparameter10)); $tmp++) {
             $dynamiccname = $a2g . '_10_cname';
             $dynamicgradesem1 = $a2g . '_10_gradesem1';
             $dynamicgradesem2 = $a2g . '_10_gradesem2';
             $dynamicgradesem3 = $a2g . '_10_gradesem3';
             $dynamiclevel = $a2g . '_10_level';
             $dynamiccredit = $a2g . '_10_credit';
             $cname = $this->params()->fromPost($dynamiccname);
             $gradesem1 = $this->params()->fromPost($dynamicgradesem1);
             $gradesem2 = $this->params()->fromPost($dynamicgradesem2);
             $gradesem3 = $this->params()->fromPost($dynamicgradesem3);
             $level = $this->params()->fromPost($dynamiclevel);
             $credit = $this->params()->fromPost($dynamiccredit);
             if ($cname[$tmp] != '' || $level[$tmp] != "" || $gradesem1[$tmp] != 'Select' || $gradesem2[$tmp] != 'Select' || $gradesem2[$tmp] != 'Select' || $credit[$tmp] != '') {
                 $jsonRequest['highSchoolCourses'][$i] = array('year' => '', 'subject' => $cname[$tmp], 'a2g' => $a2g, 'grade' => '10', 'subjectCode' => '', 'level' => $level[$tmp], 'sem1Grade' => $gradesem1[$tmp], 'sem2Grade' => $gradesem2[$tmp], 'sem3Grade' => $gradesem3[$tmp], 'credit' => $credit[$tmp]);
                 $i++;
             }
         }
         // Loop for 11 grade
         for ($tmp = 0; $tmp < count($this->params()->fromPost($dynamicparameter11)); $tmp++) {
             $dynamiccname = $a2g . '_11_cname';
             $dynamicgradesem1 = $a2g . '_11_gradesem1';
             $dynamicgradesem2 = $a2g . '_11_gradesem2';
             $dynamicgradesem3 = $a2g . '_11_gradesem3';
             $dynamiclevel = $a2g . '_11_level';
             $dynamiccredit = $a2g . '_11_credit';
             $cname = $this->params()->fromPost($dynamiccname);
             $gradesem1 = $this->params()->fromPost($dynamicgradesem1);
             $gradesem2 = $this->params()->fromPost($dynamicgradesem2);
             $gradesem3 = $this->params()->fromPost($dynamicgradesem3);
             $level = $this->params()->fromPost($dynamiclevel);
             $credit = $this->params()->fromPost($dynamiccredit);
             if ($cname[$tmp] != '' || $level[$tmp] != "" || $gradesem1[$tmp] != 'Select' || $gradesem2[$tmp] != 'Select' || $gradesem2[$tmp] != 'Select' || $credit[$tmp] != '') {
                 $jsonRequest['highSchoolCourses'][$i] = array('year' => '', 'subject' => $cname[$tmp], 'a2g' => $a2g, 'grade' => '11', 'subjectCode' => '', 'level' => $level[$tmp], 'sem1Grade' => $gradesem1[$tmp], 'sem2Grade' => $gradesem2[$tmp], 'sem3Grade' => $gradesem3[$tmp], 'credit' => $credit[$tmp]);
                 $i++;
             }
         }
         // Loop for 12 grade
         for ($tmp = 0; $tmp < count($this->params()->fromPost($dynamicparameter12)); $tmp++) {
             $dynamiccname = $a2g . '_12_cname';
             $dynamicgradesem1 = $a2g . '_12_gradesem1';
             $dynamicgradesem2 = $a2g . '_12_gradesem2';
             $dynamicgradesem3 = $a2g . '_12_gradesem3';
             $dynamiclevel = $a2g . '_12_level';
             $dynamiccredit = $a2g . '_12_credit';
             $cname = $this->params()->fromPost($dynamiccname);
             $gradesem1 = $this->params()->fromPost($dynamicgradesem1);
             $gradesem2 = $this->params()->fromPost($dynamicgradesem2);
             $gradesem3 = $this->params()->fromPost($dynamicgradesem3);
             $level = $this->params()->fromPost($dynamiclevel);
             $credit = $this->params()->fromPost($dynamiccredit);
             if ($cname[$tmp] != '' || $level[$tmp] != "" || $gradesem1[$tmp] != 'Select' || $gradesem2[$tmp] != 'Select' || $gradesem2[$tmp] != 'Select' || $credit[$tmp] != '') {
                 $jsonRequest['highSchoolCourses'][$i] = array('year' => '', 'subject' => $cname[$tmp], 'a2g' => $a2g, 'grade' => '12', 'subjectCode' => '', 'level' => $level[$tmp], 'sem1Grade' => $gradesem1[$tmp], 'sem2Grade' => $gradesem2[$tmp], 'sem3Grade' => $gradesem3[$tmp], 'credit' => $credit[$tmp]);
                 $i++;
             }
         }
     }
     $jsonRequest['commCollegeCourses'] = array();
     $commCollCount = count($this->params()->fromPost("ccollegename"));
     $cunits = $this->params()->fromPost('cunits');
     $ccollegename = $this->params()->fromPost('ccollegename');
     $cstate = $this->params()->fromPost('cstate');
     $ccoursename = $this->params()->fromPost('ccoursename');
     $cgrade = $this->params()->fromPost('cgrade');
     $ctrems = $this->params()->fromPost('ctrems');
     $cyear = $this->params()->fromPost('cyear');
     // echo "--->".$commCollCount;
     // $cgrade[$tmp];
     for ($tmp = 0; $tmp < $commCollCount; $tmp++) {
         $sem1 = "";
         $sem2 = "";
         $sem3 = "";
         if ($ctrems[$tmp] == 'Fall') {
             $sem1 = $cgrade[$tmp];
         } else {
             if ($ctrems[$tmp] == 'Winter') {
                 $sem2 = $cgrade[$tmp];
             } else {
                 if ($ctrems[$tmp] == 'Summer') {
                     $sem3 = $cgrade[$tmp];
                 } else {
                     if ($ctrems[$tmp] == 'Select') {
                         $sem1 = $cgrade[$tmp];
                     } else {
                         $sem1 = $cgrade[$tmp];
                     }
                 }
             }
         }
         if ($cyear[$tmp] != 'Select' || $ccoursename[$tmp] != '' || $cgrade[$tmp] != 'Select' || $ccollegename[$tmp] != '' || $cunits[$tmp] != '' || $ctrems[$tmp] != 'Select') {
             $jsonRequest['commCollegeCourses'][$tmp] = array("state" => $cstate[$tmp], "year" => $cyear[$tmp], "subject" => $ccoursename[$tmp], "a2g" => "", "grade" => 0, "subjectCode" => "", "sem1Grade" => $sem1, "sem2Grade" => $sem2, "sem3Grade" => $sem3, "level" => "", "collegeName" => $ccollegename[$tmp], "units" => $cunits[$tmp], "term" => 0);
         }
     }
     //
     //
     $planjson = new RESTJSONManager();
     $jsonResponse = "";
     if ($mode == "update") {
         $url = Constants::PLAN_GPA_BASE_URL;
         $url = str_replace("<UID>", $uid, $url);
         $this->LogMessage(json_encode($jsonRequest));
         $jsonResponse = $planjson->PlanJSONManager('PUT', $url, json_encode($jsonRequest), $uid);
         $this->LogMessage($jsonResponse);
     } elseif ($mode == "save") {
         $this->LogMessage(json_encode($jsonRequest));
         $this->getPlanTable()->updateGPA($uid);
         $url = Constants::PLAN_GPA_BASE_URL;
         $url = str_replace("<UID>", $uid, $url);
         $this->LogMessage(json_encode($jsonRequest));
         $jsonResponse = $planjson->PlanJSONManager('POST', $url, json_encode($jsonRequest), $uid);
         $this->LogMessage($jsonResponse);
     } elseif ($mode == "gpacalc") {
         $url = Constants::PLAN_GPA_BASE_URL;
         $url = str_replace("<UID>", $uid, $url);
         $jsonResponse = $planjson->PlanJSONManager('POST', $url, json_encode($jsonRequest), $uid);
         $url = Constants::PLAN_GPA_CALC_GENERAL;
         $url = str_replace("<UID>", $uid, $url);
         $jsonResponse = $planjson->PlanJSONManager('GET', $url, null, $uid);
     } elseif ($mode == "gpaweight_csu") {
         $url = Constants::PLAN_GPA_BASE_URL;
         $url = str_replace("<UID>", $uid, $url);
         $jsonResponse = $planjson->PlanJSONManager('POST', $url, json_encode($jsonRequest), $uid);
         $url = Constants::PLAN_GPA_CALC_CSU;
         $url = str_replace("<UID>", $uid, $url);
         $jsonResponse = $planjson->PlanJSONManager('GET', $url, json_encode($jsonRequest), $uid);
     } elseif ($mode == "gpaweight_uc") {
         $url = Constants::PLAN_GPA_BASE_URL;
         $url = str_replace("<UID>", $uid, $url);
         $jsonResponse = $planjson->PlanJSONManager('POST', $url, json_encode($jsonRequest), $uid);
         $url = Constants::PLAN_GPA_CALC_UC;
         $url = str_replace("<UID>", $uid, $url);
         $jsonResponse = $planjson->PlanJSONManager('GET', $url, json_encode($jsonRequest), $uid);
     }
     $error = "";
     $ecode = "";
     $response = "";
     if ($jsonResponse != null) {
         if ($jsonResponse->getStatusCode() == '200' || $jsonResponse->getStatusCode() == '201') {
             $response = json_decode($jsonResponse->getBody(), true);
             $ecode = $response['errorCode'];
             $error = $response['error'];
         } else {
             $ecode = "999";
             $error = "Backend API Error";
         }
         $resultret = new JsonModel(array('response' => json_decode($jsonResponse->getBody(), true), 'url' => $url, 'error' => $error, 'ecode' => $ecode, 'request' => json_encode($jsonRequest)));
     } else {
         $resultret = new JsonModel(array('response' => "", 'error' => "Access error", 'ecode' => $ecode, 'request' => json_encode($jsonRequest)));
     }
     return $resultret;
 }