コード例 #1
0
 public function calender()
 {
     $StartDateArray = strptime(Input::get('start'), '%Y-%m-%d');
     $sStartDateTimeStamp = mktime(0, 0, 0, $StartDateArray['tm_mon'] + 1, $StartDateArray['tm_mday'], $StartDateArray['tm_year'] + 1900);
     $EndDateArray = strptime(Input::get('end'), '%Y-%m-%d');
     $sEndDateTimeStamp = mktime(0, 0, 0, $EndDateArray['tm_mon'] + 1, $EndDateArray['tm_mday'], $EndDateArray['tm_year'] + 1900);
     $daysArray = $this->GetDays(Input::get('start'), Input::get('end'));
     $toReturn = array();
     if ($this->data['users']->role == "admin") {
         $assignments = assignments::whereIn('AssignDeadLine', $daysArray)->get();
     } elseif ($this->data['users']->role == "teacher") {
         $assignments = assignments::whereIn('AssignDeadLine', $daysArray)->where('teacherId', $this->data['users']->id)->get();
     } elseif ($this->data['users']->role == "student") {
         $assignments = assignments::whereIn('AssignDeadLine', $daysArray)->where('classId', 'like', '%"' . $this->data['users']->studentClass . '"%')->get();
     }
     if (isset($assignments)) {
         foreach ($assignments as $event) {
             $eventsArray['id'] = $event->id;
             $eventsArray['title'] = "Assignment : " . $event->AssignTitle;
             $eventsArray['start'] = date("c", strtotime($event->AssignDeadLine));
             $eventsArray['backgroundColor'] = 'green';
             $eventsArray['textColor'] = '#fff';
             $eventsArray['url'] = "#assignments";
             $eventsArray['allDay'] = true;
             $toReturn[] = $eventsArray;
         }
     }
     $events = events::whereIn('eventDate', $daysArray)->where('eventFor', $this->data['users']->role)->orWhere('eventFor', 'all')->get();
     foreach ($events as $event) {
         $eventsArray['id'] = $event->id;
         $eventsArray['title'] = "Event : " . $event->eventTitle;
         $eventsArray['start'] = date("c", strtotime($event->eventDate));
         $eventsArray['backgroundColor'] = 'blue';
         $eventsArray['url'] = "#events/" . $event->id;
         $eventsArray['textColor'] = '#fff';
         $eventsArray['allDay'] = true;
         $toReturn[] = $eventsArray;
     }
     $examsList = examsList::whereIn('examDate', $daysArray)->get();
     foreach ($examsList as $event) {
         $eventsArray['id'] = $event->id;
         $eventsArray['title'] = "Exam : " . $event->examTitle;
         $eventsArray['start'] = date("c", strtotime($event->examDate));
         $eventsArray['backgroundColor'] = 'red';
         $eventsArray['url'] = "#examsList";
         $eventsArray['textColor'] = '#fff';
         $eventsArray['allDay'] = true;
         $toReturn[] = $eventsArray;
     }
     $newsboard = newsboard::where('creationDate', '>=', $sStartDateTimeStamp)->where('creationDate', '<=', $sEndDateTimeStamp)->where('newsFor', $this->data['users']->role)->orWhere('newsFor', 'all')->get();
     foreach ($newsboard as $event) {
         $eventsArray['id'] = $event->id;
         $eventsArray['title'] = "News : " . $event->newsTitle;
         $eventsArray['start'] = date("c", $event->creationDate);
         $eventsArray['url'] = "#newsboard/" . $event->id;
         $eventsArray['backgroundColor'] = 'white';
         $eventsArray['textColor'] = '#000';
         $eventsArray['allDay'] = true;
         $toReturn[] = $eventsArray;
     }
     if ($this->data['users']->role == "admin") {
         $onlineExams = onlineExams::where('examDate', '>=', $sStartDateTimeStamp)->where('ExamEndDate', '<=', $sEndDateTimeStamp)->get();
     } elseif ($this->data['users']->role == "teacher") {
         $onlineExams = onlineExams::where('examDate', '>=', $sStartDateTimeStamp)->where('ExamEndDate', '<=', $sEndDateTimeStamp)->where('examTeacher', $this->data['users']->id)->get();
     } elseif ($this->data['users']->role == "student") {
         $onlineExams = onlineExams::where('examDate', '>=', $sStartDateTimeStamp)->where('ExamEndDate', '<=', $sEndDateTimeStamp)->where('examClass', 'like', '%"' . $this->data['users']->studentClass . '"%')->get();
     }
     if (isset($onlineExams)) {
         foreach ($onlineExams as $event) {
             $eventsArray['id'] = $event->id;
             $eventsArray['title'] = "Online Exam : " . $event->examTitle;
             $eventsArray['start'] = date("c", strtotime($event->examDate));
             $eventsArray['backgroundColor'] = 'red';
             $eventsArray['url'] = "#onlineExams";
             $eventsArray['textColor'] = '#000';
             $eventsArray['allDay'] = true;
             $toReturn[] = $eventsArray;
         }
     }
     return $toReturn;
 }
コード例 #2
0
ファイル: UsersController.php プロジェクト: schoex/Campusmate
 function marksheet($id)
 {
     $marks = array();
     $examsList = examsList::get();
     $examMarks = examMarks::where('studentId', $id)->get();
     if (count($examMarks) == 0) {
         return json_encode(array("jsTitle" => $this->panelInit->language['Marksheet'], "jsStatus" => "0", "jsMessage" => $this->panelInit->language['studentHaveNoMarks']));
         exit;
     }
     $subject = subject::get();
     $gradeLevels = gradeLevels::get();
     $examArray = array();
     foreach ($examsList as $exam) {
         $marks[$exam->id] = array("title" => $exam->examTitle);
     }
     $subjectArray = array();
     foreach ($subject as $sub) {
         $subjectArray[$sub->id] = $sub->subjectTitle;
     }
     $gradeLevelsArray = array();
     foreach ($gradeLevels as $grade) {
         $gradeLevelsArray[$grade->gradeName] = array('from' => $grade->gradeFrom, "to" => $grade->gradeTo, "points" => $grade->gradePoints);
     }
     foreach ($examMarks as $mark) {
         if (!isset($marks[$mark->examId]['counter'])) {
             $marks[$mark->examId]['counter'] = 0;
             $marks[$mark->examId]['points'] = 0;
             $marks[$mark->examId]['totalMarks'] = 0;
         }
         $marks[$mark->examId]['counter']++;
         $marks[$mark->examId]['data'][$mark->id]['subjectName'] = $subjectArray[$mark->subjectId];
         $marks[$mark->examId]['data'][$mark->id]['subjectId'] = $mark->subjectId;
         $marks[$mark->examId]['data'][$mark->id]['examMark'] = $mark->examMark;
         $marks[$mark->examId]['data'][$mark->id]['attendanceMark'] = $mark->attendanceMark;
         $marks[$mark->examId]['data'][$mark->id]['markComments'] = $mark->markComments;
         while (list($key, $value) = each($gradeLevelsArray)) {
             if ($mark->examMark > $value['from'] and $mark->examMark < $value['to']) {
                 $marks[$mark->examId]['points'] += $value['points'];
                 $marks[$mark->examId]['data'][$mark->id]['grade'] = $key;
                 $marks[$mark->examId]['totalMarks'] += $mark->examMark;
                 break;
             }
         }
     }
     while (list($key, $value) = each($marks)) {
         if (isset($value['points']) and $value['counter']) {
             $marks[$key]['pointsAvg'] = $value['points'] / $value['counter'];
         }
     }
     return $marks;
     exit;
 }
コード例 #3
0
 function notifications($id)
 {
     if ($this->data['users']->role != "admin") {
         exit;
     }
     if ($this->panelInit->settingsArray['examDetailsNotif'] == "0") {
         return json_encode(array("jsTitle" => $this->panelInit->language['examDetailsNot'], "jsMessage" => $this->panelInit->language['adjustExamNot']));
     }
     $examsList = examsList::where('id', $id)->first();
     $subjectArray = array();
     $subject = subject::get();
     foreach ($subject as $value) {
         $subjectArray[$value->id] = $value->subjectTitle;
     }
     $usersArray = array();
     if ($this->data['panelInit']->settingsArray['examDetailsNotifTo'] == "parent" || $this->data['panelInit']->settingsArray['examDetailsNotifTo'] == "both") {
         $users = User::where('role', 'student')->orWhere('role', 'parent')->get();
     } else {
         $users = User::where('role', 'student')->get();
     }
     foreach ($users as $value) {
         if ($value->parentOf == "" and $value->role == "parent") {
             continue;
         }
         if (!isset($usersArray[$value->id])) {
             $usersArray[$value->id] = array();
         }
         if ($value->parentOf != "") {
             $value->parentOf = json_decode($value->parentOf);
             if (!is_array($value->parentOf)) {
                 continue;
             }
             if (count($value->parentOf) > 0) {
                 $usersArray[$value->id]['parents'] = array();
             }
             foreach ($value->parentOf as $parentOf) {
                 $usersArray[$parentOf->id]['parents'][$value->id] = array('username' => $value->username, "email" => $value->email, "fullName" => $value->fullName, "mobileNo" => $value->mobileNo);
             }
         }
         $usersArray[$value->id]['student'] = array('username' => $value->username, "studentRollId" => $value->studentRollId, "mobileNo" => $value->mobileNo, "email" => $value->email, "fullName" => $value->fullName);
     }
     $return['marks'] = array();
     $examMarks = examMarks::where('examId', $id)->get();
     foreach ($examMarks as $value) {
         if (!isset($return['marks'][$value->studentId])) {
             $return['marks'][$value->studentId] = array();
         }
         if (isset($subjectArray[$value->subjectId])) {
             $return['marks'][$value->studentId][$subjectArray[$value->subjectId]] = array("examMark" => $value->examMark, "attendanceMark" => $value->attendanceMark, "markComments" => $value->markComments);
         }
     }
     $mailTemplate = mailsmsTemplates::where('templateTitle', 'Exam Details')->first();
     if ($this->panelInit->settingsArray['examDetailsNotif'] == "mail" || $this->panelInit->settingsArray['examDetailsNotif'] == "mailsms") {
         $mail = true;
     }
     if ($this->panelInit->settingsArray['examDetailsNotif'] == "sms" || $this->panelInit->settingsArray['examDetailsNotif'] == "mailsms") {
         $sms = true;
     }
     $sms = true;
     $MailSmsHandler = new MailSmsHandler();
     while (list($key, $value) = each($return['marks'])) {
         if (isset($mail)) {
             $studentTemplate = $mailTemplate->templateMail;
             $examGradesTable = "";
             while (list($keyG, $valueG) = each($value)) {
                 if ($valueG['examMark'] == "" and $valueG['attendanceMark'] == "") {
                     continue;
                 }
                 $examGradesTable .= $keyG . " Grade : " . $valueG['examMark'] . " - Attendance : " . $valueG['attendanceMark'] . " - Comments : " . $valueG['markComments'] . "<br/>";
             }
             if ($examGradesTable == "") {
                 continue;
             }
             $searchArray = array("{studentName}", "{studentRoll}", "{studentEmail}", "{studentUsername}", "{examTitle}", "{examDescription}", "{examDate}", "{schoolTitle}", "{examGradesTable}");
             $replaceArray = array($usersArray[$key]['student']['fullName'], $usersArray[$key]['student']['studentRollId'], $usersArray[$key]['student']['email'], $usersArray[$key]['student']['username'], $examsList->examTitle, $examsList->examDescription, $examsList->examDate, $this->panelInit->settingsArray['siteTitle'], $examGradesTable);
             $studentTemplate = str_replace($searchArray, $replaceArray, $studentTemplate);
             $MailSmsHandler->mail($usersArray[$key]['student']['email'], "Exam grade details", $studentTemplate, $usersArray[$key]['student']['fullName']);
             if (isset($usersArray[$key]['parents'])) {
                 while (list($keyP, $valueP) = each($usersArray[$key]['parents'])) {
                     //	$MailSmsHandler->mail($valueP['email'],"Exam grade details",$studentTemplate,$usersArray[$key]['student']['fullName']);
                 }
             }
         }
         if (isset($sms)) {
             $studentTemplate = $mailTemplate->templateSMS;
             $examGradesTable = "";
             reset($value);
             while (list($keyG, $valueG) = each($value)) {
                 if ($valueG['examMark'] == "" and $valueG['attendanceMark'] == "") {
                     continue;
                 }
                 $examGradesTable .= $keyG . " Grade : " . $valueG['examMark'] . " - Attendance : " . $valueG['attendanceMark'] . " ";
             }
             if ($examGradesTable == "") {
                 continue;
             }
             $searchArray = array("{studentName}", "{studentRoll}", "{studentEmail}", "{studentUsername}", "{examTitle}", "{examDescription}", "{examDate}", "{schoolTitle}", "{examGradesTable}");
             $replaceArray = array($usersArray[$key]['student']['fullName'], $usersArray[$key]['student']['studentRollId'], $usersArray[$key]['student']['email'], $usersArray[$key]['student']['username'], $examsList->examTitle, $examsList->examDescription, $examsList->examDate, $this->panelInit->settingsArray['siteTitle'], $examGradesTable);
             $studentTemplate = str_replace($searchArray, $replaceArray, $studentTemplate);
             if ($usersArray[$key]['student']['mobileNo'] != "") {
                 $MailSmsHandler->sms($usersArray[$key]['student']['mobileNo'], $studentTemplate);
             }
             if (isset($usersArray[$key]['parents'])) {
                 reset($usersArray[$key]['parents']);
                 while (list($keyP, $valueP) = each($usersArray[$key]['parents'])) {
                     if (trim($valueP['mobileNo']) != "") {
                         $MailSmsHandler->sms($valueP['mobileNo'], $studentTemplate);
                     }
                 }
             }
         }
     }
     return $this->panelInit->apiOutput(true, $this->panelInit->language['examDetailsNot'], $this->panelInit->language['examNotSent']);
 }