public function myAction(Request $request) { // create a task and give it some dummy data for this example $task = new Student(); $task->setTask('Write a blog post'); $task->setDueDate(new \DateTime('tomorrow')); $form = $this->createFormBuilder($task)->add('task', TextType::class)->add('dueDate', DateType::class)->add('save', SubmitType::class, array('label' => 'Create Task'))->getForm(); return $this->render('default/new.html.twig', array('form' => $form->createView())); }
public function load(ObjectManager $manager) { $student = new Student(); $student->setEmail('*****@*****.**'); $student->setFirstname('testre'); $student->setLastname('testa'); $manager->persist($student); $manager->flush(); }
/** * @dataProvider studentData */ public function testPath($name, $expectedName) { $student = new Student(); $student->setName($name); $student->setDescription(''); $student->setPath(''); $service = new GetPath(); $returnedResult = $service->getPath($student); $this->assertEquals($expectedName, $returnedResult); }
public function load(ObjectManager $manager) { $student = new Student(); $student->setEmail('*****@*****.**'); $student->setFirstName('Jean'); $student->setLastName('Dupont'); // Je sauvegarde en DB $manager->persist($student); $manager->flush(); }
public function load(ObjectManager $manager) { // Je créé les objets que je veux pour mes tests $student = new Student(); $student->setEmail('*****@*****.**'); $student->setFirstName('Jean'); $student->setLastName('Dupont'); // Je sauvegarde en DB $manager->persist($student); $manager->flush(); $this->addReference('student', $student); }
/** * Добавляет ученика. * * @Route("/") * @Method("POST") */ public function setAction() { $request = Request::createFromGlobals(); $data = json_decode($request->getContent()); $s = new Student(); $s->setFirstName($data->firstName); $s->setLastName($data->lastName); $em = $this->getDoctrine()->getManager(); $em->persist($s); $em->flush(); return new JsonResponse(['success' => true, 'data' => ['id' => $s->getId()]]); }
/** * @Route("/group/{id}/add-student", name="app_agroup_add_student") * @Template() */ public function addStudentAction(Request $request, AGroup $agroup) { $student = new Student(); $student->setAgroup($agroup); $form = $this->createForm(new StudentType(), $student); $form->handleRequest($request); if ($form->isValid()) { $student = $form->getData(); $em = $this->getDoctrine()->getManager(); $em->persist($student); $em->flush(); return $this->redirectToRoute('app_agroup_show', ['id' => $agroup->getId()]); } return ['form' => $form->createView()]; }
public function load(ObjectManager $manager) { // Je créé les objets que je veux pour mes tests $admin = new Admin(); $admin->setEmail('*****@*****.**')->setUsername('admin')->setPlainPassword('admin')->setEnabled(1)->setRoles(['ROLE_SUPER_ADMIN']); $student = new Student(); $student->setEmail('*****@*****.**')->setFirstName('John')->setLastName('Doe'); $exam = new Exam(); $exam->setName('Symfony 2')->setDescription('Best framework'); $grade = new Grade(); $grade->setGradeNumber(15)->setStudent($student)->setExam($exam); // Je sauvegarde en DB $manager->persist($admin); $manager->persist($student); $manager->persist($exam); $manager->persist($grade); $manager->flush(); }
public function load(ObjectManager $manager) { $firstNamesBoy = ['Иван', 'Петя', 'Вася', 'Максим', 'Дима', 'Вова', 'Игнат', 'Валя', 'Коля', 'Влад', 'Семен', 'Саша', 'Юра', 'Лёня', 'Артем', 'Кеша']; $lastNamesBoy = ['Иванов', 'Петров', 'Сидоров', 'Селедкин', 'Елкин', 'Палкин', 'Грибоедов', 'Путин', 'Медведев', 'Обамов', 'Абрамов', 'Серегин']; $firstNamesGirl = ['Маша', 'Таня', 'Света', 'Юля', 'Катя', 'Ира', 'Полина', 'Кристина', 'Тая', 'Люся', 'Марина', 'Наташа']; $lastNamesGirl = ['Иванова', 'Петрова', 'Сидорова', 'Селедкина', 'Елкина', 'Палкина', 'Грибоедова', 'Путина', 'Медведева', 'Обамова', 'Абрамова', 'Серегина']; for ($i = 20; $i < 40; $i++) { $firstName = $firstNamesBoy[rand(0, count($firstNamesBoy) - 1)]; $lastName = $lastNamesBoy[rand(0, count($lastNamesBoy) - 1)]; $student = new Student(); $student->setFirstName($firstName); $student->setLastName($lastName); $manager->persist($student); } for ($i = 20; $i < 40; $i++) { $firstName = $firstNamesGirl[rand(0, count($firstNamesGirl) - 1)]; $lastName = $lastNamesGirl[rand(0, count($lastNamesGirl) - 1)]; $student = new Student(); $student->setFirstName($firstName); $student->setLastName($lastName); $manager->persist($student); } $manager->flush(); }
/** * @Route("/result/create", name="result_create") */ public function createAction(Request $request) { $result = new student_module_grade(); // generating data for the form $students = Student::getAll(); $studentIds = array(); foreach ($students as $student) { $studentIds[$student->getIndexNo()] = $student->getIndexNo(); //array_push($studentIds, $student->getIndexNo()); } $modules = Module::getAll(); $moduleIds = array(); foreach ($modules as $module) { $moduleIds[$module->getCode()] = $module->getCode(); //array_push($moduleIds, $module->getCode()); } $grades = Grade::getAll(); $gradeIds = array(); foreach ($grades as $grade) { $gradeIds[$grade->getGrade()] = $grade->getGrade(); //array_push($gradeIds, $grade->getGrade()); } $form = $this->createFormBuilder($result)->add('s_id', ChoiceType::class, array('choices' => $studentIds, 'choices_as_values' => true, 'label' => 'Index No'))->add('m_code', ChoiceType::class, array('choices' => $moduleIds, 'choices_as_values' => true, 'label' => 'Module'))->add('grade', ChoiceType::class, array('choices' => $gradeIds, 'choices_as_values' => true, 'label' => 'Grade'))->add('save', SubmitType::class, array('label' => 'Add Marks'))->getForm(); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { // ... perform some action, such as saving the task to the database $result->save(); return $this->redirectToRoute('result_create'); } ////////////////////////form 2 for add multiple////////////////////////////////// $form2Data = array('message' => 'Type your message here'); $form2 = $this->createFormBuilder($form2Data)->add('m_code', ChoiceType::class, array('choices' => $moduleIds, 'choices_as_values' => true, 'label' => 'Module'))->add('marks', TextType::class)->add('save', SubmitType::class, array('label' => 'Add Marks'))->getForm(); $form2->handleRequest($request); if ($form2->isSubmitted() && $form2->isValid()) { // ... perform some action, such as saving the task to the database $data = $form2->getData(); //die($data['marks']); $module = $data['m_code']; $marks = $data['marks']; //$em = $this->getDoctrine()->getManager(); $doc = $this->getDoctrine(); student_module_grade::saveAll($module, $marks, $doc); return $this->redirectToRoute('result_create'); } ////////////////////////////////////////////////////////// // ADDED THE FORM2 array return $this->render('result/create.html.twig', array('form' => $form->createView(), 'form2' => $form2->createView())); }
public function addStudentAction(Request $request) { $data = json_decode($request->getContent()); $em = $this->getDoctrine()->getManager(); $educationForm = $em->getRepository('AppBundle:EducationForm')->find($data->educationForm); $group = $em->getRepository('AppBundle:Group')->find($data->group); $sex = $em->getRepository('AppBundle:Sex')->find($data->sex); $student = new Student(); $student->setEducationForm($educationForm); $student->setGroupa($group); $student->setFirstName($data->firstName); $student->setLastName($data->lastName); $student->setSex($sex); $student->setDisabled(0); $em->persist($student); $em->flush(); return new JsonResponse($student->jsonSerialize()); }
public static function updateGpa($semester_id) { $con = Connection::getConnectionObject()->getConnection(); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $students = Student::getAll(); $results = Semester_results::getAllSemester($semester_id); //check student in semester_resultsr foreach ($students as $student) { $inResults = false; foreach ($results as $result) { if ($student->getId() == $result->stuId) { $inResults = true; break; } } if ($inResults == false) { $result = new Semester_results(); $result->setStuId($student->getId()); $result->setSemId($semester_id); array_push($results, $result); } } foreach ($results as $result) { //vars for calculate gpa $totalMark = 0.0; $totalCredits = 0.0; //die($result->stuId); //query to get the marks and credits $stmt = $con->prepare('SELECT module.credits,grade.mark FROM module,student_module_grade,grade,student WHERE module.code = student_module_grade.m_code AND student_module_grade.grade = grade.grade AND student_module_grade.s_id = student.index_no AND module.gpa = true AND student.id = ?'); $stmt->bind_param("s", $result->stuId); $stmt->execute(); $stmt->bind_result($credits, $mark); while ($stmt->fetch()) { $totalMark += $mark * $credits; $totalCredits += $credits; } //adding the gpa to the result object if ($totalCredits > 0) { $result->gPA = $totalMark / $totalCredits; } } return $results; }
/** * @param Student $student * @param Course $course * @param Speciality $speciality * @param $studentData * @return Student * @throws ValidatorException */ public function updateStudent(Student $student, Course $course, Speciality $speciality, $studentData) { $student->setCourse($course); $student->setSpeciality($speciality); $student->setFirstName($studentData['firstName']); $student->setLastName($studentData['lastName']); $student->setFacultyNumber($studentData['facultyNumber']); $student->setEmail($studentData['email']); $student->setEducationForm($studentData['educationForm']); $errors = $this->validator->validate($student, null, array('edit')); if (count($errors) > 0) { throw new ValidatorException($errors); } $this->studentManager->saveChanges(); return $student; }
/** * Add student * * @param Student $student * * @return Activity */ public function addStudent(Student $student) { $key = $student->getId(); if ($this->students->containsKey($key)) { throw new \InvalidArgumentException('The Student has already joined this Activity'); } $this->students->set($key, $student); return $this; }
/** * @Route("/student/view/{id}", name="student_view") */ public function viewAction($id, Request $request) { $student = Student::getOne($id); return $this->render('student/view.html.twig', array('student' => $student)); }
/** * @Route("/student/edit/{id}", defaults={"id"=0}, name="student_edit_profile") * */ public function editStudentProfile(Request $request, $id) { $user = $this->getUser(); $id = $user->getUsername(); $em = $this->getDoctrine()->getManager(); $connection = $em->getConnection(); $query = 'SELECT * '; $query .= 'FROM student AS s '; $query .= 'WHERE s.id = :id'; $statement = $connection->prepare($query); $statement->bindValue('id', $id); $statement->execute(); $student_ = $statement->fetchAll(); $student = new Student(); $em = $this->getDoctrine()->getManager(); $connection = $em->getConnection(); $query = "SELECT DISTINCT faculty FROM fac_dep"; $statement = $connection->prepare($query); $statement->execute(); $result = $statement->fetchAll(); $faculty_list = array(); foreach ($result as $fac) { $faculty_list[$fac['faculty']] = $fac['faculty']; } $query = "SELECT DISTINCT department FROM fac_dep"; $statement = $connection->prepare($query); $statement->execute(); $result = $statement->fetchAll(); $department_list = array(); foreach ($result as $fac) { $department_list[$fac['department']] = $fac['department']; } $student->setId($student_[0]['id']); $student->setFirstName($student_[0]['first_name']); $student->setSecondName($student_[0]['second_name']); $student->setFaculty($student_[0]['faculty']); $student->setDepartment($student_[0]['department']); $student->setGender($student_[0]['gender']); // $birth_day = strtotime($student_[0]['birthday']); $birth__day = date('Y-m-d', strtotime($student_[0]['birthday'])); //$birth_day); //var_dump($birth__day); $student->setBirthday(new \DateTime()); //$birth__day); $student->setContactNumber($student_[0]['contact_number']); $student->setEMail($student_[0]['e_mail']); $student->setAddress($student_[0]['address']); $form = $this->createFormBuilder($student)->add('id', TextType::class)->add('firstName', TextType::class)->add('secondName', TextType::class, ['required' => false])->add('faculty', ChoiceType::class, ['choices' => $faculty_list, 'placeholder' => '-SELECT-'])->add('department', ChoiceType::class, ['choices' => $department_list, 'placeholder' => '-SELECT-'])->add('gender', ChoiceType::class, ['choices' => ['Male' => 'Male', 'Female' => 'Female'], 'choices_as_values' => true, 'placeholder' => '-SELECT-'])->add('birthday', DateType::class, ['input' => 'datetime', 'widget' => 'choice', 'years' => range(1980, 2000), 'placeholder' => '-SELECT-'])->add('contactNumber', TextType::class)->add('eMail', TextType::class, ['required' => false])->add('address', TextType::class, ['required' => false])->add('save', SubmitType::class, ['label' => 'Update Profile'])->getForm(); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getEntityManager(); $connection = $em->getConnection(); $query_student = "UPDATE student SET"; $query_student .= " first_name = '" . $student->getFirstName() . "', "; $query_student .= "second_name = '" . $student->getSecondName() . "', "; $query_student .= "faculty='" . $student->getFaculty() . "',"; $query_student .= "department = '" . $student->getDepartment() . "',"; $query_student .= "gender = '" . $student->getGender() . "',"; $query_student .= "birthday ='" . $student->getBirthday()->format('y/m/d') . "', "; $query_student .= "contact_number = '" . $student->getContactNumber() . "',"; $query_student .= "e_mail = '" . $student->getEMail() . "',"; $query_student .= "address = '" . $student->getAddress() . "'"; $query_student .= "WHERE id = '" . $student->getId() . "'"; $statement1 = $connection->prepare($query_student); $statement1->execute(); return $this->render('student/edit.html.twig'); } return $this->render('student/edit.html.twig', array('form' => $form->createView())); }
/** * @Route("/student/view", name="student_viewAll") */ public function viewallAction(Request $request) { $students = Student::getAll(); return $this->render('student/viewall.html.twig', array('students' => $students)); }
/** * StudentModel constructor. * @param Student $student * @param boolean $buildWithFullInfo */ public function __construct(Student $student, $buildWithFullInfo = false) { $this->setId($student->getId()); $this->setFirstName($student->getFirstName()); $this->setLastName($student->getLastName()); $this->setEmail($student->getEmail()); $this->setFacultyNumber($student->getFacultyNumber()); $this->setEducationForm($student->getEducationForm()); $this->setCourseName($student->getCourse()->getName()); $this->setSpecialityName($student->getSpeciality()->getSpecialityLongName()); $this->setShortSpecialityName($student->getSpeciality()->getSpecialityShortName()); if ($buildWithFullInfo) { foreach ($student->getStudentAssessments() as $studentAssessment) { $this->studentAssessments[$studentAssessment->getSubject()->getId()] = new StudentAssessmentModel($studentAssessment); } } }
public static function getAll() { $con = Connection::getConnectionObject()->getConnection(); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $students = array(); //Make an empty array $stmt = $con->prepare('SELECT id,name,index_no,CGPA,rank FROM student ORDER BY rank'); $stmt->execute(); $stmt->bind_result($id, $name, $indexNo, $cGPA, $rank); while ($stmt->fetch()) { $student = new Student(); $student->id = $id; $student->setName($name); $student->setIndexNo($indexNo); $student->setCGPA($cGPA); $student->setRank($rank); array_push($students, $student); //Push one by one } $stmt->close(); return $students; }
public function load(ObjectManager $manager) { $course1 = new Course(); $course1->setName('Първи'); $manager->persist($course1); $course2 = new Course(); $course2->setName('Втори'); $manager->persist($course2); $course3 = new Course(); $course3->setName('Трети'); $manager->persist($course3); $course4 = new Course(); $course4->setName('Четвърти'); $manager->persist($course4); $speciality1 = new Speciality(); $speciality1->setSpecialityLongName('Математика и Информатика'); $speciality1->setSpecialityShortName('МИ'); $manager->persist($speciality1); $speciality2 = new Speciality(); $speciality2->setSpecialityLongName('Софтуерни технологии и дизайн'); $speciality2->setSpecialityShortName('СТД'); $manager->persist($speciality2); $speciality3 = new Speciality(); $speciality3->setSpecialityLongName('Бизнес информационни технологии'); $speciality3->setSpecialityShortName('БИТ'); $manager->persist($speciality3); $speciality4 = new Speciality(); $speciality4->setSpecialityLongName('Информатика'); $speciality4->setSpecialityShortName('И'); $manager->persist($speciality4); $speciality5 = new Speciality(); $speciality5->setSpecialityLongName('Математика'); $speciality5->setSpecialityShortName('М'); $manager->persist($speciality5); $speciality6 = new Speciality(); $speciality6->setSpecialityLongName('Информационни технологии, математика и образователен мениджмънт '); $speciality6->setSpecialityShortName('ИТМОМ'); $manager->persist($speciality6); $speciality7 = new Speciality(); $speciality7->setSpecialityLongName('Бизнес математика'); $speciality7->setSpecialityShortName('БМ'); $manager->persist($speciality7); $speciality8 = new Speciality(); $speciality8->setSpecialityLongName('Приложна математика'); $speciality8->setSpecialityShortName('ПМ'); $manager->persist($speciality8); $speciality9 = new Speciality(); $speciality9->setSpecialityLongName('Химия'); $speciality9->setSpecialityShortName('Х'); $manager->persist($speciality9); $speciality10 = new Speciality(); $speciality10->setSpecialityLongName('Компютърна химия'); $speciality10->setSpecialityShortName('КХ'); $manager->persist($speciality10); $speciality11 = new Speciality(); $speciality11->setSpecialityLongName('Медицинска химия'); $speciality11->setSpecialityShortName('МХ'); $manager->persist($speciality11); $student1 = new Student(); $student1->setCourse($course1); $student1->setSpeciality($speciality8); $student1->setFirstName('Марио'); $student1->setLastName('Христев'); $student1->setEmail('*****@*****.**'); $student1->setFacultyNumber('1401181006'); $manager->persist($student1); $student2 = new Student(); $student2->setCourse($course2); $student2->setSpeciality($speciality2); $student2->setFirstName('Георги'); $student2->setLastName('Георгиев'); $student2->setEmail('*****@*****.**'); $student2->setFacultyNumber('1401181015'); $manager->persist($student2); $student3 = new Student(); $student3->setCourse($course3); $student3->setSpeciality($speciality3); $student3->setFirstName('Кристиан'); $student3->setLastName('Башев'); $student3->setEmail('*****@*****.**'); $student3->setFacultyNumber('1401181038'); $manager->persist($student3); $student4 = new Student(); $student4->setCourse($course4); $student4->setSpeciality($speciality4); $student4->setFirstName('Боряна'); $student4->setLastName('Котева'); $student4->setEmail('*****@*****.**'); $student4->setFacultyNumber('1401181010'); $manager->persist($student4); $student5 = new Student(); $student5->setCourse($course3); $student5->setSpeciality($speciality4); $student5->setFirstName('Жеко'); $student5->setLastName('Николов'); $student5->setEmail('*****@*****.**'); $student5->setFacultyNumber('1401181029'); $manager->persist($student5); $student6 = new Student(); $student6->setCourse($course2); $student6->setSpeciality($speciality6); $student6->setFirstName('Антон'); $student6->setLastName('Капанов'); $student6->setEmail('*****@*****.**'); $student6->setFacultyNumber('1401181040'); $manager->persist($student6); $student7 = new Student(); $student7->setCourse($course2); $student7->setSpeciality($speciality4); $student7->setFirstName('Мира'); $student7->setLastName('Спасова'); $student7->setEmail('*****@*****.**'); $student7->setFacultyNumber('1401181011'); $manager->persist($student7); $student8 = new Student(); $student8->setCourse($course2); $student8->setSpeciality($speciality2); $student8->setFirstName('Ирина'); $student8->setLastName('Джоголова'); $student8->setEmail('*****@*****.**'); $student8->setFacultyNumber('1401181017'); $manager->persist($student8); $student8 = new Student(); $student8->setCourse($course1); $student8->setSpeciality($speciality7); $student8->setFirstName('Веселина'); $student8->setLastName('Славчева'); $student8->setEmail('*****@*****.**'); $student8->setFacultyNumber('1401181034'); $manager->persist($student8); $student9 = new Student(); $student9->setCourse($course3); $student9->setSpeciality($speciality10); $student9->setFirstName('Галин'); $student9->setLastName('Иванов'); $student9->setEmail('*****@*****.**'); $student9->setFacultyNumber('1401181060'); $manager->persist($student9); $student10 = new Student(); $student10->setCourse($course3); $student10->setSpeciality($speciality10); $student10->setFirstName('Катерина'); $student10->setLastName('Попова'); $student10->setEmail('*****@*****.**'); $student10->setFacultyNumber('1401181048'); $manager->persist($student10); $student11 = new Student(); $student11->setCourse($course3); $student11->setSpeciality($speciality10); $student11->setFirstName('Неджад'); $student11->setLastName('Сюлейман'); $student11->setEmail('*****@*****.**'); $student11->setFacultyNumber('1401181045'); $manager->persist($student11); $subject1 = new Subject(); $subject1->setName('Увод в програмирането (С#)'); $subject1->setWorkloadLectures('40'); $subject1->setWorkloadExercises('60'); $manager->persist($subject1); $subject2 = new Subject(); $subject2->setName('Линейна алгебра и аналитична геометрия'); $subject2->setWorkloadLectures('60'); $subject2->setWorkloadExercises('60'); $manager->persist($subject2); $subject3 = new Subject(); $subject3->setName('Увод в информационните технологии'); $subject3->setWorkloadLectures('40'); $subject3->setWorkloadExercises('60'); $manager->persist($subject3); $subject4 = new Subject(); $subject4->setName('Английски език'); $subject4->setWorkloadLectures('30'); $subject4->setWorkloadExercises('30'); $manager->persist($subject4); $subject5 = new Subject(); $subject5->setName('Създаване на ГПИ (С#)'); $subject5->setWorkloadLectures('40'); $subject5->setWorkloadExercises('60'); $manager->persist($subject5); $subject6 = new Subject(); $subject6->setName('Основи на графичния дизайн'); $subject6->setWorkloadLectures('40'); $subject6->setWorkloadExercises('60'); $manager->persist($subject6); $subject7 = new Subject(); $subject7->setName('Софтуерни системи по математика'); $subject7->setWorkloadLectures('40'); $subject7->setWorkloadExercises('60'); $manager->persist($subject7); $subject8 = new Subject(); $subject8->setName('Спорт'); $subject8->setWorkloadLectures('40'); $subject8->setWorkloadExercises('60'); $manager->persist($subject8); $sa1 = new StudentAssessment(); $sa1->setWorkloadExercises(20); $sa1->setWorkloadLectures(30); $sa1->setAssessment(2); $sa1->setSubject($subject1); $sa1->setStudent($student1); $manager->persist($sa1); $sa2 = new StudentAssessment(); $sa2->setWorkloadExercises(20); $sa2->setWorkloadLectures(30); $sa2->setAssessment(2); $sa2->setSubject($subject1); $sa2->setStudent($student2); $manager->persist($sa2); $sa3 = new StudentAssessment(); $sa3->setWorkloadExercises(20); $sa3->setWorkloadLectures(30); $sa3->setAssessment(2); $sa3->setSubject($subject1); $sa3->setStudent($student3); $manager->persist($sa3); $sa4 = new StudentAssessment(); $sa4->setWorkloadExercises(20); $sa4->setWorkloadLectures(30); $sa4->setAssessment(2); $sa4->setSubject($subject1); $sa4->setStudent($student4); $manager->persist($sa4); $sa5 = new StudentAssessment(); $sa5->setWorkloadExercises(20); $sa5->setWorkloadLectures(30); $sa5->setAssessment(3); $sa5->setSubject($subject4); $sa5->setStudent($student5); $manager->persist($sa5); $sa6 = new StudentAssessment(); $sa6->setWorkloadExercises(40); $sa6->setWorkloadLectures(30); $sa6->setAssessment(5); $sa6->setSubject($subject4); $sa6->setStudent($student7); $manager->persist($sa6); $manager->flush(); }