/** * 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); }
public function update(Request $request, $id) { $assignment = App\Assignment::findOrFail($id); $assignment->completed_at = Carbon::now(); $assignment->save(); return view('assignments.show', compact('assignment')); }
/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker::create('en_US'); Assignment::create(['name' => 'Assignment One', 'description' => $faker->paragraph(4), 'module_id' => 1, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]); Assignment::create(['name' => 'Assignment Two', 'description' => $faker->paragraph(4), 'module_id' => 1, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]); Assignment::create(['name' => 'Assignment Three', 'description' => $faker->paragraph(4), 'module_id' => 2, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]); }
/** * Run the database seeds. * * @return void */ public function run() { if (App::environment() === 'production') { exit('Do not seed in production environment'); } DB::statement('SET FOREIGN_KEY_CHECKS = 0'); // disable foreign key constraints DB::table('event_assignments')->truncate(); Assignment::create(['eventId' => 2, 'volunteerId' => 2, 'startingDate' => Carbon::now(), 'endingDate' => Carbon::now()->addWeeks(2)]); DB::statement('SET FOREIGN_KEY_CHECKS = 1'); // enable foreign key constraints }
public function saveAssignment(Request $request) { Assignment::create($request->all()); return redirect('/assignments'); }
/** * Show an assignment * * @param $courseCode * @param $number * @return mixed */ public function showAssignment($courseCode, $number) { // Get the assignmets $assignments = Assignment::where(['courseCode' => $courseCode, 'number' => $number])->get(); return view($this->assignmentView, ['assignments' => $assignments]); }
public function sendInvoice($assignmentId) { $assignment = Assignment::findorFail($assignmentId); $user = $assignment->user; Mail::send('email.invoiceToUser', ['booking_amount' => $assignment->booking_amount, 'completion_amount' => $assignment->completion_amount], function ($message) use($user) { $message->to($user->email, $user->name)->subject('Invoice for assignment'); }); }
/** * Update the specified assignment with request info. * * @param Request $request * @return Response */ public function update_assignment(Request $request, $assignment_id) { if (!Auth::user()->hasRole('admin')) { return view('access_denied'); } $assignment = Assignment::find($request->assignment_id); //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']); } //handles errors by setting $errors array and displaying the value in blade if (!empty($errors)) { $data = array('errors' => $errors, 'old' => $request, 'assignment' => $assignment, 'courses' => Course::all(), 'tutors' => UserController::getTutors(), 'students' => UserController::getStudents(), 'professors' => UserController::getProfessors()); return view('assignment_edit', $data); } $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 updated!'); return redirect('/assignment/' . $assignment->id); }
/** * Save request info as new report in database. * and send an email of the report * * @param Request $request * @return Response */ public function add_report(Request $request) { $user = Auth::user(); if (!$user->hasRole('admin') && !$user->hasRole('tutor')) { return view('access_denied'); } $errors = array(); if ($request->assignment == 0) { $errors['assignment'] = 'The assignment field is required.'; } // TODO: Add additional error checks. if (!empty($errors)) { $assignments = []; if ($user->hasRole('admin')) { $assignments = Assignment::all(); } else { if ($user->hasRole('tutor')) { $assignments = $user->tutor_assignments; } } $data = array('errors' => $errors, 'old' => $request, 'assignments' => $assignments); return view('report_add', $data); } $report = new Report(); $report->assignment_id = $request->assignment; $report->session_date = $request->session_date; $report->session_start = DateTime::createFromFormat('Y-m-d g:ia', $request->session_date . ' ' . $request->session_start); $report->session_end = DateTime::createFromFormat('Y-m-d g:ia', $request->session_date . ' ' . $request->session_end); $report->topic = $request->topic; $report->response = $request->response; $report->plans = $request->plans; $report->student_plans = $request->student_plans; $report->comments = $request->comments; $report->save(); // send an email to the corresponding professor whenever a tutor submits a report /* Mail::send('emails.report_add_email', ['user' => $user, 'report' => $report], function ($message) use ($user, $report){ $message->from('*****@*****.**', 'Calvin Tutoring Reports'); $message->to($report->assignment->professor->email)->subject($report->assignment->course->department . '-' . $report->assignment->course->number . ' report submitted'); }); */ session()->put('success', 'New Report has been added.'); return redirect('report/' . $report->id); }
public function validate_user_assignment_link() { $link = Request::input('data'); /// user report link $id = Request::input('user_assignment_id'); $ua = UserAssignment::find($id); // user assignment /// used for (maybe) when user reached of max time to repost, then remove and return not exist to move if (!$ua) { return array('statusCode' => 500, 'content' => 'not_exist'); } $current_allow = Setting::where('name', 'time_to_repost')->first()->value; /// reached of allow time to repost if ($ua->time_to_repost == 1) { //// remove current user assignment - return to available /// message to user this assignment is Canceled $ua->delete(); return array('statusCode' => 500, 'content' => 'You have tried <strong>' . $current_allow . '</strong> times to repost but ' . $link . ' is not enough of quality. Your assignment is Canceled', 'overtime' => 'yes'); } $ua->time_to_repost = $ua->time_to_repost - 1; $ua->save(); /////********************************* $true_apply = UserAssignment::where('user_id', Auth::user()->id)->where('id', $id)->first(); if (!$true_apply) { return array('statusCode' => 500, 'content' => 'not_exist'); } $domain = strtolower($link); $domain = parse_url($domain, PHP_URL_HOST); $domain = preg_replace('/(?:https?:\\/\\/)?(?:www\\.)?(.*)\\/?$/i', '$1', $domain); $domain = preg_replace('/\\//i', '$1', $domain); /* * * BEGIN TO VALIDATE AND MINUS TIME TO TRY AND PLUS MORE TIME IF FAILED * If plus more time (minute_to_repost_time) , just get from Setting then plus with: created_at of this UA **/ //// check link domain same with user blog domain if ($domain != Auth::user()->userblog->domain) { $this->plus_time_repost($ua); return array('statusCode' => 500, 'content' => '<strong>' . $link . '</strong> is not match with your blog domain you have registered. You have <strong>' . $ua->time_to_repost . '</strong> times to try again'); } /************************************************/ /// ALL OK $assignment = Assignment::find($ua->assignment_id); $required_link = json_decode($assignment->img_link); $required_keyword = explode(',', $assignment->keyword); $wordcount = $assignment->minimum_wordcount; $curl = curl_init($link); curl_setopt($curl, CURLOPT_NOBODY, true); $result = curl_exec($curl); $headerStatusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($headerStatusCode == '404') { $this->plus_time_repost($ua); return array('statusCode' => 500, 'content' => '<strong>' . $link . '</strong> does not exist. You have <strong>' . $ua->time_to_repost . '</strong> times to try again'); } elseif ($headerStatusCode == '301') { return array('statusCode' => 500, 'content' => '<strong>' . $link . '</strong> is redirected, please use direct link. You have <strong>' . $ua->time_to_repost . '</strong> times to try again'); } elseif ($headerStatusCode == '200') { $result_complete_validate = $this->complete_validate_blog($required_link, $link, $required_keyword, $wordcount); if (isset($result_complete_validate['error']) && $result_complete_validate['error'] == 'not-enough') { /// not enough link $this->plus_time_repost($ua); $list_notfollow = ''; if (count($result_complete_validate['list_notfollow'])) { $list_notfollow .= '<ul>'; foreach ($result_complete_validate['list_notfollow'] as $ln) { $list_notfollow .= ' <li><strong> ' . $ln . '</strong> rel="nofollow" is not allowed</li> '; } $list_notfollow .= '</ul>'; } return array('statusCode' => 500, 'content' => 'Number of links required: <strong>' . $result_complete_validate['num'] . '</strong><br>' . $list_notfollow . ' . You have <strong>' . $ua->time_to_repost . '</strong> times to try again'); } if (isset($result_complete_validate['error']) && $result_complete_validate['error'] == 'not-enough-keyword') { $this->plus_time_repost($ua); $list_notOK_keyword = ''; if (count($result_complete_validate['list_notOK_keyword'])) { $list_notOK_keyword .= '<ul>'; foreach ($result_complete_validate['list_notOK_keyword'] as $ln) { $list_notOK_keyword .= ' <li>Keyword: <strong> ' . $ln . '</strong> not found</li> '; } $list_notOK_keyword .= '</ul>'; } return array('statusCode' => 500, 'content' => 'Number of keyword required: <strong>' . $result_complete_validate['num'] . '</strong><br>' . $list_notOK_keyword . '. You have <strong>' . $ua->time_to_repost . '</strong> times to try again'); } if (isset($result_complete_validate['error']) && $result_complete_validate['error'] == 'not-enough-wordcount') { $this->plus_time_repost($ua); return array('statusCode' => 500, 'content' => 'Number of words required: <strong>' . $result_complete_validate['num'] . '</strong>. You have <strong>' . $ua->time_to_repost . '</strong> times to try again'); } /// ALl OKKKKKKKKKKKKKKK. Count user_assignment by assignment_id, if full with status 3, close this assignment UserAssignment::where('user_id', Auth::user()->id)->where('id', $id)->update(array('status' => 3, 'link' => $link, 'approved_at' => date('Y-m-d H:i:s', time()))); /// 2 is Written $total = UserAssignment::where('assignment_id', $ua->assignment_id)->where('status', 3)->count(); if ($total == $assignment->max_blogger) { $assignment->status = 0; $assignment->save(); } return array('statusCode' => 200); } else { $this->plus_time_repost($ua); return array('statusCode' => 500, 'content' => '<strong>' . $link . '</strong> is not valid. You have <strong>' . $ua->time_to_repost . '</strong> times to try again'); } }
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'); }
/** * Add an assignment * * @param Request $request * @return mixed */ public function addAssignment(Request $request) { // Validate the data $validator = Validator::make($request->all(), ['number' => 'numeric|required|min:0|unique:assignments,number,NULL,id,courseCode,' . $request['courseCode'], 'title' => 'required|max:255', 'description' => 'required'], ['unique' => 'This assignment number already exists. Please choose a different number']); if ($validator->fails()) { return redirect('/teachers/assignments/add')->withErrors($validator)->withInput(); } $assignment = ['courseCode' => $request['courseCode'], 'number' => $request['number'], 'title' => $request['title'], 'description' => $request['description'], 'dueDate' => $request['dueDate']]; // Save the assignment into db Assignment::create($assignment); return redirect('/teachers/assignments'); }
public function userBidPlaced(Assignment $assignment) { $bid = $assignment->bids()->where('user_id', Authorizer::getResourceOwnerId())->get()->count(); if ($bid) { return 1; } else { return 0; } }
/** * @param $id * @return mixed */ public function getParameters($id) { $assignments = $this->assignment->find($id); return $assignments; }
public function deleteAssignment($id) { return $this->assignment->destroy($id); }
public function assignVolunteers($eventId, Request $request) { $volunteers = $request->input('volunteerIds'); $data = array(); foreach ($volunteers as $volunteerId) { $data[] = array('volunteerId' => $volunteerId, 'eventId' => $eventId); } try { Assignment::insert($data); } catch (\Exception $e) { return response()->json(['error' => ['message' => 'Could not assign volunteers' . $e->getMessage(), 'code' => 101]]); } return response()->json(['result' => $data]); }
public function getGroupsUnAssigned($groupId, $assigmentId) { $assigment = $this->assignment->find($assigmentId); return $assigment->groups()->where('id', '<>', $groupId)->get(); }