python_fixTeacherFungsion
This commit is contained in:
parent
284eca77cf
commit
d2a19fbfbe
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\NodejsTopic::find($id);
|
||||||
|
$files = \App\NodejsTopicFiles::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\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);
|
||||||
|
}
|
||||||
|
}
|
||||||
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']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
249
app/Http/Controllers/UnityController.php
Normal file
249
app/Http/Controllers/UnityController.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 UnityController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request) {
|
||||||
|
if (Auth::user()->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');
|
||||||
|
}
|
||||||
|
}
|
||||||
131
app/Http/Controllers/UnityFileResultController.php
Normal file
131
app/Http/Controllers/UnityFileResultController.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 UnityFileResultController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function create($id) {
|
||||||
|
//
|
||||||
|
$topic = \App\UnityTopic::find($id);
|
||||||
|
$files = \App\UnityTopicFiles::where('topic','=',$id)->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);
|
||||||
|
}
|
||||||
|
}
|
||||||
385
app/Http/Controllers/UnityResultController.php
Normal file
385
app/Http/Controllers/UnityResultController.php
Normal file
|
|
@ -0,0 +1,385 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class UnityResultController 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/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']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
379
app/Http/Controllers/UnityTaskResultController.php
Normal file
379
app/Http/Controllers/UnityTaskResultController.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 UnityTaskResultController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request) {
|
||||||
|
$check=\App\UnityUser::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 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']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -164,7 +164,7 @@ class ExercisePythonController extends Controller
|
||||||
|
|
||||||
$unittest = "C:\\xampp\\htdocs\\iCLOP\\public\\python-resources\\unittest\\". $fileUnittest;
|
$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 = "";
|
$validation_detail = "";
|
||||||
$status = "";
|
$status = "";
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ class ResultController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// view
|
// 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')
|
// $dt_validation = DB::table('python_students_validation')->select('python_students_validation.*', 'users.id', 'users.name')
|
||||||
->join('users', 'users.id', '=', 'python_students_validation.userid')
|
// ->join('users', 'users.id', '=', 'python_students_validation.userid')
|
||||||
->where( $where );
|
// ->where( $where );
|
||||||
|
|
||||||
|
|
||||||
$totalEnroll = $dt_validation->count();
|
// $totalEnroll = $dt_validation->count();
|
||||||
$dataSubmit = $dt_validation->get();
|
// $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(
|
array_push( $allPercobaan, array(
|
||||||
|
|
||||||
'percobaan' => $percobaan,
|
'percobaan' => $percobaan,
|
||||||
'validation' => $dataSubmit,
|
'submitted' => $dataSubmit,
|
||||||
'total' => $totalEnroll,
|
'total' => $totalEnroll,
|
||||||
) );
|
) );
|
||||||
// echo $percobaan->nama_percobaan.' : '.$totalEnroll.'<br>';
|
// echo $percobaan->nama_percobaan.' : '.$totalEnroll.'<br>';
|
||||||
|
|
@ -143,34 +156,65 @@ class ResultController extends Controller
|
||||||
$allPercobaan = array();
|
$allPercobaan = array();
|
||||||
|
|
||||||
$where = [
|
$where = [
|
||||||
'python_students_validation.id_percobaan' => $id_percobaan,
|
'id_percobaan' => $id_percobaan,
|
||||||
'uplink' => Auth::id() // id_dosen
|
'uplink' => Auth::id() // id_dosen
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
$dt_validation = DB::table('python_students_validation')->select('python_students_validation.*', 'users.id', 'users.name', 'checkresult')
|
// $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('python_students_submit', 'python_students_submit.id_submit', '=', 'python_students_validation.id_submit')
|
||||||
->join('users', 'users.id', '=', 'python_students_validation.userid')
|
// ->join('users', 'users.id', '=', 'python_students_validation.userid')
|
||||||
->where( $where );
|
// ->where( $where );
|
||||||
|
|
||||||
|
|
||||||
$totalEnroll = $dt_validation->count();
|
// $totalEnroll = $dt_validation->count();
|
||||||
$dataSubmit = $dt_validation->get();
|
// $dataSubmit = $dt_validation->get();
|
||||||
|
|
||||||
|
|
||||||
$allPercobaan = array(
|
// $allPercobaan = array(
|
||||||
|
|
||||||
'percobaan' => $dt_percobaan,
|
// 'percobaan' => $dt_percobaan,
|
||||||
'validation' => $dataSubmit,
|
// 'validation' => $dataSubmit,
|
||||||
'total' => $totalEnroll,
|
// '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
|
// hitung mahasiswa berdasarkan dospem
|
||||||
$mhs = DB::table('users')->where('uplink', Auth::id())->count();
|
$mhs = DB::table('users')->where('uplink', Auth::id())->count();
|
||||||
$dosen = DB::table('users')->where('id', Auth::id())->first();
|
$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' ));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
app/UnityStudentSubmit.php
Normal file
12
app/UnityStudentSubmit.php
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class UnityStudentSubmit extends Model
|
||||||
|
{
|
||||||
|
protected $table='student_submits';
|
||||||
|
|
||||||
|
public $primaryKey='id';
|
||||||
|
}
|
||||||
25
app/UnityTask.php
Normal file
25
app/UnityTask.php
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class UnityTask extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table='tasks';
|
||||||
|
|
||||||
|
public $primaryKey='id';
|
||||||
|
|
||||||
|
public function topic() {
|
||||||
|
return $this->belongsTo(App\UnityTopic::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTopic($id) {
|
||||||
|
return \App\UnityTopic::find($id)->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getListTopic() {
|
||||||
|
return \App\UnityTopic::pluck('name', 'id');
|
||||||
|
}
|
||||||
|
}
|
||||||
11
app/UnityTaskResult.php
Normal file
11
app/UnityTaskResult.php
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class UnityTaskResult extends Model
|
||||||
|
{
|
||||||
|
protected $table='task_results';
|
||||||
|
public $primaryKey='id';
|
||||||
|
}
|
||||||
10
app/UnityTestFiles.php
Normal file
10
app/UnityTestFiles.php
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class UnityTestFiles extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
22
app/UnityTopic.php
Normal file
22
app/UnityTopic.php
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class UnityTopic extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table='topics';
|
||||||
|
public function tasks() {
|
||||||
|
return $this->hasMany('App\UnityTask');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function topic_files() {
|
||||||
|
return $this->hasMany('App\UnityTopicFiles');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_files() {
|
||||||
|
return $this->hasMany('App\UnityTestFiles');
|
||||||
|
}
|
||||||
|
}
|
||||||
15
app/UnityTopicFiles.php
Normal file
15
app/UnityTopicFiles.php
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class UnityTopicFiles extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table='topic_files';
|
||||||
|
public $primaryKey='id';
|
||||||
|
public function topic() {
|
||||||
|
return $this->belongsTo(App\UnityTopic::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
52
app/UnityUser.php
Normal file
52
app/UnityUser.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 UnityUser 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/unitycourse/home');
|
||||||
|
} elseif ($roleid=='teacher') {
|
||||||
|
return Redirect::to('teacher/home');
|
||||||
|
} elseif ($roleid=='admin') {
|
||||||
|
return Redirect::to('admin/admin');
|
||||||
|
} else {
|
||||||
|
return Redirect::to('/home');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Tuliskan kode program dibawah ini
|
||||||
|
print "anak"
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
print "polinema"
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Tuliskan kode program dibawah ini
|
||||||
|
print ("coba")
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
# Tuliskan variabel dibawah ini
|
||||||
|
umur = 23
|
||||||
|
|
||||||
|
def konversi(umur):
|
||||||
|
return str(umur)
|
||||||
|
print (type (konversi(umu))
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
# Tuliskan variabel dibawah ini
|
||||||
|
umur = 23
|
||||||
|
|
||||||
|
def konversi(umur):
|
||||||
|
return str(umur)
|
||||||
|
print (type (konversi(umur))
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
# Tuliskan variabel dibawah ini
|
||||||
|
umur = 22
|
||||||
|
|
||||||
|
def konversi(umur):
|
||||||
|
return str(umur)
|
||||||
|
print (type (konversi(umur))
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
# Tuliskan variabel dibawah ini
|
||||||
|
umur = 22
|
||||||
|
|
||||||
|
def konversi(umur):
|
||||||
|
return str(umur)
|
||||||
|
print (type(konversi(umur))
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
# Tuliskan variabel dibawah ini
|
||||||
|
umur = 2222
|
||||||
|
|
||||||
|
def konversi(umur):
|
||||||
|
return str(umur)
|
||||||
|
print (type(konversi(umur))
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
# Tuliskan variabel dibawah ini
|
||||||
|
umur = 2222
|
||||||
|
|
||||||
|
def konversi(umur):
|
||||||
|
return str(umur)
|
||||||
|
print (type(konversi(umur));
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
tahun = 2018
|
||||||
|
def konversi(tahun):
|
||||||
|
return str(tahun)
|
||||||
|
print(type(konversi(tahun))
|
||||||
|
|
@ -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))
|
||||||
|
|
@ -44,17 +44,27 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td rowspan="{{ count( $allPercobaan['validation'] ) + 1 }}">
|
<td rowspan="{{ count( $allSubmit ) + 1 }}">
|
||||||
<small>Nama Percobaan</small>
|
<small>Nama Percobaan</small>
|
||||||
<h4>{{ $dt_percobaan->nama_percobaan }}</h4>
|
<h4>{{ $dt_percobaan->nama_percobaan }}</h4>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@foreach ( $allPercobaan['validation'] AS $nomor => $isi )
|
@foreach ( $allSubmit AS $nomor => $isi )
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $isi->name }}</td>
|
<td>{{ $isi['infoMhs']->name }}</td>
|
||||||
<td>{{ $isi->status }}</td>
|
<td>
|
||||||
<td>{{ date('d M Y H.i A', strtotime($isi->create_at)) }}</td>
|
@php
|
||||||
|
if ( $isi['status'] ) {
|
||||||
|
|
||||||
|
echo "PASSED";
|
||||||
|
} else {
|
||||||
|
|
||||||
|
echo "FAILED";
|
||||||
|
}
|
||||||
|
@endphp
|
||||||
|
</td>
|
||||||
|
<td>{{ date('d M Y H.i A', strtotime($isi['infoMhs']->created_at)) }}</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
<a href="javascript:;" data-toggle="modal" data-target="#modal-{{ $nomor }}" class="btn btn-sm btn-primary">Submitted</a>
|
<a href="javascript:;" data-toggle="modal" data-target="#modal-{{ $nomor }}" class="btn btn-sm btn-primary">Submitted</a>
|
||||||
|
|
@ -71,21 +81,28 @@
|
||||||
|
|
||||||
<b>Materi {{ $topik->nama }}</b>
|
<b>Materi {{ $topik->nama }}</b>
|
||||||
<h5 style="margin: 0px"><code>{{ $dt_percobaan->nama_percobaan }}</code></h5>
|
<h5 style="margin: 0px"><code>{{ $dt_percobaan->nama_percobaan }}</code></h5>
|
||||||
<small>Pengerjaan pada {{ date('d F Y H.i A', strtotime($isi->create_at)) }}</small>
|
|
||||||
|
@foreach ( $isi['log'] AS $detail )
|
||||||
|
<small>Pengerjaan pada {{ date('d F Y H.i A', strtotime($detail->created_at)) }}</small>
|
||||||
<div class="card card-body" style="font-family: 'Courier New', Courier, monospace">
|
<div class="card card-body" style="font-family: 'Courier New', Courier, monospace">
|
||||||
{{ $isi->report }}
|
{{ $detail->checkstat }}
|
||||||
|
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
<b>Hasil Unit Test : </b><br>
|
<b>Hasil Unit Test : </b><br>
|
||||||
<?php echo $isi->checkresult ?>
|
<?php echo $detail->checkresult ?>
|
||||||
</div>
|
</div>
|
||||||
<a href="{{ asset('python-resources/unittest/jawaban/'. $isi->file_submitted) }}.py" download>Unduh Source Code</a><br>
|
{{-- <a href="{{ asset('python-resources/unittest/jawaban/'. $detail->file_submitted) }}.py" download>Unduh Source Code</a><br>
|
||||||
<small>Klik untuk mengunduh file jawaban</small>
|
<small>Klik untuk mengunduh file jawaban</small> --}}
|
||||||
|
|
||||||
|
|
||||||
|
@endforeach
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
<tr class="text-center">
|
<tr class="text-center">
|
||||||
<th>Topik</th>
|
<th>Topik</th>
|
||||||
<th>Percobaan</th>
|
<th>Percobaan</th>
|
||||||
<th>Terkumpul</th>
|
<th>Mengerjakan</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
@ -64,9 +64,9 @@
|
||||||
<td>
|
<td>
|
||||||
@php
|
@php
|
||||||
|
|
||||||
if ( $materi['total'] > 0 ) {
|
if ( count($materi['submitted']) > 0 ) {
|
||||||
|
|
||||||
echo $materi['total'].' mhs';
|
echo count($materi['submitted']).' mhs';
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
echo '-';
|
echo '-';
|
||||||
|
|
@ -74,24 +74,24 @@
|
||||||
|
|
||||||
@endphp
|
@endphp
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td style="width: 10%; text-align: center;">
|
||||||
@php
|
@php
|
||||||
|
|
||||||
$label = "";
|
$label = "";
|
||||||
if ( count( $materi['validation'] ) == $mhs ) {
|
if ( count( $materi['submitted'] ) == $mhs ) {
|
||||||
|
|
||||||
$label = '<label class="badge badge-info">Materi Selesai</label>';
|
$label = '<label class="badge badge-info">'. count($materi['submitted']).'/'.$mhs.' mhs</label>';
|
||||||
|
|
||||||
} else if ( count( $materi['validation'] ) == 0 ) {
|
} else if ( count( $materi['submitted'] ) == 0 ) {
|
||||||
|
|
||||||
$label = '<label class="badge badge-secondary">Kosong</label>';
|
$label = '<label class="badge badge-secondary">Kosong</label>';
|
||||||
} else if ( count( $materi['validation'] ) != $mhs ) {
|
} else if ( count( $materi['submitted'] ) != $mhs ) {
|
||||||
|
|
||||||
$label = '<label class="badge badge-warning">Sebagian</label>';
|
$label = '<label class="badge badge-warning">'. count($materi['submitted']).'/'.$mhs.' mhs</label>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// echo count( $materi['validation'] );
|
|
||||||
echo $label;
|
echo $label;
|
||||||
|
|
||||||
@endphp
|
@endphp
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,17 @@ Route::group(['middleware' => ['auth', 'teacher']], function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::group(['middleware' => ['auth', 'student']], function () {
|
Route::group(['middleware' => ['auth', 'student']], function () {
|
||||||
|
//Android//
|
||||||
|
Route::patch('/student/androidcourse/results/valsub', ['as' => 'results.valsub', 'uses' => 'AndroidTaskResultController@valsub']);
|
||||||
|
Route::get('student/androidcourse/results/create/{topic}', 'AndroidTaskResultController@create');
|
||||||
|
Route::get('/student/androidcourse', 'StudentController@androidcourse');
|
||||||
|
Route::get('/student/androidcourse/topic', 'StudentController@androidcoursetopic');
|
||||||
|
Route::resource('/student/androidcourse/tasks', 'AndroidController');
|
||||||
|
Route::resource('/student/androidcourse/results', 'AndroidResultController');
|
||||||
|
Route::resource('/student/androidcourse/lfiles', 'AndroidFileResultController');
|
||||||
|
Route::get('student/lfiles/androidcourse/create/{topic}', 'AndroidFileResultController@create');
|
||||||
|
Route::get('student/lfiles/androidcourse/valid/{topic}', 'AndroidFileResultController@submit');
|
||||||
|
Route::get('student/lfiles/androidcourse/delete/{id}/{topic}', 'AndroidFileResultController@delete');
|
||||||
// Flutter //
|
// Flutter //
|
||||||
Route::patch('/student/fluttercourse/results/valsub', ['as' => 'results.valsub', 'uses' => 'FlutterTaskResultController@valsub']);
|
Route::patch('/student/fluttercourse/results/valsub', ['as' => 'results.valsub', 'uses' => 'FlutterTaskResultController@valsub']);
|
||||||
Route::get('/student/fluttercourse/results/create/{topic}', 'FlutterTaskResultController@create');
|
Route::get('/student/fluttercourse/results/create/{topic}', 'FlutterTaskResultController@create');
|
||||||
|
|
@ -174,6 +185,29 @@ Route::group(['middleware' => ['auth', 'student']], function () {
|
||||||
Route::resource('/student/flutterexercise', 'FlutterExerciseStdController');
|
Route::resource('/student/flutterexercise', 'FlutterExerciseStdController');
|
||||||
Route::resource('/student/flutterexercisesubmission', 'FlutterExerciseSubmissionController');
|
Route::resource('/student/flutterexercisesubmission', 'FlutterExerciseSubmissionController');
|
||||||
Route::resource('/student/flutterexercisevalid', 'FlutterExerciseStdValidController');
|
Route::resource('/student/flutterexercisevalid', 'FlutterExerciseStdValidController');
|
||||||
|
//NodeJs//
|
||||||
|
Route::patch('/student/nodejscourse/results/valsub', ['as' => 'results.valsub', 'uses' => 'NodejsTaskResultController@valsub']);
|
||||||
|
Route::get('/student/nodejscourse/results/create/{topic}', 'NodejsTaskResultController@create');
|
||||||
|
Route::get('/student/nodejscourse', 'StudentController@Nodejscourse');
|
||||||
|
Route::get('/student/nodejscourse/topic', 'StudentController@Nodejscoursetopic');
|
||||||
|
Route::resource('/student/nodejscourse/tasks', 'NodejsController');
|
||||||
|
Route::resource('/student/nodejscourse/results', 'NodejsResultController');
|
||||||
|
Route::resource('/student/nodejscourse/lfiles', 'NodejsFileResultController');
|
||||||
|
Route::get('/student/lfiles/nodejscourse/create/{topic}', 'NodejsFileResultController@create');
|
||||||
|
Route::get('/student/lfiles/nodejscourse/valid/{topic}', 'NodejsFileResultController@submit');
|
||||||
|
Route::get('/student/lfiles/nodejscourse/delete/{id}/{topic}', 'NodejsFileResultController@delete');
|
||||||
|
//Unity//
|
||||||
|
Route::patch('/student/unitycourse/results/valsub', ['as' => 'results.valsub', 'uses' => 'UnityTaskResultController@valsub']);
|
||||||
|
Route::get('/student/unitycourse/results/create/{topic}', 'UnityTaskResultController@create');
|
||||||
|
Route::get('/student/unitycourse', 'StudentController@unitycourse');
|
||||||
|
Route::get('/student/unitycourse/topic', 'StudentController@unitycoursetopic');
|
||||||
|
Route::resource('/student/unitycourse/tasks', 'UnityController');
|
||||||
|
Route::resource('/student/unitycourse/results', 'UnityResultController');
|
||||||
|
Route::resource('/student/unitycourse/lfiles', 'UnityFileResultController');
|
||||||
|
Route::get('/student/lfiles/unitycourse/create/{topic}', 'UnityFileResultController@create');
|
||||||
|
Route::get('/student/lfiles/unitycourse/valid/{topic}', 'UnityFileResultController@submit');
|
||||||
|
Route::get('/student/lfiles/unitycourse/delete/{id}/{topic}', 'UnityFileResultController@delete');
|
||||||
|
|
||||||
|
|
||||||
/** Python */
|
/** Python */
|
||||||
//Tampilan topik
|
//Tampilan topik
|
||||||
|
|
@ -196,10 +230,22 @@ Route::group(['middleware' => ['auth', 'student']], function () {
|
||||||
|
|
||||||
Route::get("/student/pythoncourse/python-history/{id_topik}/{id_percobaan}", [ExercisePythonController::class, 'submit_history']);
|
Route::get("/student/pythoncourse/python-history/{id_topik}/{id_percobaan}", [ExercisePythonController::class, 'submit_history']);
|
||||||
|
|
||||||
|
Route::get('/student/androidcourse/asynctask', 'StudentController@asynctask');
|
||||||
|
Route::get('/student/androidcourse/firebase', 'StudentController@firebase');
|
||||||
|
|
||||||
Route::get('/student', 'StudentController@index');
|
Route::get('/student', 'StudentController@index');
|
||||||
Route::resource('/student/tasks', 'TaskStdController');
|
Route::resource('/student/tasks', 'TaskStdController');
|
||||||
Route::resource('/student/results', 'TaskResultController');
|
Route::resource('/student/results', 'TaskResultController');
|
||||||
|
|
||||||
|
Route::patch('/student/androidcourse/results/valsub', ['as' => 'results.valsub', 'uses' => 'TaskResultController@valsub']);
|
||||||
|
Route::get('/student/androidcourse/results/create/{topic}', 'TaskResultController@create');
|
||||||
|
Route::resource('/student/androidcourse/lfiles', 'FileResultController');
|
||||||
|
Route::get('/student/lfiles/androidcourse/create/{topic}', 'FileResultController@create');
|
||||||
|
Route::get('/student/lfiles/androidcourse/valid/{topic}', 'FileResultController@submit');
|
||||||
|
Route::get('/student/lfiles/androidcourse/delete/{id}/{topic}', 'FileResultController@delete');
|
||||||
|
Route::resource('/student/androidcourse/rankview', 'StudentResultRankController');
|
||||||
|
Route::resource('/student/androidcourse/valid', 'StudentValidController');
|
||||||
|
Route::resource('/student/androidcourse/rankview', 'StudentResultRankController');
|
||||||
Route::patch('/student/results/valsub', ['as' => 'results.valsub', 'uses' => 'TaskResultController@valsub']);
|
Route::patch('/student/results/valsub', ['as' => 'results.valsub', 'uses' => 'TaskResultController@valsub']);
|
||||||
Route::get('student/results/create/{topic}', 'TaskResultController@create');
|
Route::get('student/results/create/{topic}', 'TaskResultController@create');
|
||||||
Route::resource('/student/lfiles', 'FileResultController');
|
Route::resource('/student/lfiles', 'FileResultController');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user