/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $assignment = new Assignment(); $assignment->classId = '5'; $assignment->name = $request->name; $assignment->save(); session()->flash('flash_message', 'Task successfully added!'); return redirect('assignment/create'); }
public function store(Request $request, $lecture_id, $subject_id) { $subject = Subject::find($subject_id); $assignment = new Assignment(); $assignment->due_date = $request->due_date . ' 23:59'; $assignment->subject()->associate($subject); $assignment->save(); $assignment->knowledgeunits()->attach(Input::get('knowledgeunits')); return redirect('/lectures/' . $lecture_id . '/assignments/subjects/' . $subject_id); }
/** * Save request info as new assignment in database. * * @param Request $request * @return Response */ public function add_assignment(Request $request) { if (!Auth::user()->hasRole('admin')) { return view('access_denied'); } //check whether duplicates do not exist in the database $duplicateCheck = Assignment::where('tutor_id', '=', $request->tutor)->where('student_id', '=', $request->student)->where('course_id', '=', $request->course)->first(); if ($duplicateCheck != null) { $errors['duplicate'] = 'This tutor assignment already exists!'; session()->put('error', $errors['duplicate']); } //check whether professor matches the course $correctProfessorCheck = DB::select('select * from current_professors where user_id = ? and course_id = ?', [$request->professor, $request->course]); if ($correctProfessorCheck == null) { $errors['badProf'] = 'This professor is not currently teaching this course!'; session()->put('error', $errors['badProf']); } //check whether tutor matches the course $correctTutorCheck = DB::select('select * from available_tutors where user_id = ? and course_id = ?', [$request->tutor, $request->course]); if ($correctTutorCheck == null) { $errors['badTutor'] = 'This tutor is not currently tutoring this course!'; session()->put('error', $errors['badTutor']); } if (!empty($errors)) { $data = array('errors' => $errors, 'old' => $request, 'courses' => Course::all(), 'tutors' => UserController::getTutors(), 'students' => UserController::getStudents(), 'professors' => UserController::getProfessors()); return view('assignment_add', $data); } $assignment = new Assignment(); $assignment->tutor_id = $request->tutor; $assignment->student_id = $request->student; $assignment->course_id = $request->course; $assignment->professor_id = $request->professor; $assignment->save(); session()->put('success', 'Tutor assignment successfully created!'); return redirect('/assignment/' . $assignment->id); }
public function quick_create_assignment() { if (Request::isMethod('get')) { if (Request::input('key') && Request::input('key') == '8855a5gp2C6577') { $customerAPI = json_decode($this->curlGet()); $langs = Language::all(); return view('admin.assignment.quick-create', array('langs' => $langs, 'customerAPI' => $customerAPI)); } else { return 'You do not have permission to view this page'; } } /* POST link is link id in riversystem DB, bf_links */ $data = Request::all(); $customer = $data['customer']; $release_date = $data['release_date']; $customerName = $data['customerName']; $max_blogger = $data['max_blogger']; $lang_code = $data['lang_code']; $keyword = $data['keyword']; $minimum_wordcount = $data['minimum_wordcount']; if (isset($data['img'])) { $img = $data['img']; } else { $img = null; } $categories = implode(',', $data['category']); if (isset($data['link'])) { $link = $data['link']; } else { $link = null; } if (isset($data['anchor_text'])) { $anchor_text = $data['anchor_text']; } if ($link) { foreach ($link as $key => $value) { $listUploadedImg_Link[$key]['img'] = $img[$key]; $listUploadedImg_Link[$key]['link'] = $link[$key]; $listUploadedImg_Link[$key]['anchor_text'] = $anchor_text[$key]; } $imgLink_store = json_encode($listUploadedImg_Link); } else { $imgLink_store = null; } foreach ($release_date as $key => $release_date_val) { $a = new Assignment(); $a->customer_id = $customer; $a->customer_name = $customerName; $a->keyword = $keyword; $a->minimum_wordcount = $minimum_wordcount; $a->max_blogger = $max_blogger; $a->blog_categories = $categories; $a->lang_code = $lang_code; $a->img_link = $imgLink_store; $a->release_date = $release_date_val; $a->save(); } return redirect('admin/quick-create-assignment?key=8855a5gp2C6577')->with('ok', 'Create Assignment Successful'); }