first commit
This commit is contained in:
commit
f4c1678b92
18
Penilaian-Esai/.editorconfig
Normal file
18
Penilaian-Esai/.editorconfig
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[docker-compose.yml]
|
||||||
|
indent_size = 4
|
||||||
10
Penilaian-Esai/.gitattributes
vendored
Normal file
10
Penilaian-Esai/.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
* text=auto
|
||||||
|
|
||||||
|
*.blade.php diff=html
|
||||||
|
*.css diff=css
|
||||||
|
*.html diff=html
|
||||||
|
*.md diff=markdown
|
||||||
|
*.php diff=php
|
||||||
|
|
||||||
|
/.github export-ignore
|
||||||
|
CHANGELOG.md export-ignore
|
||||||
14
Penilaian-Esai/.gitignore
vendored
Normal file
14
Penilaian-Esai/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
/node_modules
|
||||||
|
/public/hot
|
||||||
|
/public/storage
|
||||||
|
/storage/*.key
|
||||||
|
/vendor
|
||||||
|
.env
|
||||||
|
.env.backup
|
||||||
|
.phpunit.result.cache
|
||||||
|
Homestead.json
|
||||||
|
Homestead.yaml
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
/.idea
|
||||||
|
/.vscode
|
||||||
12
Penilaian-Esai/.styleci.yml
Normal file
12
Penilaian-Esai/.styleci.yml
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
php:
|
||||||
|
preset: laravel
|
||||||
|
disabled:
|
||||||
|
- no_unused_imports
|
||||||
|
finder:
|
||||||
|
not-name:
|
||||||
|
- index.php
|
||||||
|
js:
|
||||||
|
finder:
|
||||||
|
not-name:
|
||||||
|
- webpack.mix.js
|
||||||
|
css: true
|
||||||
18
Penilaian-Esai/README.md
Normal file
18
Penilaian-Esai/README.md
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
## First initialize project
|
||||||
|
|
||||||
|
1. Run the following command to clone the project
|
||||||
|
`git clone https://github.com/rsakml/Penilaian-Esai.git`
|
||||||
|
|
||||||
|
2. Run the following command to update the laravel package.
|
||||||
|
`composer update`
|
||||||
|
|
||||||
|
3. Run the following command to copy the env.example file into .env
|
||||||
|
`cp .env.example .env`
|
||||||
|
|
||||||
|
4. Run the following command to generate key
|
||||||
|
`php artisan key:generate`
|
||||||
|
|
||||||
|
5. Import database ke MySQL database. Sesuaikan nama database pada MySQL dengan yang ada pada project Laravel, file .env.
|
||||||
|
|
||||||
|
6. Then run laravel on another port, this case using port = 8001
|
||||||
|
`Penilaian-Esai>php artisan serve –-port=8001`
|
||||||
32
Penilaian-Esai/app/Console/Kernel.php
Normal file
32
Penilaian-Esai/app/Console/Kernel.php
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console;
|
||||||
|
|
||||||
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
|
|
||||||
|
class Kernel extends ConsoleKernel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the application's command schedule.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function schedule(Schedule $schedule)
|
||||||
|
{
|
||||||
|
// $schedule->command('inspire')->hourly();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the commands for the application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function commands()
|
||||||
|
{
|
||||||
|
$this->load(__DIR__.'/Commands');
|
||||||
|
|
||||||
|
require base_path('routes/console.php');
|
||||||
|
}
|
||||||
|
}
|
||||||
50
Penilaian-Esai/app/Exceptions/Handler.php
Normal file
50
Penilaian-Esai/app/Exceptions/Handler.php
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class Handler extends ExceptionHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A list of exception types with their corresponding custom log levels.
|
||||||
|
*
|
||||||
|
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
|
||||||
|
*/
|
||||||
|
protected $levels = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of the exception types that are not reported.
|
||||||
|
*
|
||||||
|
* @var array<int, class-string<\Throwable>>
|
||||||
|
*/
|
||||||
|
protected $dontReport = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of the inputs that are never flashed to the session on validation exceptions.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $dontFlash = [
|
||||||
|
'current_password',
|
||||||
|
'password',
|
||||||
|
'password_confirmation',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the exception handling callbacks for the application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$this->reportable(function (Throwable $e) {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,131 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Requests\API\CreateBadgeSettingAPIRequest;
|
||||||
|
use App\Http\Requests\API\UpdateBadgeSettingAPIRequest;
|
||||||
|
use App\Models\BadgeSetting;
|
||||||
|
use App\Repositories\BadgeSettingRepository;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\AppBaseController;
|
||||||
|
use Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class BadgeSettingController
|
||||||
|
* @package App\Http\Controllers\API
|
||||||
|
*/
|
||||||
|
|
||||||
|
class BadgeSettingAPIController extends AppBaseController
|
||||||
|
{
|
||||||
|
/** @var BadgeSettingRepository */
|
||||||
|
private $badgeSettingRepository;
|
||||||
|
|
||||||
|
public function __construct(BadgeSettingRepository $badgeSettingRepo)
|
||||||
|
{
|
||||||
|
$this->badgeSettingRepository = $badgeSettingRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the BadgeSetting.
|
||||||
|
* GET|HEAD /badgeSettings
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$badgeSettings = $this->badgeSettingRepository->all(
|
||||||
|
$request->except(['skip', 'limit']),
|
||||||
|
$request->get('skip'),
|
||||||
|
$request->get('limit')
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->sendResponse($badgeSettings->toArray(), 'Badge Settings retrieved successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created BadgeSetting in storage.
|
||||||
|
* POST /badgeSettings
|
||||||
|
*
|
||||||
|
* @param CreateBadgeSettingAPIRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(CreateBadgeSettingAPIRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
$badgeSetting = $this->badgeSettingRepository->create($input);
|
||||||
|
|
||||||
|
return $this->sendResponse($badgeSetting->toArray(), 'Badge Setting saved successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified BadgeSetting.
|
||||||
|
* GET|HEAD /badgeSettings/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
/** @var BadgeSetting $badgeSetting */
|
||||||
|
$badgeSetting = $this->badgeSettingRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($badgeSetting)) {
|
||||||
|
return $this->sendError('Badge Setting not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->sendResponse($badgeSetting->toArray(), 'Badge Setting retrieved successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified BadgeSetting in storage.
|
||||||
|
* PUT/PATCH /badgeSettings/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param UpdateBadgeSettingAPIRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update($id, UpdateBadgeSettingAPIRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
/** @var BadgeSetting $badgeSetting */
|
||||||
|
$badgeSetting = $this->badgeSettingRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($badgeSetting)) {
|
||||||
|
return $this->sendError('Badge Setting not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$badgeSetting = $this->badgeSettingRepository->update($input, $id);
|
||||||
|
|
||||||
|
return $this->sendResponse($badgeSetting->toArray(), 'BadgeSetting updated successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified BadgeSetting from storage.
|
||||||
|
* DELETE /badgeSettings/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
/** @var BadgeSetting $badgeSetting */
|
||||||
|
$badgeSetting = $this->badgeSettingRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($badgeSetting)) {
|
||||||
|
return $this->sendError('Badge Setting not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$badgeSetting->delete();
|
||||||
|
|
||||||
|
return $this->sendSuccess('Badge Setting deleted successfully');
|
||||||
|
}
|
||||||
|
}
|
||||||
131
Penilaian-Esai/app/Http/Controllers/API/ContentAPIController.php
Normal file
131
Penilaian-Esai/app/Http/Controllers/API/ContentAPIController.php
Normal file
|
|
@ -0,0 +1,131 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Requests\API\CreateContentAPIRequest;
|
||||||
|
use App\Http\Requests\API\UpdateContentAPIRequest;
|
||||||
|
use App\Models\Content;
|
||||||
|
use App\Repositories\ContentRepository;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\AppBaseController;
|
||||||
|
use Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ContentController
|
||||||
|
* @package App\Http\Controllers\API
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ContentAPIController extends AppBaseController
|
||||||
|
{
|
||||||
|
/** @var ContentRepository */
|
||||||
|
private $contentRepository;
|
||||||
|
|
||||||
|
public function __construct(ContentRepository $contentRepo)
|
||||||
|
{
|
||||||
|
$this->contentRepository = $contentRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the Content.
|
||||||
|
* GET|HEAD /contents
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$contents = $this->contentRepository->all(
|
||||||
|
$request->except(['skip', 'limit']),
|
||||||
|
$request->get('skip'),
|
||||||
|
$request->get('limit')
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->sendResponse($contents->toArray(), 'Contents retrieved successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created Content in storage.
|
||||||
|
* POST /contents
|
||||||
|
*
|
||||||
|
* @param CreateContentAPIRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(CreateContentAPIRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
$content = $this->contentRepository->create($input);
|
||||||
|
|
||||||
|
return $this->sendResponse($content->toArray(), 'Content saved successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified Content.
|
||||||
|
* GET|HEAD /contents/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
/** @var Content $content */
|
||||||
|
$content = $this->contentRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($content)) {
|
||||||
|
return $this->sendError('Content not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->sendResponse($content->toArray(), 'Content retrieved successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified Content in storage.
|
||||||
|
* PUT/PATCH /contents/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param UpdateContentAPIRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update($id, UpdateContentAPIRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
/** @var Content $content */
|
||||||
|
$content = $this->contentRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($content)) {
|
||||||
|
return $this->sendError('Content not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$content = $this->contentRepository->update($input, $id);
|
||||||
|
|
||||||
|
return $this->sendResponse($content->toArray(), 'Content updated successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified Content from storage.
|
||||||
|
* DELETE /contents/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
/** @var Content $content */
|
||||||
|
$content = $this->contentRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($content)) {
|
||||||
|
return $this->sendError('Content not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$content->delete();
|
||||||
|
|
||||||
|
return $this->sendSuccess('Content deleted successfully');
|
||||||
|
}
|
||||||
|
}
|
||||||
131
Penilaian-Esai/app/Http/Controllers/API/CourseAPIController.php
Normal file
131
Penilaian-Esai/app/Http/Controllers/API/CourseAPIController.php
Normal file
|
|
@ -0,0 +1,131 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Requests\API\CreateCourseAPIRequest;
|
||||||
|
use App\Http\Requests\API\UpdateCourseAPIRequest;
|
||||||
|
use App\Models\Course;
|
||||||
|
use App\Repositories\CourseRepository;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\AppBaseController;
|
||||||
|
use Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CourseController
|
||||||
|
* @package App\Http\Controllers\API
|
||||||
|
*/
|
||||||
|
|
||||||
|
class CourseAPIController extends AppBaseController
|
||||||
|
{
|
||||||
|
/** @var CourseRepository */
|
||||||
|
private $courseRepository;
|
||||||
|
|
||||||
|
public function __construct(CourseRepository $courseRepo)
|
||||||
|
{
|
||||||
|
$this->courseRepository = $courseRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the Course.
|
||||||
|
* GET|HEAD /courses
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$courses = $this->courseRepository->all(
|
||||||
|
$request->except(['skip', 'limit']),
|
||||||
|
$request->get('skip'),
|
||||||
|
$request->get('limit')
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->sendResponse($courses->toArray(), 'Courses retrieved successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created Course in storage.
|
||||||
|
* POST /courses
|
||||||
|
*
|
||||||
|
* @param CreateCourseAPIRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(CreateCourseAPIRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
$course = $this->courseRepository->create($input);
|
||||||
|
|
||||||
|
return $this->sendResponse($course->toArray(), 'Course saved successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified Course.
|
||||||
|
* GET|HEAD /courses/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
/** @var Course $course */
|
||||||
|
$course = $this->courseRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($course)) {
|
||||||
|
return $this->sendError('Course not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->sendResponse($course->toArray(), 'Course retrieved successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified Course in storage.
|
||||||
|
* PUT/PATCH /courses/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param UpdateCourseAPIRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update($id, UpdateCourseAPIRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
/** @var Course $course */
|
||||||
|
$course = $this->courseRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($course)) {
|
||||||
|
return $this->sendError('Course not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$course = $this->courseRepository->update($input, $id);
|
||||||
|
|
||||||
|
return $this->sendResponse($course->toArray(), 'Course updated successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified Course from storage.
|
||||||
|
* DELETE /courses/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
/** @var Course $course */
|
||||||
|
$course = $this->courseRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($course)) {
|
||||||
|
return $this->sendError('Course not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$course->delete();
|
||||||
|
|
||||||
|
return $this->sendSuccess('Course deleted successfully');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\AppBaseController;
|
||||||
|
use App\Models\ErrorCodeLog;
|
||||||
|
use App\Models\TotalScore;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class DashboardAPIController extends AppBaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
public function getChartData(Request $request)
|
||||||
|
{
|
||||||
|
// $err_logs = ErrorCodeLog::select(DB::raw('question_id, count(*) as total'))
|
||||||
|
// ->groupBy('question_id')
|
||||||
|
// ->with(["question"])->get();
|
||||||
|
|
||||||
|
$summ = TotalScore::select(DB::raw('question_id, count(*) as total'))
|
||||||
|
->groupBy('question_id')
|
||||||
|
->with(["question"])->get();
|
||||||
|
|
||||||
|
return Response([
|
||||||
|
"chart_data" => [
|
||||||
|
"questions" => $summ,
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,166 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Requests\API\CreateQuestionAPIRequest;
|
||||||
|
use App\Http\Requests\API\UpdateQuestionAPIRequest;
|
||||||
|
use App\Models\Answer;
|
||||||
|
use App\Models\Question;
|
||||||
|
use App\Models\UserScore;
|
||||||
|
use App\Repositories\QuestionRepository;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\AppBaseController;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Response;
|
||||||
|
use function MongoDB\BSON\toJSON;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class QuestionController
|
||||||
|
* @package App\Http\Controllers\API
|
||||||
|
*/
|
||||||
|
|
||||||
|
class QuestionAPIController extends AppBaseController
|
||||||
|
{
|
||||||
|
/** @var QuestionRepository */
|
||||||
|
private $questionRepository;
|
||||||
|
|
||||||
|
public function __construct(QuestionRepository $questionRepo)
|
||||||
|
{
|
||||||
|
$this->questionRepository = $questionRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the Question.
|
||||||
|
* GET|HEAD /questions
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$questions = $this->questionRepository->all(
|
||||||
|
$request->except(['skip', 'limit']),
|
||||||
|
$request->get('skip'),
|
||||||
|
$request->get('limit')
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->sendResponse($questions->toArray(), 'Questions retrieved successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQuestionAnswer($content_id){
|
||||||
|
$qa = Question::where("content_id", $content_id)->with("answers")->get();
|
||||||
|
return $this->sendResponse([
|
||||||
|
...$qa->toArray(),
|
||||||
|
], "success");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkAnswer(Request $request){
|
||||||
|
dd('masuk');
|
||||||
|
//if(Auth::check()){
|
||||||
|
$score = 0;
|
||||||
|
$data = json_decode($request->getContent(), true);
|
||||||
|
foreach ($data["answer_ids"] as $ans){
|
||||||
|
$answer = Answer::find($ans);
|
||||||
|
$is_right = (bool) $answer->is_right;
|
||||||
|
if($is_right){
|
||||||
|
$get_score = $answer->question->score;
|
||||||
|
$score+=$get_score;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$user_score = UserScore::where("user_id", $data["user_id"]);
|
||||||
|
//if($user_score->count() == 0){
|
||||||
|
UserScore::create(["user_id"=> $data["user_id"], "content_id" => $data["content_id"], "score" => $score ]);
|
||||||
|
//}
|
||||||
|
return $this->sendResponse(["score"=>$score], "success");
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Store a newly created Question in storage.
|
||||||
|
* POST /questions
|
||||||
|
*
|
||||||
|
* @param CreateQuestionAPIRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(CreateQuestionAPIRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
$question = $this->questionRepository->create($input);
|
||||||
|
|
||||||
|
return $this->sendResponse($question->toArray(), 'Question saved successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified Question.
|
||||||
|
* GET|HEAD /questions/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
// public function show($id)
|
||||||
|
// {
|
||||||
|
// /** @var Question $question */
|
||||||
|
// $question = $this->questionRepository->find($id);
|
||||||
|
// dd([$id,$question]);
|
||||||
|
|
||||||
|
// if (empty($question)) {
|
||||||
|
// return $this->sendError('Question not found');
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return $this->sendResponse($question->toArray(), 'Question retrieved successfully');
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified Question in storage.
|
||||||
|
* PUT/PATCH /questions/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param UpdateQuestionAPIRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update($id, UpdateQuestionAPIRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
/** @var Question $question */
|
||||||
|
$question = $this->questionRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($question)) {
|
||||||
|
return $this->sendError('Question not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$question = $this->questionRepository->update($input, $id);
|
||||||
|
|
||||||
|
return $this->sendResponse($question->toArray(), 'Question updated successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified Question from storage.
|
||||||
|
* DELETE /questions/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
/** @var Question $question */
|
||||||
|
$question = $this->questionRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($question)) {
|
||||||
|
return $this->sendError('Question not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$question->delete();
|
||||||
|
|
||||||
|
return $this->sendSuccess('Question deleted successfully');
|
||||||
|
}
|
||||||
|
}
|
||||||
131
Penilaian-Esai/app/Http/Controllers/API/RoleAPIController.php
Normal file
131
Penilaian-Esai/app/Http/Controllers/API/RoleAPIController.php
Normal file
|
|
@ -0,0 +1,131 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Requests\API\CreateRoleAPIRequest;
|
||||||
|
use App\Http\Requests\API\UpdateRoleAPIRequest;
|
||||||
|
use App\Models\Role;
|
||||||
|
use App\Repositories\RoleRepository;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\AppBaseController;
|
||||||
|
use Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class RoleController
|
||||||
|
* @package App\Http\Controllers\API
|
||||||
|
*/
|
||||||
|
|
||||||
|
class RoleAPIController extends AppBaseController
|
||||||
|
{
|
||||||
|
/** @var RoleRepository */
|
||||||
|
private $roleRepository;
|
||||||
|
|
||||||
|
public function __construct(RoleRepository $roleRepo)
|
||||||
|
{
|
||||||
|
$this->roleRepository = $roleRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the Role.
|
||||||
|
* GET|HEAD /roles
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$roles = $this->roleRepository->all(
|
||||||
|
$request->except(['skip', 'limit']),
|
||||||
|
$request->get('skip'),
|
||||||
|
$request->get('limit')
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->sendResponse($roles->toArray(), 'Roles retrieved successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created Role in storage.
|
||||||
|
* POST /roles
|
||||||
|
*
|
||||||
|
* @param CreateRoleAPIRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(CreateRoleAPIRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
$role = $this->roleRepository->create($input);
|
||||||
|
|
||||||
|
return $this->sendResponse($role->toArray(), 'Role saved successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified Role.
|
||||||
|
* GET|HEAD /roles/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
/** @var Role $role */
|
||||||
|
$role = $this->roleRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($role)) {
|
||||||
|
return $this->sendError('Role not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->sendResponse($role->toArray(), 'Role retrieved successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified Role in storage.
|
||||||
|
* PUT/PATCH /roles/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param UpdateRoleAPIRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update($id, UpdateRoleAPIRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
/** @var Role $role */
|
||||||
|
$role = $this->roleRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($role)) {
|
||||||
|
return $this->sendError('Role not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$role = $this->roleRepository->update($input, $id);
|
||||||
|
|
||||||
|
return $this->sendResponse($role->toArray(), 'Role updated successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified Role from storage.
|
||||||
|
* DELETE /roles/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
/** @var Role $role */
|
||||||
|
$role = $this->roleRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($role)) {
|
||||||
|
return $this->sendError('Role not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$role->delete();
|
||||||
|
|
||||||
|
return $this->sendSuccess('Role deleted successfully');
|
||||||
|
}
|
||||||
|
}
|
||||||
131
Penilaian-Esai/app/Http/Controllers/API/lessonAPIController.php
Normal file
131
Penilaian-Esai/app/Http/Controllers/API/lessonAPIController.php
Normal file
|
|
@ -0,0 +1,131 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Requests\API\CreateLessonAPIRequest;
|
||||||
|
use App\Http\Requests\API\UpdateLessonAPIRequest;
|
||||||
|
use App\Models\Lesson;
|
||||||
|
use App\Repositories\LessonRepository;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\AppBaseController;
|
||||||
|
use Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class lessonController
|
||||||
|
* @package App\Http\Controllers\API
|
||||||
|
*/
|
||||||
|
|
||||||
|
class lessonAPIController extends AppBaseController
|
||||||
|
{
|
||||||
|
/** @var lessonRepository */
|
||||||
|
private $lessonRepository;
|
||||||
|
|
||||||
|
public function __construct(LessonRepository $lessonRepo)
|
||||||
|
{
|
||||||
|
$this->lessonRepository = $lessonRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the lesson.
|
||||||
|
* GET|HEAD /lessons
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$lessons = $this->lessonRepository->all(
|
||||||
|
$request->except(['skip', 'limit']),
|
||||||
|
$request->get('skip'),
|
||||||
|
$request->get('limit')
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->sendResponse($lessons->toArray(), 'Lessons retrieved successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created lesson in storage.
|
||||||
|
* POST /lessons
|
||||||
|
*
|
||||||
|
* @param CreateLessonAPIRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(CreateLessonAPIRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
$lesson = $this->lessonRepository->create($input);
|
||||||
|
|
||||||
|
return $this->sendResponse($lesson->toArray(), 'Lesson saved successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified lesson.
|
||||||
|
* GET|HEAD /lessons/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
/** @var lesson $lesson */
|
||||||
|
$lesson = $this->lessonRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($lesson)) {
|
||||||
|
return $this->sendError('Lesson not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->sendResponse($lesson->toArray(), 'Lesson retrieved successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified lesson in storage.
|
||||||
|
* PUT/PATCH /lessons/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param UpdateLessonAPIRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update($id, UpdateLessonAPIRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
/** @var lesson $lesson */
|
||||||
|
$lesson = $this->lessonRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($lesson)) {
|
||||||
|
return $this->sendError('Lesson not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$lesson = $this->lessonRepository->update($input, $id);
|
||||||
|
|
||||||
|
return $this->sendResponse($lesson->toArray(), 'lesson updated successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified lesson from storage.
|
||||||
|
* DELETE /lessons/{id}
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
/** @var lesson $lesson */
|
||||||
|
$lesson = $this->lessonRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($lesson)) {
|
||||||
|
return $this->sendError('Lesson not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$lesson->delete();
|
||||||
|
|
||||||
|
return $this->sendSuccess('Lesson deleted successfully');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,182 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\AppBaseController;
|
||||||
|
use App\Http\Requests\CreateBadgeSettingRequest;
|
||||||
|
use App\Http\Requests\UpdateBadgeSettingRequest;
|
||||||
|
use App\Repositories\BadgeSettingRepository;
|
||||||
|
use App\Models\BadgeSetting;
|
||||||
|
use Flash;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Response;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
|
||||||
|
class BadgeSettingController extends AppBaseController
|
||||||
|
{
|
||||||
|
/** @var BadgeSettingRepository $badgeSettingRepository*/
|
||||||
|
private $badgeSettingRepository;
|
||||||
|
|
||||||
|
public function __construct(BadgeSettingRepository $badgeSettingRepo)
|
||||||
|
{
|
||||||
|
$this->badgeSettingRepository = $badgeSettingRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the BadgeSetting.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$badgeSettings = $this->badgeSettingRepository->paginate(10);
|
||||||
|
|
||||||
|
return view('admin.badge_settings.index')
|
||||||
|
->with('badgeSettings', $badgeSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new BadgeSetting.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('admin.badge_settings.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created BadgeSetting in storage.
|
||||||
|
*
|
||||||
|
* @param CreateBadgeSettingRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(CreateBadgeSettingRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
$badgeSetting = $this->badgeSettingRepository->create($input);
|
||||||
|
|
||||||
|
// $path = $badgeSetting->file('file')->store('image_upload', 'assets/images');
|
||||||
|
|
||||||
|
if ($image = $request->file('file')) {
|
||||||
|
$destinationPath = 'image_upload/';
|
||||||
|
$profileImage = date('YmdHis') . "." . $image->getClientOriginalExtension();
|
||||||
|
$image->move($destinationPath, $profileImage);
|
||||||
|
$input['file'] = "$profileImage";
|
||||||
|
}
|
||||||
|
|
||||||
|
BadgeSetting::create($input);
|
||||||
|
|
||||||
|
// Product::create($request->all());
|
||||||
|
|
||||||
|
Flash::success('Badge Setting saved successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.badgeSettings.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified BadgeSetting.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$badgeSetting = $this->badgeSettingRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($badgeSetting)) {
|
||||||
|
Flash::error('Badge Setting not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.badgeSettings.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.badge_settings.show')->with('badgeSetting', $badgeSetting);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified BadgeSetting.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$badgeSetting = $this->badgeSettingRepository->find($id);
|
||||||
|
|
||||||
|
|
||||||
|
if (empty($badgeSetting)) {
|
||||||
|
Flash::error('Badge Setting not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.badgeSettings.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.badge_settings.edit')->with('badgeSetting', $badgeSetting);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified BadgeSetting in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param UpdateBadgeSettingRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update($id, UpdateBadgeSettingRequest $request)
|
||||||
|
{
|
||||||
|
$badgeSetting = $this->badgeSettingRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($badgeSetting)) {
|
||||||
|
Flash::error('Badge Setting not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.badgeSettings.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$input = $request->all();
|
||||||
|
$badgeSetting = $this->badgeSettingRepository->update($request->all(), $id);
|
||||||
|
|
||||||
|
if ($image = $request->file('file')) {
|
||||||
|
$destinationPath = 'image_upload/';
|
||||||
|
$profileImage = date('YmdHis') . "." . $image->getClientOriginalExtension();
|
||||||
|
$image->move($destinationPath, $profileImage);
|
||||||
|
$input['file'] = "$profileImage";
|
||||||
|
}
|
||||||
|
|
||||||
|
$badgeSetting->update($input);
|
||||||
|
|
||||||
|
Flash::success('Badge Setting updated successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.badgeSettings.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified BadgeSetting from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$badgeSetting = $this->badgeSettingRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($badgeSetting)) {
|
||||||
|
Flash::error('Badge Setting not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.badgeSettings.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->badgeSettingRepository->delete($id);
|
||||||
|
|
||||||
|
Flash::success('Badge Setting deleted successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.badgeSettings.index'));
|
||||||
|
}
|
||||||
|
}
|
||||||
159
Penilaian-Esai/app/Http/Controllers/Admin/ContentController.php
Normal file
159
Penilaian-Esai/app/Http/Controllers/Admin/ContentController.php
Normal file
|
|
@ -0,0 +1,159 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Requests\CreateContentRequest;
|
||||||
|
use App\Http\Requests\UpdateContentRequest;
|
||||||
|
use App\Repositories\ContentRepository;
|
||||||
|
use App\Http\Controllers\AppBaseController;
|
||||||
|
use App\Models\Lesson;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Laracasts\Flash\Flash;
|
||||||
|
use Response;
|
||||||
|
|
||||||
|
class ContentController extends AppBaseController
|
||||||
|
{
|
||||||
|
/** @var ContentRepository $contentRepository*/
|
||||||
|
private $contentRepository;
|
||||||
|
|
||||||
|
public function __construct(ContentRepository $contentRepo)
|
||||||
|
{
|
||||||
|
$this->contentRepository = $contentRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the Content.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$contents = $this->contentRepository->paginate(10);
|
||||||
|
|
||||||
|
return view('admin.contents.index')
|
||||||
|
->with('contents', $contents);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new Content.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$lessons = Lesson::all()->pluck("title", "id");
|
||||||
|
return view('admin.contents.create', ["lessons" => $lessons]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created Content in storage.
|
||||||
|
*
|
||||||
|
* @param CreateContentRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(CreateContentRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
$content = $this->contentRepository->create($input);
|
||||||
|
|
||||||
|
Flash::success('Content saved successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.contents.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified Content.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$content = $this->contentRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($content)) {
|
||||||
|
Flash::error('Content not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.contents.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.contents.show')->with('content', $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified Content.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$content = $this->contentRepository->find($id);
|
||||||
|
$lessons = Lesson::all()->pluck("title", "id");
|
||||||
|
|
||||||
|
if (empty($content)) {
|
||||||
|
Flash::error('Content not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.contents.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.contents.edit')->with('content', $content)->with('lessons', $lessons);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified Content in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param UpdateContentRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update($id, UpdateContentRequest $request)
|
||||||
|
{
|
||||||
|
$content = $this->contentRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($content)) {
|
||||||
|
Flash::error('Content not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.contents.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$content = $this->contentRepository->update($request->all(), $id);
|
||||||
|
|
||||||
|
Flash::success('Content updated successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.contents.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified Content from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$content = $this->contentRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($content)) {
|
||||||
|
Flash::error('Content not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.contents.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->contentRepository->delete($id);
|
||||||
|
|
||||||
|
Flash::success('Content deleted successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.contents.index'));
|
||||||
|
}
|
||||||
|
}
|
||||||
157
Penilaian-Esai/app/Http/Controllers/Admin/CourseController.php
Normal file
157
Penilaian-Esai/app/Http/Controllers/Admin/CourseController.php
Normal file
|
|
@ -0,0 +1,157 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Requests\CreateCourseRequest;
|
||||||
|
use App\Http\Requests\UpdateCourseRequest;
|
||||||
|
use App\Repositories\CourseRepository;
|
||||||
|
use App\Http\Controllers\AppBaseController;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
//use Flash;
|
||||||
|
use Laracasts\Flash\Flash as Flash;
|
||||||
|
use Response;
|
||||||
|
|
||||||
|
class CourseController extends AppBaseController
|
||||||
|
{
|
||||||
|
/** @var CourseRepository $courseRepository*/
|
||||||
|
private $courseRepository;
|
||||||
|
|
||||||
|
public function __construct(CourseRepository $courseRepo)
|
||||||
|
{
|
||||||
|
$this->courseRepository = $courseRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the Course.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$courses = $this->courseRepository->paginate(25);
|
||||||
|
|
||||||
|
return view('admin.courses.index')
|
||||||
|
->with('courses', $courses);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new Course.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('admin.courses.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created Course in storage.
|
||||||
|
*
|
||||||
|
* @param CreateCourseRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(CreateCourseRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
$course = $this->courseRepository->create($input);
|
||||||
|
|
||||||
|
Flash::success('Course saved successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.courses.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified Course.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$course = $this->courseRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($course)) {
|
||||||
|
Flash::error('Course not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.courses.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.courses.show')->with('course', $course);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified Course.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$course = $this->courseRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($course)) {
|
||||||
|
Flash::error('Course not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.courses.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.courses.edit')->with('course', $course);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified Course in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param UpdateCourseRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update($id, UpdateCourseRequest $request)
|
||||||
|
{
|
||||||
|
$course = $this->courseRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($course)) {
|
||||||
|
Flash::error('Course not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.courses.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$course = $this->courseRepository->update($request->all(), $id);
|
||||||
|
|
||||||
|
Flash::success('Course updated successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.courses.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified Course from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$course = $this->courseRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($course)) {
|
||||||
|
Flash::error('Course not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.courses.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->courseRepository->delete($id);
|
||||||
|
|
||||||
|
Flash::success('Course deleted successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.courses.index'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,255 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\BadgeSetting;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\WonderingScore;
|
||||||
|
use App\Models\Question;
|
||||||
|
use App\Models\Content;
|
||||||
|
use App\Models\EssayQuestion;
|
||||||
|
use App\Models\UserAnswer;
|
||||||
|
use App\Models\UserScore;
|
||||||
|
use App\Models\TotalScore;
|
||||||
|
use App\Models\ExplainingScore;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class DashboardController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the application dashboard.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\Support\Renderable
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('admin.dashboard.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function leaderboard()
|
||||||
|
{
|
||||||
|
$user_id = User::where('role_id', 2)->get();
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($user_id as $user) {
|
||||||
|
$wondering = WonderingScore::where(["user_id" => $user->id])->sum("score");
|
||||||
|
$exploring = UserScore::where("user_id", $user->id)->sum("score");
|
||||||
|
$explainKonteks = ExplainingScore::where("user_id", $user->id)->sum("konteks_penjelasan");
|
||||||
|
$explainBenar = ExplainingScore::where("user_id", $user->id)->sum("kebenaran");
|
||||||
|
$explainKeruntutan = ExplainingScore::where("user_id", $user->id)->sum("keruntutan");
|
||||||
|
$final_score = $wondering + $exploring + $explainKonteks + $explainBenar + $explainKeruntutan;
|
||||||
|
$current_badge = BadgeSetting::where("min", "<=", $final_score)->where("max", ">=", $final_score)->first();
|
||||||
|
|
||||||
|
$data[] = [
|
||||||
|
'user' => $user,
|
||||||
|
'final_score' => $final_score,
|
||||||
|
'current_badge' => $current_badge,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = collect($data)->sortByDesc('final_score')->values()->all();
|
||||||
|
|
||||||
|
if (Auth::user()->role_id == 1) {
|
||||||
|
return view('admin.dashboard.leaderboard', compact('data'));
|
||||||
|
} else if (Auth::user()->role_id == 2) {
|
||||||
|
return view('student_courses.leaderboard_student', compact('data'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function report($user_id = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$users = User::all();
|
||||||
|
|
||||||
|
if (!empty($user_id)) {
|
||||||
|
$user_score = UserScore::where(["user_id" => $user_id])->get();
|
||||||
|
$take = UserScore::where("user_id", $user_id)->pluck("question_id")->toArray();
|
||||||
|
$code_test_score = UserScore::where(["user_id" => $user_id])->whereNotNull("question_id")->get();
|
||||||
|
$wondering = WonderingScore::where(["user_id" => $user_id])->sum("score");
|
||||||
|
$exploring = UserScore::where("user_id", $user_id)->sum("score");
|
||||||
|
$explainKonteks = ExplainingScore::where("user_id", $user_id)->sum("konteks_penjelasan");
|
||||||
|
$explainBenar = ExplainingScore::where("user_id", $user_id)->sum("kebenaran");
|
||||||
|
$explainKeruntutan = ExplainingScore::where("user_id", $user_id)->sum("keruntutan");
|
||||||
|
$final_score = $wondering + $exploring + $explainKonteks + $explainBenar + $explainKeruntutan;
|
||||||
|
$current_badge = BadgeSetting::where("min", "<=", $final_score)->where("max", ">=", $final_score)->first();
|
||||||
|
|
||||||
|
return view("admin.dashboard.report", [
|
||||||
|
"score" => $user_score,
|
||||||
|
"current_badge" => $current_badge,
|
||||||
|
"percentage" => UserScore::getPercentage($user_id),
|
||||||
|
"finish_code_tests" => $take,
|
||||||
|
"user_id" => $user_id,
|
||||||
|
"users" => $users,
|
||||||
|
"code_score" => $code_test_score,
|
||||||
|
"final_score" => $final_score
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.dashboard.report', ["user_id" => $user_id, 'users' => $users]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function penilaian($user_id, $content_id)
|
||||||
|
{
|
||||||
|
$user = User::firstwhere('id', $user_id);
|
||||||
|
$content = Content::where('id', $content_id)->first();
|
||||||
|
$read = WonderingScore::where('user_id', $user_id)->where('content_id', $content_id)->first();
|
||||||
|
$coding = UserScore::where('user_id', $user_id)->where('content_id', $content_id)->first();
|
||||||
|
$question = Question::where('content_id', $content_id)->first();
|
||||||
|
$question_id = Question::where('content_id', $content_id)->pluck('id');
|
||||||
|
$essay = EssayQuestion::whereIn('question_id', $question_id)->pluck('id');
|
||||||
|
$answer = UserAnswer::whereIn('essay_question_id', $essay)->where('user_id', $user_id)->get();
|
||||||
|
|
||||||
|
$explain_score = ExplainingScore::where('content_id', $content_id)->where('question_id', $question_id)->where('user_id', $user_id)->get();
|
||||||
|
$isAccepted = ExplainingScore::where('content_id', $content_id)
|
||||||
|
->where('question_id', $question_id)
|
||||||
|
->where('user_id', $user_id)
|
||||||
|
->get()
|
||||||
|
->pluck('is_accepted');
|
||||||
|
|
||||||
|
|
||||||
|
if ($explain_score->count() > 0) {
|
||||||
|
$total = $explain_score->sum(function ($explain_score) {
|
||||||
|
return $explain_score->keruntutan + $explain_score->kebenaran + $explain_score->konteks_penjelasan;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($explain_score as $index => $item) {
|
||||||
|
|
||||||
|
// $isAcceptedKonteks = $explain_score[0]->is_accepted;
|
||||||
|
// $isAcceptedRuntut = $explain_score[1]->is_accepted;
|
||||||
|
// $isAcceptedKebenaran = $explain_score[2]->is_accepted;
|
||||||
|
|
||||||
|
$convertKonteks = $explain_score[0]->konteks_penjelasan;
|
||||||
|
$convertRuntut = $explain_score[1]->keruntutan;
|
||||||
|
$convertKebenaran = $explain_score[2]->kebenaran;
|
||||||
|
|
||||||
|
$id_konteks = $explain_score[0]->id;
|
||||||
|
$id_runtut = $explain_score[1]->id;
|
||||||
|
$id_benar = $explain_score[2]->id;
|
||||||
|
|
||||||
|
$konteks = $this->reverseConvert($convertKonteks);
|
||||||
|
$benar = $this->reverseConvert($convertKebenaran);
|
||||||
|
$runtut = $this->reverseConvert($convertRuntut);
|
||||||
|
};
|
||||||
|
// dd([$konteks, $benar, $runtut]);
|
||||||
|
|
||||||
|
return view('admin.dashboard.penilaian', compact('user', 'read', 'coding', 'essay', 'answer', 'content', 'question', 'explain_score', 'total', 'konteks', 'runtut', 'benar', 'id_benar', 'id_runtut', 'id_konteks', 'convertKonteks', 'convertRuntut', 'convertKebenaran', 'isAccepted'));
|
||||||
|
} else {
|
||||||
|
return view('admin.dashboard.penilaian', compact('user', 'read', 'coding', 'essay', 'answer', 'content', 'question', 'explain_score'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function reverseConvert($value)
|
||||||
|
{
|
||||||
|
switch ($value) {
|
||||||
|
case 3:
|
||||||
|
return 1;
|
||||||
|
case 5:
|
||||||
|
return 2;
|
||||||
|
case 10:
|
||||||
|
return 3;
|
||||||
|
case 15:
|
||||||
|
return 4;
|
||||||
|
case 20:
|
||||||
|
return 5;
|
||||||
|
default:
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addPenilaian(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
$check_explain = ExplainingScore::where('content_id', $request->content_id)->where('question_id', $request->question_id)->where('user_id', $request->user_id);
|
||||||
|
|
||||||
|
if ($check_explain->count() == 0) {
|
||||||
|
$total_score = TotalScore::create([
|
||||||
|
'content_id' => $request->content_id,
|
||||||
|
'user_id' => $request->user_id,
|
||||||
|
'question_id' => $request->question_id,
|
||||||
|
'score' => $request->tot_score,
|
||||||
|
'wondering_score_id' => $request->wondering_id,
|
||||||
|
'user_score_id' => $request->exploring_id
|
||||||
|
]);
|
||||||
|
|
||||||
|
$explainKonteks = ExplainingScore::create([
|
||||||
|
'total_score_id' => $total_score->id,
|
||||||
|
'content_id' => $request->content_id,
|
||||||
|
'user_id' => $request->user_id,
|
||||||
|
'question_id' => $request->question_id,
|
||||||
|
'konteks_penjelasan' => $request->ikonteks,
|
||||||
|
'essay_question_id' => $request->essay_question_konteks,
|
||||||
|
'user_answer_id' => $request->user_answer_konteks
|
||||||
|
]);
|
||||||
|
|
||||||
|
$explainRuntut = ExplainingScore::create([
|
||||||
|
'total_score_id' => $total_score->id,
|
||||||
|
'content_id' => $request->content_id,
|
||||||
|
'user_id' => $request->user_id,
|
||||||
|
'question_id' => $request->question_id,
|
||||||
|
'keruntutan' => $request->iruntut,
|
||||||
|
'essay_question_id' => $request->essay_question_runtut,
|
||||||
|
'user_answer_id' => $request->user_answer_runtut
|
||||||
|
]);
|
||||||
|
|
||||||
|
$explainBenar = ExplainingScore::create([
|
||||||
|
'total_score_id' => $total_score->id,
|
||||||
|
'content_id' => $request->content_id,
|
||||||
|
'user_id' => $request->user_id,
|
||||||
|
'question_id' => $request->question_id,
|
||||||
|
'kebenaran' => $request->ibenar,
|
||||||
|
'essay_question_id' => $request->essay_question_kebenaran,
|
||||||
|
'user_answer_id' => $request->user_answer_kebenaran
|
||||||
|
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$check_total = $check_explain->first()->total->id;
|
||||||
|
|
||||||
|
$total_score = TotalScore::findOrFail($check_total);
|
||||||
|
$total_score->score = $request->tot_score;
|
||||||
|
$total_score->save();
|
||||||
|
|
||||||
|
$konteks = ExplainingScore::firstwhere('id', $request->id_konteks);
|
||||||
|
$konteks->konteks_penjelasan = $request->ikonteks;
|
||||||
|
$konteks->is_accepted = ($request->acc == 'true');
|
||||||
|
$konteks->save();
|
||||||
|
|
||||||
|
$runtut = ExplainingScore::firstwhere('id', $request->id_runtut);
|
||||||
|
$runtut->keruntutan = $request->iruntut;
|
||||||
|
$runtut->is_accepted = ($request->acc == 'true');
|
||||||
|
$runtut->save();
|
||||||
|
|
||||||
|
$benar = ExplainingScore::firstwhere('id', $request->id_benar);
|
||||||
|
$benar->kebenaran = $request->ibenar;
|
||||||
|
$benar->is_accepted = ($request->acc == 'true');
|
||||||
|
$benar->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => '200',
|
||||||
|
'message' => 'Success add user score'
|
||||||
|
], 200);
|
||||||
|
} catch (Exception $err) {
|
||||||
|
return response()->json([
|
||||||
|
'status' => '500',
|
||||||
|
'message' => 'Error add score',
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,119 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Models\Explains;
|
||||||
|
use App\Models\UserAnswer;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class ExplanationController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$explain = Explains::where('code', 0)->get();
|
||||||
|
$title = "summary";
|
||||||
|
return view('admin.explain.index', compact('explain', 'title'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showCode()
|
||||||
|
{
|
||||||
|
$explain = UserAnswer::paginate(10);
|
||||||
|
$title = "code";
|
||||||
|
return view('admin.explain.index', compact('explain', 'title'));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$explain = Explains::find($id);
|
||||||
|
$title = "summary";
|
||||||
|
return view('admin.explain.edit', compact('explain', 'title'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function editCode($id)
|
||||||
|
{
|
||||||
|
$explain = Explains::find($id);
|
||||||
|
$title = "code";
|
||||||
|
return view('admin.explain.edit', compact('explain', 'title'));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$explain = Explains::find($id);
|
||||||
|
$explain->description = $request->description;
|
||||||
|
$explain->edited_admin = Auth::id();
|
||||||
|
$explain->save();
|
||||||
|
|
||||||
|
return redirect(route('admin.explaination.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateCode(Request $request, $id)
|
||||||
|
{
|
||||||
|
$explain = Explains::find($id);
|
||||||
|
$explain->description = $request->description;
|
||||||
|
$explain->edited_admin = Auth::id();
|
||||||
|
$explain->save();
|
||||||
|
|
||||||
|
return redirect(route('admin.code.index.explanation'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
164
Penilaian-Esai/app/Http/Controllers/Admin/LessonController.php
Normal file
164
Penilaian-Esai/app/Http/Controllers/Admin/LessonController.php
Normal file
|
|
@ -0,0 +1,164 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Requests\CreateLessonRequest;
|
||||||
|
use App\Http\Requests\UpdateLessonRequest;
|
||||||
|
use App\Repositories\LessonRepository;
|
||||||
|
use App\Http\Controllers\AppBaseController;
|
||||||
|
use App\Models\Course;
|
||||||
|
use App\Models\Level;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Laracasts\Flash\Flash;
|
||||||
|
use Response;
|
||||||
|
|
||||||
|
class LessonController extends AppBaseController
|
||||||
|
{
|
||||||
|
/** @var LessonRepository $lessonRepository*/
|
||||||
|
private $lessonRepository;
|
||||||
|
|
||||||
|
public function __construct(LessonRepository $lessonRepo)
|
||||||
|
{
|
||||||
|
$this->lessonRepository = $lessonRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the lesson.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$lessons = $this->lessonRepository->paginate(25);
|
||||||
|
|
||||||
|
return view('admin.lessons.index')
|
||||||
|
->with('lessons', $lessons);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new lesson.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$courses = Course::all()->pluck("course_name", "id")->toArray();
|
||||||
|
$level = Level::all()->pluck("name","id")->toArray();
|
||||||
|
Log::debug($courses);
|
||||||
|
return view('admin.lessons.create', ["courses" => $courses, "level" => $level]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created lesson in storage.
|
||||||
|
*
|
||||||
|
* @param CreatelessonRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(CreateLessonRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
$lesson = $this->lessonRepository->create($input);
|
||||||
|
|
||||||
|
Flash::success('Lesson saved successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.lessons.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified lesson.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$lesson = $this->lessonRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($lesson)) {
|
||||||
|
Flash::error('Lesson not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.lessons.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.lessons.show', compact('lesson'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified lesson.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$lesson = $this->lessonRepository->find($id);
|
||||||
|
$courses = Course::all()->pluck("course_name", "id")->toArray();
|
||||||
|
$level = Level::all()->pluck("name","id")->toArray();
|
||||||
|
|
||||||
|
if (empty($lesson)) {
|
||||||
|
Flash::error('Lesson not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.lessons.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.lessons.edit', compact('lesson','courses','level'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified lesson in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param UpdatelessonRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update($id, UpdateLessonRequest $request)
|
||||||
|
{
|
||||||
|
$lesson = $this->lessonRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($lesson)) {
|
||||||
|
Flash::error('Lesson not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.lessons.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$lesson = $this->lessonRepository->update($request->all(), $id);
|
||||||
|
|
||||||
|
Flash::success('Lesson updated successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.lessons.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified lesson from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$lesson = $this->lessonRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($lesson)) {
|
||||||
|
Flash::error('Lesson not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.lessons.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->lessonRepository->delete($id);
|
||||||
|
|
||||||
|
Flash::success('Lesson deleted successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.lessons.index'));
|
||||||
|
}
|
||||||
|
}
|
||||||
112
Penilaian-Esai/app/Http/Controllers/Admin/LevelController.php
Normal file
112
Penilaian-Esai/app/Http/Controllers/Admin/LevelController.php
Normal file
|
|
@ -0,0 +1,112 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
use App\Models\Level;
|
||||||
|
use App\Models\Course;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Laracasts\Flash\Flash;
|
||||||
|
|
||||||
|
class LevelController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$level = Level::all();
|
||||||
|
|
||||||
|
return view('admin.level.index', compact('level'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$courses = Course::all()->pluck("course_name", "id")->toArray();
|
||||||
|
return view('admin.level.create',compact('courses'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$level = Level::create([
|
||||||
|
'name' => $request->name,
|
||||||
|
'description' => $request->description,
|
||||||
|
'course_id' => $request->course_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect(route('admin.level.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$level = Level::find($id);
|
||||||
|
$courses = Course::all()->pluck("course_name", "id")->toArray();
|
||||||
|
return view('admin.level.edit', compact('level','courses'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$level = Level::find($id);
|
||||||
|
$level->name = $request->name;
|
||||||
|
$level->description = $request->description;
|
||||||
|
$level->course_id = $request->course_id;
|
||||||
|
$level->save();
|
||||||
|
|
||||||
|
Flash::success('Level updated successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.level.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$level = Level::firstwhere('id', $id);
|
||||||
|
$level->delete();
|
||||||
|
|
||||||
|
Flash::success('Level delated successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.level.index'));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,156 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\AppBaseController;
|
||||||
|
use App\Http\Requests\CreateBadgeSettingRequest;
|
||||||
|
use App\Http\Requests\UpdateBadgeSettingRequest;
|
||||||
|
use App\Repositories\BadgeSettingRepository;
|
||||||
|
use Flash;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Response;
|
||||||
|
|
||||||
|
class LevelSettingController extends AppBaseController
|
||||||
|
{
|
||||||
|
/** @var BadgeSettingRepository $badgeSettingRepository*/
|
||||||
|
private $badgeSettingRepository;
|
||||||
|
|
||||||
|
public function __construct(BadgeSettingRepository $badgeSettingRepo)
|
||||||
|
{
|
||||||
|
$this->badgeSettingRepository = $badgeSettingRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the BadgeSetting.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$badgeSettings = $this->badgeSettingRepository->paginate(10);
|
||||||
|
|
||||||
|
return view('admin.badge_settings.index')
|
||||||
|
->with('badgeSettings', $badgeSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new BadgeSetting.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('admin.badge_settings.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created BadgeSetting in storage.
|
||||||
|
*
|
||||||
|
* @param CreateBadgeSettingRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(CreateBadgeSettingRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
$badgeSetting = $this->badgeSettingRepository->create($input);
|
||||||
|
|
||||||
|
Flash::success('Badge Setting saved successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.badgeSettings.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified BadgeSetting.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$badgeSetting = $this->badgeSettingRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($badgeSetting)) {
|
||||||
|
Flash::error('Badge Setting not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.badgeSettings.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.badge_settings.show')->with('badgeSetting', $badgeSetting);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified BadgeSetting.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$badgeSetting = $this->badgeSettingRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($badgeSetting)) {
|
||||||
|
Flash::error('Badge Setting not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.badgeSettings.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.badge_settings.edit')->with('badgeSetting', $badgeSetting);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified BadgeSetting in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param UpdateBadgeSettingRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update($id, UpdateBadgeSettingRequest $request)
|
||||||
|
{
|
||||||
|
$badgeSetting = $this->badgeSettingRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($badgeSetting)) {
|
||||||
|
Flash::error('Badge Setting not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.badgeSettings.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$badgeSetting = $this->badgeSettingRepository->update($request->all(), $id);
|
||||||
|
|
||||||
|
Flash::success('Badge Setting updated successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.badgeSettings.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified BadgeSetting from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$badgeSetting = $this->badgeSettingRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($badgeSetting)) {
|
||||||
|
Flash::error('Badge Setting not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.badgeSettings.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->badgeSettingRepository->delete($id);
|
||||||
|
|
||||||
|
Flash::success('Badge Setting deleted successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.badgeSettings.index'));
|
||||||
|
}
|
||||||
|
}
|
||||||
274
Penilaian-Esai/app/Http/Controllers/Admin/QuestionController.php
Normal file
274
Penilaian-Esai/app/Http/Controllers/Admin/QuestionController.php
Normal file
|
|
@ -0,0 +1,274 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Requests\CreateQuestionRequest;
|
||||||
|
use App\Http\Requests\UpdateQuestionRequest;
|
||||||
|
use App\Models\Answer;
|
||||||
|
use App\Models\EssayQuestion;
|
||||||
|
use App\Models\UserAnswer;
|
||||||
|
use App\Models\UserScore;
|
||||||
|
use App\Repositories\QuestionRepository;
|
||||||
|
use App\Http\Controllers\AppBaseController;
|
||||||
|
use App\Models\Content;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Laracasts\Flash\Flash;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Response;
|
||||||
|
|
||||||
|
class QuestionController extends AppBaseController
|
||||||
|
{
|
||||||
|
/** @var QuestionRepository $questionRepository*/
|
||||||
|
private $questionRepository;
|
||||||
|
|
||||||
|
public function __construct(QuestionRepository $questionRepo)
|
||||||
|
{
|
||||||
|
$this->questionRepository = $questionRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the Question.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$questions = $this->questionRepository->paginate(10);
|
||||||
|
|
||||||
|
return view('admin.questions.index')
|
||||||
|
->with('questions', $questions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new Question.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$title = "create";
|
||||||
|
$contents = Content::all()->pluck("title", "id");
|
||||||
|
return view('admin.questions.create', ["contents" => $contents, "answers" => [], "title" => $title]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created Question in storage.
|
||||||
|
*
|
||||||
|
* @param CreateQuestionRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
$question = $this->questionRepository->create($input);
|
||||||
|
if ($request['is_essay'] != '1') {
|
||||||
|
for ($i = 0; $i < 4; $i++) {
|
||||||
|
$ans = $request["answers_$i"];
|
||||||
|
$is_r = @$request["is_right_$i"];
|
||||||
|
Answer::create(["question_id" => $question->id, "answer" => $ans, "is_right" => $is_r]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$essay_question = $request->input('essay_question');
|
||||||
|
$key_answer = $request->input('answer_key');
|
||||||
|
$key_answer2 = $request->input('answer_key2');
|
||||||
|
$key_answer3 = $request->input('answer_key3');
|
||||||
|
$key_answer4 = $request->input('answer_key4');
|
||||||
|
|
||||||
|
foreach ($essay_question as $index => $eques) {
|
||||||
|
$keys = $key_answer[$index];
|
||||||
|
$keys2 = $key_answer2[$index];
|
||||||
|
$keys3 = $key_answer3[$index];
|
||||||
|
$keys4 = $key_answer4[$index];
|
||||||
|
|
||||||
|
// $keys = isset($key_answer[$index]) ? $key_answer[$index] : null;
|
||||||
|
// $keys2 = isset($key_answer2[$index]) ? $key_answer2[$index] : null;
|
||||||
|
// $keys3 = isset($key_answer3[$index]) ? $key_answer3[$index] : null;
|
||||||
|
// $keys4 = isset($key_answer4[$index]) ? $key_answer4[$index] : null;
|
||||||
|
|
||||||
|
EssayQuestion::create([
|
||||||
|
'question_id' => $question->id,
|
||||||
|
'user_id' => Auth::id(),
|
||||||
|
'question' => $eques,
|
||||||
|
'answer' => $keys,
|
||||||
|
'answer2' => $keys2,
|
||||||
|
'answer3' => $keys3,
|
||||||
|
'answer4' => $keys4
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Flash::success('Question saved successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.questions.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified Question.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$question = $this->questionRepository->find($id);
|
||||||
|
$essay_question = EssayQuestion::where('question_id', $id)->get();
|
||||||
|
|
||||||
|
if (empty($question)) {
|
||||||
|
Flash::error('Question not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.questions.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.questions.show')->with('question', $question)->with('essay', $essay_question);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified Question.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$question = $this->questionRepository->find($id);
|
||||||
|
|
||||||
|
$contents = Content::all()->pluck("title", "id");
|
||||||
|
$title = "edit";
|
||||||
|
$essay = EssayQuestion::where('question_id', $id)->get();
|
||||||
|
if (empty($question)) {
|
||||||
|
Flash::error('Question not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.questions.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.questions.edit')->with('question', $question)->with("contents", $contents)->with("answers", $question->answers)->with('title', $title)->with('essay', $essay);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified Question in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param UpdateQuestionRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update($id, Request $request)
|
||||||
|
{
|
||||||
|
$question = $this->questionRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($question)) {
|
||||||
|
Flash::error('Question not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.questions.index'));
|
||||||
|
}
|
||||||
|
$question = $this->questionRepository->update($request->all(), $id);
|
||||||
|
|
||||||
|
$answers = $question->answers;
|
||||||
|
if ($request['is_essay'] != '1') {
|
||||||
|
if ($answers->count() == 0) {
|
||||||
|
for ($i = 0; $i < 4; $i++) {
|
||||||
|
$ans = $request["answers_$i"];
|
||||||
|
$is_r = @$request["is_right_$i"];
|
||||||
|
|
||||||
|
Answer::create(["question_id" => $question->id, "answer" => $ans, "is_right" => $is_r]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for ($i = 0; $i < 4; $i++) {
|
||||||
|
$ans = $request["answers_$i"];
|
||||||
|
$is_r = @$request["is_right_$i"];
|
||||||
|
$id_ans = @$request["answer_id_$i"];
|
||||||
|
if (empty($id_ans)) {
|
||||||
|
Answer::create(["question_id" => $question->id, "answer" => $ans, "is_right" => $is_r]);
|
||||||
|
} else {
|
||||||
|
$answ = Answer::find((int)$id_ans);
|
||||||
|
$answ->update(["question_id" => $question->id, "answer" => $ans, "is_right" => $is_r]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$question = $this->questionRepository->update(["is_essay" => 1], $id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$essay_question = $request->input('essay_question');
|
||||||
|
$key_answer = $request->input('answer_key');
|
||||||
|
$key_answer2 = $request->input('answer_key2');
|
||||||
|
$key_answer3 = $request->input('answer_key3');
|
||||||
|
$key_answer4 = $request->input('answer_key4');
|
||||||
|
$essay_id = $request->input('essay_id');
|
||||||
|
|
||||||
|
foreach ($essay_question as $index => $eques) {
|
||||||
|
$keys = $key_answer[$index];
|
||||||
|
$keys2 = $key_answer2[$index];
|
||||||
|
$keys3 = $key_answer3[$index];
|
||||||
|
$keys4 = $key_answer4[$index];
|
||||||
|
$essay = $essay_id[$index];
|
||||||
|
|
||||||
|
$check_data = EssayQuestion::where('id', $essay);
|
||||||
|
if ($check_data->count() == 0) {
|
||||||
|
EssayQuestion::create([
|
||||||
|
'question_id' => $question->id,
|
||||||
|
'user_id' => Auth::id(),
|
||||||
|
'question' => $eques,
|
||||||
|
'answer' => $keys,
|
||||||
|
'answer2' => $keys2,
|
||||||
|
'answer3' => $keys3,
|
||||||
|
'answer4' => $keys4
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$data_essay = EssayQuestion::firstwhere('id', $essay);
|
||||||
|
$data_essay->question = $eques;
|
||||||
|
$data_essay->answer = $keys;
|
||||||
|
$data_essay->answer2 = $keys2;
|
||||||
|
$data_essay->answer3 = $keys3;
|
||||||
|
$data_essay->answer4 = $keys4;
|
||||||
|
$data_essay->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Flash::success('Question updated successfully.');
|
||||||
|
Log::debug($request->all());
|
||||||
|
|
||||||
|
return redirect(route('admin.questions.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified Question from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$question = $this->questionRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($question)) {
|
||||||
|
Flash::error('Question not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.questions.index'));
|
||||||
|
}
|
||||||
|
$essay = EssayQuestion::where('question_id', $id);
|
||||||
|
$id_essay = $essay->pluck('id');
|
||||||
|
$user_answer = UserAnswer::whereIn('essay_question_id', $id_essay);
|
||||||
|
$user_score = UserScore::where('question_id', $id);
|
||||||
|
|
||||||
|
$user_score->delete();
|
||||||
|
$user_answer->delete();
|
||||||
|
$essay->delete();
|
||||||
|
$this->questionRepository->delete($id);
|
||||||
|
|
||||||
|
Flash::success('Question deleted successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.questions.index'));
|
||||||
|
}
|
||||||
|
}
|
||||||
156
Penilaian-Esai/app/Http/Controllers/Admin/RoleController.php
Normal file
156
Penilaian-Esai/app/Http/Controllers/Admin/RoleController.php
Normal file
|
|
@ -0,0 +1,156 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Requests\CreateRoleRequest;
|
||||||
|
use App\Http\Requests\UpdateRoleRequest;
|
||||||
|
use App\Repositories\RoleRepository;
|
||||||
|
use App\Http\Controllers\AppBaseController;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Laracasts\Flash\Flash;
|
||||||
|
use Response;
|
||||||
|
|
||||||
|
class RoleController extends AppBaseController
|
||||||
|
{
|
||||||
|
/** @var RoleRepository $roleRepository*/
|
||||||
|
private $roleRepository;
|
||||||
|
|
||||||
|
public function __construct(RoleRepository $roleRepo)
|
||||||
|
{
|
||||||
|
$this->roleRepository = $roleRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the Role.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$roles = $this->roleRepository->paginate(10);
|
||||||
|
|
||||||
|
return view('admin.roles.index')
|
||||||
|
->with('roles', $roles);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new Role.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('admin.roles.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created Role in storage.
|
||||||
|
*
|
||||||
|
* @param CreateRoleRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(CreateRoleRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
$role = $this->roleRepository->create($input);
|
||||||
|
|
||||||
|
Flash::success('Role saved successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.roles.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified Role.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$role = $this->roleRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($role)) {
|
||||||
|
Flash::error('Role not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.roles.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.roles.show')->with('role', $role);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified Role.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$role = $this->roleRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($role)) {
|
||||||
|
Flash::error('Role not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.roles.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.roles.edit')->with('role', $role);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified Role in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param UpdateRoleRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update($id, UpdateRoleRequest $request)
|
||||||
|
{
|
||||||
|
$role = $this->roleRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($role)) {
|
||||||
|
Flash::error('Role not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.roles.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$role = $this->roleRepository->update($request->all(), $id);
|
||||||
|
|
||||||
|
Flash::success('Role updated successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.roles.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified Role from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$role = $this->roleRepository->find($id);
|
||||||
|
|
||||||
|
if (empty($role)) {
|
||||||
|
Flash::error('Role not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.roles.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->roleRepository->delete($id);
|
||||||
|
|
||||||
|
Flash::success('Role deleted successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.roles.index'));
|
||||||
|
}
|
||||||
|
}
|
||||||
129
Penilaian-Esai/app/Http/Controllers/Admin/UserController.php
Normal file
129
Penilaian-Esai/app/Http/Controllers/Admin/UserController.php
Normal file
|
|
@ -0,0 +1,129 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Models\Role;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class UserController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$users = User::all();
|
||||||
|
|
||||||
|
return view('admin.users.index', compact('users'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$roles = Role::get()->pluck('role', 'id');
|
||||||
|
$code = "create";
|
||||||
|
|
||||||
|
return view('admin.users.create', compact('roles','code'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$user = User::create($request->only('name','email', 'role_id','class') + ['password' => bcrypt($request->password)]);
|
||||||
|
return redirect()->route('admin.users.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$user = User::find($id);
|
||||||
|
$roles = Role::all()->pluck("role", "id")->toArray();
|
||||||
|
// if (empty($lesson)) {
|
||||||
|
// Flash::error('Lesson not found');
|
||||||
|
//
|
||||||
|
// return redirect(route('admin.lessons.index'));
|
||||||
|
// }
|
||||||
|
return view('admin.users.show')->with('user', $user)->with("roles", $roles);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
|
||||||
|
$user = User::find($id);
|
||||||
|
$roles = Role::all()->pluck("role", "id")->toArray();
|
||||||
|
$code = "edit";
|
||||||
|
// if (empty($lesson)) {
|
||||||
|
// Flash::error('Lesson not found');
|
||||||
|
//
|
||||||
|
// return redirect(route('admin.lessons.index'));
|
||||||
|
// }
|
||||||
|
return view('admin.users.edit')->with('user', $user)->with("roles", $roles)->with("code", $code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request,User $user)
|
||||||
|
{
|
||||||
|
$user->update($request->only('name','email', 'role_id','class') + ['password' => bcrypt($request->password)]);
|
||||||
|
return redirect()->route('admin.users.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy(Request $data, $id)
|
||||||
|
{
|
||||||
|
|
||||||
|
User::find($id)->delete([
|
||||||
|
'name' => $data->name,
|
||||||
|
'email' => $data->email,
|
||||||
|
'password' => $data->password,
|
||||||
|
'role_id' => $data->role_id,
|
||||||
|
'class' => $data->class,
|
||||||
|
]);
|
||||||
|
return redirect()->route('admin.users.index')->with(['message'=> 'Successfully deleted!!']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// $post =User::where('id', $id)->first();
|
||||||
|
//
|
||||||
|
// if ($post != null) {
|
||||||
|
// $post->delete();
|
||||||
|
// return redirect()->route('admin.users.index')->with(['message'=> 'Successfully deleted!!']);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return redirect()->route('admin.users.index')->with(['message'=> 'Wrong ID!!']);
|
||||||
|
//
|
||||||
|
// }
|
||||||
122
Penilaian-Esai/app/Http/Controllers/ApiController.php
Normal file
122
Penilaian-Esai/app/Http/Controllers/ApiController.php
Normal file
|
|
@ -0,0 +1,122 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use JWTAuth;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Tymon\JWTAuth\Exceptions\JWTException;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
|
class ApiController extends Controller
|
||||||
|
{
|
||||||
|
public function register(Request $request)
|
||||||
|
{
|
||||||
|
//Validate data
|
||||||
|
$data = $request->only('name', 'email', 'password');
|
||||||
|
$validator = Validator::make($data, [
|
||||||
|
'name' => 'required|string',
|
||||||
|
'email' => 'required|email|unique:users',
|
||||||
|
'password' => 'required|string|min:6|max:50'
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Send failed response if request is not valid
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return response()->json(['error' => $validator->messages()], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Request is valid, create new user
|
||||||
|
$user = User::create([
|
||||||
|
'name' => $request->name,
|
||||||
|
'email' => $request->email,
|
||||||
|
'password' => bcrypt($request->password)
|
||||||
|
]);
|
||||||
|
|
||||||
|
//User created, return success response
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'User created successfully',
|
||||||
|
'data' => $user
|
||||||
|
], Response::HTTP_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function authenticate(Request $request)
|
||||||
|
{
|
||||||
|
$credentials = $request->only('email', 'password');
|
||||||
|
Log::debug($request->all());
|
||||||
|
//valid credential
|
||||||
|
$validator = Validator::make($credentials, [
|
||||||
|
'email' => 'required|email',
|
||||||
|
'password' => 'required|string|min:6|max:50'
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Send failed response if request is not valid
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return response()->json(['error' => $validator->messages()], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Request is validated
|
||||||
|
//Crean token
|
||||||
|
try {
|
||||||
|
if (! $token = JWTAuth::attempt($credentials)) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Login credentials are invalid.',
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
|
} catch (JWTException $e) {
|
||||||
|
return $credentials;
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Could not create token.',
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Token created, return with success response and jwt token
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'token' => $token,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logout(Request $request)
|
||||||
|
{
|
||||||
|
//valid credential
|
||||||
|
$validator = Validator::make($request->only('token'), [
|
||||||
|
'token' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Send failed response if request is not valid
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return response()->json(['error' => $validator->messages()], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Request is validated, do logout
|
||||||
|
try {
|
||||||
|
JWTAuth::invalidate($request->token);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'User has been logged out'
|
||||||
|
]);
|
||||||
|
} catch (JWTException $exception) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Sorry, user cannot be logged out'
|
||||||
|
], Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_user(Request $request)
|
||||||
|
{
|
||||||
|
$this->validate($request, [
|
||||||
|
'token' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = JWTAuth::authenticate($request->token);
|
||||||
|
|
||||||
|
return response()->json(['user' => $user]);
|
||||||
|
}
|
||||||
|
}
|
||||||
38
Penilaian-Esai/app/Http/Controllers/AppBaseController.php
Normal file
38
Penilaian-Esai/app/Http/Controllers/AppBaseController.php
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use InfyOm\Generator\Utils\ResponseUtil;
|
||||||
|
use Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SWG\Swagger(
|
||||||
|
* basePath="/api/v1",
|
||||||
|
* @SWG\Info(
|
||||||
|
* title="Laravel Generator APIs",
|
||||||
|
* version="1.0.0",
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
* This class should be parent class for other API controllers
|
||||||
|
* Class AppBaseController
|
||||||
|
*/
|
||||||
|
class AppBaseController extends Controller
|
||||||
|
{
|
||||||
|
public function sendResponse($result, $message)
|
||||||
|
{
|
||||||
|
return Response::json(ResponseUtil::makeResponse($message, $result));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendError($error, $code = 404)
|
||||||
|
{
|
||||||
|
return Response::json(ResponseUtil::makeError($error), $code);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendSuccess($message)
|
||||||
|
{
|
||||||
|
return Response::json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => $message
|
||||||
|
], 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
||||||
|
|
||||||
|
class ConfirmPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Confirm Password Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling password confirmations and
|
||||||
|
| uses a simple trait to include the behavior. You're free to explore
|
||||||
|
| this trait and override any functions that require customization.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use ConfirmsPasswords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users when the intended url fails.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = RouteServiceProvider::HOME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||||
|
|
||||||
|
class ForgotPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Password Reset Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling password reset emails and
|
||||||
|
| includes a trait which assists in sending these notifications from
|
||||||
|
| your application to your users. Feel free to explore this trait.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use SendsPasswordResetEmails;
|
||||||
|
}
|
||||||
40
Penilaian-Esai/app/Http/Controllers/Auth/LoginController.php
Normal file
40
Penilaian-Esai/app/Http/Controllers/Auth/LoginController.php
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||||
|
|
||||||
|
class LoginController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Login Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller handles authenticating users for the application and
|
||||||
|
| redirecting them to your home screen. The controller uses a trait
|
||||||
|
| to conveniently provide its functionality to your applications.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use AuthenticatesUsers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after login.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = RouteServiceProvider::HOME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('guest')->except('logout');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
|
class RegisterController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller handles the registration of new users as well as their
|
||||||
|
| validation and creation. By default this controller uses a trait to
|
||||||
|
| provide this functionality without requiring any additional code.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use RegistersUsers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after registration.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = RouteServiceProvider::HOME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('guest');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a validator for an incoming registration request.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return \Illuminate\Contracts\Validation\Validator
|
||||||
|
*/
|
||||||
|
protected function validator(array $data)
|
||||||
|
{
|
||||||
|
return Validator::make($data, [
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||||
|
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||||
|
'class' => ['required','integer']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new user instance after a valid registration.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return \App\Models\User
|
||||||
|
*/
|
||||||
|
|
||||||
|
protected function create(array $data)
|
||||||
|
{
|
||||||
|
return User::create([
|
||||||
|
'name' => $data['name'],
|
||||||
|
'email' => $data['email'],
|
||||||
|
'password' => Hash::make($data['password']),
|
||||||
|
'role_id' => '2',
|
||||||
|
'class' => $data['class'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||||
|
|
||||||
|
class ResetPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Password Reset Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling password reset requests
|
||||||
|
| and uses a simple trait to include this behavior. You're free to
|
||||||
|
| explore this trait and override any methods you wish to tweak.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use ResetsPasswords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after resetting their password.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = RouteServiceProvider::HOME;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||||
|
|
||||||
|
class VerificationController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Email Verification Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling email verification for any
|
||||||
|
| user that recently registered with the application. Emails may also
|
||||||
|
| be re-sent if the user didn't receive the original email message.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use VerifiesEmails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after verification.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = RouteServiceProvider::HOME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
$this->middleware('signed')->only('verify');
|
||||||
|
$this->middleware('throttle:6,1')->only('verify', 'resend');
|
||||||
|
}
|
||||||
|
}
|
||||||
264
Penilaian-Esai/app/Http/Controllers/CodeTestController.php
Normal file
264
Penilaian-Esai/app/Http/Controllers/CodeTestController.php
Normal file
|
|
@ -0,0 +1,264 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\ErrorCodeLog;
|
||||||
|
use App\Models\Question;
|
||||||
|
use App\Models\UserCodeTestScore;
|
||||||
|
use App\Models\UserScore;
|
||||||
|
use App\Models\ExerciseCodeLog;
|
||||||
|
use App\Models\EssayQuestion;
|
||||||
|
use App\Models\UserAnswer;
|
||||||
|
use App\Models\Level;
|
||||||
|
use App\Models\ExplainingScore;
|
||||||
|
use App\Models\Explains;
|
||||||
|
use App\Models\TotalScore;
|
||||||
|
use App\Models\WonderingScore;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class CodeTestController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
public function index($course_id, Request $request)
|
||||||
|
{
|
||||||
|
$question = Question::find($course_id);
|
||||||
|
$score = UserScore::where("user_id", Auth::id())->where("question_id", $course_id);
|
||||||
|
$explain = Explains::where("user_id", Auth::id())->where('question_id', $course_id)->get();
|
||||||
|
// $data_essay = UserAnswer::where('user_id', Auth::id())
|
||||||
|
// $level = Level::firstwhere('id',$request->level_id);
|
||||||
|
// dd([Auth::id(), $course_id, $explain]);
|
||||||
|
$essay = EssayQuestion::where('question_id', $course_id)->get();
|
||||||
|
$duration = "";
|
||||||
|
|
||||||
|
$user_score = $score->first();
|
||||||
|
$err_logs = ErrorCodeLog::where("user_id", Auth::id())->where("question_id", $course_id)->get();
|
||||||
|
$exer_logs = ExerciseCodeLog::where("user_id", Auth::id())->where("question_id", $course_id)->orderBy('id', 'DESC')->get();
|
||||||
|
|
||||||
|
if ($user_score) {
|
||||||
|
$a = Carbon::parse($user_score->started_at);
|
||||||
|
$b = Carbon::parse($user_score->ended_at);
|
||||||
|
$duration = $b->diff($a)->format('%Hh %Im %Ss'); // Menghitung durasi pengerjaan soal
|
||||||
|
}
|
||||||
|
|
||||||
|
$isFinish = false;
|
||||||
|
if ($score->count() > 0) {
|
||||||
|
$isFinish = true; // Menentukan apakah pengguna telah menyelesaikan soal
|
||||||
|
}
|
||||||
|
|
||||||
|
return view("student_courses.code_test", [
|
||||||
|
"question" => $question,
|
||||||
|
'score' => $score->sum('score'), //Menghitung total skor
|
||||||
|
'is_finish' => $isFinish, // Menyatakan apakah pengguna telah menyelesaikan soal
|
||||||
|
'user_score' => $user_score,
|
||||||
|
'duration' => $duration,
|
||||||
|
'error_logs' => $err_logs, // Mengirimkan log kesalahan ke tampilan
|
||||||
|
'exercise_logs' => $exer_logs, // Mengirimkan log latihan ke tampilan
|
||||||
|
'explain' => $explain, // Mengirimkan penjelasan ke tampilan
|
||||||
|
'essay' => $essay // Mengirimkan pertanyaan esai ke tampilan
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function codeTestSubmit(Request $request)
|
||||||
|
{
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
// Mendapatkan model skor pengguna berdasarkan ID pengguna dan ID soal
|
||||||
|
$model = UserScore::where("user_id", $request->get("user_id"))->where("question_id", $request->get("question_id"));
|
||||||
|
$question = Question::find($request->get("question_id"));
|
||||||
|
$check_explain = Explains::where("user_id", $request->get("user_id"))->where('question_id', $request->get("question_id"));
|
||||||
|
Log::debug($model->count());
|
||||||
|
|
||||||
|
// Jika skor lebih dari 0, lakukan proses penyimpanan
|
||||||
|
if ($request->score > 0) {
|
||||||
|
if ($model->count() == 0) {
|
||||||
|
// Jika belum ada skor, buat entri baru
|
||||||
|
UserScore::create(
|
||||||
|
[
|
||||||
|
"user_id" => $request->get("user_id"),
|
||||||
|
"question_id" => $request->get("question_id"),
|
||||||
|
"content_id" => $request->get("content_id"),
|
||||||
|
"score" => $request->get('score') == 10 ? $question->score : 0,
|
||||||
|
"started_at" => $request->get("started_at"),
|
||||||
|
"ended_at" => $request->get("ended_at"),
|
||||||
|
"on_timer" => $request->get("on_timer"),
|
||||||
|
"level_id" => $request->get('level_id')
|
||||||
|
]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Jika sudah ada skor, update entri yang ada
|
||||||
|
$check = UserScore::where("user_id", $request->get("user_id"))->where("question_id", $request->get("question_id"))->first();
|
||||||
|
$user_score = UserScore::firstwhere('id', $check->id);
|
||||||
|
// $user_score->score = $request->get('score');
|
||||||
|
$user_score->score = $request->get('score') == 10 ? $question->score : 0;
|
||||||
|
$user_score->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Memproses jawaban esai
|
||||||
|
// Mengambil Input dari Pengguna:
|
||||||
|
$jawaban = $request->input('answer');
|
||||||
|
$pertanyaanId = $request->input('essay_id');
|
||||||
|
|
||||||
|
$nilai = [];
|
||||||
|
foreach ($pertanyaanId as $key => $id_essay) {
|
||||||
|
$answer = $jawaban[$key]; // user answere
|
||||||
|
$essayAnswer = EssayQuestion::find($id_essay)->answer;
|
||||||
|
$essayAnswer2 = EssayQuestion::find($id_essay)->answer2;
|
||||||
|
$essayAnswer3 = EssayQuestion::find($id_essay)->answer3;
|
||||||
|
$essayAnswer4 = EssayQuestion::find($id_essay)->answer4;
|
||||||
|
$check_data = UserAnswer::where('user_id', Auth::id())->where('essay_question_id', $id_essay);
|
||||||
|
|
||||||
|
// Menyimpan atau memperbarui jawaban pengguna
|
||||||
|
if ($check_data->count() == 0) {
|
||||||
|
UserAnswer::create([
|
||||||
|
'user_id' => Auth::id(),
|
||||||
|
'essay_question_id' => $id_essay,
|
||||||
|
'answer' => $answer
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$check_rubrik = ExplainingScore::where('user_id', Auth::id())->where('user_answer_id', $check_data->first()->id)->count();
|
||||||
|
if ($check_rubrik == 0) {
|
||||||
|
$data_explain = UserAnswer::firstwhere('id', $check_data->first()->id);
|
||||||
|
$data_explain->answer = $answer;
|
||||||
|
$data_explain->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Memanggil API untuk mengoreksi jawaban esai
|
||||||
|
try {
|
||||||
|
$response = Http::asForm()->post(env("GENERATE_GRADE_URL", "http://127.0.0.1:8000/compiler/generate/grade"), [
|
||||||
|
'esay_answer' => $essayAnswer,
|
||||||
|
'esay_answer2' => $essayAnswer2,
|
||||||
|
'esay_answer3' => $essayAnswer3,
|
||||||
|
'esay_answer4' => $essayAnswer4,
|
||||||
|
'user_answer' => $answer,
|
||||||
|
]);
|
||||||
|
$data = $response->json(); // $data['output'] | 0 - 1 // Mengambil hasil koreksi
|
||||||
|
// $nilai[] = $this->convertNilai($data['output']);
|
||||||
|
$nilai[] = $data['output'];
|
||||||
|
} catch (Exception $err) {
|
||||||
|
return response()->json([
|
||||||
|
'status' => '500',
|
||||||
|
'message' => 'Error add score',
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mengambil Skor Penjelasan, Wondering, dan Skor Pengguna:
|
||||||
|
$check_explain = ExplainingScore::where('content_id', $request->content_id)->where('question_id', $request->question_id)->where('user_id', $request->user_id);
|
||||||
|
$wondering = WonderingScore::where('content_id', $request->content_id)->where('user_id', $request->user_id)->first();
|
||||||
|
$user_score = UserScore::where('content_id', $request->content_id)->where('user_id', $request->user_id)->where('question_id', $request->question_id)->first();
|
||||||
|
//Menghitung Total Skor:
|
||||||
|
$tot_score = $wondering->score + $user_score->score + $nilai[0] + $nilai[1] + $nilai[2];
|
||||||
|
|
||||||
|
if ($check_explain->count() == 0) {
|
||||||
|
// Membuat entri total skor dan skor penjelasan
|
||||||
|
$total_score = TotalScore::create([
|
||||||
|
'content_id' => $request->content_id,
|
||||||
|
'user_id' => $request->user_id,
|
||||||
|
'question_id' => $request->question_id,
|
||||||
|
'score' => $tot_score,
|
||||||
|
'wondering_score_id' => $wondering->id,
|
||||||
|
'user_score_id' => $user_score->id
|
||||||
|
]);
|
||||||
|
|
||||||
|
$konteksAnswer = UserAnswer::where('user_id', $request->user_id)->where('essay_question_id', $request->essay_id[0])->first();
|
||||||
|
$explainKonteks = ExplainingScore::create([
|
||||||
|
'total_score_id' => $total_score->id,
|
||||||
|
'content_id' => $request->content_id,
|
||||||
|
'user_id' => $request->user_id,
|
||||||
|
'question_id' => $request->question_id,
|
||||||
|
'konteks_penjelasan' => $nilai[0],
|
||||||
|
'is_accepted' => false,
|
||||||
|
'essay_question_id' => $request->essay_id[0],
|
||||||
|
'user_answer_id' => $konteksAnswer->id
|
||||||
|
]);
|
||||||
|
|
||||||
|
$runtutAnswer = UserAnswer::where('user_id', $request->user_id)->where('essay_question_id', $request->essay_id[1])->first();
|
||||||
|
$explainRuntut = ExplainingScore::create([
|
||||||
|
'total_score_id' => $total_score->id,
|
||||||
|
'content_id' => $request->content_id,
|
||||||
|
'user_id' => $request->user_id,
|
||||||
|
'question_id' => $request->question_id,
|
||||||
|
'keruntutan' => $nilai[1],
|
||||||
|
'is_accepted' => false,
|
||||||
|
'essay_question_id' => $request->essay_id[1],
|
||||||
|
'user_answer_id' => $runtutAnswer->id
|
||||||
|
|
||||||
|
]);
|
||||||
|
|
||||||
|
$benarAnswer = UserAnswer::where('user_id', $request->user_id)->where('essay_question_id', $request->essay_id[2])->first();
|
||||||
|
$explainBenar = ExplainingScore::create([
|
||||||
|
'total_score_id' => $total_score->id,
|
||||||
|
'content_id' => $request->content_id,
|
||||||
|
'user_id' => $request->user_id,
|
||||||
|
'question_id' => $request->question_id,
|
||||||
|
'kebenaran' => $nilai[2],
|
||||||
|
'is_accepted' => false,
|
||||||
|
'essay_question_id' => $request->essay_id[2],
|
||||||
|
'user_answer_id' => $benarAnswer->id
|
||||||
|
]);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$check_total = $check_explain->first()->total->id;
|
||||||
|
|
||||||
|
$check_explain = ExplainingScore::where('content_id', $request->content_id)->where('question_id', $request->question_id)->where('user_id', $request->user_id);
|
||||||
|
|
||||||
|
$total_score = TotalScore::firstwhere('id', $check_total);
|
||||||
|
$total_score->score = $tot_score;
|
||||||
|
$total_score->save();
|
||||||
|
|
||||||
|
$konteks = ExplainingScore::firstwhere('id', $check_explain->get()[0]->id);
|
||||||
|
$konteks->konteks_penjelasan = $nilai[0];
|
||||||
|
$konteks->save();
|
||||||
|
|
||||||
|
$runtut = ExplainingScore::firstwhere('id', $check_explain->get()[1]->id);
|
||||||
|
$runtut->keruntutan = $nilai[1];
|
||||||
|
$runtut->save();
|
||||||
|
|
||||||
|
$benar = ExplainingScore::firstwhere('id', $check_explain->get()[2]->id);
|
||||||
|
$benar->kebenaran = $nilai[2];
|
||||||
|
$benar->save();
|
||||||
|
}
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => '200',
|
||||||
|
'message' => 'Success add user score',
|
||||||
|
'data' => $data
|
||||||
|
], 200);
|
||||||
|
} else {
|
||||||
|
return response()->json([
|
||||||
|
'status' => '500',
|
||||||
|
'message' => 'Error add user',
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
} catch (Exception $err) {
|
||||||
|
DB::rollBack();
|
||||||
|
return response()->json([
|
||||||
|
'status' => '500',
|
||||||
|
'message' => 'Error add score',
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function convertNilai($value)
|
||||||
|
{
|
||||||
|
if ($value > 0 && $value <= 0.2) {
|
||||||
|
return 3;
|
||||||
|
} else if ($value > 0.2 && $value <= 0.4) {
|
||||||
|
return 5;
|
||||||
|
} else if ($value > 0.4 && $value <= 0.6) {
|
||||||
|
return 10;
|
||||||
|
} else if ($value > 0.6 && $value <= 0.8) {
|
||||||
|
return 15;
|
||||||
|
} else if ($value > 0.8 && $value <= 1.0) {
|
||||||
|
return 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
Penilaian-Esai/app/Http/Controllers/Controller.php
Normal file
13
Penilaian-Esai/app/Http/Controllers/Controller.php
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
|
||||||
|
class Controller extends BaseController
|
||||||
|
{
|
||||||
|
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||||
|
}
|
||||||
16
Penilaian-Esai/app/Http/Controllers/CourseController.php
Normal file
16
Penilaian-Esai/app/Http/Controllers/CourseController.php
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class CourseController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware("auth");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\ErrorCodeLog;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ErrorCodeLogController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
|
||||||
|
public function create(Request $request)
|
||||||
|
{
|
||||||
|
$user_id = $request->get("user_id");
|
||||||
|
$question = $request->get("question_id");
|
||||||
|
$err = $request->get("error_message");
|
||||||
|
|
||||||
|
$model = ErrorCodeLog::create([
|
||||||
|
"user_id" => $user_id,
|
||||||
|
"question_id" => $question,
|
||||||
|
"error_message" => $err,
|
||||||
|
"total_count" => 1
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response($model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
use App\Models\ExerciseCodeLog;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ExerciseCodeLogController extends Controller
|
||||||
|
{
|
||||||
|
public function create(Request $request)
|
||||||
|
{
|
||||||
|
$user_id = $request->get("user_id");
|
||||||
|
$question = $request->get("question_id");
|
||||||
|
$message = $request->get("message_content");
|
||||||
|
$is_error = $request->get("is_error");
|
||||||
|
|
||||||
|
$model = ExerciseCodeLog::create([
|
||||||
|
"user_id" => $user_id,
|
||||||
|
"question_id" => $question,
|
||||||
|
"message" => $message,
|
||||||
|
"total_count" => 1,
|
||||||
|
"is_error" => $is_error
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response($model);
|
||||||
|
}
|
||||||
|
}
|
||||||
137
Penilaian-Esai/app/Http/Controllers/ExplainingController.php
Normal file
137
Penilaian-Esai/app/Http/Controllers/ExplainingController.php
Normal file
|
|
@ -0,0 +1,137 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\Explains;
|
||||||
|
use App\Models\UserAnswer;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Yajra\DataTables\Facades\DataTables;
|
||||||
|
|
||||||
|
class ExplainingController extends Controller
|
||||||
|
{
|
||||||
|
public function show(){
|
||||||
|
$explain = Explains::where('code', 0)->get();
|
||||||
|
$title = "summary";
|
||||||
|
$ownership = Explains::where('user_id', Auth::id());
|
||||||
|
return view('student_courses.explain', compact('explain', 'title'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showCode(){
|
||||||
|
$explain = UserAnswer::where('user_id', Auth::id())->paginate(10);
|
||||||
|
$title = "code";
|
||||||
|
return view('student_courses.explain', compact('explain', 'title'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(Request $request, $level_id){
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
try{
|
||||||
|
$explain = Explains::create([
|
||||||
|
'description' => $request->explanation,
|
||||||
|
'level_id' => $level_id,
|
||||||
|
'user_id' => Auth::user()->id
|
||||||
|
]);
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => '200',
|
||||||
|
'message' => 'Success add explaination',
|
||||||
|
'data' => $explain
|
||||||
|
],200);
|
||||||
|
}catch(Exception $err){
|
||||||
|
DB::rollBack();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => '500',
|
||||||
|
'error' => $err->getMessage(),
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id){
|
||||||
|
$explain = Explains::find($id);
|
||||||
|
$title = 1;
|
||||||
|
return view('student_courses.explain_edit', compact('explain','title'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function editCode($id){
|
||||||
|
$explain = Explains::find($id);
|
||||||
|
$title = 2;
|
||||||
|
return view('student_courses.explain_edit', compact('explain','title'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function editEssay($id){
|
||||||
|
$user_answer = UserAnswer::find($id);
|
||||||
|
return view('student_courses.essay_edit', compact('user_answer'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateEssay(Request $request, $id){
|
||||||
|
$user_answer= UserAnswer::find($id);
|
||||||
|
$user_answer->answer = $request->answer;
|
||||||
|
$user_answer->save();
|
||||||
|
|
||||||
|
return redirect(route('student_course.show.explain.code'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request ,$id, $title){
|
||||||
|
$explain = Explains::find($id);
|
||||||
|
$explain->description = $request->description;
|
||||||
|
$explain->edited_admin = 0;
|
||||||
|
$explain->save();
|
||||||
|
|
||||||
|
if($title == 1){
|
||||||
|
return redirect(route('student_course.show.explain'));
|
||||||
|
} else{
|
||||||
|
return redirect(route('student_course.show.explain.code'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tableExplain(){
|
||||||
|
$explain = Explains::all();
|
||||||
|
if (request()->ajax()) {
|
||||||
|
return Datatables::of($explain)
|
||||||
|
->addIndexColumn()
|
||||||
|
->addColumn('name', function ($explain) {
|
||||||
|
$image =
|
||||||
|
'
|
||||||
|
<div class="col-auto p-0">
|
||||||
|
<div class="text-left"> ' . $explain->users->name . ' </div>
|
||||||
|
</div>';
|
||||||
|
|
||||||
|
return $image;
|
||||||
|
})
|
||||||
|
->addColumn('level', function ($explain) {
|
||||||
|
$image =
|
||||||
|
'
|
||||||
|
<div class="col-auto p-0">
|
||||||
|
<div class="text-left"> ' . $explain->level->name . ' </div>
|
||||||
|
</div>';
|
||||||
|
|
||||||
|
return $image;
|
||||||
|
})
|
||||||
|
->addColumn('action', function ($ekspedisi) {
|
||||||
|
// if($explain->users->id == Auth::id()){
|
||||||
|
$button =
|
||||||
|
'
|
||||||
|
<div class="col-auto">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-auto p-1">edit-ekspedisi
|
||||||
|
<a type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-explain' . $explain->id . '" style="width: 30px; height:30px; padding:20%">
|
||||||
|
<span style="font-size: 15px; color:white;" class="iconify" data-icon="bxs:pencil"></span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
return $button;
|
||||||
|
// }
|
||||||
|
})
|
||||||
|
->rawColumns(['action', 'name','level'])
|
||||||
|
->make(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
35
Penilaian-Esai/app/Http/Controllers/HomeController.php
Normal file
35
Penilaian-Esai/app/Http/Controllers/HomeController.php
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Course;
|
||||||
|
use App\Models\StudentCourse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class HomeController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the application dashboard.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\Support\Renderable
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$courses = Course::all();
|
||||||
|
$takeCourseIds = StudentCourse::where(["user_id" => Auth::user()->id])->pluck("course_id")->toArray();
|
||||||
|
|
||||||
|
return view('home', ['courses' => $courses, "take_ids" => $takeCourseIds]);
|
||||||
|
}
|
||||||
|
}
|
||||||
267
Penilaian-Esai/app/Http/Controllers/StudentCourseController.php
Normal file
267
Penilaian-Esai/app/Http/Controllers/StudentCourseController.php
Normal file
|
|
@ -0,0 +1,267 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\BadgeSetting;
|
||||||
|
use App\Models\Content;
|
||||||
|
use App\Models\Course;
|
||||||
|
use App\Models\EssayQuestion;
|
||||||
|
use App\Models\Question;
|
||||||
|
use App\Models\StudentCourse;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Level;
|
||||||
|
use App\Models\Lesson;
|
||||||
|
use App\Models\UserScore;
|
||||||
|
use App\Models\WonderingScore;
|
||||||
|
use App\Models\ExplainingScore;
|
||||||
|
use App\Models\TotalScore;
|
||||||
|
use App\Models\Explains;
|
||||||
|
use App\Models\ExerciseCodeLog;
|
||||||
|
use App\Models\UserAnswer;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use stdClass;
|
||||||
|
|
||||||
|
class StudentCourseController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
|
||||||
|
function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
if (Auth::check()) {
|
||||||
|
$user_id = Auth::user()->id;
|
||||||
|
$student_courses = Course::select(["courses.id", "courses.course_name", "courses.description"])
|
||||||
|
->join("student_courses", "courses.id", "=", "student_courses.course_id")
|
||||||
|
->where("student_courses.user_id", $user_id)->get();
|
||||||
|
return view("student_courses.index", ["studentCourses" => $student_courses]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function detail($course_id)
|
||||||
|
{
|
||||||
|
$course = Course::find($course_id);
|
||||||
|
$total_score = UserScore::where("user_id", Auth::id())->sum("score");
|
||||||
|
$current_badge = BadgeSetting::all();
|
||||||
|
$fullbadge = BadgeSetting::all();
|
||||||
|
$getBadge = "(SELECT badge_settings.name FROM badge_settings WHERE badge_settings.min <= 'total_score' and badge_settings.max >= 'total_score' LIMIT 1)";
|
||||||
|
|
||||||
|
$getBadgeFile = "(SELECT badge_settings.file FROM badge_settings WHERE badge_settings.min <= 'total_score' and badge_settings.max >= 'total_score' LIMIT 1)";
|
||||||
|
$leader_board = UserScore::select(DB::raw("user_id, SUM(score) as total_score, $getBadge as badge_name, $getBadgeFile as file"))->groupBy("user_id")->orderBy("total_score", "DESC")->get();
|
||||||
|
|
||||||
|
$question = Question::where("is_essay", "1")->pluck("id");
|
||||||
|
|
||||||
|
$lboard = [];
|
||||||
|
foreach ($leader_board as $key => $lead) {
|
||||||
|
$answeredQues = UserScore::where("user_id", $lead->user_id)->whereIn("question_id", $question)->count();
|
||||||
|
$percentage = number_format((float)$answeredQues / $question->count() * 100, 1, '.', '');
|
||||||
|
|
||||||
|
$badge = BadgeSetting::where("min", "<=", $lead->total_score)->where("max", ">=", $lead->total_score)->first();
|
||||||
|
|
||||||
|
$lboard[$key]['user'] = User::find($lead->user_id)->name;
|
||||||
|
$lboard[$key]['total_score'] = $lead->total_score;
|
||||||
|
$lboard[$key]['percentage'] = $percentage;
|
||||||
|
$lboard[$key]['badge_name'] = $badge->name;
|
||||||
|
$lboard[$key]['file'] = $badge->file;
|
||||||
|
$lboard[$key]['answered_question'] = $answeredQues;
|
||||||
|
$lboard[$key]['code_questions'] = $question->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
return view("student_courses.detail", [
|
||||||
|
"course" => $course,
|
||||||
|
"total_score" => $total_score,
|
||||||
|
"current_badge" => $current_badge,
|
||||||
|
"leader_board" => $lboard
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
public function takeCourse(Request $request)
|
||||||
|
{
|
||||||
|
if (Auth::check()) {
|
||||||
|
$user_id = Auth::user()->id;
|
||||||
|
$check_course = StudentCourse::where(["user_id" => $user_id, "course_id" => $request["course_id"]]);
|
||||||
|
if ($check_course->count() == 0) {
|
||||||
|
$student_course = StudentCourse::create(["user_id" => $user_id, "course_id" => $request["course_id"]]);
|
||||||
|
if ($student_course->save()) {
|
||||||
|
session()->flash('msg_error1', 'You take it success');
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
session()->flash('msg_error', 'You already take it');
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function my_course($course_id , $level_id, $content_id = null)
|
||||||
|
{
|
||||||
|
if($content_id == 1){
|
||||||
|
$check = WonderingScore::where('user_id', Auth::id())->where('content_id', $content_id);
|
||||||
|
if($check->count()==0){
|
||||||
|
WonderingScore::create([
|
||||||
|
'user_id'=>Auth::id(),
|
||||||
|
'content_id' => $content_id,
|
||||||
|
'score'=>10,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$course = Course::find($course_id);
|
||||||
|
$level = Level::find($level_id);
|
||||||
|
$contents = $content_id != null ? Content::find($content_id) : $level->lessons[0]->contents->first();
|
||||||
|
// $user_score = UserScore::where(["content_id" => $content_id == null ? $contents->id : $content_id, "user_id" => Auth::id()])->first();
|
||||||
|
$user_score = TotalScore::where(["content_id" => $content_id == null ? $contents->id : $content_id, "user_id" => Auth::id()])->first();
|
||||||
|
|
||||||
|
$wondering = WonderingScore::where(["user_id" => Auth::id()])->sum("score");
|
||||||
|
$exploring = UserScore::where("user_id", Auth::id())->sum("score");
|
||||||
|
$explainKonteks = ExplainingScore::where("user_id",Auth::id())->sum("konteks_penjelasan");
|
||||||
|
$explainBenar = ExplainingScore::where("user_id", Auth::id())->sum("kebenaran");
|
||||||
|
$explainKeruntutan = ExplainingScore::where("user_id", Auth::id())->sum("keruntutan");
|
||||||
|
$final_score = $wondering + $exploring + $explainKonteks + $explainBenar + $explainKeruntutan;
|
||||||
|
$current_badge = BadgeSetting::where("min", "<=", $final_score)->where("max", ">=", $final_score)->first();
|
||||||
|
|
||||||
|
$active_lesson = $content_id != null ? Content::find($content_id)->lesson : $level->lessons->first();
|
||||||
|
$questions = Question::where(["is_essay" => "0", "content_id" => $content_id])->get();
|
||||||
|
$code_test = Question::where(["is_essay" => "1", "content_id" => $content_id])->get();
|
||||||
|
$take = UserScore::where("user_id", Auth::id())->pluck("question_id")->toArray();
|
||||||
|
|
||||||
|
$check_read = WonderingScore::where(["user_id" => Auth::id()])->where('content_id', $content_id)->count();
|
||||||
|
|
||||||
|
$is_last = 0;
|
||||||
|
$check_explain = 0;
|
||||||
|
if($content_id != null){
|
||||||
|
$last_lesson = Lesson::where('level_id', $level_id)->orderBy('posisition', 'Desc')->first();
|
||||||
|
$content = Content::where('lesson_id', $last_lesson->id)->pluck('id')->toArray();
|
||||||
|
$last_question = Question::whereIn('content_id', $content)->pluck('id')->toArray();
|
||||||
|
|
||||||
|
$last_content = max($content);
|
||||||
|
$history_question = UserScore::where('user_id', Auth::id())->whereIn('content_id', $content)->pluck('question_id')->toArray();
|
||||||
|
$check_explain = Explains::where("user_id", Auth::id())->where('level_id', $level_id)->where('code', 0)->count();
|
||||||
|
$check_question = array_diff($last_question, $history_question);
|
||||||
|
if(empty($check_question) && $last_content == $content_id){
|
||||||
|
$is_last = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// $tanya = Question::where('content_id', 7)->pluck('id')->toArray();
|
||||||
|
|
||||||
|
// $check = UserScore::where('user_id', Auth::user()->id)->where('content_id', 7)->orderBy('question_id', 'asc')->pluck('question_id')->toArray();
|
||||||
|
// $different = array_diff($tanya, $check);
|
||||||
|
// if(empty($different)){
|
||||||
|
// $pass = 1;
|
||||||
|
// } else{
|
||||||
|
// $pass =0;
|
||||||
|
// }
|
||||||
|
// dd([$tanya, $check, $pass]);
|
||||||
|
//active_lesson untuk melihat course yang dibuka saat ini
|
||||||
|
return view("student_courses.my_course", [
|
||||||
|
"level" => $level,
|
||||||
|
"course" => $course,
|
||||||
|
"content" => $contents,
|
||||||
|
"score" => $user_score,
|
||||||
|
"final_score" => $final_score,
|
||||||
|
"active_lesson" => $active_lesson,
|
||||||
|
"active_content" => $contents,
|
||||||
|
"current_badge" => $current_badge,
|
||||||
|
"questions" => $questions,
|
||||||
|
"code_tests" => $code_test,
|
||||||
|
"percentage" => UserScore::getPercentage(),
|
||||||
|
"finish_code_tests" => $take,
|
||||||
|
"is_last" => $is_last,
|
||||||
|
"check_explain" => $check_explain,
|
||||||
|
"check_read" => $check_read
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function report()
|
||||||
|
{
|
||||||
|
$user_score = UserScore::where(["user_id" => Auth::id()])->get();
|
||||||
|
$take = UserScore::where("user_id", Auth::id())->pluck("question_id")->toArray();
|
||||||
|
$code_test_score = UserScore::where(["user_id" => Auth::id()])->whereNotNull("question_id")->get();
|
||||||
|
$wondering = WonderingScore::where(["user_id" => Auth::id()])->sum("score");
|
||||||
|
$exploring = UserScore::where("user_id", Auth::id())->sum("score");
|
||||||
|
$explainKonteks = ExplainingScore::where("user_id",Auth::id())->sum("konteks_penjelasan");
|
||||||
|
$explainBenar = ExplainingScore::where("user_id", Auth::id())->sum("kebenaran");
|
||||||
|
$explainKeruntutan = ExplainingScore::where("user_id", Auth::id())->sum("keruntutan");
|
||||||
|
$final_score = $wondering + $exploring + $explainKonteks + $explainBenar + $explainKeruntutan;
|
||||||
|
$current_badge = BadgeSetting::where("min", "<=", $final_score)->where("max", ">=", $final_score)->first();
|
||||||
|
|
||||||
|
// $his_error = ExerciseCodeLog::where()
|
||||||
|
// $his_success = ExerciseCodeLog::where
|
||||||
|
|
||||||
|
return view("student_courses.report", [
|
||||||
|
"score" => $user_score,
|
||||||
|
"final_score" => $final_score,
|
||||||
|
"current_badge" => $current_badge,
|
||||||
|
"percentage" => UserScore::getPercentage(),
|
||||||
|
"finish_code_tests" => $take,
|
||||||
|
"code_score" => $code_test_score,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function detailReport($question_id){
|
||||||
|
$user_id = Auth::id();
|
||||||
|
$question = Question::find($question_id);
|
||||||
|
// $score = UserScore::where("user_id", Auth::id())->where("question_id", $question_id)->first();
|
||||||
|
$score = TotalScore::where("user_id", Auth::id())->where("question_id", $question_id)->first();
|
||||||
|
$wondering = WonderingScore::where(["user_id" => Auth::id()])->sum("score");
|
||||||
|
$exploring = UserScore::where("user_id", Auth::id())->sum("score");
|
||||||
|
$explainKonteks = ExplainingScore::where("user_id",Auth::id())->sum("konteks_penjelasan");
|
||||||
|
$explainBenar = ExplainingScore::where("user_id", Auth::id())->sum("kebenaran");
|
||||||
|
$explainKeruntutan = ExplainingScore::where("user_id", Auth::id())->sum("keruntutan");
|
||||||
|
$final_score = $wondering + $exploring + $explainKonteks + $explainBenar + $explainKeruntutan;
|
||||||
|
$exercise_logs = ExerciseCodeLog::where("user_id", Auth::id())->where("question_id", $question_id)->orderBy('id','DESC')->get();
|
||||||
|
|
||||||
|
$essay = EssayQuestion::where('question_id', $question_id)->pluck('id');
|
||||||
|
$explain = UserAnswer::whereIn('essay_question_id', $essay)->where('user_id', $user_id)->get();
|
||||||
|
$title = "code";
|
||||||
|
|
||||||
|
return view("student_courses.detail_report", compact('exercise_logs', 'score', 'question', 'explain', 'title', 'final_score'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function level($course_id){
|
||||||
|
$level = Level::where('course_id', $course_id)->get();
|
||||||
|
$l = Level::firstwhere('id',2);
|
||||||
|
//isi level 1
|
||||||
|
$level_down = $l->id - 1;
|
||||||
|
$lessons1 = Lesson::where('level_id', $level_down)->pluck('id');
|
||||||
|
$content1 = Content::whereIn('lesson_id', $lessons1)->pluck('id');
|
||||||
|
$question1 = Question::whereIn('content_id', $content1)->pluck('id')->toArray();
|
||||||
|
|
||||||
|
|
||||||
|
$check = UserScore::where('user_id', Auth::user()->id)->where('level_id', $level_down)->orderBy('question_id', 'asc')->pluck('question_id')->toArray();
|
||||||
|
|
||||||
|
return view("student_courses.level", compact('level', 'course_id'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function readScore(Request $request){
|
||||||
|
try{
|
||||||
|
|
||||||
|
$content_id = $request->input('content_id');
|
||||||
|
$check = WonderingScore::where('user_id', Auth::id())->where('content_id', $content_id);
|
||||||
|
if($check->count() == 0){
|
||||||
|
WonderingScore::create([
|
||||||
|
'user_id' => Auth::id(),
|
||||||
|
'content_id' => $content_id,
|
||||||
|
'score' => 10,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => '200',
|
||||||
|
'message' => 'Success add score',
|
||||||
|
],200);
|
||||||
|
|
||||||
|
} catch(Exception $err){
|
||||||
|
return response()->json([
|
||||||
|
'status' => '500',
|
||||||
|
'message' => 'Error add score',
|
||||||
|
],500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
72
Penilaian-Esai/app/Http/Kernel.php
Normal file
72
Penilaian-Esai/app/Http/Kernel.php
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||||
|
|
||||||
|
class Kernel extends HttpKernel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The application's global HTTP middleware stack.
|
||||||
|
*
|
||||||
|
* These middleware are run during every request to your application.
|
||||||
|
*
|
||||||
|
* @var array<int, class-string|string>
|
||||||
|
*/
|
||||||
|
protected $middleware = [
|
||||||
|
// \App\Http\Middleware\TrustHosts::class,
|
||||||
|
\App\Http\Middleware\TrustProxies::class,
|
||||||
|
\Illuminate\Http\Middleware\HandleCors::class,
|
||||||
|
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||||
|
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||||
|
\App\Http\Middleware\TrimStrings::class,
|
||||||
|
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application's route middleware groups.
|
||||||
|
*
|
||||||
|
* @var array<string, array<int, class-string|string>>
|
||||||
|
*/
|
||||||
|
protected $middlewareGroups = [
|
||||||
|
'web' => [
|
||||||
|
\App\Http\Middleware\EncryptCookies::class,
|
||||||
|
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||||
|
\Illuminate\Session\Middleware\StartSession::class,
|
||||||
|
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||||
|
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||||
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
'api' => [
|
||||||
|
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||||
|
'throttle:api',
|
||||||
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application's route middleware.
|
||||||
|
*
|
||||||
|
* These middleware may be assigned to groups or used individually.
|
||||||
|
*
|
||||||
|
* @var array<string, class-string|string>
|
||||||
|
*/
|
||||||
|
protected $routeMiddleware = [
|
||||||
|
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||||
|
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||||
|
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||||
|
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||||
|
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||||
|
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||||
|
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||||
|
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||||
|
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||||
|
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||||
|
"admin" => \App\Http\Middleware\IsAdmin::class,
|
||||||
|
'jwt.verify' => \App\Http\Middleware\JwtMiddleware::class,
|
||||||
|
'jwt.auth' => Tymon\JWTAuth\Middleware\GetUserFromToken::class,
|
||||||
|
'jwt.refresh' => Tymon\JWTAuth\Middleware\RefreshToken::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
21
Penilaian-Esai/app/Http/Middleware/Authenticate.php
Normal file
21
Penilaian-Esai/app/Http/Middleware/Authenticate.php
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||||
|
|
||||||
|
class Authenticate extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the path the user should be redirected to when they are not authenticated.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
protected function redirectTo($request)
|
||||||
|
{
|
||||||
|
if (! $request->expectsJson()) {
|
||||||
|
return route('login');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
Penilaian-Esai/app/Http/Middleware/EncryptCookies.php
Normal file
17
Penilaian-Esai/app/Http/Middleware/EncryptCookies.php
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||||
|
|
||||||
|
class EncryptCookies extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The names of the cookies that should not be encrypted.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
25
Penilaian-Esai/app/Http/Middleware/IsAdmin.php
Normal file
25
Penilaian-Esai/app/Http/Middleware/IsAdmin.php
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class IsAdmin
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||||
|
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next)
|
||||||
|
{
|
||||||
|
if(Auth::user() && Auth::user()->role_id == 1) {
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
return redirect('/')->with('error','You have not admin access');
|
||||||
|
}
|
||||||
|
}
|
||||||
35
Penilaian-Esai/app/Http/Middleware/JwtMiddleware.php
Normal file
35
Penilaian-Esai/app/Http/Middleware/JwtMiddleware.php
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use JWTAuth;
|
||||||
|
use Exception;
|
||||||
|
use Tymon\JWTAuth\Http\Middleware\BaseMiddleware;
|
||||||
|
|
||||||
|
class JwtMiddleware extends BaseMiddleware
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle($request, Closure $next)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = JWTAuth::parseToken()->authenticate();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException){
|
||||||
|
return response()->json(['status' => 'Token is Invalid']);
|
||||||
|
}else if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenExpiredException){
|
||||||
|
return response()->json(['status' => 'Token is Expired']);
|
||||||
|
}else{
|
||||||
|
return response()->json(['status' => 'Authorization Token not found']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||||
|
|
||||||
|
class PreventRequestsDuringMaintenance extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The URIs that should be reachable while maintenance mode is enabled.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class RedirectIfAuthenticated
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||||
|
* @param string|null ...$guards
|
||||||
|
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next, ...$guards)
|
||||||
|
{
|
||||||
|
$guards = empty($guards) ? [null] : $guards;
|
||||||
|
|
||||||
|
foreach ($guards as $guard) {
|
||||||
|
if (Auth::guard($guard)->check()) {
|
||||||
|
return redirect(RouteServiceProvider::HOME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
19
Penilaian-Esai/app/Http/Middleware/TrimStrings.php
Normal file
19
Penilaian-Esai/app/Http/Middleware/TrimStrings.php
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||||
|
|
||||||
|
class TrimStrings extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The names of the attributes that should not be trimmed.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
'current_password',
|
||||||
|
'password',
|
||||||
|
'password_confirmation',
|
||||||
|
];
|
||||||
|
}
|
||||||
20
Penilaian-Esai/app/Http/Middleware/TrustHosts.php
Normal file
20
Penilaian-Esai/app/Http/Middleware/TrustHosts.php
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||||
|
|
||||||
|
class TrustHosts extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the host patterns that should be trusted.
|
||||||
|
*
|
||||||
|
* @return array<int, string|null>
|
||||||
|
*/
|
||||||
|
public function hosts()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$this->allSubdomainsOfApplicationUrl(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
28
Penilaian-Esai/app/Http/Middleware/TrustProxies.php
Normal file
28
Penilaian-Esai/app/Http/Middleware/TrustProxies.php
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class TrustProxies extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The trusted proxies for this application.
|
||||||
|
*
|
||||||
|
* @var array<int, string>|string|null
|
||||||
|
*/
|
||||||
|
protected $proxies;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The headers that should be used to detect proxies.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $headers =
|
||||||
|
Request::HEADER_X_FORWARDED_FOR |
|
||||||
|
Request::HEADER_X_FORWARDED_HOST |
|
||||||
|
Request::HEADER_X_FORWARDED_PORT |
|
||||||
|
Request::HEADER_X_FORWARDED_PROTO |
|
||||||
|
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||||
|
}
|
||||||
17
Penilaian-Esai/app/Http/Middleware/VerifyCsrfToken.php
Normal file
17
Penilaian-Esai/app/Http/Middleware/VerifyCsrfToken.php
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||||
|
|
||||||
|
class VerifyCsrfToken extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The URIs that should be excluded from CSRF verification.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\API;
|
||||||
|
|
||||||
|
use App\Models\BadgeSetting;
|
||||||
|
use InfyOm\Generator\Request\APIRequest;
|
||||||
|
|
||||||
|
class CreateBadgeSettingAPIRequest extends APIRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return BadgeSetting::$rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\API;
|
||||||
|
|
||||||
|
use App\Models\Content;
|
||||||
|
use InfyOm\Generator\Request\APIRequest;
|
||||||
|
|
||||||
|
class CreateContentAPIRequest extends APIRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return Content::$rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\API;
|
||||||
|
|
||||||
|
use App\Models\Course;
|
||||||
|
use InfyOm\Generator\Request\APIRequest;
|
||||||
|
|
||||||
|
class CreateCourseAPIRequest extends APIRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return Course::$rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\API;
|
||||||
|
|
||||||
|
use App\Models\Lesson;
|
||||||
|
use InfyOm\Generator\Request\APIRequest;
|
||||||
|
|
||||||
|
class CreateLessonAPIRequest extends APIRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return lesson::$rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\API;
|
||||||
|
|
||||||
|
use App\Models\Question;
|
||||||
|
use InfyOm\Generator\Request\APIRequest;
|
||||||
|
|
||||||
|
class CreateQuestionAPIRequest extends APIRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return Question::$rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\API;
|
||||||
|
|
||||||
|
use App\Models\Role;
|
||||||
|
use InfyOm\Generator\Request\APIRequest;
|
||||||
|
|
||||||
|
class CreateRoleAPIRequest extends APIRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return Role::$rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\API;
|
||||||
|
|
||||||
|
use App\Models\BadgeSetting;
|
||||||
|
use InfyOm\Generator\Request\APIRequest;
|
||||||
|
|
||||||
|
class UpdateBadgeSettingAPIRequest extends APIRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = BadgeSetting::$rules;
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\API;
|
||||||
|
|
||||||
|
use App\Models\Content;
|
||||||
|
use InfyOm\Generator\Request\APIRequest;
|
||||||
|
|
||||||
|
class UpdateContentAPIRequest extends APIRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = Content::$rules;
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\API;
|
||||||
|
|
||||||
|
use App\Models\Course;
|
||||||
|
use InfyOm\Generator\Request\APIRequest;
|
||||||
|
|
||||||
|
class UpdateCourseAPIRequest extends APIRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = Course::$rules;
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\API;
|
||||||
|
|
||||||
|
use App\Models\Lesson;
|
||||||
|
use InfyOm\Generator\Request\APIRequest;
|
||||||
|
|
||||||
|
class UpdateLessonAPIRequest extends APIRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = lesson::$rules;
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\API;
|
||||||
|
|
||||||
|
use App\Models\Question;
|
||||||
|
use InfyOm\Generator\Request\APIRequest;
|
||||||
|
|
||||||
|
class UpdateQuestionAPIRequest extends APIRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = Question::$rules;
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\API;
|
||||||
|
|
||||||
|
use App\Models\Role;
|
||||||
|
use InfyOm\Generator\Request\APIRequest;
|
||||||
|
|
||||||
|
class UpdateRoleAPIRequest extends APIRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = Role::$rules;
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use App\Models\BadgeSetting;
|
||||||
|
|
||||||
|
class CreateBadgeSettingRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return BadgeSetting::$rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
29
Penilaian-Esai/app/Http/Requests/CreateContentRequest.php
Normal file
29
Penilaian-Esai/app/Http/Requests/CreateContentRequest.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use App\Models\Content;
|
||||||
|
|
||||||
|
class CreateContentRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return Content::$rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
29
Penilaian-Esai/app/Http/Requests/CreateCourseRequest.php
Normal file
29
Penilaian-Esai/app/Http/Requests/CreateCourseRequest.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use App\Models\Course;
|
||||||
|
|
||||||
|
class CreateCourseRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return Course::$rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
29
Penilaian-Esai/app/Http/Requests/CreateLessonRequest.php
Normal file
29
Penilaian-Esai/app/Http/Requests/CreateLessonRequest.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use App\Models\Lesson;
|
||||||
|
|
||||||
|
class CreateLessonRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return Lesson::$rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
29
Penilaian-Esai/app/Http/Requests/CreateQuestionRequest.php
Normal file
29
Penilaian-Esai/app/Http/Requests/CreateQuestionRequest.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use App\Models\Question;
|
||||||
|
|
||||||
|
class CreateQuestionRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return Question::$rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
29
Penilaian-Esai/app/Http/Requests/CreateRoleRequest.php
Normal file
29
Penilaian-Esai/app/Http/Requests/CreateRoleRequest.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use App\Models\Role;
|
||||||
|
|
||||||
|
class CreateRoleRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return Role::$rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use App\Models\BadgeSetting;
|
||||||
|
|
||||||
|
class UpdateBadgeSettingRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = BadgeSetting::$rules;
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
31
Penilaian-Esai/app/Http/Requests/UpdateContentRequest.php
Normal file
31
Penilaian-Esai/app/Http/Requests/UpdateContentRequest.php
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use App\Models\Content;
|
||||||
|
|
||||||
|
class UpdateContentRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = Content::$rules;
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
31
Penilaian-Esai/app/Http/Requests/UpdateCourseRequest.php
Normal file
31
Penilaian-Esai/app/Http/Requests/UpdateCourseRequest.php
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use App\Models\Course;
|
||||||
|
|
||||||
|
class UpdateCourseRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = Course::$rules;
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
31
Penilaian-Esai/app/Http/Requests/UpdateLessonRequest.php
Normal file
31
Penilaian-Esai/app/Http/Requests/UpdateLessonRequest.php
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use App\Models\Lesson;
|
||||||
|
|
||||||
|
class UpdateLessonRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = lesson::$rules;
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
31
Penilaian-Esai/app/Http/Requests/UpdateQuestionRequest.php
Normal file
31
Penilaian-Esai/app/Http/Requests/UpdateQuestionRequest.php
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use App\Models\Question;
|
||||||
|
|
||||||
|
class UpdateQuestionRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = Question::$rules;
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
31
Penilaian-Esai/app/Http/Requests/UpdateRoleRequest.php
Normal file
31
Penilaian-Esai/app/Http/Requests/UpdateRoleRequest.php
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use App\Models\Role;
|
||||||
|
|
||||||
|
class UpdateRoleRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = Role::$rules;
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
17
Penilaian-Esai/app/Models/Answer.php
Normal file
17
Penilaian-Esai/app/Models/Answer.php
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Answer extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $table = "answers";
|
||||||
|
protected $fillable = ["answer", "is_right", "question_id"];
|
||||||
|
|
||||||
|
public function question(){
|
||||||
|
return $this->belongsTo(Question::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
57
Penilaian-Esai/app/Models/BadgeSetting.php
Normal file
57
Penilaian-Esai/app/Models/BadgeSetting.php
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Eloquent as Model;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class BadgeSetting
|
||||||
|
* @package App\Models
|
||||||
|
* @version May 31, 2022, 3:11 pm UTC
|
||||||
|
*
|
||||||
|
* @property string $name
|
||||||
|
* @property integer $min
|
||||||
|
* @property integer $max
|
||||||
|
*/
|
||||||
|
class BadgeSetting extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public $table = 'badge_settings';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public $fillable = [
|
||||||
|
'name',
|
||||||
|
'file',
|
||||||
|
'min',
|
||||||
|
'max'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be casted to native types.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'id' => 'integer',
|
||||||
|
'name' => 'string',
|
||||||
|
'file' => 'string',
|
||||||
|
'min' => 'integer',
|
||||||
|
'max' => 'integer'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validation rules
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $rules = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
82
Penilaian-Esai/app/Models/Content.php
Normal file
82
Penilaian-Esai/app/Models/Content.php
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Eloquent as Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Content
|
||||||
|
* @package App\Models
|
||||||
|
* @version May 30, 2022, 2:15 pm UTC
|
||||||
|
*
|
||||||
|
* @property \App\Models\lesson $lesson
|
||||||
|
* @property string $title
|
||||||
|
* @property integer $lesson_id
|
||||||
|
* @property string $description
|
||||||
|
* @property string $url_video
|
||||||
|
* @property integer $published
|
||||||
|
*/
|
||||||
|
class Content extends Model
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
|
||||||
|
public $table = 'contents';
|
||||||
|
|
||||||
|
|
||||||
|
protected $dates = ['deleted_at'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public $fillable = [
|
||||||
|
'title',
|
||||||
|
'lesson_id',
|
||||||
|
'description',
|
||||||
|
'url_video',
|
||||||
|
'published'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be casted to native types.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'id' => 'integer',
|
||||||
|
'title' => 'string',
|
||||||
|
'lesson_id' => 'integer',
|
||||||
|
'description' => 'string',
|
||||||
|
'url_video' => 'string',
|
||||||
|
'published' => 'integer'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validation rules
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $rules = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
|
**/
|
||||||
|
public function lesson()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\Lesson::class, 'lesson_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function questions()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Question::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function wondering(){
|
||||||
|
return $this->hasMany(WonderingScore::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function explainingscore(){
|
||||||
|
return $this->hasMany(ExplainingScore::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
70
Penilaian-Esai/app/Models/Course.php
Normal file
70
Penilaian-Esai/app/Models/Course.php
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Eloquent as Model;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Course
|
||||||
|
* @package App\Models
|
||||||
|
* @version May 30, 2022, 11:55 am UTC
|
||||||
|
*
|
||||||
|
* @property string $course_name
|
||||||
|
* @property string $description
|
||||||
|
* @property string $image
|
||||||
|
* @property integer $published
|
||||||
|
*/
|
||||||
|
class Course extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public $table = 'courses';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public $fillable = [
|
||||||
|
'course_name',
|
||||||
|
'description',
|
||||||
|
'image',
|
||||||
|
'published'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be casted to native types.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'id' => 'integer',
|
||||||
|
'course_name' => 'string',
|
||||||
|
'description' => 'string',
|
||||||
|
'image' => 'string',
|
||||||
|
'published' => 'integer'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validation rules
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $rules = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
public function lessons(){
|
||||||
|
return $this->hasMany(Lesson::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function student_courses(){
|
||||||
|
return $this->hasMany(StudentCourse::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function level(){
|
||||||
|
return $this->hasMany(Level::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
18
Penilaian-Esai/app/Models/ErrorCodeLog.php
Normal file
18
Penilaian-Esai/app/Models/ErrorCodeLog.php
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ErrorCodeLog extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $table = "code_error_logs";
|
||||||
|
protected $fillable = ["user_id", "question_id", "error_message", "total_count"];
|
||||||
|
|
||||||
|
public function question()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\Question::class, 'question_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
42
Penilaian-Esai/app/Models/EssayQuestion.php
Normal file
42
Penilaian-Esai/app/Models/EssayQuestion.php
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class EssayQuestion extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
protected $table = "essay_question";
|
||||||
|
protected $fillable=[
|
||||||
|
'question_id',
|
||||||
|
'user_id',
|
||||||
|
'question',
|
||||||
|
'answer',
|
||||||
|
'answer2',
|
||||||
|
'answer3',
|
||||||
|
'answer4',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function questions()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\Question::class, 'question_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\User::class, 'user_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function userAnswer(){
|
||||||
|
return $this->hasMany(UserAnswer::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function explainingscore(){
|
||||||
|
return $this->hasMany(ExplainingScore::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
25
Penilaian-Esai/app/Models/ExerciseCodeLog.php
Normal file
25
Penilaian-Esai/app/Models/ExerciseCodeLog.php
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ExerciseCodeLog extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $table = "code_history_logs";
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
"user_id",
|
||||||
|
"question_id",
|
||||||
|
"message",
|
||||||
|
"total_count",
|
||||||
|
"is_error"
|
||||||
|
];
|
||||||
|
|
||||||
|
public function question()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\Question::class, 'question_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
50
Penilaian-Esai/app/Models/ExplainingScore.php
Normal file
50
Penilaian-Esai/app/Models/ExplainingScore.php
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ExplainingScore extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $table = "explaining_score";
|
||||||
|
protected $fillable=[
|
||||||
|
'content_id',
|
||||||
|
'user_id',
|
||||||
|
'konteks_penjelasan',
|
||||||
|
'keruntutan',
|
||||||
|
'kebenaran',
|
||||||
|
'is_accepted',
|
||||||
|
'user_answer_id',
|
||||||
|
'essay_question_id',
|
||||||
|
'question_id',
|
||||||
|
'total_score_id'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\User::class, 'user_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function content()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\Content::class, 'content_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function essay()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\EssayQuestion::class, 'essay_question_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function answer()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\UserAnswer::class, 'user_answer_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function total()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\TotalScore::class, 'total_score_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
32
Penilaian-Esai/app/Models/Explains.php
Normal file
32
Penilaian-Esai/app/Models/Explains.php
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Explains extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $table = 'explains';
|
||||||
|
protected $fillable =[
|
||||||
|
'description',
|
||||||
|
'level_id',
|
||||||
|
'user_id',
|
||||||
|
'edited_admin',
|
||||||
|
'code',
|
||||||
|
'question_id'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function level(){
|
||||||
|
return $this->belongsTo(\App\Models\Level::class, 'level_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function users(){
|
||||||
|
return $this->belongsTo(\App\Models\User::class, 'user_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function question(){
|
||||||
|
return $this->belongsTo(\App\Models\Question::class, 'question_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
76
Penilaian-Esai/app/Models/Lesson.php
Normal file
76
Penilaian-Esai/app/Models/Lesson.php
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Eloquent as Model;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class lesson
|
||||||
|
* @package App\Models
|
||||||
|
* @version May 30, 2022, 12:03 pm UTC
|
||||||
|
*
|
||||||
|
* @property \App\Models\Course $course
|
||||||
|
* @property string $title
|
||||||
|
* @property string $description
|
||||||
|
* @property integer $course_id
|
||||||
|
* @property integer $posisition
|
||||||
|
* @property integer $published
|
||||||
|
*/
|
||||||
|
class Lesson extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public $table = 'lessons';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public $fillable = [
|
||||||
|
'title',
|
||||||
|
'description',
|
||||||
|
'course_id',
|
||||||
|
'level_id',
|
||||||
|
'posisition',
|
||||||
|
'published'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be casted to native types.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'id' => 'integer',
|
||||||
|
'title' => 'string',
|
||||||
|
'description' => 'string',
|
||||||
|
'course_id' => 'integer',
|
||||||
|
'posisition' => 'integer',
|
||||||
|
'published' => 'integer',
|
||||||
|
'level_id' => 'integer'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validation rules
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $rules = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
|
**/
|
||||||
|
public function course()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\Course::class, 'course_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function contents(){
|
||||||
|
return $this->hasMany(Content::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function level(){
|
||||||
|
return $this->belongsTo(\App\Models\Level::class, 'level_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
31
Penilaian-Esai/app/Models/Level.php
Normal file
31
Penilaian-Esai/app/Models/Level.php
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class Level extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, SoftDeletes;
|
||||||
|
protected $table = "levels";
|
||||||
|
protected $fillable=[
|
||||||
|
'name',
|
||||||
|
'course_id',
|
||||||
|
'description'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function lessons(){
|
||||||
|
return $this->hasMany(Lesson::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function Explains(){
|
||||||
|
return $this->hasMany(Explains::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function course()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\Course::class, 'course_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
88
Penilaian-Esai/app/Models/Question.php
Normal file
88
Penilaian-Esai/app/Models/Question.php
Normal file
|
|
@ -0,0 +1,88 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Eloquent as Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Question
|
||||||
|
* @package App\Models
|
||||||
|
* @version May 30, 2022, 3:00 pm UTC
|
||||||
|
*
|
||||||
|
* @property \App\Models\Content $content
|
||||||
|
* @property integer $content_id
|
||||||
|
* @property string $question
|
||||||
|
* @property string $image
|
||||||
|
* @property integer $score
|
||||||
|
*/
|
||||||
|
class Question extends Model
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
|
||||||
|
public $table = 'questions';
|
||||||
|
|
||||||
|
|
||||||
|
protected $dates = ['deleted_at'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public $fillable = [
|
||||||
|
'content_id',
|
||||||
|
'question',
|
||||||
|
'question_name',
|
||||||
|
'image',
|
||||||
|
'score',
|
||||||
|
'is_essay',
|
||||||
|
'timer',
|
||||||
|
'hint'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be casted to native types.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'id' => 'integer',
|
||||||
|
'content_id' => 'integer',
|
||||||
|
'question' => 'string',
|
||||||
|
'question_name' => 'string',
|
||||||
|
'image' => 'string',
|
||||||
|
'score' => 'integer',
|
||||||
|
'is_essay' => 'integer'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validation rules
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $rules = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
|
**/
|
||||||
|
public function content()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\Content::class, 'content_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function answers()
|
||||||
|
{
|
||||||
|
return $this->hasMany(\App\Models\Answer::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function explains(){
|
||||||
|
return $this->hasMany(Explains::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function essay(){
|
||||||
|
return $this->hasMany(EssayQuestion::class);
|
||||||
|
}
|
||||||
|
public function total(){
|
||||||
|
return $this->hasMany(TotalScore::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
47
Penilaian-Esai/app/Models/Role.php
Normal file
47
Penilaian-Esai/app/Models/Role.php
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Eloquent as Model;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Role
|
||||||
|
* @package App\Models
|
||||||
|
* @version May 30, 2022, 11:47 am UTC
|
||||||
|
*
|
||||||
|
* @property string $role
|
||||||
|
*/
|
||||||
|
class Role extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public $table = 'roles';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public $fillable = [
|
||||||
|
'role'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be casted to native types.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'id' => 'integer',
|
||||||
|
'role' => 'string'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validation rules
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $rules = [];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
20
Penilaian-Esai/app/Models/StudentCourse.php
Normal file
20
Penilaian-Esai/app/Models/StudentCourse.php
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class StudentCourse extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = "student_courses";
|
||||||
|
protected $fillable = ["user_id", "course_id"];
|
||||||
|
|
||||||
|
public function course(){
|
||||||
|
return $this->hasOne(Course::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
25
Penilaian-Esai/app/Models/TotalScore.php
Normal file
25
Penilaian-Esai/app/Models/TotalScore.php
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class TotalScore extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $table = "total_score";
|
||||||
|
protected $fillable=[
|
||||||
|
'wondering_score_id',
|
||||||
|
'user_score_id',
|
||||||
|
'score',
|
||||||
|
'user_id',
|
||||||
|
'content_id',
|
||||||
|
'question_id'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function question()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\Question::class, 'question_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
84
Penilaian-Esai/app/Models/User.php
Normal file
84
Penilaian-Esai/app/Models/User.php
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Laravel\Sanctum\HasApiTokens;
|
||||||
|
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||||
|
|
||||||
|
class User extends Authenticatable implements JWTSubject
|
||||||
|
{
|
||||||
|
use HasApiTokens, HasFactory, Notifiable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'email',
|
||||||
|
'password',
|
||||||
|
'role_id',
|
||||||
|
'class'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be hidden for serialization.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $hidden = [
|
||||||
|
'password',
|
||||||
|
'remember_token',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be cast.
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'email_verified_at' => 'datetime',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function getJWTIdentifier()
|
||||||
|
{
|
||||||
|
return $this->getKey();
|
||||||
|
}
|
||||||
|
public function getJWTCustomClaims()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function role()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Role::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function roles(){
|
||||||
|
return $this->hasMany(Role::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function Explains(){
|
||||||
|
return $this->hasMany(Explains::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function essay(){
|
||||||
|
return $this->hasMany(EssayQuestion::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function userAnswer(){
|
||||||
|
return $this->hasMany(UserAnswer::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function wondering(){
|
||||||
|
return $this->hasMany(WonderingScore::class);
|
||||||
|
}
|
||||||
|
public function explainingscore(){
|
||||||
|
return $this->hasMany(ExplainingScore::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
34
Penilaian-Esai/app/Models/UserAnswer.php
Normal file
34
Penilaian-Esai/app/Models/UserAnswer.php
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class UserAnswer extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
protected $table = "user_answer";
|
||||||
|
protected $fillable=[
|
||||||
|
'essay_question_id',
|
||||||
|
'user_id',
|
||||||
|
'answer'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function essay()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\EssayQuestion::class, 'essay_question_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\User::class, 'user_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function explainingscore(){
|
||||||
|
return $this->hasMany(ExplainingScore::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
16
Penilaian-Esai/app/Models/UserCodeTestScore.php
Normal file
16
Penilaian-Esai/app/Models/UserCodeTestScore.php
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class UserCodeTestScore extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = "user_code_test_score";
|
||||||
|
protected $fillable = ["question_id", "user_id", "score"];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
39
Penilaian-Esai/app/Models/UserScore.php
Normal file
39
Penilaian-Esai/app/Models/UserScore.php
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class UserScore extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
protected $table = "user_scores";
|
||||||
|
protected $fillable = ["user_id", "content_id", "score", "question_id", "started_at", "ended_at", "on_timer","level_id"];
|
||||||
|
|
||||||
|
public static function getScore()
|
||||||
|
{
|
||||||
|
$score = UserScore::where("user_id", Auth::id())->sum("score");
|
||||||
|
return $score;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPercentage($user_id = null)
|
||||||
|
{
|
||||||
|
$user = !empty($user_id) ? $user_id : Auth::id();
|
||||||
|
|
||||||
|
$question = Question::where("is_essay", "1")->pluck("id");
|
||||||
|
$answeredQues = UserScore::where("user_id", $user)->whereIn("question_id", $question);
|
||||||
|
|
||||||
|
return number_format((float)$answeredQues->count() / $question->count() * 100, 1, '.', '');
|
||||||
|
}
|
||||||
|
}
|
||||||
27
Penilaian-Esai/app/Models/WonderingScore.php
Normal file
27
Penilaian-Esai/app/Models/WonderingScore.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class WonderingScore extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $table = "wondering_score";
|
||||||
|
protected $fillable=[
|
||||||
|
'content_id',
|
||||||
|
'user_id',
|
||||||
|
'score',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\User::class, 'user_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function content()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\Content::class, 'content_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
28
Penilaian-Esai/app/Providers/AppServiceProvider.php
Normal file
28
Penilaian-Esai/app/Providers/AppServiceProvider.php
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
30
Penilaian-Esai/app/Providers/AuthServiceProvider.php
Normal file
30
Penilaian-Esai/app/Providers/AuthServiceProvider.php
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
|
||||||
|
class AuthServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The model to policy mappings for the application.
|
||||||
|
*
|
||||||
|
* @var array<class-string, class-string>
|
||||||
|
*/
|
||||||
|
protected $policies = [
|
||||||
|
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register any authentication / authorization services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->registerPolicies();
|
||||||
|
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
21
Penilaian-Esai/app/Providers/BroadcastServiceProvider.php
Normal file
21
Penilaian-Esai/app/Providers/BroadcastServiceProvider.php
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Broadcast;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class BroadcastServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
Broadcast::routes();
|
||||||
|
|
||||||
|
require base_path('routes/channels.php');
|
||||||
|
}
|
||||||
|
}
|
||||||
42
Penilaian-Esai/app/Providers/EventServiceProvider.php
Normal file
42
Penilaian-Esai/app/Providers/EventServiceProvider.php
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Events\Registered;
|
||||||
|
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||||
|
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Event;
|
||||||
|
|
||||||
|
class EventServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The event to listener mappings for the application.
|
||||||
|
*
|
||||||
|
* @var array<class-string, array<int, class-string>>
|
||||||
|
*/
|
||||||
|
protected $listen = [
|
||||||
|
Registered::class => [
|
||||||
|
SendEmailVerificationNotification::class,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register any events for your application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if events and listeners should be automatically discovered.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function shouldDiscoverEvents()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user