private function getSubjects()
 {
     $subjects = SubjectQuery::create()->orderByName()->find();
     $subjects_arr = ['' => ''];
     foreach ($subjects as $subject) {
         $name = $subject->__toString();
         $id = $subject->getId();
         $subjects_arr[$id] = $name;
     }
     return $subjects_arr;
 }
 /**
  * Create Subject query.
  *
  */
 protected function createQuery($array, $search)
 {
     $this->subjects = SubjectQuery::create()->orderByCode();
     if (isset($array['Name']) && $array['Name'] !== "") {
         $this->subjects->where("subject.name like '%" . $array['Name'] . "%'");
     }
     if (isset($array['Code']) && $array['Code'] !== "") {
         $this->subjects->where("subject.code like '%" . $array['Code'] . "%'");
     }
     if ($search) {
         session(['subject_filter' => $array]);
     }
 }
 private function getSubjects($status)
 {
     $subjects = SubjectQuery::create()->orderByName();
     if ($status === 'professor') {
         $subjects->joinEngagement();
         $subjects->where('Engagement.professor_id = ?', \Auth::user()->getProfessorId());
     } else {
         if ($status === 'student') {
             $subjects->joinStudyProgram();
             $subjects->where('StudyProgram.course_id = ?', \Auth::user()->getStudent()->getCourseId());
         }
     }
     $subjects->find();
     $subjects_arr = ['' => ''];
     foreach ($subjects as $subject) {
         $name = $subject->__toString();
         $id = $subject->getId();
         $subjects_arr[$id] = $name;
     }
     return $subjects_arr;
 }
 public function getApplications($subject_id, $school_year_id, $course_id)
 {
     $subject = SubjectQuery::create()->findPk($subject_id);
     $course = CourseQuery::create()->findPk($course_id);
     $schoolYear = SchoolYearQuery::create()->findPk($school_year_id);
     $applications = ApplicationQuery::create()->where('Application.subject_id = ?', $subject_id)->where('Application.school_year_id = ?', $school_year_id)->join('Application.Student')->join('Application.Period')->where('Student.course_id = ?', $course_id)->select(['Student.FirstName', 'Student.LastName', 'Student.CourseId', 'Period.Name', 'ApplicationDate', 'ExamDate', 'ExamTime', 'ExamScore'])->find();
     //dd($applications);
     $applications_arr = [];
     $cnt = 0;
     foreach ($applications as $key => $application) {
         $professor = $this->getProfessorName($subject_id, $application['Student.CourseId'], $school_year_id);
         $applications_arr[$professor][$cnt]['student'] = $application['Student.FirstName'] . ' ' . $application['Student.LastName'];
         $applications_arr[$professor][$cnt]['period'] = $application['Period.Name'];
         $applications_arr[$professor][$cnt]['application_date'] = $application['ApplicationDate'];
         $applications_arr[$professor][$cnt]['exam_datetime'] = $application['ExamDate'] . " " . $application['ExamTime'];
         $applications_arr[$professor][$cnt]['exam_score'] = isset($application['ExamScore']) && $application['ExamScore'] != 0 ? $application['ExamScore'] : '';
         $cnt++;
     }
     $result['data'] = $applications_arr;
     $result['course'] = $course->__toString();
     $result['subject'] = $subject->__toString();
     $result['school_year'] = $schoolYear->__toString();
     return $result;
 }
 /**
  * Get the associated ChildSubject object
  *
  * @param  ConnectionInterface $con Optional Connection object.
  * @return ChildSubject The associated ChildSubject object.
  * @throws PropelException
  */
 public function getSubject(ConnectionInterface $con = null)
 {
     if ($this->aSubject === null && $this->subject_id !== null) {
         $this->aSubject = ChildSubjectQuery::create()->findPk($this->subject_id, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aSubject->addApplications($this);
            */
     }
     return $this->aSubject;
 }
 /**
  * Performs an INSERT on the database, given a Subject or Criteria object.
  *
  * @param mixed               $criteria Criteria or Subject object containing data that is used to create the INSERT statement.
  * @param ConnectionInterface $con the ConnectionInterface connection to use
  * @return mixed           The new primary key.
  * @throws PropelException Any exceptions caught during processing will be
  *                         rethrown wrapped into a PropelException.
  */
 public static function doInsert($criteria, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(SubjectTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from Subject object
     }
     if ($criteria->containsKey(SubjectTableMap::COL_ID) && $criteria->keyContainsValue(SubjectTableMap::COL_ID)) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . SubjectTableMap::COL_ID . ')');
     }
     // Set the correct dbName
     $query = SubjectQuery::create()->mergeWith($criteria);
     // use transaction because $criteria could contain info
     // for more than one table (I guess, conceivably)
     return $con->transaction(function () use($con, $query) {
         return $query->doInsert($con);
     });
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $subject = SubjectQuery::create()->findPK($id);
     $subject->delete();
     flash()->success("DELETED");
     session(['attribute' => \Lang::get('general.SUBJECT')]);
     return redirect($this->main_page);
 }
Exemple #8
0
 /**
  * Builds a Criteria object containing the primary key for this object.
  *
  * Unlike buildCriteria() this method includes the primary key values regardless
  * of whether or not they have been modified.
  *
  * @throws LogicException if no primary key is defined
  *
  * @return Criteria The Criteria object containing value(s) for primary key(s).
  */
 public function buildPkeyCriteria()
 {
     $criteria = ChildSubjectQuery::create();
     $criteria->add(SubjectTableMap::COL_ID, $this->id);
     return $criteria;
 }