diff --git a/app/AndroidFileresult.php b/app/AndroidFileresult.php new file mode 100644 index 0000000..682e768 --- /dev/null +++ b/app/AndroidFileresult.php @@ -0,0 +1,11 @@ +belongsTo(App\AndroidTopic::class); + } + + public function getTopic($id) { + return \App\AndroidTopic::find($id)->name; + } + + public function getListTopic() { + return \App\AndroidTopic::pluck('name', 'id'); + } +} diff --git a/app/AndroidTaskResult.php b/app/AndroidTaskResult.php new file mode 100644 index 0000000..dc68530 --- /dev/null +++ b/app/AndroidTaskResult.php @@ -0,0 +1,11 @@ +hasMany('App\AndroidTask'); + } + + public function topic_files() { + return $this->hasMany('App\AndroidTopicFiles'); + } + + public function test_files() { + return $this->hasMany('App\AndroidTestFiles'); + } +} diff --git a/app/AndroidTopicFiles.php b/app/AndroidTopicFiles.php new file mode 100644 index 0000000..a8184d0 --- /dev/null +++ b/app/AndroidTopicFiles.php @@ -0,0 +1,15 @@ +belongsTo(App\AndroidTopic::class); + } +} diff --git a/app/AndroidUser.php b/app/AndroidUser.php new file mode 100644 index 0000000..f8a5f28 --- /dev/null +++ b/app/AndroidUser.php @@ -0,0 +1,52 @@ + 'datetime', + ]; + + public function checkRoleId($roleid) { + if ($roleid=='student') { + return Redirect::to('student/Androidcourse/home'); + } elseif ($roleid=='teacher') { + return Redirect::to('teacher/home'); + } elseif ($roleid=='admin') { + return Redirect::to('admin/admin'); + } else { + return Redirect::to('/home'); + } + } +} diff --git a/app/Http/Controllers/AndroidController.php b/app/Http/Controllers/AndroidController.php new file mode 100644 index 0000000..9b52230 --- /dev/null +++ b/app/Http/Controllers/AndroidController.php @@ -0,0 +1,249 @@ +roleid=='student/androidcourse') { + $check=\App\User::find(Auth::user()->id); + if ($check->status!='active') return view('student/androidcourse/home')->with(['status'=>$check->status]); + } + $topiclist=\App\AndroidTopic::where('status','=','1') + ->orderBy('name','asc')->get(); + + $items = \App\AndroidTopic::where('status','=','1') + ->orderBy('status','desc') + ->orderBy('name','asc') + ->pluck('name', 'id'); + + $itemslearning = \App\AndroidTopic::where('status','=','1') + ->orderBy('status','desc') + ->orderBy('name','asc') + ->where('level','=','1') + ->pluck('name', 'id'); + + $filter = $request->input('topicList',$topiclist[0]['id']); + + if ($filter=='0') { + $entities=\App\AndroidTask::all(); + } else { + + $entities = \App\AndroidTask::where('topic','=',$filter) + ->select( + 'tasks.id', + 'tasks.taskno', + 'tasks.desc', + 'tasks.topic', + 'topics.name' + ) + ->join( + 'topics', + 'topics.id','=','tasks.topic' + ) + ->orderBy('tasks.taskno','asc') + ->get(); + } + + if (Auth::user()->roleid=='admin') { + return view('admin/tasks/index') + ->with(compact('entities')) + ->with(compact('items')) + ->with(compact('filter')); + } else { + $topic = \App\AndroidTopic::where('topics.id','=',$filter) + ->select( + 'topics.id', + 'topics.name', + 'topics.desc', + 'learning_files.guide', + 'learning_files.testfile', + 'learning_files.supplement', + 'learning_files.other' + ) + ->leftJoin('learning_files', 'learning_files.topic', '=', 'topics.id') + ->first(); + return view('student/androidcourse/tasks/index') + ->with(compact('entities')) + ->with(compact('items')) + ->with(compact('itemslearning')) + ->with(compact('filter')) + ->with(compact('topic')); + } +} + + +public function getTopic($id){ + $items = \App\AndroidTopic::find($id); + + return $items['name']; +} + + +public function filterTask() { + $filters = \App\AndroidTopic::get(); + $filter = \App\AndroidTopic::findOrFail(Input::get('filter_id')); + + $data= \App\AndroidTask::with('topic')->where('topic', '=' , $filter->id )->latest()->get(); + + return View::make('admin.tasks.index',compact('filters'))->withProfiles($data)->with('title', 'filter'); +} + +/** + * Show the form for creating a new resource. + * + * @return Response + */ +public function create() +{ + // + $items = \App\AndroidTopic::pluck('name', 'id'); +//echo "kljasd;lkasdl"; + return view('admin/tasks/create')->with(compact('items')); +} +/** + * Store a newly created resource in storage. + * + * @return Response + */ +public function store(Request $request) +{ +//echo "YAAANNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"; + // + $rules =[ + 'taskno'=>'required', + 'desc'=>'required' + ]; + + $msg=[ + 'taskno.required'=>'Task number must not empty', + 'desc.required'=>'Description must not empty' + ]; + + $validator=Validator::make($request->all(),$rules,$msg); + + //jika data ada yang kosong + if ($validator->fails()) { + + //refresh halaman + return Redirect::to('admin/tasks/create') + ->withErrors($validator); + + }else{ + + $entity=new \App\AndroidTask; + + $entity->desc=$request->get('desc'); + $entity->taskno=$request->get('taskno'); + $entity->topic=$request->get('topic'); + $entity->save(); + + Session::flash('message','A New Task Stored'); + + //return "Add new topic is success"; + return Redirect::to('admin/tasks'); + } +} + +/** + * Display the specified resource. + * + * @param int $id + * @return Response + */ +public function show(Request $request, $id) +{ + $entity = \App\AndroidTask::find($id); + $topic = \App\AndroidTopic::find($entity->topic); + $x=['data'=>$entity, 'topic'=>$topic]; + + if ($request->is('admin/*')) { + return view('admin/tasks/show')->with($x); + } else { + return view('student/androidcourse/tasks/show')->with($x); + } +} + +/** + * Show the form for editing the specified resource. + * + * @param int $id + * @return Response + */ +public function edit($id) +{ + // + $entity = \App\AndroidTask::find($id); + $x=['data'=>$entity]; + $items = \App\AndroidTopic::pluck('name', 'id'); + return view('admin/tasks/edit')->with($x)->with(compact('items')); +} + +/** + * Update the specified resource in storage. + * + * @param int $id + * @return Response + */ +public function update(Request $request, $id) +{ + // + $rules =[ + 'taskno'=>'required', + 'desc'=>'required' + ]; + + $msg=[ + 'taskno.required'=>'Task number must not empty', + 'desc.required'=>'Description must not empty' + ]; + + + $validator=Validator::make($request->all(),$rules,$msg); + + if ($validator->fails()) { + return Redirect::to('admin/topics/'.$id.'/edit') + ->withErrors($validator); + + }else{ + $entity=\App\AndroidTask::find($id); + + $entity->desc=$request->get('desc'); + $entity->taskno=$request->get('taskno'); + $entity->topic=$request->get('topic'); + $entity->save(); + + Session::flash('message','Task with Id='.$id.' is changed'); + + return Redirect::to('admin/tasks'); + } +} + +/** + * Remove the specified resource from storage. + * + * @param int $id + * @return Response + */ +public function destroy($id) +{ + // + $entity = \App\AndroidTask::find($id); + $entity->delete(); + Session::flash('message','Task with Id='.$id.' is deleted'); + return Redirect::to('admin/tasks'); +} +} diff --git a/app/Http/Controllers/AndroidFileResultController.php b/app/Http/Controllers/AndroidFileResultController.php new file mode 100644 index 0000000..f8fa79d --- /dev/null +++ b/app/Http/Controllers/AndroidFileResultController.php @@ -0,0 +1,131 @@ +get(); + + return view('student/androidcourse/lfiles/create') + ->with(compact('files')) + ->with(compact('topic')); + } + + public function store(Request $request) + { + // + $rules =[ + 'rscfile'=>'required' + ]; + + $msg=[ + 'rscfile.required'=>'Resource File must not empty' + ]; + + $validator=Validator::make($request->all(),$rules,$msg); + + //jika data ada yang kosong + if ($validator->fails()) { + return Redirect::to('student/androidcourse/lfiles/create/'.$request->get('topic')) + ->withErrors($validator); + } else { + $file = $request->file('rscfile'); + $filename = $file->getClientOriginalName(); + + $fileinfo = \App\AndroidTopicFiles::find($request->get('fileid')); + if ($fileinfo['fileName']!=$filename) { + return Redirect::to('student/androidcourse/lfiles/create/'.$request->get('topic')) + ->withErrors("File name should be ".$fileinfo['fileName']); + } else { + $result = \App\AndroidFileResult::where('userid','=',Auth::user()->id) + ->where('fileid','=',$request->get('fileid')) + ->get(); + if (count($result)>0) { + return Redirect::to('student/androidcourse/lfiles/create/'.$request->get('topic')) + ->withErrors('File '.$fileinfo['fileName'].' was already submitted'); + } else { + $rsc=$file->store('resource','public'); + $entity=new \App\AndroidFileResult; + + $entity->userid=Auth::user()->id; + $entity->fileid=$request->get('fileid'); + $entity->rscfile=$rsc; + $entity->save(); + + Session::flash('message','A New File Result Stored'); + + //return "Add new topic is success"; + return Redirect::to('student/androidcourse/results?topicList='.$fileinfo['topic'])->with( [ 'topic' => $request->get('topic') ] ); + } + } + } + } + + public function destroy(Request $request,$id) + { + // + $entity = \App\AndroidFileResult::find($id); + + $path = storage_path('app\\public\\').$entity['rscfile']; + //$path = str_replace('\\',DIRECTORY_SEPARATOR,$path); + + //$dirpath = storage_path('app\\public\\\'); + File::delete(getPath($path)); + + $entity->delete(); + Session::flash('File Result with Id='.$id.' is deleted'); + return Redirect::to('student/androidcourse/results?topicList='.$request->get('topic')); + } + + + public function delete($id,$topic) + { + // + $entity = \App\AndroidFileResult::find($id); + + $path = storage_path('app\\public\\').$entity['rscfile']; + //$path = str_replace('\\',DIRECTORY_SEPARATOR,$path); + + //$dirpath = storage_path('app\\public\\\'); + File::delete($path); + + $entity->delete(); + Session::flash('File Result with Id='.$id.' is deleted'); + return Redirect::to('student/androidcourse/results?topicList='.$topic.'&option=files'); + } + + + public function submit($id) { + // + $entity=new \App\AndroidStudentSubmit; + + $entity->userid=Auth::user()->id; + $entity->topic=$id; + $entity->validstat="valid"; + $entity->save(); + + $topic = \App\AndroidTopic::find($id); + Session::flash('message','Topic '.$topic['name'].' Validation is Success'); + + //return "Add new topic is success"; + return Redirect::to('student/androidcourse/results?topicList='.$id); + + } + + public function getPath($path) { + $res = str_replace('\\',DIRECTORY_SEPARATOR,$path); + return str_replace('/',DIRECTORY_SEPARATOR,$res); + } +} diff --git a/app/Http/Controllers/AndroidResultController.php b/app/Http/Controllers/AndroidResultController.php new file mode 100644 index 0000000..9880c82 --- /dev/null +++ b/app/Http/Controllers/AndroidResultController.php @@ -0,0 +1,404 @@ +id); + //if ($check->count()==0) return view('student/home')->with(['count'=>$check->count()]); +$check=\App\User::find(Auth::user()->id); +if ($check->status!='active') return view('student/androidcourse/home')->with(['status'=>$check->status]); + + $filter = $request->input('topicList','6'); + if ($filter=='0') { + $entities=\App\AndroidTaskResult::where('userid','=',Auth::user()->id); + } else { + $entities = \App\AndroidTask::where('tasks.topic','=',$filter) + ->select( + 'task_results.id', + 'task_results.taskid', + 'task_results.userid', + 'task_results.status', + 'task_results.duration', + 'task_results.comment', + 'task_results.imgFile', + 'tasks.taskno', + 'tasks.desc', + 'tasks.topic' + ) + ->leftJoin('task_results', function($join) + { + $join->on('tasks.id','=','task_results.taskid') + ->where('task_results.userid', '=', Auth::user()->id); + } + ) + ->orderBy('tasks.taskno', 'asc') + ->get(); + } + + $lfiles = \App\AndroidTopicFiles::where('topic_files.topic','=',$filter) + ->select( + 'file_results.id', + 'file_results.userid', + 'file_results.rscfile', + 'file_results.fileid', + 'topic_files.fileName', + 'topic_files.path', + 'topic_files.desc' + ) + ->leftJoin('file_results', function($join) + { + $join->on('topic_files.id','=','file_results.fileid') + ->where('file_results.userid', '=', Auth::user()->id); + } + ) + ->orderBy('topic_files.fileName', 'asc') + ->get(); + + $items = \App\AndroidTopic:: + where('status','>=','0') + ->where('androidclass','=','AndroidX') + ->orderBy('name','asc') + ->orderBy('level','asc') + ->pluck('name', 'id'); + + $valid = \App\AndroidStudentSubmit::where('userid','=',Auth::user()->id) + ->where('topic','=',$filter) + ->get()->count(); + + $option = $request->input('option','github'); + + $currtopic = \App\AndroidTopic::find($filter); + + return view('student/androidcourse/results/index') + ->with(compact('entities')) + ->with(compact('lfiles')) + ->with(compact('items')) + ->with(compact('filter')) + ->with(compact('option')) + ->with(compact('currtopic')) + ->with(compact('valid')); + + } + + + + public function getTaskData($topic) { + $items = \App\AndroidTask::where('tasks.topic','=',$topic) + ->select( + 'tasks.id', + 'tasks.taskno', + 'tasks.desc', + 'topics.name' + ) + ->join( + 'topics', + 'topics.id','=','tasks.topic' + ) + ->orderBy('topics.name', 'asc') + ->orderBy('tasks.taskno', 'asc') + ->get(); + + return $items; + } + public function create($id) + { + $items = \App\AndroidTask::where('topic','=',$id) + ->orderBy('taskno', 'asc') + ->get(); + $topic = \App\AndroidTopic::find($id); + return view('student/androidcourse/results/create') + ->with(compact('topic')) + ->with(compact('items')); + } + +private function validateByFiles($userid, $topic) { + // + $entity=new \App\AndroidStudentSubmit; + + $entity->userid=$userid; + $entity->topic=$topic; + $entity->validstat="valid"; + $entity->save(); + + $data = \App\AndroidTopic::find($topic); + Session::flash('message','Topic '.$data['name'].' Validation is Success'); + + //return "Add new topic is success"; + return Redirect::to('student/androidcourse/results?topicList='.$topic.'&option=files'); +} + +private function validateZipFile($userid, $topic, $file, $path) { + // + //$file = $request->file('zipfile'); + if ($path!='' ) { + //$array = explode('.', $path); + //$ext = strtolower(end($array)); + $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION)); + if ($ext=="zip") { + $zipFile=$file->store('results','public'); + + if ($zipFile!='') { + $entity=new \App\AndroidStudentSubmit; + + $entity->userid=$userid; + $entity->topic=$topic; + $entity->validstat="valid"; + $entity->projectfile=$zipFile; + + $entity->save(); + + $data = \App\AndroidTopic::find($topic); + Session::flash('message','Topic '.$data['name'].' Validation by Uploading Zip Project is Success'); + } else { + Session::flash('message','Storing file '.$request->file('zipfile').' was FAILED'); + } + } else { + Session::flash('message','File extension is not zip -> '.$path.' is wrong .'.$ext); + } + } else { + Session::flash('message','Zip File is empty'); + } + + + //return "Add new topic is success"; + return Redirect::to('student/androidcourse/results?topicList='.$topic.'&option=zipfile'); +} + + +private function validateGithubLink($userid, $topic, $link, $projname) { + // + $trimmedlink = trim($link); + if ($this->validateUrl($trimmedlink,$projname)) { + /* + $zipFile=$file->store('results','public'); + + if ($zipFile!='') { + $entity=new \App\AndroidStudentSubmit; + + $entity->userid=$userid; + $entity->topic=$topic; + $entity->validstat="valid"; + $entity->projectfile=$zipFile; + + $entity->save(); + + $data = \App\AndroidTopic::find($topic); + Session::flash('message','Topic '.$data['name'].' Validation is Success'); + } else { + Session::flash('message','Storing file '.$request->file('zipfile').' was FAILED'); + } + */ + $entity=new \App\AndroidStudentSubmit; + + $entity->userid=$userid; + $entity->topic=$topic; + $entity->validstat="valid"; + $entity->githublink=$trimmedlink; + + $entity->save(); + + $data = \App\AndroidTopic::find($topic); + Session::flash('message','Topic '.$data['name'].' Validation by submitting GitHub link is Success'); + + //Session::flash('message','URL valid '.$link); + + } else { + Session::flash('message','URL is not VALID '.$link); + } + + + //return "Add new topic is success"; + return Redirect::to('student/androidcourse/results?topicList='.$topic.'&option=github'); +} + +private function validateUrl($url,$projname) { + $path = parse_url($url, PHP_URL_PATH); + $encoded_path = array_map('urlencode', explode('/', $path)); + $url = str_replace($path, implode('/', $encoded_path), $url); + + if (filter_var($url, FILTER_VALIDATE_URL)) { + $result = parse_url($url); + if ( ($result['scheme']=='https') && ($this->endsWith($result['host'],'github.com')) + && (strpos($result['path'],$projname)) ) { + return true; + } else { + return false; + } + } else { + return false; + } +} + +private function endsWith($haystack, $needle) { + return substr_compare($haystack, $needle, -strlen($needle)) === 0; +} + + + private function saveTaskResult(Request $request) + { + // + $rules =[ + 'duration'=>'required', + 'image'=>'required', + 'comment'=>'required' + ]; + + $msg=[ + 'duration.required'=>'Duration time must not empty', + 'image.required'=>'Evidence image file must not empty', + 'comment.required'=>'Comment must not empty' + ]; + + $validator=Validator::make($request->all(),$rules,$msg); + + //jika data ada yang kosong + if ($validator->fails()) { + + //refresh halaman + return Redirect::to('student/androidcourse/results/create/'.$request->get('topic')) + ->withErrors($validator); + + } else { + $check = \App\AndroidTaskResult::where('userid','=',Auth::user()->id) + ->where('taskid','=',$request->get('taskid')) + ->get(); + + if (sizeof($check)>0) { + $task = \App\AndroidTask::find($request->get('taskid')); + $message = 'Result of Task '.$task['desc'].' is already submitted!!'; + //Session::flash('message',); + return Redirect::to('student/androidcourse/results/create'.$request->get('topic'))->withErrors($message); + + } else { + $file = $request->file('image'); + $imgFile=$file->store('results','public'); + + $entity=new \App\AndroidTaskResult; + + $comment = ($request->get('comment')==null)?'-':$request->get('comment'); + + $entity->userid=Auth::user()->id; + $entity->taskid=$request->get('taskid'); + $entity->status=$request->get('status'); + $entity->duration=$request->get('duration'); + $entity->comment=$comment; + $entity->imgFile=$imgFile; + $entity->save(); + + Session::flash('message','A New Task Result Stored'); + + //return "Add new topic is success"; + return Redirect::to('student/androidcourse/results?topicList='.$request->get('topic'))->with( [ 'topic' => $request->get('topic') ] ); + } + } + } + + + public function store(Request $request) + { + if (strlen($request->get('option'))>3) { + if (($request->get('action')=='validate') && (strlen($request->submitbutton)>5)) { + if ($request->get('option')=='files') { + return $this->validateByFiles(Auth::user()->id, $request->get('topic')); + } else if ($request->get('option')=='zipfile') { + $file = $request->file('zipfile'); + $filename = $file->getClientOriginalName(); + return $this->validateZipFile(Auth::user()->id, $request->get('topic'), $file, $filename); + } else if ($request->get('option')=='github') { + return $this->validateGithubLink(Auth::user()->id, $request->get('topic'), $request->get('githublink'), + $request->get('projname')); + } else { + return Redirect::to('student/androidcourse/results?topicList='.$request->get('topic').'&option='.$request->get('option'). + '&submit='.$request->submitbutton); + } + } else { //clicking radio button + return Redirect::to('student/androidcourse/results?topicList='.$request->get('topic').'&option='.$request->get('option')); + //'&submit='.$request->submitbutton); + } + + } else { //echo $request; + return $this->saveTaskResult($request); + } + } + + + public function destroy(Request $request, $id) + { + // + $entity = \App\AndroidTaskResult::find($id); + $entity->delete(); + Session::flash('message','Task Result with Id='.$id.' is deleted'); + return Redirect::to('student/androidcourse/results?topicList='.$request->get('topic')); + } + + public function edit($id) + { + // + $entity = \App\AndroidTaskResult::where('id','=',$id)->first(); + $task = \App\AndroidTask::where('id','=',$entity['taskid'])->first(); + return view('student/androidcourse/results/edit')->with(compact('entity')) + ->with(compact('task')); + } + + public function valsub(Request $request) + { + $items = \App\AndroidTask::where('topic','=',$id) + ->orderBy('taskno', 'asc') + ->get(); + $topic = \App\AndroidTopic::find($id); + return view('student/androidcourse/results/create') + ->with(compact('topic')) + ->with(compact('items')); + } + + + public function update(Request $request, $id) { + // + $rules =[ + 'duration'=>'required', + ]; + + $msg=[ + 'duration.required'=>'Duration time must not empty', + ]; + + + $validator=Validator::make($request->all(),$rules,$msg); + + if ($validator->fails()) { + return Redirect::to('student/androidcourse/results/'.$id.'/edit') + ->withErrors($validator); + + }else{ + $file = $request->file('image'); + + $entity=\App\AndroidTaskResult::find($id); + + $entity->taskid=$request->get('taskid'); + $entity->status=$request->get('status'); + $entity->duration=$request->get('duration'); + $entity->comment=$request->get('comment'); + + if ($file!='') { + $imgFile=$file->store('results','public'); + $entity->imgFile=$imgFile; + } + $entity->save(); + + Session::flash('message','Task Result with Id='.$id.' is changed'); + + $task = \App\AndroidTask::find($request->get('taskid')); + return Redirect::to('student/androidcourse/results?topicList='.$task['topic']); + } + } +} + diff --git a/app/Http/Controllers/AndroidTaskResultController.php b/app/Http/Controllers/AndroidTaskResultController.php new file mode 100644 index 0000000..461147d --- /dev/null +++ b/app/Http/Controllers/AndroidTaskResultController.php @@ -0,0 +1,379 @@ +id); +if ($check->status!='active') return view('student/androidcourse/home')->with(['status'=>$check->status]); + + $filter = $request->input('topicList','6'); + if ($filter=='0') { + $entities=\App\AndroidTaskResult::where('userid','=',Auth::user()->id); + } else { + $entities = \App\AndroidTask::where('tasks.topic','=',$filter) + ->select( + 'task_results.id', + 'task_results.taskid', + 'task_results.userid', + 'task_results.status', + 'task_results.duration', + 'task_results.comment', + 'task_results.imgFile', + 'tasks.taskno', + 'tasks.desc', + 'tasks.topic' + ) + ->leftJoin('task_results', function($join) + { + $join->on('tasks.id','=','task_results.taskid') + ->where('task_results.userid', '=', Auth::user()->id); + } + ) + ->orderBy('tasks.taskno', 'asc') + ->get(); + } + + $lfiles = \App\AndroidTopicFiles::where('topic_files.topic','=',$filter) + ->select( + 'file_results.id', + 'file_results.userid', + 'file_results.rscfile', + 'file_results.fileid', + 'topic_files.fileName', + 'topic_files.path', + 'topic_files.desc' + ) + ->leftJoin('file_results', function($join) + { + $join->on('topic_files.id','=','file_results.fileid') + ->where('file_results.userid', '=', Auth::user()->id); + } + ) + ->orderBy('topic_files.fileName', 'asc') + ->get(); + + $items = \App\AndroidTopic:: + where('status','>=','0') + ->where('androidclass','=','AndroidX') + ->orderBy('name','asc') + ->orderBy('level','asc') + ->pluck('name', 'id'); + + $valid = \App\AndroidStudentSubmit::where('userid','=',Auth::user()->id) + ->where('topic','=',$filter) + ->get()->count(); + + $option = $request->input('option','github'); + + $currtopic = \App\AndroidTopic::find($filter); + + return view('student/androidcourse/results/index') + ->with(compact('entities')) + ->with(compact('lfiles')) + ->with(compact('items')) + ->with(compact('filter')) + ->with(compact('option')) + ->with(compact('currtopic')) + ->with(compact('valid')); + + } + + + + public function getTaskData($topic) { + $items = \App\AndroidTask::where('tasks.topic','=',$topic) + ->select( + 'tasks.id', + 'tasks.taskno', + 'tasks.desc', + 'topics.name' + ) + ->join( + 'topics', + 'topics.id','=','tasks.topic' + ) + ->orderBy('topics.name', 'asc') + ->orderBy('tasks.taskno', 'asc') + ->get(); + + return $items; + } + public function create($id) + { + $items = \App\AndroidTask::where('topic','=',$id) + ->orderBy('taskno', 'asc') + ->get(); + $topic = \App\AndroidTopic::find($id); + return view('student/androidcourse/results/create') + ->with(compact('topic')) + ->with(compact('items')); + } + +private function validateByFiles($userid, $topic) { + // + $entity=new \App\AndroidStudentSubmit; + + $entity->userid=$userid; + $entity->topic=$topic; + $entity->validstat="valid"; + $entity->save(); + + $data = \App\AndroidTopic::find($topic); + Session::flash('message','Topic '.$data['name'].' Validation is Success'); + + return Redirect::to('student/androidcourse/results?topicList='.$topic.'&option=files'); +} + +private function validateZipFile($userid, $topic, $file, $path) { + + if ($path!='' ) { + $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION)); + if ($ext=="zip") { + $zipFile=$file->store('results','public'); + + if ($zipFile!='') { + $entity=new \App\AndroidStudentSubmit; + + $entity->userid=$userid; + $entity->topic=$topic; + $entity->validstat="valid"; + $entity->projectfile=$zipFile; + + $entity->save(); + + $data = \App\AndroidTopic::find($topic); + Session::flash('message','Topic '.$data['name'].' Validation by Uploading Zip Project is Success'); + } else { + Session::flash('message','Storing file '.$request->file('zipfile').' was FAILED'); + } + } else { + Session::flash('message','File extension is not zip -> '.$path.' is wrong .'.$ext); + } + } else { + Session::flash('message','Zip File is empty'); + } + + + //return "Add new topic is success"; + return Redirect::to('student/androidcourse/results?topicList='.$topic.'&option=zipfile'); +} + +private function validateGithubLink($userid, $topic, $link, $projname) { + // + $trimmedlink = trim($link); + if ($this->validateUrl($trimmedlink,$projname)) { + + $entity=new \App\AndroidStudentSubmit; + + $entity->userid=$userid; + $entity->topic=$topic; + $entity->validstat="valid"; + $entity->githublink=$trimmedlink; + + $entity->save(); + + $data = \App\AndroidTopic::find($topic); + Session::flash('message','Topic '.$data['name'].' Validation by submitting GitHub link is Success'); + + //Session::flash('message','URL valid '.$link); + + } else { + Session::flash('message','URL is not VALID '.$link); + } + + + //return "Add new topic is success"; + return Redirect::to('student/androidcourse/results?topicList='.$topic.'&option=github'); +} + +private function validateUrl($url,$projname) { + $path = parse_url($url, PHP_URL_PATH); + $encoded_path = array_map('urlencode', explode('/', $path)); + $url = str_replace($path, implode('/', $encoded_path), $url); + + if (filter_var($url, FILTER_VALIDATE_URL)) { + $result = parse_url($url); + if ( ($result['scheme']=='https') && ($this->endsWith($result['host'],'github.com')) + && (strpos($result['path'],$projname)) ) { + return true; + } else { + return false; + } + } else { + return false; + } +} + +private function endsWith($haystack, $needle) { + return substr_compare($haystack, $needle, -strlen($needle)) === 0; +} + + + private function saveTaskResult(Request $request) + { + // + $rules =[ + 'duration'=>'required', + 'image'=>'required', + 'comment'=>'required' + ]; + + $msg=[ + 'duration.required'=>'Duration time must not empty', + 'image.required'=>'Evidence image file must not empty', + 'comment.required'=>'Comment must not empty' + ]; + + $validator=Validator::make($request->all(),$rules,$msg); + + //jika data ada yang kosong + if ($validator->fails()) { + + //refresh halaman + return Redirect::to('student/androidcourse/results/create/'.$request->get('topic')) + ->withErrors($validator); + + } else { + $check = \App\AndroidTaskResult::where('userid','=',Auth::user()->id) + ->where('taskid','=',$request->get('taskid')) + ->get(); + + if (sizeof($check)>0) { + $task = \App\AndroidTask::find($request->get('taskid')); + $message = 'Result of Task '.$task['desc'].' is already submitted!!'; + //Session::flash('message',); + return Redirect::to('student/androidcourse/results/create'.$request->get('topic'))->withErrors($message); + + } else { + $file = $request->file('image'); + $imgFile=$file->store('result','public'); + + $entity=new \App\AndroidTaskResult; + + $comment = ($request->get('comment')==null)?'-':$request->get('comment'); + + $entity->userid=Auth::user()->id; + $entity->taskid=$request->get('taskid'); + $entity->status=$request->get('status'); + $entity->duration=$request->get('duration'); + $entity->comment=$comment; + $entity->imgFile=$imgFile; + $entity->save(); + + Session::flash('message','A New Task Result Stored'); + + //return "Add new topic is success"; + return Redirect::to('student/androidcourse/results?topicList='.$request->get('topic'))->with( [ 'topic' => $request->get('topic') ] ); + } + } + } + + + public function store(Request $request) + { + if (strlen($request->get('option'))>3) { + if (($request->get('action')=='validate') && (strlen($request->submitbutton)>5)) { + if ($request->get('option')=='files') { + return $this->validateByFiles(Auth::user()->id, $request->get('topic')); + } else if ($request->get('option')=='zipfile') { + $file = $request->file('zipfile'); + $filename = $file->getClientOriginalName(); + return $this->validateZipFile(Auth::user()->id, $request->get('topic'), $file, $filename); + } else if ($request->get('option')=='github') { + return $this->validateGithubLink(Auth::user()->id, $request->get('topic'), $request->get('githublink'), + $request->get('projname')); + } else { + return Redirect::to('student/androidcourse/results?topicList='.$request->get('topic').'&option='.$request->get('option'). + '&submit='.$request->submitbutton); + } + } else { //clicking radio button + return Redirect::to('student/androidcourse/results?topicList='.$request->get('topic').'&option='.$request->get('option')); + //'&submit='.$request->submitbutton); + } + + } else { //echo $request; + return $this->saveTaskResult($request); + } + } + + + public function destroy(Request $request, $id) + { + // + $entity = \App\AndroidTaskResult::find($id); + $entity->delete(); + Session::flash('message','Task Result with Id='.$id.' is deleted'); + return Redirect::to('student/androidcourse/results?topicList='.$request->get('topic')); + } + + public function edit($id) + { + // + $entity = \App\AndroidTaskResult::where('id','=',$id)->first(); + $task = \App\AndroidTask::where('id','=',$entity['taskid'])->first(); + return view('student/androidcourse/results/edit')->with(compact('entity')) + ->with(compact('task')); + } + + public function valsub(Request $request) + { + $items = \App\AndroidTask::where('topic','=',$id) + ->orderBy('taskno', 'asc') + ->get(); + $topic = \App\AndroidTopic::find($id); + return view('student/androidcourse/results/create') + ->with(compact('topic')) + ->with(compact('items')); + } + + + public function update(Request $request, $id) { + // + $rules =[ + 'duration'=>'required', + ]; + + $msg=[ + 'duration.required'=>'Duration time must not empty', + ]; + + + $validator=Validator::make($request->all(),$rules,$msg); + + if ($validator->fails()) { + return Redirect::to('student/androidcourse/results/'.$id.'/edit') + ->withErrors($validator); + + }else{ + $file = $request->file('image'); + + $entity=\App\AndroidTaskResult::find($id); + + $entity->taskid=$request->get('taskid'); + $entity->status=$request->get('status'); + $entity->duration=$request->get('duration'); + $entity->comment=$request->get('comment'); + + if ($file!='') { + $imgFile=$file->store('results','public'); + $entity->imgFile=$imgFile; + } + $entity->save(); + + Session::flash('message','Task Result with Id='.$id.' is changed'); + + $task = \App\AndroidTask::find($request->get('taskid')); + return Redirect::to('student/androidcourse/results?topicList='.$task['topic']); + } + } +} + diff --git a/resources/views/student/androidcourse/asynctask/index.blade.php b/resources/views/student/androidcourse/asynctask/index.blade.php deleted file mode 100644 index a0c5226..0000000 --- a/resources/views/student/androidcourse/asynctask/index.blade.php +++ /dev/null @@ -1,206 +0,0 @@ -@extends('student/androidcourse/home') -@section('content') -
-
-
-

- Start Learning Android Programming with iCLOP -

-
-
-
-
- - -
- - -
- - -
-
-
-
- - - - - - - - - - - - - - - - - - - -
Guide DocumentsTest FilesSupplement FilesOther Files
- Resource for - C2:Java - AsyncTask - for - Android Studio - -
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Task No.DescriptionTopic NameShow
1 Create Layout and Project Configuration - C2:Java- AsyncTask Java Edition - -
- -
-
2 Create Layout Activity_Main Image Download - C2:Java- AsyncTask Java Edition - -
- -
-
3Create Layout Activity_Audio Play Music - C2:Java- AsyncTask Java Edition - -
- -
-
4Configuration MainActivity Download Image with AsyncTask - C2:Java- AsyncTask Java Edition - -
- -
-
5Configuration Activity Play Music with AsyncTask - C2:Java- AsyncTask Java Edition - -
- -
-
-
-
-
-
-
-@endsection diff --git a/resources/views/student/androidcourse/bujank/index.blade.php b/resources/views/student/androidcourse/bujank/index.blade.php deleted file mode 100644 index bb92392..0000000 --- a/resources/views/student/androidcourse/bujank/index.blade.php +++ /dev/null @@ -1,336 +0,0 @@ -@extends('student/androidcourse/home') -@section('content') -
-
-
-

- Start Learning Android Programming with iCLOP -

-
-
-
-
- - -
- - -
- - -
-
-
-
- - - - - - - - - - - - - - - - - - - -
Guide DocumentsTest FilesSupplement FilesOther Files
- Resource for - A1:Java - Basic UI Java Edition - for - Android Studio 3.x - - - - - - - - -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Task No.DescriptionTopic NameShow
1Project Configuration - A1:Java - Basic UI Java Edition - for - Android Studio 3.x - -
- -
-
2Resource configuration - A1:Java - Basic UI Java Edition - for - Android Studio 3.x - -
- -
-
3Main layout, textview, button - A1:Java - Basic UI Java Edition - for - Android Studio 3.x - -
- -
-
4Space and Child layout - A1:Java - Basic UI Java Edition - for - Android Studio 3.x - -
- -
-
5String-array, EditText, Spinner - A1:Java - Basic UI Java Edition - for - Android Studio 3.x - -
- -
-
6Checkbox - A1:Java - Basic UI Java Edition - for - Android Studio 3.x - -
- -
-
7RadioGroup - A1:Java - Basic UI Java Edition - for - Android Studio 3.x - -
- -
-
8Image resource and ImageView - A1:Java - Basic UI Java Edition - for - Android Studio 3.x - -
- -
-
9Drawable resource and Table layout - A1:Java - Basic UI Java Edition - for - Android Studio 3.x - -
- -
-
-
-
-
-
-
-@endsection diff --git a/resources/views/student/androidcourse/firebase/index.blade.php b/resources/views/student/androidcourse/firebase/index.blade.php deleted file mode 100644 index bfee176..0000000 --- a/resources/views/student/androidcourse/firebase/index.blade.php +++ /dev/null @@ -1,286 +0,0 @@ -@extends('student/androidcourse/home') -@section('content') -
-
-
-

- Start Learning Android Programming with iCLOP -

-
-
-
-
- - -
- - -
- - -
-
-
-
- - - - - - - - - - - - - - - - - - - -
Guide DocumentsTest FilesSupplement FilesOther Files
- Resource for - A3:Java - Firebase - for - Android Studio - -
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Task No.DescriptionTopic NameShow
1Firebase Configuration - C3:Java - Firebase Java Edition - -
- -
-
2Create Register Activity - C3:Java - Firebase Java Edition - -
- -
-
3Create Login Activity - C3:Java - CFirebase Java Edition - -
- -
-
4Desain UI Seller Home and develope Seller Home Activity - C3:Java - Firebase Java Edition - -
- -
-
5Desain UI Seller Home AddProduct and Develope Seller Home - C3:Java - Firebase Java Edition - -
- -
-
6Desain UI Seller Home Detail Product dan Develop Seller Home Detail Product Activity - C3:Java - Firebase Java Edition - -
- -
-
7Desain UI Buyer Home dan Develop Buyer Home Activity - C3:Java - Firebase Java Edition - -
- -
-
8Desain UI Buyer Home Detail Productdan Develop Buyer Home Detail ProductActivity - C3:Java - Firebase Java Edition - -
- -
-
9Desain UI Cart dan Develop Cart Activity - C3:Java - Firebase Java Edition - -
- -
-
10Desain UI Detail Cart dan Develop Detail Cart Activity - C3:Java - Firebase Java Edition - -
- -
-
-
-
-
-
-
-@endsection diff --git a/resources/views/student/androidcourse/flutter/index.blade.php b/resources/views/student/androidcourse/flutter/index.blade.php deleted file mode 100644 index bfee176..0000000 --- a/resources/views/student/androidcourse/flutter/index.blade.php +++ /dev/null @@ -1,286 +0,0 @@ -@extends('student/androidcourse/home') -@section('content') -
-
-
-

- Start Learning Android Programming with iCLOP -

-
-
-
-
- - -
- - -
- - -
-
-
-
- - - - - - - - - - - - - - - - - - - -
Guide DocumentsTest FilesSupplement FilesOther Files
- Resource for - A3:Java - Firebase - for - Android Studio - -
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Task No.DescriptionTopic NameShow
1Firebase Configuration - C3:Java - Firebase Java Edition - -
- -
-
2Create Register Activity - C3:Java - Firebase Java Edition - -
- -
-
3Create Login Activity - C3:Java - CFirebase Java Edition - -
- -
-
4Desain UI Seller Home and develope Seller Home Activity - C3:Java - Firebase Java Edition - -
- -
-
5Desain UI Seller Home AddProduct and Develope Seller Home - C3:Java - Firebase Java Edition - -
- -
-
6Desain UI Seller Home Detail Product dan Develop Seller Home Detail Product Activity - C3:Java - Firebase Java Edition - -
- -
-
7Desain UI Buyer Home dan Develop Buyer Home Activity - C3:Java - Firebase Java Edition - -
- -
-
8Desain UI Buyer Home Detail Productdan Develop Buyer Home Detail ProductActivity - C3:Java - Firebase Java Edition - -
- -
-
9Desain UI Cart dan Develop Cart Activity - C3:Java - Firebase Java Edition - -
- -
-
10Desain UI Detail Cart dan Develop Detail Cart Activity - C3:Java - Firebase Java Edition - -
- -
-
-
-
-
-
-
-@endsection diff --git a/resources/views/student/androidcourse/footer.blade.php b/resources/views/student/androidcourse/footer.blade.php index 599034a..366a1d7 100644 --- a/resources/views/student/androidcourse/footer.blade.php +++ b/resources/views/student/androidcourse/footer.blade.php @@ -4,5 +4,5 @@ Login as {{ Auth::user()->roleid }} - Copyright © 2020 Android Programming Learning Assistance System (APLAS). All rights reserved. + Copyright © 2022 Intelligent Computer Assisted Programming Learning Platform(iCLOP). All rights reserved. diff --git a/resources/views/student/androidcourse/header.blade.php b/resources/views/student/androidcourse/header.blade.php index 71cb1b4..4f82072 100644 --- a/resources/views/student/androidcourse/header.blade.php +++ b/resources/views/student/androidcourse/header.blade.php @@ -1,18 +1,13 @@ -