nodejs
This commit is contained in:
parent
7c86ddb72c
commit
263b065ff6
|
|
@ -109,7 +109,7 @@ class FlutterFileResultController extends Controller
|
||||||
|
|
||||||
public function submit($id) {
|
public function submit($id) {
|
||||||
//
|
//
|
||||||
$entity=new \App\StudentSubmit;
|
$entity=new \App\FlutterStudentSubmit;
|
||||||
|
|
||||||
$entity->userid=Auth::user()->id;
|
$entity->userid=Auth::user()->id;
|
||||||
$entity->topic=$id;
|
$entity->topic=$id;
|
||||||
|
|
|
||||||
249
app/Http/Controllers/NodejsController.php
Normal file
249
app/Http/Controllers/NodejsController.php
Normal file
|
|
@ -0,0 +1,249 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class NodejsController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request) {
|
||||||
|
if (Auth::user()->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');
|
||||||
|
}
|
||||||
|
}
|
||||||
131
app/Http/Controllers/NodejsFileResultController.php
Normal file
131
app/Http/Controllers/NodejsFileResultController.php
Normal file
|
|
@ -0,0 +1,131 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class NodejsFileResultController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function create($id) {
|
||||||
|
//
|
||||||
|
$topic = \App\Topic::find($id);
|
||||||
|
$files = \App\TopicFiles::where('topic','=',$id)->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\TopicFiles::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\FileResult::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\FileResult;
|
||||||
|
|
||||||
|
$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\FileResult::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\FileResult::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);
|
||||||
|
}
|
||||||
|
}
|
||||||
404
app/Http/Controllers/NodejsResultController.php
Normal file
404
app/Http/Controllers/NodejsResultController.php
Normal file
|
|
@ -0,0 +1,404 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class NodejsResultController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request) {
|
||||||
|
//$check=\App\StudentTeacher::where('student','=',Auth::user()->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']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
379
app/Http/Controllers/NodejsTaskResultController.php
Normal file
379
app/Http/Controllers/NodejsTaskResultController.php
Normal file
|
|
@ -0,0 +1,379 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class NodejsTaskResultController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request) {
|
||||||
|
$check=\App\NodejsUser::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 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']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -77,7 +77,7 @@ if ($check->status!='active') return view('student/home')->with(['status'=>$chec
|
||||||
$option = $request->input('option','github');
|
$option = $request->input('option','github');
|
||||||
|
|
||||||
$currtopic = \App\Topic::find($filter);
|
$currtopic = \App\Topic::find($filter);
|
||||||
|
|
||||||
return view('student/results/index')
|
return view('student/results/index')
|
||||||
->with(compact('entities'))
|
->with(compact('entities'))
|
||||||
->with(compact('lfiles'))
|
->with(compact('lfiles'))
|
||||||
|
|
|
||||||
12
app/NodejsStudentSubmit.php
Normal file
12
app/NodejsStudentSubmit.php
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class NodejsStudentSubmit extends Model
|
||||||
|
{
|
||||||
|
protected $table='student_submits';
|
||||||
|
|
||||||
|
public $primaryKey='id';
|
||||||
|
}
|
||||||
25
app/NodejsTask.php
Normal file
25
app/NodejsTask.php
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class NodejsTask extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table='tasks';
|
||||||
|
|
||||||
|
public $primaryKey='id';
|
||||||
|
|
||||||
|
public function topic() {
|
||||||
|
return $this->belongsTo(App\NodejsTopic::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTopic($id) {
|
||||||
|
return \App\NodejsTopic::find($id)->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getListTopic() {
|
||||||
|
return \App\NodejsTopic::pluck('name', 'id');
|
||||||
|
}
|
||||||
|
}
|
||||||
11
app/NodejsTaskResult.php
Normal file
11
app/NodejsTaskResult.php
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class NodejsTaskResult extends Model
|
||||||
|
{
|
||||||
|
protected $table='task_results';
|
||||||
|
public $primaryKey='id';
|
||||||
|
}
|
||||||
10
app/NodejsTestFiles.php
Normal file
10
app/NodejsTestFiles.php
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class NodejsTestFiles extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
22
app/NodejsTopic.php
Normal file
22
app/NodejsTopic.php
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class NodejsTopic extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table='topics';
|
||||||
|
public function tasks() {
|
||||||
|
return $this->hasMany('App\NodejsTask');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function topic_files() {
|
||||||
|
return $this->hasMany('App\NodejsTopicFiles');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_files() {
|
||||||
|
return $this->hasMany('App\NodejsTestFiles');
|
||||||
|
}
|
||||||
|
}
|
||||||
15
app/NodejsTopicFiles.php
Normal file
15
app/NodejsTopicFiles.php
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class NodejsTopicFiles extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table='topic_files';
|
||||||
|
public $primaryKey='id';
|
||||||
|
public function topic() {
|
||||||
|
return $this->belongsTo(App\NodejsTopic::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
52
app/NodejsUser.php
Normal file
52
app/NodejsUser.php
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
|
||||||
|
|
||||||
|
class NodejsUser extends Authenticatable
|
||||||
|
{
|
||||||
|
use Notifiable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name', 'roleid', 'email', 'password','uplink','status'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be hidden for arrays.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $hidden = [
|
||||||
|
'password', 'remember_token',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be cast to native types.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'email_verified_at' => '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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -83,7 +83,7 @@
|
||||||
<div class="icon-box" data-aos="fade-up" data-aos-delay="200">
|
<div class="icon-box" data-aos="fade-up" data-aos-delay="200">
|
||||||
<div class="icon"><i class='bx bxl-nodejs'></i></div>
|
<div class="icon"><i class='bx bxl-nodejs'></i></div>
|
||||||
<h4 class="title"><a href="">NodeJs</a></h4>
|
<h4 class="title"><a href="">NodeJs</a></h4>
|
||||||
<p class="description">Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore</p>
|
<p class="description">Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on a JavaScript Engine and executes JavaScript code outside a web browser, which was designed to build scalable network applications.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,10 @@
|
||||||
Tools: Windows PowerShell 5.0+, Git 2.x
|
Tools: Windows PowerShell 5.0+, Git 2.x
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Android Studio (Flutter Extension)
|
Android Studio
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Jest (SuperTest)
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</p2>
|
</p2>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
@extends('admin/admin')
|
@extends('student/nodejscourse/home')
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<img src="{{asset('lte/dist/img/iclop-logo.png')}}" alt="iCLOP logo" class="brand-image elevation-3"
|
<img src="{{asset('lte/dist/img/iclop-logo.png')}}" alt="iCLOP logo" class="brand-image elevation-3"
|
||||||
style="width:120px;height:60px;">
|
style="width:120px;height:60px;">
|
||||||
<br>
|
<br>
|
||||||
<span class="brand-text font-weight-light" style="font-size:160%;"> NodeJs Course</span>
|
<span class="brand-text font-weight-light" style="font-size:160%;"> Nodejs Course</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<!-- Sidebar -->
|
<!-- Sidebar -->
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
@extends('student/nodejscourse/home')
|
@extends('student/fluttercourse/home')
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
|
|
||||||
|
|
@ -127,24 +127,18 @@ Route::group(['middleware' => ['auth', 'student']], function() {
|
||||||
Route::get('student/lfiles/fluttercourse/valid/{topic}', 'FlutterFileResultController@submit');
|
Route::get('student/lfiles/fluttercourse/valid/{topic}', 'FlutterFileResultController@submit');
|
||||||
Route::get('student/lfiles/fluttercourse/delete/{id}/{topic}', 'FlutterFileResultController@delete');
|
Route::get('student/lfiles/fluttercourse/delete/{id}/{topic}', 'FlutterFileResultController@delete');
|
||||||
|
|
||||||
Route::patch('/student/nodejscourse/results/valsub',['as' => 'results.valsub', 'uses' => 'FlutterTaskResultController@valsub']);
|
Route::patch('/student/nodejscourse/results/valsub',['as' => 'results.valsub', 'uses' => 'NodejsTaskResultController@valsub']);
|
||||||
Route::get('student/nodejscourse/results/create/{topic}', 'FlutterTaskResultController@create');
|
Route::get('student/nodejscourse/results/create/{topic}', 'NodejsTaskResultController@create');
|
||||||
Route::get('/student/nodejscourse', 'StudentController@fluttercourse');
|
Route::get('/student/nodejscourse', 'StudentController@Nodejscourse');
|
||||||
Route::get('/student/nodejscourse/topic', 'StudentController@fluttercoursetopic');
|
Route::get('/student/nodejscourse/topic', 'StudentController@Nodejscoursetopic');
|
||||||
Route::resource('/student/nodejscourse/tasks', 'FlutterController');
|
Route::resource('/student/nodejscourse/tasks', 'NodejsController');
|
||||||
Route::resource('/student/nodejscourse/results', 'FlutterResultController');
|
Route::resource('/student/nodejscourse/results', 'NodejsResultController');
|
||||||
Route::resource('/student/nodejscourse/lfiles', 'FlutterFileResultController');
|
Route::resource('/student/nodejscourse/lfiles', 'NodejsFileResultController');
|
||||||
Route::get('student/lfiles/nodejscourse/create/{topic}', 'FlutterFileResultController@create');
|
Route::get('student/lfiles/nodejscourse/create/{topic}', 'NodejsFileResultController@create');
|
||||||
Route::get('student/lfiles/nodejscourse/valid/{topic}', 'FlutterFileResultController@submit');
|
Route::get('student/lfiles/nodejscourse/valid/{topic}', 'NodejsFileResultController@submit');
|
||||||
Route::get('student/lfiles/nodejscourse/delete/{id}/{topic}', 'FlutterFileResultController@delete');
|
Route::get('student/lfiles/nodejscourse/delete/{id}/{topic}', 'NodejsFileResultController@delete');
|
||||||
|
|
||||||
|
|
||||||
Route::get('/student/nodejscourse', 'StudentController@nodejscourse');
|
|
||||||
Route::get('/student/nodejscourse/topic', 'StudentController@nodejscoursetopic');
|
|
||||||
Route::get('/student/nodejscourse', 'StudentController@nodejscourse');
|
|
||||||
Route::resource('/student/nodejscourse/tasks', 'TaskStdController');
|
|
||||||
Route::resource('/student/nodejscourse/results', 'TaskResultController');
|
|
||||||
|
|
||||||
|
|
||||||
/** Python */
|
/** Python */
|
||||||
//Tampilan topik
|
//Tampilan topik
|
||||||
|
|
@ -177,9 +171,9 @@ Route::group(['middleware' => ['auth', 'student']], function() {
|
||||||
Route::get('/student/unitycourse/page', 'StudentController@unitycoursepage');
|
Route::get('/student/unitycourse/page', 'StudentController@unitycoursepage');
|
||||||
//
|
//
|
||||||
|
|
||||||
Route::get('/student/nodejs', 'StudentController@nodejscourse');
|
// Route::get('/student/nodejs', 'StudentController@nodejscourse');
|
||||||
Route::get('/student/nodejscourse/basic-html', 'StudentController@nodejscourseBasicHTML');
|
// Route::get('/student/nodejscourse/basic-html', 'StudentController@nodejscourseBasicHTML');
|
||||||
Route::get('/student/nodejscourse/dynamic-content', 'StudentController@nodejscourseDynamicContent');
|
// Route::get('/student/nodejscourse/dynamic-content', 'StudentController@nodejscourseDynamicContent');
|
||||||
|
|
||||||
Route::get('/student', 'StudentController@index');
|
Route::get('/student', 'StudentController@index');
|
||||||
Route::resource('/student/tasks', 'TaskStdController');
|
Route::resource('/student/tasks', 'TaskStdController');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user