diff --git a/app/Http/Controllers/NodejsController.php b/app/Http/Controllers/NodejsController.php
new file mode 100644
index 0000000..0195d3c
--- /dev/null
+++ b/app/Http/Controllers/NodejsController.php
@@ -0,0 +1,249 @@
+roleid=='student/nodejscourse') {
+ $check=\App\User::find(Auth::user()->id);
+ if ($check->status!='active') return view('student/nodejscourse/home')->with(['status'=>$check->status]);
+ }
+ $topiclist=\App\NodejsTopic::where('status','=','1')
+ ->orderBy('name','asc')->get();
+
+ $items = \App\NodejsTopic::where('status','=','1')
+ ->orderBy('status','desc')
+ ->orderBy('name','asc')
+ ->pluck('name', 'id');
+
+ $itemslearning = \App\NodejsTopic::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\NodejsTask::all();
+ } else {
+
+ $entities = \App\NodejsTask::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\NodejsTopic::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/nodejscourse/tasks/index')
+ ->with(compact('entities'))
+ ->with(compact('items'))
+ ->with(compact('itemslearning'))
+ ->with(compact('filter'))
+ ->with(compact('topic'));
+ }
+}
+
+
+public function getTopic($id){
+ $items = \App\NodejsTopic::find($id);
+
+ return $items['name'];
+}
+
+
+public function filterTask() {
+ $filters = \App\NodejsTopic::get();
+ $filter = \App\NodejsTopic::findOrFail(Input::get('filter_id'));
+
+ $data= \App\NodejsTask::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\NodejsTopic::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\NodejsTask;
+
+ $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\NodejsTask::find($id);
+ $topic = \App\NodejsTopic::find($entity->topic);
+ $x=['data'=>$entity, 'topic'=>$topic];
+
+ if ($request->is('admin/*')) {
+ return view('admin/tasks/show')->with($x);
+ } else {
+ return view('student/nodejscourse/tasks/show')->with($x);
+ }
+}
+
+/**
+ * Show the form for editing the specified resource.
+ *
+ * @param int $id
+ * @return Response
+ */
+public function edit($id)
+{
+ //
+ $entity = \App\NodejsTask::find($id);
+ $x=['data'=>$entity];
+ $items = \App\NodejsTopic::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\NodejsTask::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\NodejsTask::find($id);
+ $entity->delete();
+ Session::flash('message','Task with Id='.$id.' is deleted');
+ return Redirect::to('admin/tasks');
+}
+}
diff --git a/app/Http/Controllers/NodejsFileResultController.php b/app/Http/Controllers/NodejsFileResultController.php
new file mode 100644
index 0000000..6e7aabc
--- /dev/null
+++ b/app/Http/Controllers/NodejsFileResultController.php
@@ -0,0 +1,131 @@
+get();
+
+ return view('student/nodejscourse/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/nodejscourse/lfiles/create/'.$request->get('topic'))
+ ->withErrors($validator);
+ } else {
+ $file = $request->file('rscfile');
+ $filename = $file->getClientOriginalName();
+
+ $fileinfo = \App\NodejsTopicFiles::find($request->get('fileid'));
+ if ($fileinfo['fileName']!=$filename) {
+ return Redirect::to('student/nodejscourse/lfiles/create/'.$request->get('topic'))
+ ->withErrors("File name should be ".$fileinfo['fileName']);
+ } else {
+ $result = \App\NodejsFileResult::where('userid','=',Auth::user()->id)
+ ->where('fileid','=',$request->get('fileid'))
+ ->get();
+ if (count($result)>0) {
+ return Redirect::to('student/nodejscourse/lfiles/create/'.$request->get('topic'))
+ ->withErrors('File '.$fileinfo['fileName'].' was already submitted');
+ } else {
+ $rsc=$file->store('resource','public');
+ $entity=new \App\NodejsFileResult;
+
+ $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/nodejscourse/results?topicList='.$fileinfo['topic'])->with( [ 'topic' => $request->get('topic') ] );
+ }
+ }
+ }
+ }
+
+ public function destroy(Request $request,$id)
+ {
+ //
+ $entity = \App\NodejsFileResult::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/nodejscourse/results?topicList='.$request->get('topic'));
+ }
+
+
+ public function delete($id,$topic)
+ {
+ //
+ $entity = \App\NodejsFileResult::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/nodejscourse/results?topicList='.$topic.'&option=files');
+ }
+
+
+ public function submit($id) {
+ //
+ $entity=new \App\NodejsStudentSubmit;
+
+ $entity->userid=Auth::user()->id;
+ $entity->topic=$id;
+ $entity->validstat="valid";
+ $entity->save();
+
+ $topic = \App\NodejsTopic::find($id);
+ Session::flash('message','Topic '.$topic['name'].' Validation is Success');
+
+ //return "Add new topic is success";
+ return Redirect::to('student/nodejscourse/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/NodejsResultController.php b/app/Http/Controllers/NodejsResultController.php
new file mode 100644
index 0000000..0002cbf
--- /dev/null
+++ b/app/Http/Controllers/NodejsResultController.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/nodejscourse/home')->with(['status'=>$check->status]);
+
+ $filter = $request->input('topicList','6');
+ if ($filter=='0') {
+ $entities=\App\NodejsTaskResult::where('userid','=',Auth::user()->id);
+ } else {
+ $entities = \App\NodejsTask::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\NodejsTopicFiles::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\NodejsTopic::
+ where('status','>=','0')
+ ->where('androidclass','=','AndroidX')
+ ->orderBy('name','asc')
+ ->orderBy('level','asc')
+ ->pluck('name', 'id');
+
+ $valid = \App\NodejsStudentSubmit::where('userid','=',Auth::user()->id)
+ ->where('topic','=',$filter)
+ ->get()->count();
+
+ $option = $request->input('option','github');
+
+ $currtopic = \App\NodejsTopic::find($filter);
+
+ return view('student/nodejscourse/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\NodejsTask::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\NodejsTask::where('topic','=',$id)
+ ->orderBy('taskno', 'asc')
+ ->get();
+ $topic = \App\NodejsTopic::find($id);
+ return view('student/nodejscourse/results/create')
+ ->with(compact('topic'))
+ ->with(compact('items'));
+ }
+
+private function validateByFiles($userid, $topic) {
+ //
+ $entity=new \App\NodejsStudentSubmit;
+
+ $entity->userid=$userid;
+ $entity->topic=$topic;
+ $entity->validstat="valid";
+ $entity->save();
+
+ $data = \App\NodejsTopic::find($topic);
+ Session::flash('message','Topic '.$data['name'].' Validation is Success');
+
+ //return "Add new topic is success";
+ return Redirect::to('student/nodejscourse/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\NodejsStudentSubmit;
+
+ $entity->userid=$userid;
+ $entity->topic=$topic;
+ $entity->validstat="valid";
+ $entity->projectfile=$zipFile;
+
+ $entity->save();
+
+ $data = \App\NodejsTopic::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/nodejscourse/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\NodejsStudentSubmit;
+
+ $entity->userid=$userid;
+ $entity->topic=$topic;
+ $entity->validstat="valid";
+ $entity->projectfile=$zipFile;
+
+ $entity->save();
+
+ $data = \App\NodejsTopic::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\NodejsStudentSubmit;
+
+ $entity->userid=$userid;
+ $entity->topic=$topic;
+ $entity->validstat="valid";
+ $entity->githublink=$trimmedlink;
+
+ $entity->save();
+
+ $data = \App\NodejsTopic::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/nodejscourse/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/nodejscourse/results/create/'.$request->get('topic'))
+ ->withErrors($validator);
+
+ } else {
+ $check = \App\NodejsTaskResult::where('userid','=',Auth::user()->id)
+ ->where('taskid','=',$request->get('taskid'))
+ ->get();
+
+ if (sizeof($check)>0) {
+ $task = \App\NodejsTask::find($request->get('taskid'));
+ $message = 'Result of Task '.$task['desc'].' is already submitted!!';
+ //Session::flash('message',);
+ return Redirect::to('student/nodejscourse/results/create'.$request->get('topic'))->withErrors($message);
+
+ } else {
+ $file = $request->file('image');
+ $imgFile=$file->store('results','public');
+
+ $entity=new \App\NodejsTaskResult;
+
+ $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/nodejscourse/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/nodejscourse/results?topicList='.$request->get('topic').'&option='.$request->get('option').
+ '&submit='.$request->submitbutton);
+ }
+ } else { //clicking radio button
+ return Redirect::to('student/nodejscourse/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\NodejsTaskResult::find($id);
+ $entity->delete();
+ Session::flash('message','Task Result with Id='.$id.' is deleted');
+ return Redirect::to('student/nodejscourse/results?topicList='.$request->get('topic'));
+ }
+
+ public function edit($id)
+ {
+ //
+ $entity = \App\NodejsTaskResult::where('id','=',$id)->first();
+ $task = \App\NodejsTask::where('id','=',$entity['taskid'])->first();
+ return view('student/nodejscourse/results/edit')->with(compact('entity'))
+ ->with(compact('task'));
+ }
+
+ public function valsub(Request $request)
+ {
+ $items = \App\NodejsTask::where('topic','=',$id)
+ ->orderBy('taskno', 'asc')
+ ->get();
+ $topic = \App\NodejsTopic::find($id);
+ return view('student/nodejscourse/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/nodejscourse/results/'.$id.'/edit')
+ ->withErrors($validator);
+
+ }else{
+ $file = $request->file('image');
+
+ $entity=\App\NodejsTaskResult::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\NodejsTask::find($request->get('taskid'));
+ return Redirect::to('student/nodejscourse/results?topicList='.$task['topic']);
+ }
+ }
+}
+
diff --git a/app/Http/Controllers/NodejsTaskResultController.php b/app/Http/Controllers/NodejsTaskResultController.php
new file mode 100644
index 0000000..7d6392b
--- /dev/null
+++ b/app/Http/Controllers/NodejsTaskResultController.php
@@ -0,0 +1,379 @@
+id);
+if ($check->status!='active') return view('student/nodejscourse/home')->with(['status'=>$check->status]);
+
+ $filter = $request->input('topicList','6');
+ if ($filter=='0') {
+ $entities=\App\NodejsTaskResult::where('userid','=',Auth::user()->id);
+ } else {
+ $entities = \App\NodejsTask::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\NodejsTopicFiles::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\NodejsTopic::
+ where('status','>=','0')
+ ->where('androidclass','=','AndroidX')
+ ->orderBy('name','asc')
+ ->orderBy('level','asc')
+ ->pluck('name', 'id');
+
+ $valid = \App\NodejsStudentSubmit::where('userid','=',Auth::user()->id)
+ ->where('topic','=',$filter)
+ ->get()->count();
+
+ $option = $request->input('option','github');
+
+ $currtopic = \App\NodejsTopic::find($filter);
+
+ return view('student/nodejscourse/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\NodejsTask::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\NodejsTask::where('topic','=',$id)
+ ->orderBy('taskno', 'asc')
+ ->get();
+ $topic = \App\NodejsTopic::find($id);
+ return view('student/nodejscourse/results/create')
+ ->with(compact('topic'))
+ ->with(compact('items'));
+ }
+
+private function validateByFiles($userid, $topic) {
+ //
+ $entity=new \App\NodejsStudentSubmit;
+
+ $entity->userid=$userid;
+ $entity->topic=$topic;
+ $entity->validstat="valid";
+ $entity->save();
+
+ $data = \App\NodejsTopic::find($topic);
+ Session::flash('message','Topic '.$data['name'].' Validation is Success');
+
+ return Redirect::to('student/nodejscourse/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\NodejsStudentSubmit;
+
+ $entity->userid=$userid;
+ $entity->topic=$topic;
+ $entity->validstat="valid";
+ $entity->projectfile=$zipFile;
+
+ $entity->save();
+
+ $data = \App\NodejsTopic::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/nodejscourse/results?topicList='.$topic.'&option=zipfile');
+}
+
+private function validateGithubLink($userid, $topic, $link, $projname) {
+ //
+ $trimmedlink = trim($link);
+ if ($this->validateUrl($trimmedlink,$projname)) {
+
+ $entity=new \App\NodejsStudentSubmit;
+
+ $entity->userid=$userid;
+ $entity->topic=$topic;
+ $entity->validstat="valid";
+ $entity->githublink=$trimmedlink;
+
+ $entity->save();
+
+ $data = \App\NodejsTopic::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/nodejscourse/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/nodejscourse/results/create/'.$request->get('topic'))
+ ->withErrors($validator);
+
+ } else {
+ $check = \App\NodejsTaskResult::where('userid','=',Auth::user()->id)
+ ->where('taskid','=',$request->get('taskid'))
+ ->get();
+
+ if (sizeof($check)>0) {
+ $task = \App\NodejsTask::find($request->get('taskid'));
+ $message = 'Result of Task '.$task['desc'].' is already submitted!!';
+ //Session::flash('message',);
+ return Redirect::to('student/nodejscourse/results/create'.$request->get('topic'))->withErrors($message);
+
+ } else {
+ $file = $request->file('image');
+ $imgFile=$file->store('result','public');
+
+ $entity=new \App\NodejsTaskResult;
+
+ $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/nodejscourse/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/nodejscourse/results?topicList='.$request->get('topic').'&option='.$request->get('option').
+ '&submit='.$request->submitbutton);
+ }
+ } else { //clicking radio button
+ return Redirect::to('student/nodejscourse/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\NodejsTaskResult::find($id);
+ $entity->delete();
+ Session::flash('message','Task Result with Id='.$id.' is deleted');
+ return Redirect::to('student/nodejscourse/results?topicList='.$request->get('topic'));
+ }
+
+ public function edit($id)
+ {
+ //
+ $entity = \App\NodejsTaskResult::where('id','=',$id)->first();
+ $task = \App\NodejsTask::where('id','=',$entity['taskid'])->first();
+ return view('student/nodejscourse/results/edit')->with(compact('entity'))
+ ->with(compact('task'));
+ }
+
+ public function valsub(Request $request)
+ {
+ $items = \App\NodejsTask::where('topic','=',$id)
+ ->orderBy('taskno', 'asc')
+ ->get();
+ $topic = \App\NodejsTopic::find($id);
+ return view('student/nodejscourse/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/nodejscourse/results/'.$id.'/edit')
+ ->withErrors($validator);
+
+ }else{
+ $file = $request->file('image');
+
+ $entity=\App\NodejsTaskResult::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\NodejsTask::find($request->get('taskid'));
+ return Redirect::to('student/nodejscourse/results?topicList='.$task['topic']);
+ }
+ }
+}
+
diff --git a/app/Http/Controllers/UnityController.php b/app/Http/Controllers/UnityController.php
new file mode 100644
index 0000000..945e386
--- /dev/null
+++ b/app/Http/Controllers/UnityController.php
@@ -0,0 +1,249 @@
+roleid=='student/unitycourse') {
+ $check=\App\User::find(Auth::user()->id);
+ if ($check->status!='active') return view('student/unitycourse/home')->with(['status'=>$check->status]);
+ }
+ $topiclist=\App\UnityTopic::where('status','=','1')
+ ->orderBy('name','asc')->get();
+
+ $items = \App\UnityTopic::where('status','=','1')
+ ->orderBy('status','desc')
+ ->orderBy('name','asc')
+ ->pluck('name', 'id');
+
+ $itemslearning = \App\UnityTopic::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\UnityTask::all();
+ } else {
+
+ $entities = \App\UnityTask::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\UnityTopic::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/unitycourse/tasks/index')
+ ->with(compact('entities'))
+ ->with(compact('items'))
+ ->with(compact('itemslearning'))
+ ->with(compact('filter'))
+ ->with(compact('topic'));
+ }
+}
+
+
+public function getTopic($id){
+ $items = \App\UnityTopic::find($id);
+
+ return $items['name'];
+}
+
+
+public function filterTask() {
+ $filters = \App\UnityTopic::get();
+ $filter = \App\UnityTopic::findOrFail(Input::get('filter_id'));
+
+ $data= \App\UnityTask::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\UnityTopic::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\UnityTask;
+
+ $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\UnityTask::find($id);
+ $topic = \App\UnityTopic::find($entity->topic);
+ $x=['data'=>$entity, 'topic'=>$topic];
+
+ if ($request->is('admin/*')) {
+ return view('admin/tasks/show')->with($x);
+ } else {
+ return view('student/unitycourse/tasks/show')->with($x);
+ }
+}
+
+/**
+ * Show the form for editing the specified resource.
+ *
+ * @param int $id
+ * @return Response
+ */
+public function edit($id)
+{
+ //
+ $entity = \App\UnityTask::find($id);
+ $x=['data'=>$entity];
+ $items = \App\UnityTopic::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\UnityTask::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\UnityTask::find($id);
+ $entity->delete();
+ Session::flash('message','Task with Id='.$id.' is deleted');
+ return Redirect::to('admin/tasks');
+}
+}
diff --git a/app/Http/Controllers/UnityFileResultController.php b/app/Http/Controllers/UnityFileResultController.php
new file mode 100644
index 0000000..7c7700f
--- /dev/null
+++ b/app/Http/Controllers/UnityFileResultController.php
@@ -0,0 +1,131 @@
+get();
+
+ return view('student/unitycourse/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/unitycourse/lfiles/create/'.$request->get('topic'))
+ ->withErrors($validator);
+ } else {
+ $file = $request->file('rscfile');
+ $filename = $file->getClientOriginalName();
+
+ $fileinfo = \App\UnityTopicFiles::find($request->get('fileid'));
+ if ($fileinfo['fileName']!=$filename) {
+ return Redirect::to('student/unitycourse/lfiles/create/'.$request->get('topic'))
+ ->withErrors("File name should be ".$fileinfo['fileName']);
+ } else {
+ $result = \App\UnityFileResult::where('userid','=',Auth::user()->id)
+ ->where('fileid','=',$request->get('fileid'))
+ ->get();
+ if (count($result)>0) {
+ return Redirect::to('student/unitycourse/lfiles/create/'.$request->get('topic'))
+ ->withErrors('File '.$fileinfo['fileName'].' was already submitted');
+ } else {
+ $rsc=$file->store('resource','public');
+ $entity=new \App\UnityFileResult;
+
+ $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/unitycourse/results?topicList='.$fileinfo['topic'])->with( [ 'topic' => $request->get('topic') ] );
+ }
+ }
+ }
+ }
+
+ public function destroy(Request $request,$id)
+ {
+ //
+ $entity = \App\UnityFileResult::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/unitycourse/results?topicList='.$request->get('topic'));
+ }
+
+
+ public function delete($id,$topic)
+ {
+ //
+ $entity = \App\UnityFileResult::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/unitycourse/results?topicList='.$topic.'&option=files');
+ }
+
+
+ public function submit($id) {
+ //
+ $entity=new \App\UnityStudentSubmit;
+
+ $entity->userid=Auth::user()->id;
+ $entity->topic=$id;
+ $entity->validstat="valid";
+ $entity->save();
+
+ $topic = \App\UnityTopic::find($id);
+ Session::flash('message','Topic '.$topic['name'].' Validation is Success');
+
+ //return "Add new topic is success";
+ return Redirect::to('student/unitycourse/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/UnityResultController.php b/app/Http/Controllers/UnityResultController.php
new file mode 100644
index 0000000..a58b3a7
--- /dev/null
+++ b/app/Http/Controllers/UnityResultController.php
@@ -0,0 +1,385 @@
+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/unitycourse/home')->with(['status'=>$check->status]);
+
+ $filter = $request->input('topicList','6');
+ if ($filter=='0') {
+ $entities=\App\UnityTaskResult::where('userid','=',Auth::user()->id);
+ } else {
+ $entities = \App\UnityTask::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\UnityTopicFiles::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\UnityTopic::
+ where('status','>=','0')
+ ->where('androidclass','=','AndroidX')
+ ->orderBy('name','asc')
+ ->orderBy('level','asc')
+ ->pluck('name', 'id');
+
+ $valid = \App\UnityStudentSubmit::where('userid','=',Auth::user()->id)
+ ->where('topic','=',$filter)
+ ->get()->count();
+
+ $option = $request->input('option','github');
+
+ $currtopic = \App\UnityTopic::find($filter);
+
+ return view('student/unitycourse/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\UnityTask::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\UnityTask::where('topic','=',$id)
+ ->orderBy('taskno', 'asc')
+ ->get();
+ $topic = \App\UnityTopic::find($id);
+ return view('student/unitycourse/results/create')
+ ->with(compact('topic'))
+ ->with(compact('items'));
+ }
+
+private function validateByFiles($userid, $topic) {
+ //
+ $entity=new \App\UnityStudentSubmit;
+
+ $entity->userid=$userid;
+ $entity->topic=$topic;
+ $entity->validstat="valid";
+ $entity->save();
+
+ $data = \App\UnityTopic::find($topic);
+ Session::flash('message','Topic '.$data['name'].' Validation is Success');
+
+ //return "Add new topic is success";
+ return Redirect::to('student/unitycourse/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\UnityStudentSubmit;
+
+ $entity->userid=$userid;
+ $entity->topic=$topic;
+ $entity->validstat="valid";
+ $entity->projectfile=$zipFile;
+
+ $entity->save();
+
+ $data = \App\UnityTopic::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/unitycourse/results?topicList='.$topic.'&option=zipfile');
+}
+
+
+private function validateGithubLink($userid, $topic, $link, $projname) {
+ //
+ $trimmedlink = trim($link);
+ if ($this->validateUrl($trimmedlink,$projname)) {
+ $entity=new \App\UnityStudentSubmit;
+
+ $entity->userid=$userid;
+ $entity->topic=$topic;
+ $entity->validstat="valid";
+ $entity->githublink=$trimmedlink;
+
+ $entity->save();
+
+ $data = \App\UnityTopic::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/unitycourse/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/unitycourse/results/create/'.$request->get('topic'))
+ ->withErrors($validator);
+
+ } else {
+ $check = \App\UnityTaskResult::where('userid','=',Auth::user()->id)
+ ->where('taskid','=',$request->get('taskid'))
+ ->get();
+
+ if (sizeof($check)>0) {
+ $task = \App\UnityTask::find($request->get('taskid'));
+ $message = 'Result of Task '.$task['desc'].' is already submitted!!';
+ //Session::flash('message',);
+ return Redirect::to('student/unitycourse/results/create'.$request->get('topic'))->withErrors($message);
+
+ } else {
+ $file = $request->file('image');
+ $imgFile=$file->store('results','public');
+
+ $entity=new \App\UnityTaskResult;
+
+ $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/unitycourse/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/unitycourse/results?topicList='.$request->get('topic').'&option='.$request->get('option').
+ '&submit='.$request->submitbutton);
+ }
+ } else { //clicking radio button
+ return Redirect::to('student/unitycourse/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\UnityTaskResult::find($id);
+ $entity->delete();
+ Session::flash('message','Task Result with Id='.$id.' is deleted');
+ return Redirect::to('student/unitycourse/results?topicList='.$request->get('topic'));
+ }
+
+ public function edit($id)
+ {
+ //
+ $entity = \App\UnityTaskResult::where('id','=',$id)->first();
+ $task = \App\UnityTask::where('id','=',$entity['taskid'])->first();
+ return view('student/unitycourse/results/edit')->with(compact('entity'))
+ ->with(compact('task'));
+ }
+
+ public function valsub(Request $request)
+ {
+ $items = \App\UnityTask::where('topic','=',$id)
+ ->orderBy('taskno', 'asc')
+ ->get();
+ $topic = \App\UnityTopic::find($id);
+ return view('student/unitycourse/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/unitycourse/results/'.$id.'/edit')
+ ->withErrors($validator);
+
+ }else{
+ $file = $request->file('image');
+
+ $entity=\App\UnityTaskResult::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\UnityTask::find($request->get('taskid'));
+ return Redirect::to('student/unitycourse/results?topicList='.$task['topic']);
+ }
+ }
+}
+
diff --git a/app/Http/Controllers/UnityTaskResultController.php b/app/Http/Controllers/UnityTaskResultController.php
new file mode 100644
index 0000000..213481d
--- /dev/null
+++ b/app/Http/Controllers/UnityTaskResultController.php
@@ -0,0 +1,379 @@
+id);
+if ($check->status!='active') return view('student/unitycourse/home')->with(['status'=>$check->status]);
+
+ $filter = $request->input('topicList','6');
+ if ($filter=='0') {
+ $entities=\App\UnityTaskResult::where('userid','=',Auth::user()->id);
+ } else {
+ $entities = \App\UnityTask::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\UnityTopicFiles::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\UnityTopic::
+ where('status','>=','0')
+ ->where('androidclass','=','AndroidX')
+ ->orderBy('name','asc')
+ ->orderBy('level','asc')
+ ->pluck('name', 'id');
+
+ $valid = \App\UnityStudentSubmit::where('userid','=',Auth::user()->id)
+ ->where('topic','=',$filter)
+ ->get()->count();
+
+ $option = $request->input('option','github');
+
+ $currtopic = \App\UnityTopic::find($filter);
+
+ return view('student/unitycourse/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\UnityTask::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\UnityTask::where('topic','=',$id)
+ ->orderBy('taskno', 'asc')
+ ->get();
+ $topic = \App\UnityTopic::find($id);
+ return view('student/unitycourse/results/create')
+ ->with(compact('topic'))
+ ->with(compact('items'));
+ }
+
+private function validateByFiles($userid, $topic) {
+ //
+ $entity=new \App\UnityStudentSubmit;
+
+ $entity->userid=$userid;
+ $entity->topic=$topic;
+ $entity->validstat="valid";
+ $entity->save();
+
+ $data = \App\UnityTopic::find($topic);
+ Session::flash('message','Topic '.$data['name'].' Validation is Success');
+
+ return Redirect::to('student/unitycourse/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\UnityStudentSubmit;
+
+ $entity->userid=$userid;
+ $entity->topic=$topic;
+ $entity->validstat="valid";
+ $entity->projectfile=$zipFile;
+
+ $entity->save();
+
+ $data = \App\UnityTopic::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/unitycourse/results?topicList='.$topic.'&option=zipfile');
+}
+
+private function validateGithubLink($userid, $topic, $link, $projname) {
+ //
+ $trimmedlink = trim($link);
+ if ($this->validateUrl($trimmedlink,$projname)) {
+
+ $entity=new \App\UnityStudentSubmit;
+
+ $entity->userid=$userid;
+ $entity->topic=$topic;
+ $entity->validstat="valid";
+ $entity->githublink=$trimmedlink;
+
+ $entity->save();
+
+ $data = \App\UnityTopic::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/unitycourse/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/unitycourse/results/create/'.$request->get('topic'))
+ ->withErrors($validator);
+
+ } else {
+ $check = \App\UnityTaskResult::where('userid','=',Auth::user()->id)
+ ->where('taskid','=',$request->get('taskid'))
+ ->get();
+
+ if (sizeof($check)>0) {
+ $task = \App\UnityTask::find($request->get('taskid'));
+ $message = 'Result of Task '.$task['desc'].' is already submitted!!';
+ //Session::flash('message',);
+ return Redirect::to('student/unitycourse/results/create'.$request->get('topic'))->withErrors($message);
+
+ } else {
+ $file = $request->file('image');
+ $imgFile=$file->store('result','public');
+
+ $entity=new \App\UnityTaskResult;
+
+ $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/unitycourse/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/unitycourse/results?topicList='.$request->get('topic').'&option='.$request->get('option').
+ '&submit='.$request->submitbutton);
+ }
+ } else { //clicking radio button
+ return Redirect::to('student/unitycourse/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\UnityTaskResult::find($id);
+ $entity->delete();
+ Session::flash('message','Task Result with Id='.$id.' is deleted');
+ return Redirect::to('student/unitycourse/results?topicList='.$request->get('topic'));
+ }
+
+ public function edit($id)
+ {
+ //
+ $entity = \App\UnityTaskResult::where('id','=',$id)->first();
+ $task = \App\UnityTask::where('id','=',$entity['taskid'])->first();
+ return view('student/unitycourse/results/edit')->with(compact('entity'))
+ ->with(compact('task'));
+ }
+
+ public function valsub(Request $request)
+ {
+ $items = \App\UnityTask::where('topic','=',$id)
+ ->orderBy('taskno', 'asc')
+ ->get();
+ $topic = \App\UnityTopic::find($id);
+ return view('student/unitycourse/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/unitycourse/results/'.$id.'/edit')
+ ->withErrors($validator);
+
+ }else{
+ $file = $request->file('image');
+
+ $entity=\App\UnityTaskResult::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\UnityTask::find($request->get('taskid'));
+ return Redirect::to('student/unitycourse/results?topicList='.$task['topic']);
+ }
+ }
+}
+
diff --git a/app/Http/Controllers/python/ExercisePythonController.php b/app/Http/Controllers/python/ExercisePythonController.php
index 847bcb2..c23a72b 100644
--- a/app/Http/Controllers/python/ExercisePythonController.php
+++ b/app/Http/Controllers/python/ExercisePythonController.php
@@ -164,7 +164,7 @@ class ExercisePythonController extends Controller
$unittest = "C:\\xampp\\htdocs\\iCLOP\\public\\python-resources\\unittest\\". $fileUnittest;
- $output = shell_exec("C:\Users\Rania\AppData\Local\Programs\Python\Python310\python.exe ".$unittest." ".$packageDirectory." ".$fileName." --verbose 2>&1");
+ $output = shell_exec("C:\Users\Rania\AppData\Local\Programs\Python\Python310\python.exe".$unittest." ".$packageDirectory." ".$fileName." --verbose 2>&1");
$validation_detail = "";
$status = "";
diff --git a/app/Http/Controllers/python/ResultController.php b/app/Http/Controllers/python/ResultController.php
index 4f9fabb..459dc30 100644
--- a/app/Http/Controllers/python/ResultController.php
+++ b/app/Http/Controllers/python/ResultController.php
@@ -52,7 +52,7 @@ class ResultController extends Controller
}
// view
- return view('student.pythoncourse.python_result.result_student', compact('dt_hasil'));
+ return view('student.python_result.result_student', compact('dt_hasil'));
}
@@ -89,19 +89,32 @@ class ResultController extends Controller
];
- $dt_validation = DB::table('python_students_validation')->select('python_students_validation.*', 'users.id', 'users.name')
- ->join('users', 'users.id', '=', 'python_students_validation.userid')
- ->where( $where );
+ // $dt_validation = DB::table('python_students_validation')->select('python_students_validation.*', 'users.id', 'users.name')
+ // ->join('users', 'users.id', '=', 'python_students_validation.userid')
+ // ->where( $where );
- $totalEnroll = $dt_validation->count();
- $dataSubmit = $dt_validation->get();
+ // $totalEnroll = $dt_validation->count();
+ // $dataSubmit = $dt_validation->get();
+ // array_push( $allPercobaan, array(
+
+ // 'percobaan' => $percobaan,
+ // 'validation' => $dataSubmit,
+ // 'total' => $totalEnroll,
+ // ) );
+
+ $dt_submit = DB::table("python_students_submit")->select("python_students_submit.*", 'users.id', 'users.name')
+ ->join('users', 'users.id', '=', 'python_students_submit.userid')
+ ->where( $where )->groupBy('python_students_submit.userid');
+
+ $totalEnroll = $dt_submit->count();
+ $dataSubmit = $dt_submit->get();
array_push( $allPercobaan, array(
- 'percobaan' => $percobaan,
- 'validation' => $dataSubmit,
+ 'percobaan' => $percobaan,
+ 'submitted' => $dataSubmit,
'total' => $totalEnroll,
) );
// echo $percobaan->nama_percobaan.' : '.$totalEnroll.'
';
@@ -143,34 +156,65 @@ class ResultController extends Controller
$allPercobaan = array();
$where = [
- 'python_students_validation.id_percobaan' => $id_percobaan,
+ 'id_percobaan' => $id_percobaan,
'uplink' => Auth::id() // id_dosen
];
- $dt_validation = DB::table('python_students_validation')->select('python_students_validation.*', 'users.id', 'users.name', 'checkresult')
- ->join('python_students_submit', 'python_students_submit.id_submit', '=', 'python_students_validation.id_submit')
- ->join('users', 'users.id', '=', 'python_students_validation.userid')
- ->where( $where );
+ // $dt_validation = DB::table('python_students_validation')->select('python_students_validation.*', 'users.id', 'users.name', 'checkresult')
+ // ->join('python_students_submit', 'python_students_submit.id_submit', '=', 'python_students_validation.id_submit')
+ // ->join('users', 'users.id', '=', 'python_students_validation.userid')
+ // ->where( $where );
- $totalEnroll = $dt_validation->count();
- $dataSubmit = $dt_validation->get();
+ // $totalEnroll = $dt_validation->count();
+ // $dataSubmit = $dt_validation->get();
- $allPercobaan = array(
+ // $allPercobaan = array(
- 'percobaan' => $dt_percobaan,
- 'validation' => $dataSubmit,
- 'total' => $totalEnroll,
- );
+ // 'percobaan' => $dt_percobaan,
+ // 'validation' => $dataSubmit,
+ // 'total' => $totalEnroll,
+ // );
+
+
+ $allSubmit = array();
+ $dt_submit = DB::table("python_students_submit")->select("python_students_submit.*", 'users.id', 'users.name')
+ ->join('users', 'users.id', '=', 'python_students_submit.userid')
+ ->where( $where )->groupBy('python_students_submit.userid');
+
+
+ foreach ( $dt_submit->get() as $row ) {
+
+ // detail submit
+ $where = array('python_students_submit.userid' => $row->id, 'python_students_submit.id_percobaan' => $id_percobaan);
+
+ $detail = DB::table("python_students_submit")->select("python_students_submit.*", "python_students_validation.*")
+ ->join('python_students_validation', 'python_students_submit.id_submit', '=', 'python_students_validation.id_submit', 'left outer')
+ ->where( $where )->get();
+
+ $wherePassed = array_merge( $where, array('checkstat' => "PASSED") );
+ $cekKondisi = DB::table("python_students_submit")->select("python_students_submit.*")->where( $wherePassed )->count();
+ $statusPassed = false;
+
+ if ( $cekKondisi > 0 ) $statusPassed = true;
+
+ array_push( $allSubmit, array(
+
+ 'infoMhs' => $row,
+ 'log' => $detail,
+ 'status' => $statusPassed
+ ) );
+
+ }
// hitung mahasiswa berdasarkan dospem
$mhs = DB::table('users')->where('uplink', Auth::id())->count();
$dosen = DB::table('users')->where('id', Auth::id())->first();
- return view('teacher.python.py_student_result_detail', compact( 'allPercobaan', 'mhs', 'dosen', 'topik', 'dt_percobaan' ));
+ return view('teacher.python.py_student_result_detail', compact( 'allSubmit', 'mhs', 'dosen', 'topik', 'dt_percobaan' ));
}
}
diff --git a/app/NodejsStudentSubmit.php b/app/NodejsStudentSubmit.php
new file mode 100644
index 0000000..1d52852
--- /dev/null
+++ b/app/NodejsStudentSubmit.php
@@ -0,0 +1,12 @@
+belongsTo(App\NodejsTopic::class);
+ }
+
+ public function getTopic($id) {
+ return \App\NodejsTopic::find($id)->name;
+ }
+
+ public function getListTopic() {
+ return \App\NodejsTopic::pluck('name', 'id');
+ }
+}
diff --git a/app/NodejsTaskResult.php b/app/NodejsTaskResult.php
new file mode 100644
index 0000000..409ad2c
--- /dev/null
+++ b/app/NodejsTaskResult.php
@@ -0,0 +1,11 @@
+hasMany('App\NodejsTask');
+ }
+
+ public function topic_files() {
+ return $this->hasMany('App\NodejsTopicFiles');
+ }
+
+ public function test_files() {
+ return $this->hasMany('App\NodejsTestFiles');
+ }
+}
diff --git a/app/NodejsTopicFiles.php b/app/NodejsTopicFiles.php
new file mode 100644
index 0000000..2b691c1
--- /dev/null
+++ b/app/NodejsTopicFiles.php
@@ -0,0 +1,15 @@
+belongsTo(App\NodejsTopic::class);
+ }
+}
diff --git a/app/NodejsUser.php b/app/NodejsUser.php
new file mode 100644
index 0000000..c625ab7
--- /dev/null
+++ b/app/NodejsUser.php
@@ -0,0 +1,52 @@
+ 'datetime',
+ ];
+
+ public function checkRoleId($roleid) {
+ if ($roleid=='student') {
+ return Redirect::to('student/Nodejscourse/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/UnityStudentSubmit.php b/app/UnityStudentSubmit.php
new file mode 100644
index 0000000..de33156
--- /dev/null
+++ b/app/UnityStudentSubmit.php
@@ -0,0 +1,12 @@
+belongsTo(App\UnityTopic::class);
+ }
+
+ public function getTopic($id) {
+ return \App\UnityTopic::find($id)->name;
+ }
+
+ public function getListTopic() {
+ return \App\UnityTopic::pluck('name', 'id');
+ }
+}
diff --git a/app/UnityTaskResult.php b/app/UnityTaskResult.php
new file mode 100644
index 0000000..6ed6e04
--- /dev/null
+++ b/app/UnityTaskResult.php
@@ -0,0 +1,11 @@
+hasMany('App\UnityTask');
+ }
+
+ public function topic_files() {
+ return $this->hasMany('App\UnityTopicFiles');
+ }
+
+ public function test_files() {
+ return $this->hasMany('App\UnityTestFiles');
+ }
+}
diff --git a/app/UnityTopicFiles.php b/app/UnityTopicFiles.php
new file mode 100644
index 0000000..f72ce1b
--- /dev/null
+++ b/app/UnityTopicFiles.php
@@ -0,0 +1,15 @@
+belongsTo(App\UnityTopic::class);
+ }
+}
diff --git a/app/UnityUser.php b/app/UnityUser.php
new file mode 100644
index 0000000..b6e56a1
--- /dev/null
+++ b/app/UnityUser.php
@@ -0,0 +1,52 @@
+ 'datetime',
+ ];
+
+ public function checkRoleId($roleid) {
+ if ($roleid=='student') {
+ return Redirect::to('student/unitycourse/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/public/python-resources/unittest/jawaban/633d42e2e34ff_1664959202.py b/public/python-resources/unittest/jawaban/633d42e2e34ff_1664959202.py
new file mode 100644
index 0000000..4dae200
--- /dev/null
+++ b/public/python-resources/unittest/jawaban/633d42e2e34ff_1664959202.py
@@ -0,0 +1,2 @@
+# Tuliskan kode program dibawah ini
+print "anak"
\ No newline at end of file
diff --git a/public/python-resources/unittest/jawaban/633d430dd6c4c_1664959245.py b/public/python-resources/unittest/jawaban/633d430dd6c4c_1664959245.py
new file mode 100644
index 0000000..3bbde22
--- /dev/null
+++ b/public/python-resources/unittest/jawaban/633d430dd6c4c_1664959245.py
@@ -0,0 +1 @@
+print "polinema"
\ No newline at end of file
diff --git a/public/python-resources/unittest/jawaban/633d4347b24c1_1664959303.py b/public/python-resources/unittest/jawaban/633d4347b24c1_1664959303.py
new file mode 100644
index 0000000..b72b8c3
--- /dev/null
+++ b/public/python-resources/unittest/jawaban/633d4347b24c1_1664959303.py
@@ -0,0 +1,2 @@
+# Tuliskan kode program dibawah ini
+print ("coba")
\ No newline at end of file
diff --git a/public/python-resources/unittest/jawaban/633d44381dfb1_1664959544.py b/public/python-resources/unittest/jawaban/633d44381dfb1_1664959544.py
new file mode 100644
index 0000000..84f0ead
--- /dev/null
+++ b/public/python-resources/unittest/jawaban/633d44381dfb1_1664959544.py
@@ -0,0 +1,6 @@
+# Tuliskan variabel dibawah ini
+umur = 23
+
+def konversi(umur):
+ return str(umur)
+print (type (konversi(umu))
\ No newline at end of file
diff --git a/public/python-resources/unittest/jawaban/633d443ea3caa_1664959550.py b/public/python-resources/unittest/jawaban/633d443ea3caa_1664959550.py
new file mode 100644
index 0000000..c0ae9eb
--- /dev/null
+++ b/public/python-resources/unittest/jawaban/633d443ea3caa_1664959550.py
@@ -0,0 +1,6 @@
+# Tuliskan variabel dibawah ini
+umur = 23
+
+def konversi(umur):
+ return str(umur)
+print (type (konversi(umur))
\ No newline at end of file
diff --git a/public/python-resources/unittest/jawaban/633d444896752_1664959560.py b/public/python-resources/unittest/jawaban/633d444896752_1664959560.py
new file mode 100644
index 0000000..24b3c65
--- /dev/null
+++ b/public/python-resources/unittest/jawaban/633d444896752_1664959560.py
@@ -0,0 +1,6 @@
+# Tuliskan variabel dibawah ini
+umur = 22
+
+def konversi(umur):
+ return str(umur)
+print (type (konversi(umur))
\ No newline at end of file
diff --git a/public/python-resources/unittest/jawaban/633d44653b089_1664959589.py b/public/python-resources/unittest/jawaban/633d44653b089_1664959589.py
new file mode 100644
index 0000000..988725f
--- /dev/null
+++ b/public/python-resources/unittest/jawaban/633d44653b089_1664959589.py
@@ -0,0 +1,6 @@
+# Tuliskan variabel dibawah ini
+umur = 22
+
+def konversi(umur):
+ return str(umur)
+print (type(konversi(umur))
\ No newline at end of file
diff --git a/public/python-resources/unittest/jawaban/633d44a097ab0_1664959648.py b/public/python-resources/unittest/jawaban/633d44a097ab0_1664959648.py
new file mode 100644
index 0000000..1cd7fe0
--- /dev/null
+++ b/public/python-resources/unittest/jawaban/633d44a097ab0_1664959648.py
@@ -0,0 +1,6 @@
+# Tuliskan variabel dibawah ini
+umur = 2222
+
+def konversi(umur):
+ return str(umur)
+print (type(konversi(umur))
\ No newline at end of file
diff --git a/public/python-resources/unittest/jawaban/633d44a7d4702_1664959655.py b/public/python-resources/unittest/jawaban/633d44a7d4702_1664959655.py
new file mode 100644
index 0000000..49bc3cf
--- /dev/null
+++ b/public/python-resources/unittest/jawaban/633d44a7d4702_1664959655.py
@@ -0,0 +1,6 @@
+# Tuliskan variabel dibawah ini
+umur = 2222
+
+def konversi(umur):
+ return str(umur)
+print (type(konversi(umur));
\ No newline at end of file
diff --git a/public/python-resources/unittest/jawaban/633d44b4c5f4f_1664959668.py b/public/python-resources/unittest/jawaban/633d44b4c5f4f_1664959668.py
new file mode 100644
index 0000000..3b46851
--- /dev/null
+++ b/public/python-resources/unittest/jawaban/633d44b4c5f4f_1664959668.py
@@ -0,0 +1,4 @@
+tahun = 2018
+def konversi(tahun):
+ return str(tahun)
+print(type(konversi(tahun))
\ No newline at end of file
diff --git a/public/python-resources/unittest/jawaban/633d4525c8a43_1664959781.py b/public/python-resources/unittest/jawaban/633d4525c8a43_1664959781.py
new file mode 100644
index 0000000..e8da204
--- /dev/null
+++ b/public/python-resources/unittest/jawaban/633d4525c8a43_1664959781.py
@@ -0,0 +1,7 @@
+# Tuliskan kode program dibawah ini
+x=5
+y=5.1
+z="5"
+print (type(x))
+print (type(y))
+print (type(z))
\ No newline at end of file
diff --git a/resources/views/teacher/python/py_student_result_detail.blade.php b/resources/views/teacher/python/py_student_result_detail.blade.php
index 66983b7..eac5b43 100644
--- a/resources/views/teacher/python/py_student_result_detail.blade.php
+++ b/resources/views/teacher/python/py_student_result_detail.blade.php
@@ -44,17 +44,27 @@