iCLOP
This commit is contained in:
parent
8a5f98980c
commit
7c86ddb72c
15
.editorconfig
Normal file
15
.editorconfig
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
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
|
||||||
46
.env.example
Normal file
46
.env.example
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
APP_NAME=Laravel
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_URL=http://localhost
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
|
||||||
|
DB_CONNECTION=mysql
|
||||||
|
DB_HOST=127.0.0.1
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_DATABASE=laravel
|
||||||
|
DB_USERNAME=root
|
||||||
|
DB_PASSWORD=
|
||||||
|
|
||||||
|
BROADCAST_DRIVER=log
|
||||||
|
CACHE_DRIVER=file
|
||||||
|
QUEUE_CONNECTION=sync
|
||||||
|
SESSION_DRIVER=file
|
||||||
|
SESSION_LIFETIME=120
|
||||||
|
|
||||||
|
REDIS_HOST=127.0.0.1
|
||||||
|
REDIS_PASSWORD=null
|
||||||
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
MAIL_DRIVER=smtp
|
||||||
|
MAIL_HOST=smtp.mailtrap.io
|
||||||
|
MAIL_PORT=2525
|
||||||
|
MAIL_USERNAME=null
|
||||||
|
MAIL_PASSWORD=null
|
||||||
|
MAIL_ENCRYPTION=null
|
||||||
|
MAIL_FROM_ADDRESS=null
|
||||||
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
AWS_ACCESS_KEY_ID=
|
||||||
|
AWS_SECRET_ACCESS_KEY=
|
||||||
|
AWS_DEFAULT_REGION=us-east-1
|
||||||
|
AWS_BUCKET=
|
||||||
|
|
||||||
|
PUSHER_APP_ID=
|
||||||
|
PUSHER_APP_KEY=
|
||||||
|
PUSHER_APP_SECRET=
|
||||||
|
PUSHER_APP_CLUSTER=mt1
|
||||||
|
|
||||||
|
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||||
|
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||||
5
.gitattributes
vendored
Normal file
5
.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
* text=auto
|
||||||
|
*.css linguist-vendored
|
||||||
|
*.scss linguist-vendored
|
||||||
|
*.js linguist-vendored
|
||||||
|
CHANGELOG.md export-ignore
|
||||||
12
.gitignore
vendored
Normal file
12
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
/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
|
||||||
13
.styleci.yml
Normal file
13
.styleci.yml
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
php:
|
||||||
|
preset: laravel
|
||||||
|
disabled:
|
||||||
|
- unused_use
|
||||||
|
finder:
|
||||||
|
not-name:
|
||||||
|
- index.php
|
||||||
|
- server.php
|
||||||
|
js:
|
||||||
|
finder:
|
||||||
|
not-name:
|
||||||
|
- webpack.mix.js
|
||||||
|
css: true
|
||||||
1
.vscode/configurationCache.log
vendored
Normal file
1
.vscode/configurationCache.log
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"buildTargets":[],"launchTargets":[],"customConfigurationProvider":{"workspaceBrowse":{"browsePath":[],"compilerArgs":[]},"fileIndex":[]}}
|
||||||
5
.vscode/dryrun.log
vendored
Normal file
5
.vscode/dryrun.log
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
make: Entering directory 'c:/xampp/htdocs/aplas_app'
|
||||||
|
make: Leaving directory 'c:/xampp/htdocs/aplas_app'
|
||||||
|
|
||||||
|
make: *** No targets specified and no makefile found. Stop.
|
||||||
|
|
||||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"makefile.extensionOutputFolder": "./.vscode"
|
||||||
|
}
|
||||||
287
.vscode/targets.log
vendored
Normal file
287
.vscode/targets.log
vendored
Normal file
|
|
@ -0,0 +1,287 @@
|
||||||
|
make.exe all --print-data-base --no-builtin-variables --no-builtin-rules --question
|
||||||
|
make: *** No rule to make target 'all'. Stop.
|
||||||
|
|
||||||
|
# GNU Make 4.3
|
||||||
|
# Built for Windows32
|
||||||
|
# Copyright (C) 1988-2020 Free Software Foundation, Inc.
|
||||||
|
# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
||||||
|
# This is free software: you are free to change and redistribute it.
|
||||||
|
# There is NO WARRANTY, to the extent permitted by law.
|
||||||
|
|
||||||
|
# Make data base, printed on Mon Aug 15 10:42:19 2022
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
|
||||||
|
# environment
|
||||||
|
SYSTEMDRIVE = C:
|
||||||
|
# environment
|
||||||
|
LC_ALL = C
|
||||||
|
# environment
|
||||||
|
USERPROFILE = C:\Users\A.S.H
|
||||||
|
# environment
|
||||||
|
LOCALAPPDATA = C:\Users\A.S.H\AppData\Local
|
||||||
|
# environment
|
||||||
|
LCOV_HOME = C:\ProgramData\chocolatey\lib\lcov\tools
|
||||||
|
# environment
|
||||||
|
VSCODE_CWD = C:\Users\A.S.H\AppData\Local\Programs\Microsoft VS Code
|
||||||
|
# environment
|
||||||
|
CHOCOLATEYINSTALL = C:\ProgramData\chocolatey
|
||||||
|
# environment
|
||||||
|
SYSTEMROOT = C:\WINDOWS
|
||||||
|
# environment
|
||||||
|
PROCESSOR_LEVEL = 6
|
||||||
|
# environment
|
||||||
|
PSMODULEPATH = C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
|
||||||
|
# default
|
||||||
|
MAKE_COMMAND := C:/ProgramData/chocolatey/lib/make/tools/install/bin/make.exe
|
||||||
|
# automatic
|
||||||
|
@D = $(patsubst %/,%,$(patsubst %\,%,$(dir $@)))
|
||||||
|
# environment
|
||||||
|
CHROME_CRASHPAD_PIPE_NAME = \\.\pipe\crashpad_5268_TDRCDSCQJFFFEAJH
|
||||||
|
# environment
|
||||||
|
VSCODE_HANDLES_UNCAUGHT_ERRORS = true
|
||||||
|
# default
|
||||||
|
.VARIABLES :=
|
||||||
|
# automatic
|
||||||
|
%D = $(patsubst %/,%,$(patsubst %\,%,$(dir $%)))
|
||||||
|
# automatic
|
||||||
|
^D = $(patsubst %/,%,$(patsubst %\,%,$(dir $^)))
|
||||||
|
# automatic
|
||||||
|
%F = $(notdir $%)
|
||||||
|
# environment
|
||||||
|
VSCODE_CODE_CACHE_PATH = C:\Users\A.S.H\AppData\Roaming\Code\CachedData\6d9b74a70ca9c7733b29f0456fd8195364076dda
|
||||||
|
# environment
|
||||||
|
LANG = C
|
||||||
|
# default
|
||||||
|
.LOADED :=
|
||||||
|
# environment
|
||||||
|
TMP = C:\Users\AS98BE~1.H\AppData\Local\Temp
|
||||||
|
# default
|
||||||
|
.INCLUDE_DIRS = .
|
||||||
|
# environment
|
||||||
|
PROCESSOR_ARCHITEW6432 = AMD64
|
||||||
|
# makefile
|
||||||
|
MAKEFLAGS = pqrR
|
||||||
|
# environment
|
||||||
|
ONEDRIVE = C:\Users\A.S.H\OneDrive
|
||||||
|
# makefile
|
||||||
|
CURDIR := c:/xampp/htdocs/aplas_app
|
||||||
|
# environment
|
||||||
|
APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL = true
|
||||||
|
# automatic
|
||||||
|
*D = $(patsubst %/,%,$(patsubst %\,%,$(dir $*)))
|
||||||
|
# environment
|
||||||
|
PROGRAMFILES = C:\Program Files (x86)
|
||||||
|
# environment
|
||||||
|
MFLAGS = -pqrR
|
||||||
|
# default
|
||||||
|
.SHELLFLAGS := -c
|
||||||
|
# environment
|
||||||
|
COMMONPROGRAMW6432 = C:\Program Files\Common Files
|
||||||
|
# automatic
|
||||||
|
+D = $(patsubst %/,%,$(patsubst %\,%,$(dir $+)))
|
||||||
|
# makefile
|
||||||
|
MAKEFILE_LIST :=
|
||||||
|
# automatic
|
||||||
|
@F = $(notdir $@)
|
||||||
|
# environment
|
||||||
|
VSCODE_PID = 5268
|
||||||
|
# automatic
|
||||||
|
?D = $(patsubst %/,%,$(patsubst %\,%,$(dir $?)))
|
||||||
|
# automatic
|
||||||
|
*F = $(notdir $*)
|
||||||
|
# automatic
|
||||||
|
<D = $(patsubst %/,%,$(patsubst %\,%,$(dir $<)))
|
||||||
|
# environment
|
||||||
|
VSCODE_NLS_CONFIG = {"locale":"en-us","availableLanguages":{},"_languagePackSupport":true}
|
||||||
|
# default
|
||||||
|
MAKE_HOST := Windows32
|
||||||
|
# environment
|
||||||
|
PROGRAMDATA = C:\ProgramData
|
||||||
|
# default
|
||||||
|
SHELL := sh.exe
|
||||||
|
# environment
|
||||||
|
HOMEPATH = \Users\A.S.H
|
||||||
|
# environment
|
||||||
|
PLATFORMIO_CALLER = vscode
|
||||||
|
# default
|
||||||
|
MAKECMDGOALS := all
|
||||||
|
# environment
|
||||||
|
DRIVERDATA = C:\Windows\System32\Drivers\DriverData
|
||||||
|
# environment
|
||||||
|
COMSPEC = C:\WINDOWS\system32\cmd.exe
|
||||||
|
# environment
|
||||||
|
WINDIR = C:\WINDOWS
|
||||||
|
# environment
|
||||||
|
MAKELEVEL := 0
|
||||||
|
# default
|
||||||
|
MAKE = $(MAKE_COMMAND)
|
||||||
|
# environment
|
||||||
|
PATH = C:\Python310\Scripts\;C:\Python310\;C:\Program Files\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\xampp\php;C:\composer;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\tools\php81;C:\ProgramData\ComposerSetup\bin;C:\Users\A.S.H\AppData\Local\Microsoft\WindowsApps;C:\Users\A.S.H\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\A.S.H\AppData\Roaming\npm;C:\src\flutter\bin;C:\tools\dart-sdk\bin;C:\Users\A.S.H\AppData\Roaming\Pub\Cache\bin;C:\Users\A.S.H\AppData\Roaming\Composer\vendor\bin
|
||||||
|
# environment
|
||||||
|
ZES_ENABLE_SYSMAN = 1
|
||||||
|
# environment
|
||||||
|
COMPUTERNAME = RIANBTK
|
||||||
|
# default
|
||||||
|
MAKEFILES :=
|
||||||
|
# automatic
|
||||||
|
^F = $(notdir $^)
|
||||||
|
# environment
|
||||||
|
PROMPT = $P$G
|
||||||
|
# environment
|
||||||
|
CHOCOLATEYLASTPATHUPDATE = 133044145133986719
|
||||||
|
# environment
|
||||||
|
LOGONSERVER = \\RIANBTK
|
||||||
|
# environment
|
||||||
|
USERNAME = A.S.H
|
||||||
|
# environment
|
||||||
|
COMMONPROGRAMFILES = C:\Program Files (x86)\Common Files
|
||||||
|
# automatic
|
||||||
|
?F = $(notdir $?)
|
||||||
|
# environment
|
||||||
|
PROGRAMW6432 = C:\Program Files
|
||||||
|
# environment
|
||||||
|
NO_PROXY = 127.0.0.1
|
||||||
|
# environment
|
||||||
|
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW
|
||||||
|
# automatic
|
||||||
|
+F = $(notdir $+)
|
||||||
|
# environment
|
||||||
|
ORIGINAL_XDG_CURRENT_DESKTOP = undefined
|
||||||
|
# environment
|
||||||
|
USERDOMAIN = RIANBTK
|
||||||
|
# 'override' directive
|
||||||
|
GNUMAKEFLAGS :=
|
||||||
|
# environment
|
||||||
|
OS = Windows_NT
|
||||||
|
# environment
|
||||||
|
PLATFORMIO_PATH = C:\Users\A.S.H\.platformio\python3;C:\Python310\Scripts\;C:\Python310\;C:\Program Files\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\xampp\php;C:\composer;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\tools\php81;C:\ProgramData\ComposerSetup\bin;C:\Users\A.S.H\AppData\Local\Microsoft\WindowsApps;C:\Users\A.S.H\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\A.S.H\AppData\Roaming\npm;C:\src\flutter\bin;C:\tools\dart-sdk\bin;C:\Users\A.S.H\AppData\Roaming\Pub\Cache\bin;C:\Users\A.S.H\AppData\Roaming\Composer\vendor\bin;C:\Python310\Scripts\;C:\Python310\;C:\Program Files\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\xampp\php;C:\composer;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\tools\php81;C:\ProgramData\ComposerSetup\bin;C:\Users\A.S.H\AppData\Local\Microsoft\WindowsApps;C:\Users\A.S.H\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\A.S.H\AppData\Roaming\npm;C:\src\flutter\bin;C:\tools\dart-sdk\bin;C:\Users\A.S.H\AppData\Roaming\Pub\Cache\bin;C:\Users\A.S.H\AppData\Roaming\Composer\vendor\bin
|
||||||
|
# makefile
|
||||||
|
.DEFAULT_GOAL :=
|
||||||
|
# default
|
||||||
|
MAKE_VERSION := 4.3
|
||||||
|
# environment
|
||||||
|
PROGRAMFILES(X86) = C:\Program Files (x86)
|
||||||
|
# environment
|
||||||
|
USERDOMAIN_ROAMINGPROFILE = RIANBTK
|
||||||
|
# environment
|
||||||
|
NUMBER_OF_PROCESSORS = 4
|
||||||
|
# environment
|
||||||
|
PUBLIC = C:\Users\Public
|
||||||
|
# environment
|
||||||
|
ASL.LOG = Destination=file
|
||||||
|
# environment
|
||||||
|
APPDATA = C:\Users\A.S.H\AppData\Roaming
|
||||||
|
# environment
|
||||||
|
HOMEDRIVE = C:
|
||||||
|
# environment
|
||||||
|
PROCESSOR_ARCHITECTURE = x86
|
||||||
|
# environment
|
||||||
|
VSCODE_AMD_ENTRYPOINT = vs/workbench/api/node/extensionHostProcess
|
||||||
|
# environment
|
||||||
|
PLATFORMIO_IDE = 2.5.2
|
||||||
|
# environment
|
||||||
|
COMMONPROGRAMFILES(X86) = C:\Program Files (x86)\Common Files
|
||||||
|
# environment
|
||||||
|
ELECTRON_RUN_AS_NODE = 1
|
||||||
|
# environment
|
||||||
|
TEMP = C:\Users\AS98BE~1.H\AppData\Local\Temp
|
||||||
|
# environment
|
||||||
|
VSCODE_IPC_HOOK = \\.\pipe\01aad43d2802e152d6fad3a253789a9a-1.70.1-main-sock
|
||||||
|
# default
|
||||||
|
.RECIPEPREFIX :=
|
||||||
|
# automatic
|
||||||
|
<F = $(notdir $<)
|
||||||
|
# default
|
||||||
|
SUFFIXES :=
|
||||||
|
# environment
|
||||||
|
ALLUSERSPROFILE = C:\ProgramData
|
||||||
|
# environment
|
||||||
|
SESSIONNAME = Console
|
||||||
|
# environment
|
||||||
|
PROG27B48B2C054 = 1
|
||||||
|
# default
|
||||||
|
.FEATURES := target-specific order-only second-expansion else-if shortest-stem undefine oneshell nocomment grouped-target extra-prereqs archives jobserver output-sync load
|
||||||
|
# environment
|
||||||
|
PROCESSOR_REVISION = 8e0c
|
||||||
|
# environment
|
||||||
|
CHOCOLATEYTOOLSLOCATION = C:\tools
|
||||||
|
# environment
|
||||||
|
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 142 Stepping 12, GenuineIntel
|
||||||
|
# variable set hash-table stats:
|
||||||
|
# Load=98/1024=10%, Rehash=0, Collisions=9/122=7%
|
||||||
|
|
||||||
|
# Pattern-specific Variable Values
|
||||||
|
|
||||||
|
# No pattern-specific variable values.
|
||||||
|
|
||||||
|
# Directories
|
||||||
|
|
||||||
|
# . (key c:/xampp/htdocs/aplas_app, mtime 1660534936): 27 files, no impossibilities.
|
||||||
|
|
||||||
|
# 27 files, no impossibilities in 1 directories.
|
||||||
|
|
||||||
|
# Implicit Rules
|
||||||
|
|
||||||
|
# No implicit rules.
|
||||||
|
|
||||||
|
# Files
|
||||||
|
|
||||||
|
# Not a target:
|
||||||
|
Makefile:
|
||||||
|
# Implicit rule search has been done.
|
||||||
|
# File does not exist.
|
||||||
|
# File has been updated.
|
||||||
|
# Failed to be updated.
|
||||||
|
|
||||||
|
# Not a target:
|
||||||
|
.DEFAULT:
|
||||||
|
# Implicit rule search has not been done.
|
||||||
|
# Modification time never checked.
|
||||||
|
# File has not been updated.
|
||||||
|
|
||||||
|
# Not a target:
|
||||||
|
all:
|
||||||
|
# Command line target.
|
||||||
|
# Implicit rule search has been done.
|
||||||
|
# File does not exist.
|
||||||
|
# File has not been updated.
|
||||||
|
|
||||||
|
# Not a target:
|
||||||
|
makefile:
|
||||||
|
# Implicit rule search has been done.
|
||||||
|
# File does not exist.
|
||||||
|
# File has been updated.
|
||||||
|
# Failed to be updated.
|
||||||
|
|
||||||
|
# Not a target:
|
||||||
|
makefile.mak:
|
||||||
|
# Implicit rule search has been done.
|
||||||
|
# File does not exist.
|
||||||
|
# File has been updated.
|
||||||
|
# Failed to be updated.
|
||||||
|
|
||||||
|
# Not a target:
|
||||||
|
GNUmakefile:
|
||||||
|
# Implicit rule search has been done.
|
||||||
|
# File does not exist.
|
||||||
|
# File has been updated.
|
||||||
|
# Failed to be updated.
|
||||||
|
|
||||||
|
# files hash-table stats:
|
||||||
|
# Load=7/1024=1%, Rehash=0, Collisions=0/16=0%
|
||||||
|
# VPATH Search Paths
|
||||||
|
|
||||||
|
# No 'vpath' search paths.
|
||||||
|
|
||||||
|
# No general ('VPATH' variable) search path.
|
||||||
|
|
||||||
|
# strcache buffers: 1 (0) / strings = 34 / storage = 322 B / avg = 9 B
|
||||||
|
# current buf: size = 8174 B / used = 322 B / count = 34 / avg = 9 B
|
||||||
|
|
||||||
|
# strcache performance: lookups = 37 / hit rate = 8%
|
||||||
|
# hash-table stats:
|
||||||
|
# Load=34/8192=0%, Rehash=0, Collisions=0/37=0%
|
||||||
|
# Finished Make data base on Mon Aug 15 10:42:19 2022
|
||||||
|
|
||||||
|
|
||||||
78
README.md
Normal file
78
README.md
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
<p align="center"><img src="https://res.cloudinary.com/dtfbvvkyp/image/upload/v1566331377/laravel-logolockup-cmyk-red.svg" width="400"></p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## About Laravel
|
||||||
|
|
||||||
|
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||||
|
|
||||||
|
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||||
|
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||||
|
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||||
|
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||||
|
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||||
|
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||||
|
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||||
|
|
||||||
|
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||||
|
|
||||||
|
## Learning Laravel
|
||||||
|
|
||||||
|
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||||
|
|
||||||
|
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||||
|
|
||||||
|
## Laravel Sponsors
|
||||||
|
|
||||||
|
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
|
||||||
|
|
||||||
|
- **[Vehikl](https://vehikl.com/)**
|
||||||
|
- **[Tighten Co.](https://tighten.co)**
|
||||||
|
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||||
|
- **[64 Robots](https://64robots.com)**
|
||||||
|
- **[Cubet Techno Labs](https://cubettech.com)**
|
||||||
|
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
||||||
|
- **[British Software Development](https://www.britishsoftware.co)**
|
||||||
|
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
|
||||||
|
- **[DevSquad](https://devsquad.com)**
|
||||||
|
- [UserInsights](https://userinsights.com)
|
||||||
|
- [Fragrantica](https://www.fragrantica.com)
|
||||||
|
- [SOFTonSOFA](https://softonsofa.com/)
|
||||||
|
- [User10](https://user10.com)
|
||||||
|
- [Soumettre.fr](https://soumettre.fr/)
|
||||||
|
- [CodeBrisk](https://codebrisk.com)
|
||||||
|
- [1Forge](https://1forge.com)
|
||||||
|
- [TECPRESSO](https://tecpresso.co.jp/)
|
||||||
|
- [Runtime Converter](http://runtimeconverter.com/)
|
||||||
|
- [WebL'Agence](https://weblagence.com/)
|
||||||
|
- [Invoice Ninja](https://www.invoiceninja.com)
|
||||||
|
- [iMi digital](https://www.imi-digital.de/)
|
||||||
|
- [Earthlink](https://www.earthlink.ro/)
|
||||||
|
- [Steadfast Collective](https://steadfastcollective.com/)
|
||||||
|
- [We Are The Robots Inc.](https://watr.mx/)
|
||||||
|
- [Understand.io](https://www.understand.io/)
|
||||||
|
- [Abdel Elrafa](https://abdelelrafa.com)
|
||||||
|
- [Hyper Host](https://hyper.host)
|
||||||
|
- [Appoly](https://www.appoly.co.uk)
|
||||||
|
- [OP.GG](https://op.gg)
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||||
|
|
||||||
|
## Code of Conduct
|
||||||
|
|
||||||
|
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||||
|
|
||||||
|
## Security Vulnerabilities
|
||||||
|
|
||||||
|
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||||
11
app/AplasSummary.php
Normal file
11
app/AplasSummary.php
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class AplasSummary extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table='aplas_summary';
|
||||||
|
}
|
||||||
18
app/ClassMember.php
Normal file
18
app/ClassMember.php
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ClassMember extends Model
|
||||||
|
{
|
||||||
|
protected $table='class_members';
|
||||||
|
|
||||||
|
public function classid() {
|
||||||
|
return $this->belongsTo(App\Classroom::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function student() {
|
||||||
|
return $this->belongsTo(App\User::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
15
app/Classroom.php
Normal file
15
app/Classroom.php
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Classroom extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table='classrooms';
|
||||||
|
|
||||||
|
public function owner() {
|
||||||
|
return $this->belongsTo(App\User::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
42
app/Console/Kernel.php
Normal file
42
app/Console/Kernel.php
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console;
|
||||||
|
|
||||||
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
|
|
||||||
|
class Kernel extends ConsoleKernel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The Artisan commands provided by your application.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $commands = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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');
|
||||||
|
}
|
||||||
|
}
|
||||||
15
app/DownloadHistory.php
Normal file
15
app/DownloadHistory.php
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class DownloadHistory extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table='download_history';
|
||||||
|
|
||||||
|
public function userid() {
|
||||||
|
return $this->belongsTo(App\User::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
55
app/Exceptions/Handler.php
Normal file
55
app/Exceptions/Handler.php
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
|
|
||||||
|
class Handler extends ExceptionHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A list of the exception types that are not reported.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $dontReport = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of the inputs that are never flashed for validation exceptions.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $dontFlash = [
|
||||||
|
'password',
|
||||||
|
'password_confirmation',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report or log an exception.
|
||||||
|
*
|
||||||
|
* @param \Exception $exception
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function report(Exception $exception)
|
||||||
|
{
|
||||||
|
parent::report($exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render an exception into an HTTP response.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Exception $exception
|
||||||
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function render($request, Exception $exception)
|
||||||
|
{
|
||||||
|
return parent::render($request, $exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
17
app/ExerciseFiles.php
Normal file
17
app/ExerciseFiles.php
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ExerciseFiles extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table = 'exercise_files';
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
public function topic()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(App\ExerciseTopic::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
13
app/ExerciseFilesResult.php
Normal file
13
app/ExerciseFilesResult.php
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ExerciseFilesResult extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table = 'exercise_file_results';
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
}
|
||||||
|
|
||||||
12
app/ExerciseStudentResultView.php
Normal file
12
app/ExerciseStudentResultView.php
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ExerciseStudentResultView extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table = 'exercise_student_submits_view';
|
||||||
|
}
|
||||||
|
|
||||||
13
app/ExerciseSubmit.php
Normal file
13
app/ExerciseSubmit.php
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ExerciseSubmit extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'exercise_submits';
|
||||||
|
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
}
|
||||||
|
|
||||||
26
app/ExerciseTopic.php
Normal file
26
app/ExerciseTopic.php
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ExerciseTopic extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table = 'exercises';
|
||||||
|
public function tasks()
|
||||||
|
{
|
||||||
|
return $this->hasMany('App\Task');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function topic_files()
|
||||||
|
{
|
||||||
|
return $this->hasMany('App\TopicFiles');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_files()
|
||||||
|
{
|
||||||
|
return $this->hasMany('App\TestFiles');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
17
app/ExerciseTopicFiles.php
Normal file
17
app/ExerciseTopicFiles.php
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ExerciseTopicFiles extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table = 'exercise_topic_files';
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
public function topic()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(App\ExerciseTopic::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
12
app/ExerciseValidation.php
Normal file
12
app/ExerciseValidation.php
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ExerciseValidation extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table = 'exercise_validations';
|
||||||
|
}
|
||||||
|
|
||||||
11
app/FileResult.php
Normal file
11
app/FileResult.php
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class FileResult extends Model
|
||||||
|
{
|
||||||
|
protected $table='file_results';
|
||||||
|
public $primaryKey='id';
|
||||||
|
}
|
||||||
10
app/Flight.php
Normal file
10
app/Flight.php
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Flight extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
12
app/FlutterStudentSubmit.php
Normal file
12
app/FlutterStudentSubmit.php
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class FlutterStudentSubmit extends Model
|
||||||
|
{
|
||||||
|
protected $table='student_submits';
|
||||||
|
|
||||||
|
public $primaryKey='id';
|
||||||
|
}
|
||||||
25
app/FlutterTask.php
Normal file
25
app/FlutterTask.php
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class FlutterTask extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table='tasks';
|
||||||
|
|
||||||
|
public $primaryKey='id';
|
||||||
|
|
||||||
|
public function topic() {
|
||||||
|
return $this->belongsTo(App\FlutterTopic::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTopic($id) {
|
||||||
|
return \App\FlutterTopic::find($id)->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getListTopic() {
|
||||||
|
return \App\FlutterTopic::pluck('name', 'id');
|
||||||
|
}
|
||||||
|
}
|
||||||
11
app/FlutterTaskResult.php
Normal file
11
app/FlutterTaskResult.php
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class FlutterTaskResult extends Model
|
||||||
|
{
|
||||||
|
protected $table='task_results';
|
||||||
|
public $primaryKey='id';
|
||||||
|
}
|
||||||
10
app/FlutterTestFiles.php
Normal file
10
app/FlutterTestFiles.php
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class FlutterTestFiles extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
22
app/FlutterTopic.php
Normal file
22
app/FlutterTopic.php
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class FlutterTopic extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table='topics';
|
||||||
|
public function tasks() {
|
||||||
|
return $this->hasMany('App\FlutterTask');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function topic_files() {
|
||||||
|
return $this->hasMany('App\FlutterTopicFiles');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_files() {
|
||||||
|
return $this->hasMany('App\FlutterTestFiles');
|
||||||
|
}
|
||||||
|
}
|
||||||
15
app/FlutterTopicFiles.php
Normal file
15
app/FlutterTopicFiles.php
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class FlutterTopicFiles extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
protected $table='topic_files';
|
||||||
|
public $primaryKey='id';
|
||||||
|
public function topic() {
|
||||||
|
return $this->belongsTo(App\FlutterTopic::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
52
app/FlutterUser.php
Normal file
52
app/FlutterUser.php
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
|
||||||
|
|
||||||
|
class FlutterUser extends Authenticatable
|
||||||
|
{
|
||||||
|
use Notifiable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name', 'roleid', 'email', 'password','uplink','status'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be hidden for arrays.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $hidden = [
|
||||||
|
'password', 'remember_token',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be cast to native types.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'email_verified_at' => 'datetime',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function checkRoleId($roleid) {
|
||||||
|
if ($roleid=='student') {
|
||||||
|
return Redirect::to('student/fluttercourse/home');
|
||||||
|
} elseif ($roleid=='teacher') {
|
||||||
|
return Redirect::to('teacher/home');
|
||||||
|
} elseif ($roleid=='admin') {
|
||||||
|
return Redirect::to('admin/admin');
|
||||||
|
} else {
|
||||||
|
return Redirect::to('/home');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
19
app/Http/Controllers/AdminController.php
Normal file
19
app/Http/Controllers/AdminController.php
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class AdminController extends Controller
|
||||||
|
{
|
||||||
|
public function index() {
|
||||||
|
|
||||||
|
$entities=\App\AplasSummary::all();
|
||||||
|
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
|
||||||
|
return view('admin/main')->with($data);
|
||||||
|
//return view('admin/main');
|
||||||
|
}
|
||||||
|
}
|
||||||
84
app/Http/Controllers/AssignStudentController.php
Normal file
84
app/Http/Controllers/AssignStudentController.php
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class AssignStudentController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
$entities=\App\User::where('users.roleid','=','student')
|
||||||
|
->select('users.id', 'users.name', 'users.roleid', 'users.email')
|
||||||
|
->leftJoin('student_teachers','users.id','=','student_teachers.student')
|
||||||
|
->whereNull('student_teachers.teacher')
|
||||||
|
->orderBy('users.name','asc')
|
||||||
|
->get();
|
||||||
|
*/
|
||||||
|
|
||||||
|
$entities = \App\User::where('uplink','=',Auth::user()->id)->where('status','=','pending')->where('roleid','=','student')
|
||||||
|
->select('id', 'name', 'roleid', 'email')
|
||||||
|
->orderBy('name','asc')->get();
|
||||||
|
|
||||||
|
$classroom=\App\Classroom::where('owner','=',Auth::user()->id)
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
$data=['entities'=>$entities, 'classroom'=>$classroom];
|
||||||
|
|
||||||
|
return view('teacher/assignstudent/index')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$students = $request->get('students');
|
||||||
|
$x = 0;
|
||||||
|
if (is_array($students)) {
|
||||||
|
//$classid = $request->get('classroom');
|
||||||
|
//$x .= $classid;
|
||||||
|
foreach ($students as $std) {
|
||||||
|
$user=\App\User::find($std);
|
||||||
|
$user->status='active';
|
||||||
|
$user->save();
|
||||||
|
|
||||||
|
$member = new \App\ClassMember;
|
||||||
|
$member->classid = $request->get('classroom');
|
||||||
|
$member->student = $std;
|
||||||
|
$member->save();
|
||||||
|
$x++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Session::flash('message','Validation for '.$x.' student(s) was succeed');
|
||||||
|
return Redirect::to('teacher/assignstudent/index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
$entities=\App\User::where('users.roleid','=','student')
|
||||||
|
->select('users.id', 'users.name', 'users.roleid', 'users.email')
|
||||||
|
->leftJoin('student_teachers','users.id','=','student_teachers.student')
|
||||||
|
->whereNull('student_teachers.teacher')
|
||||||
|
->orderBy('users.name','asc')
|
||||||
|
->get();
|
||||||
|
*/
|
||||||
|
$entities = \App\User::where('uplink','=',Auth::user()->id)->where('status','=','pending')->where('roleid','=','student')
|
||||||
|
->select('id', 'name', 'roleid', 'email')
|
||||||
|
->orderBy('name','asc')->get();
|
||||||
|
|
||||||
|
$classroom=\App\Classroom::where('owner','=',Auth::user()->id)
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
$data=['entities'=>$entities, 'classroom'=>$classroom];
|
||||||
|
|
||||||
|
return view('teacher/assignstudent/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
59
app/Http/Controllers/AssignTeacherController.php
Normal file
59
app/Http/Controllers/AssignTeacherController.php
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class AssignTeacherController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
//$entities=\App\User::where('roleid','=','student')
|
||||||
|
// ->orderBy('name','asc')
|
||||||
|
// ->get();
|
||||||
|
|
||||||
|
$entities=\App\User::where('users.roleid','=','student')
|
||||||
|
->select('users.id','users.name','users.email','users.roleid','users.uplink','users.status','B.name as teacher')
|
||||||
|
->leftJoin('users as B', 'users.uplink', '=', 'B.id')
|
||||||
|
->orderBy('users.name','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
|
||||||
|
return view('admin/assignteacher/index')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$entity=\App\User::find($id);
|
||||||
|
|
||||||
|
$entity->roleid='teacher';
|
||||||
|
$entity->status='active';
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$classroom = new \App\Classroom;
|
||||||
|
$classroom->name='Default';
|
||||||
|
$classroom->owner=$id;
|
||||||
|
$classroom->desc='Default class for teacher '.$entity['name'];
|
||||||
|
$classroom->save();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Session::flash('message','User with name = '.$entity['name'].' now as a teacher and Default classroom was created');
|
||||||
|
return Redirect::to('/admin/assignteacher/index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show()
|
||||||
|
{
|
||||||
|
$entities=\App\User::where('roleid','=','student')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
|
||||||
|
return view('admin/assignteacher/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
40
app/Http/Controllers/Auth/ConfirmPasswordController.php
Normal file
40
app/Http/Controllers/Auth/ConfirmPasswordController.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\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');
|
||||||
|
}
|
||||||
|
}
|
||||||
22
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
22
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
|
|
@ -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
app/Http/Controllers/Auth/LoginController.php
Normal file
40
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');
|
||||||
|
}
|
||||||
|
}
|
||||||
82
app/Http/Controllers/Auth/RegisterController.php
Normal file
82
app/Http/Controllers/Auth/RegisterController.php
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use App\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 = '/student';//RouteServiceProvider::HOME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('guest');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showRegistrationForm() {
|
||||||
|
//$teacher = \App\User::where('roleid','=','student')->pluck('name', 'id');
|
||||||
|
$teacher = \App\User::where('roleid','=','teacher')
|
||||||
|
->select('id','name')->get();
|
||||||
|
|
||||||
|
return view('auth.register')->with(compact('teacher'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new user instance after a valid registration.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return \App\User
|
||||||
|
*/
|
||||||
|
protected function create(array $data)
|
||||||
|
{
|
||||||
|
return User::create([
|
||||||
|
'name' => $data['name'],
|
||||||
|
'email' => $data['email'],
|
||||||
|
'uplink' => $data['teacher'],
|
||||||
|
'password' => Hash::make($data['password']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
30
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
30
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
|
|
@ -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;
|
||||||
|
}
|
||||||
42
app/Http/Controllers/Auth/VerificationController.php
Normal file
42
app/Http/Controllers/Auth/VerificationController.php
Normal file
|
|
@ -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');
|
||||||
|
}
|
||||||
|
}
|
||||||
165
app/Http/Controllers/ClassroomController.php
Normal file
165
app/Http/Controllers/ClassroomController.php
Normal file
|
|
@ -0,0 +1,165 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class ClassroomController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entities=\App\Classroom::where('classrooms.owner','=',Auth::user()->id)
|
||||||
|
->leftJoin('class_members_group','classrooms.id','=','class_members_group.classid')
|
||||||
|
->select('classrooms.id','classrooms.name','classrooms.status','classrooms.desc','class_members_group.count')
|
||||||
|
->orderBy('classrooms.name','asc')
|
||||||
|
->get();
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
|
||||||
|
return view('teacher/crooms/index')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return view('teacher/crooms/create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'name'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'name.required'=>'Class name must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('teacher/crooms/create')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$entity=new \App\Classroom;
|
||||||
|
$desc = ($request->get('desc')==null)?'-':$request->get('desc');
|
||||||
|
$entity->name=$request->get('name');
|
||||||
|
$entity->owner=Auth::user()->id;
|
||||||
|
$entity->desc=$desc;
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New Classroom Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('teacher/crooms');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$entity = \App\ClassMember::where('class_members.classid','=',$id)
|
||||||
|
->join('users','users.id','=','class_members.student')
|
||||||
|
->select('users.id','users.name','users.email')
|
||||||
|
->orderBy('users.name','asc')->get();
|
||||||
|
$x=['entities'=>$entity];
|
||||||
|
return view('teacher/crooms/show')->with($x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\Classroom::find($id);
|
||||||
|
$x=['classroom'=>$entity];
|
||||||
|
return view('teacher/crooms/edit')->with($x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request,$id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'name'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'name.required'=>'Class name must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('teacher/crooms/'.$id.'/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$entity = \App\Classroom::find($id);
|
||||||
|
$desc = ($request->get('desc')==null)?'-':$request->get('desc');
|
||||||
|
|
||||||
|
$entity->name=$request->get('name');
|
||||||
|
$entity->desc=$desc;
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','Class with Id='.$id.' is changed');
|
||||||
|
return Redirect::to('teacher/crooms');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\Classroom::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message','Class with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('teacher/crooms');
|
||||||
|
}
|
||||||
|
}
|
||||||
13
app/Http/Controllers/Controller.php
Normal file
13
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;
|
||||||
|
}
|
||||||
119
app/Http/Controllers/DownloadController.php
Normal file
119
app/Http/Controllers/DownloadController.php
Normal file
|
|
@ -0,0 +1,119 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class DownloadController extends Controller
|
||||||
|
{
|
||||||
|
public function saveHistory($file_path, $topic_name, $doctype, $fname) {
|
||||||
|
$item = new \App\DownloadHistory;
|
||||||
|
|
||||||
|
$item->userid=Auth::user()->id;
|
||||||
|
$item->topicname=$topic_name;
|
||||||
|
$item->doctype=$doctype;
|
||||||
|
$item->filepath=$file_path;
|
||||||
|
$item->downfile=$fname;
|
||||||
|
$item->host=$_SERVER['REMOTE_ADDR'];
|
||||||
|
$item->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downFile($file_name, $topic_name, $doctype, $folder) {
|
||||||
|
$dirname = str_replace('\\',DIRECTORY_SEPARATOR,'app\public\\'.$folder.'\\');
|
||||||
|
$file_path = storage_path($dirname.$file_name);
|
||||||
|
$ext = pathinfo($file_path, PATHINFO_EXTENSION);
|
||||||
|
$headers = array('Content-Type' => 'application/zip','Content-Type' => 'application/pdf',
|
||||||
|
'Content-Type' => 'application/rar','Content-Type' => 'application/txt');
|
||||||
|
|
||||||
|
$fname=$topic_name.'-'.$doctype.'.'.$ext;
|
||||||
|
$this->saveHistory($file_path,$topic_name,$doctype,$fname);
|
||||||
|
return response()->download($file_path, $fname, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function downLearning($file_name, $topic_name, $doctype) {
|
||||||
|
/*
|
||||||
|
$dirname = str_replace('\\',DIRECTORY_SEPARATOR,'app\public\learning\\');
|
||||||
|
$file_path = storage_path($dirname.$file_name);
|
||||||
|
$ext = pathinfo($file_path, PATHINFO_EXTENSION);
|
||||||
|
$headers = array('Content-Type' => 'application/zip','Content-Type' => 'application/pdf','Content-Type' => 'application/rar');
|
||||||
|
|
||||||
|
$fname=$topic_name.'-'.$doctype.'.'.$ext;
|
||||||
|
$this->saveHistory($file_path,$topic_name,$doctype,$fname);
|
||||||
|
return response()->download($file_path, $fname, $headers);
|
||||||
|
*/
|
||||||
|
return $this->downFile($file_name, $topic_name, $doctype,'learning');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downGuide($file_name, $topic_name) {
|
||||||
|
return $this->downLearning($file_name,$topic_name,'GuideDocuments');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downTest($file_name, $topic_name) {
|
||||||
|
return $this->downLearning($file_name,$topic_name,'TestFiles');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downSupplement($file_name, $topic_name) {
|
||||||
|
return $this->downLearning($file_name,$topic_name,'SupplementFiles');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downOther($file_name, $topic_name) {
|
||||||
|
return $this->downLearning($file_name,$topic_name,'OtherFiles');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exercise download
|
||||||
|
public function downExercise($file_name, $topic_name, $doctype)
|
||||||
|
{
|
||||||
|
return $this->downFile($file_name, $topic_name, $doctype, 'exercise_files');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downExerciseGuide($file_name, $topic_name)
|
||||||
|
{
|
||||||
|
return $this->downExercise($file_name, $topic_name, 'GuideDocuments');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downExerciseTest($file_name, $topic_name)
|
||||||
|
{
|
||||||
|
return $this->downExercise($file_name, $topic_name, 'TestFiles');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downExerciseSupplement($file_name, $topic_name)
|
||||||
|
{
|
||||||
|
return $this->downExercise($file_name, $topic_name, 'SupplementFiles');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downExerciseOther($file_name, $topic_name)
|
||||||
|
{
|
||||||
|
return $this->downExercise($file_name, $topic_name, 'OtherFiles');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Jplas
|
||||||
|
public function downJplasPackage($file_name, $topic_name) {
|
||||||
|
return $this->downLearning($file_name,$topic_name,'JplasPackage');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downJplasGuide($file_name, $topic_name) {
|
||||||
|
return $this->downLearning($file_name,$topic_name,'JplasGuide');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downJplasResult($file_name, $topic_name) {
|
||||||
|
return $this->downFile($file_name,$topic_name,'JplasResult','results');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
public function download(Request $request){
|
||||||
|
//PDF file is stored under project/public/download/info.pdf
|
||||||
|
$file="./".$request->get('fileid');
|
||||||
|
return Response::download($file);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
public function download($file_name) {
|
||||||
|
$file_path = public_path('files/'.$file_name);
|
||||||
|
return response()->download($file_path);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
201
app/Http/Controllers/ExerciseFilesController.php
Normal file
201
app/Http/Controllers/ExerciseFilesController.php
Normal file
|
|
@ -0,0 +1,201 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class ExerciseFilesController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $filepath = 'public';
|
||||||
|
protected $dirname = 'exercise_files';
|
||||||
|
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$entities = \App\ExerciseFiles::select(
|
||||||
|
'exercise_files.id',
|
||||||
|
'exercise_files.guide',
|
||||||
|
'exercise_files.testfile',
|
||||||
|
'exercise_files.supplement',
|
||||||
|
'exercise_files.other',
|
||||||
|
'exercise_files.desc',
|
||||||
|
'exercises.name'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'exercises',
|
||||||
|
'exercises.id',
|
||||||
|
'=',
|
||||||
|
'exercise_files.exercise'
|
||||||
|
)
|
||||||
|
->orderBy('exercises.name', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
//$items = \App\Topic::all();
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
return view('admin/exercisefiles/index')->with(compact('entities'));
|
||||||
|
} else {
|
||||||
|
return view('student/lfiles/index')->with(compact('entities'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$items = \App\ExerciseTopic::pluck('name', 'id');
|
||||||
|
|
||||||
|
return view('admin/exercisefiles/create')->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules = [
|
||||||
|
'guide' => 'required',
|
||||||
|
'testfile' => 'required',
|
||||||
|
'supplement' => 'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg = [
|
||||||
|
'guide.required' => 'Guide file must not empty',
|
||||||
|
'testfile.required' => 'Test file must not empty',
|
||||||
|
'supplement.required' => 'Supplement file must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $rules, $msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('admin/exercisefiles/create')
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
$check = \App\ExerciseFiles::where('exercise', '=', $request->get('topic'))->get();
|
||||||
|
|
||||||
|
if (sizeof($check) > 0) {
|
||||||
|
$topic = \App\ExerciseTopic::find($request->get('name'));
|
||||||
|
$message = 'Learning File of ' . $topic['name'] . ' is already exist!!';
|
||||||
|
//Session::flash('message',);
|
||||||
|
return Redirect::to('admin/exercisefiles/create')->withErrors($message);
|
||||||
|
} else {
|
||||||
|
$entity = new \App\ExerciseFiles();
|
||||||
|
|
||||||
|
$entity->exercise = $request->get('topic');
|
||||||
|
|
||||||
|
$file1 = $request->file('guide')->store($this->dirname, $this->filepath);
|
||||||
|
$entity->guide = $file1;
|
||||||
|
|
||||||
|
$file2 = $request->file('testfile')->store($this->dirname, $this->filepath);
|
||||||
|
$entity->testfile = $file2;
|
||||||
|
|
||||||
|
$file3 = $request->file('supplement')->store($this->dirname, $this->filepath);
|
||||||
|
$entity->supplement = $file3;
|
||||||
|
|
||||||
|
$file4 = $request->file('other');
|
||||||
|
if ($file4 != '') {
|
||||||
|
$file4 = $request->file('other')->store($this->dirname, $this->filepath);
|
||||||
|
$entity->other = $file4;
|
||||||
|
}
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message', 'A New Exercise File Stored');
|
||||||
|
|
||||||
|
return Redirect::to('admin/exercisefiles');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTopic($fileid)
|
||||||
|
{
|
||||||
|
$item = \App\ExerciseFiles::find($fileid);
|
||||||
|
return $item->exercise;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$topic = \App\ExerciseTopic::find($this->getTopic($id));
|
||||||
|
$x = ['data' => $topic];
|
||||||
|
$fileid = $id;
|
||||||
|
return view('admin/exercisefiles/edit')->with($x)->with(compact('fileid'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$entity = \App\ExerciseFiles::find($id);
|
||||||
|
$change = false;
|
||||||
|
|
||||||
|
$dirpath = storage_path($this->dirname);
|
||||||
|
$file1 = $request->file('guide');
|
||||||
|
if ($file1 != '') {
|
||||||
|
// File::delete(getPath($dirpath.$entity->guide));
|
||||||
|
$fname = $file1->store($this->dirname, $this->filepath);
|
||||||
|
$entity->guide = $fname;
|
||||||
|
$change = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$file2 = $request->file('testfile');
|
||||||
|
if ($file2 != '') {
|
||||||
|
//File::delete(getPath($dirpath.$entity->testfile));
|
||||||
|
$fname = $file2->store($this->dirname, $this->filepath);
|
||||||
|
$entity->testfile = $fname;
|
||||||
|
$change = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$file3 = $request->file('supplement');
|
||||||
|
if ($file3 != '') {
|
||||||
|
//File::delete(getPath($dirpath.$entity->supplement));
|
||||||
|
$fname = $file3->store($this->dirname, $this->filepath);
|
||||||
|
$entity->supplement = $fname;
|
||||||
|
$change = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$file4 = $request->file('other');
|
||||||
|
if ($file4 != '') {
|
||||||
|
//File::delete(getPath($dirpath.$entity->other));
|
||||||
|
$fname = $file4->store($this->dirname, $this->filepath);
|
||||||
|
$entity->other = $fname;
|
||||||
|
$change = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($change) {
|
||||||
|
$entity->save();
|
||||||
|
Session::flash('message', 'A Exercise File is changed');
|
||||||
|
} else {
|
||||||
|
Session::flash('message', 'Nothing is changed');
|
||||||
|
}
|
||||||
|
return Redirect::to('admin/exercisefiles');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\ExerciseFiles::find($id);
|
||||||
|
/*
|
||||||
|
$dirpath = storage_path('app\public\\');
|
||||||
|
File::delete(getPath($dirpath.$entity['guide']));
|
||||||
|
File::delete(getPath($dirpath.$entity['supplement']));
|
||||||
|
File::delete(getPath($dirpath.$entity['testfiles']));
|
||||||
|
if ($entity['other']!='') {
|
||||||
|
File::delete(getPath($dirpath.$entity['other']));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message', 'Exercise Files with Id=' . $id . ' is deleted');
|
||||||
|
return Redirect::to('admin/exercisefiles');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPath($path)
|
||||||
|
{
|
||||||
|
$res = str_replace('\\', DIRECTORY_SEPARATOR, $path);
|
||||||
|
return str_replace('/', DIRECTORY_SEPARATOR, $res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
237
app/Http/Controllers/ExerciseResourcesController.php
Normal file
237
app/Http/Controllers/ExerciseResourcesController.php
Normal file
|
|
@ -0,0 +1,237 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class ExerciseResourcesController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$stagelist = \App\ExerciseTopic::orderBy('stage', 'asc')->get();
|
||||||
|
$exerciselist = \App\ExerciseTopic::orderBy('name', 'asc')->get();
|
||||||
|
|
||||||
|
if ($exerciselist->count() > 0) {
|
||||||
|
|
||||||
|
// daftar stage untuk dropdown menu
|
||||||
|
$itemsstage = \App\ExerciseTopic::orderBy('stage', 'asc')
|
||||||
|
->selectRaw('stage, min(id) as id')
|
||||||
|
->groupBy('stage')
|
||||||
|
->pluck('stage', 'id');
|
||||||
|
|
||||||
|
// id stageList dari url
|
||||||
|
$filter = $request->input('stageList', $stagelist[0]['id']);
|
||||||
|
|
||||||
|
// id exerciseList dari url
|
||||||
|
$filterexercise = $request->input('exerciseList', $exerciselist[0]['id']);
|
||||||
|
|
||||||
|
// get nama stage dari $filter
|
||||||
|
$stagename = \App\ExerciseTopic::orderBy('stage', 'asc')
|
||||||
|
->where('id', $filter)
|
||||||
|
->pluck('stage');
|
||||||
|
|
||||||
|
// daftar exercise untuk dropdown menu
|
||||||
|
$itemsexercise = \App\ExerciseTopic::orderBy('id', 'asc')
|
||||||
|
->where('stage', $stagename)
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
if (!($this->checkstage($filter, $filterexercise))) {
|
||||||
|
return Redirect::to('admin/exerciseresources?stageList=' . $filter . '&exerciseList=' . $filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
$entities = \App\ExerciseTopicFiles::where('exercise', '=', $filterexercise)
|
||||||
|
->select(
|
||||||
|
'exercise_topic_files.id',
|
||||||
|
'exercise_topic_files.fileName',
|
||||||
|
'exercise_topic_files.path',
|
||||||
|
'exercise_topic_files.exercise',
|
||||||
|
'exercise_topic_files.desc',
|
||||||
|
'exercises.name'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'exercises',
|
||||||
|
'exercises.id',
|
||||||
|
'=',
|
||||||
|
'exercise_topic_files.exercise'
|
||||||
|
)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return view('admin/exerciseresources/index')
|
||||||
|
->with(compact('itemsstage'))
|
||||||
|
->with(compact('itemsexercise'))
|
||||||
|
->with(compact('filter'))
|
||||||
|
->with(compact('filterexercise'))
|
||||||
|
->with(compact('entities'));
|
||||||
|
} else {
|
||||||
|
return view('admin/exerciseresources/index');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkstage($stage, $exercise)
|
||||||
|
{
|
||||||
|
$stagename = \App\ExerciseTopic::orderBy('stage', 'asc')
|
||||||
|
->where('id', $stage)
|
||||||
|
->pluck('stage');
|
||||||
|
$exercisestage = \App\ExerciseTopic::orderBy('stage', 'asc')
|
||||||
|
->where('id', $exercise)
|
||||||
|
->pluck('stage');
|
||||||
|
|
||||||
|
if ($stagename == $exercisestage) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$items = \App\ExerciseTopic::pluck('name', 'id');
|
||||||
|
|
||||||
|
return view('admin/exerciseresources/create')->with(compact('items'));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules = [
|
||||||
|
'filename' => 'required',
|
||||||
|
'path' => 'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg = [
|
||||||
|
'filename.required' => 'File Name must not empty',
|
||||||
|
'path.required' => 'Folder Path must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $rules, $msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('admin/exerciseresources/create')
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$entity = new \App\ExerciseFiles;
|
||||||
|
|
||||||
|
$entity->fileName = $request->get('filename');
|
||||||
|
$entity->path = str_replace('\\', '/', $request->get('path'));
|
||||||
|
$entity->exercise = $request->get('exercise');
|
||||||
|
$entity->desc = $request->get('desc');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message', 'A New Exercise Resource Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('admin/exerciseresources');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$entity = \App\ExerciseFiles::find($id);
|
||||||
|
$exercise = \App\ExerciseTopic::find($entity->exercise);
|
||||||
|
$x = ['data' => $entity, 'topic' => $exercise];
|
||||||
|
|
||||||
|
return view('admin/exerciseresources/show')->with($x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\ExerciseFiles::find($id);
|
||||||
|
$x = ['data' => $entity];
|
||||||
|
$items = \App\ExerciseTopic::pluck('name', 'id');
|
||||||
|
return view('admin/exerciseresources/edit')->with($x)->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules = [
|
||||||
|
'filename' => 'required',
|
||||||
|
'path' => 'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg = [
|
||||||
|
'filename.required' => 'File Name must not empty',
|
||||||
|
'path.required' => 'Folder Path must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $rules, $msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('admin/exerciseresources/' . $id . '/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
$entity = \App\ExerciseFiles::find($id);
|
||||||
|
|
||||||
|
$entity->fileName = $request->get('filename');
|
||||||
|
$entity->path = str_replace('\\', '/', $request->get('path'));
|
||||||
|
$entity->exercise = $request->get('exercise');
|
||||||
|
$entity->desc = $request->get('desc');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message', 'Resource with Id=' . $id . ' is changed');
|
||||||
|
|
||||||
|
return Redirect::to('admin/exerciseresources');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\ExerciseFiles::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message', 'Resource with Id=' . $id . ' is deleted');
|
||||||
|
return Redirect::to('admin/exerciseresources');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
31
app/Http/Controllers/ExerciseResultViewController.php
Normal file
31
app/Http/Controllers/ExerciseResultViewController.php
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ExerciseResultViewController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entities = \App\ExerciseStudentResultView::orderBy('id', 'desc')->get();
|
||||||
|
$data = ['entities' => $entities];
|
||||||
|
return view('admin/exerciseresview/index')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showhistory($student, $topicid)
|
||||||
|
{
|
||||||
|
$entities = \App\UiStudentResultView::where('userid', $student)
|
||||||
|
->where('uitopicid', $topicid)
|
||||||
|
->orderBy('id', 'DESC')->get();
|
||||||
|
|
||||||
|
$topic = \App\UiTopics::find($topicid);
|
||||||
|
$user = \App\User::find($student);
|
||||||
|
$data = ['entities' => $entities, 'topic' => $topic, 'student' => $user];
|
||||||
|
return view('admin/uiresview/show')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
243
app/Http/Controllers/ExerciseStdController.php
Normal file
243
app/Http/Controllers/ExerciseStdController.php
Normal file
|
|
@ -0,0 +1,243 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class ExerciseStdController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
if (Auth::user()->roleid == 'student') {
|
||||||
|
$check = \App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status != 'active') return view('student/home')->with(['status' => $check->status]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$stagelist = \App\ExerciseTopic::orderBy('stage', 'asc')->get();
|
||||||
|
$topiclist = \App\ExerciseTopic::orderBy('name', 'asc')->get();
|
||||||
|
|
||||||
|
if ($topiclist->count() > 0) {
|
||||||
|
$itemsstage = \App\ExerciseTopic::orderBy('stage', 'asc')
|
||||||
|
->selectRaw('stage, min(id) as id')
|
||||||
|
->groupBy('stage')
|
||||||
|
->pluck('stage', 'id');
|
||||||
|
|
||||||
|
// $filter = $request->input('topicList', $topiclist[0]['id']);
|
||||||
|
|
||||||
|
$filter = $request->input('stageList', $topiclist[0]['id']);
|
||||||
|
|
||||||
|
$option = $request->input('option', 'github');
|
||||||
|
|
||||||
|
$stage = \App\ExerciseTopic::where('exercises.id', '=', $filter)
|
||||||
|
->select(
|
||||||
|
'exercises.id',
|
||||||
|
'exercises.stage'
|
||||||
|
)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$topic = \App\ExerciseTopic::where('exercises.stage', '=', $stage[0]['stage'])
|
||||||
|
->select(
|
||||||
|
'exercises.id',
|
||||||
|
'exercises.name',
|
||||||
|
'exercises.desc',
|
||||||
|
'exercise_files.guide',
|
||||||
|
'exercise_files.testfile',
|
||||||
|
'exercise_files.supplement',
|
||||||
|
'exercise_files.other'
|
||||||
|
)
|
||||||
|
->leftJoin('exercise_files', 'exercise_files.exercise', '=', 'exercises.id')
|
||||||
|
->get();
|
||||||
|
// $result = \App\ExerciseValidation::where('exercise_validations.userid', Auth::user()->id)
|
||||||
|
// ->where('exercise_submits.exercise', $filter)
|
||||||
|
// ->select(
|
||||||
|
// 'exercise_submits.checkstat',
|
||||||
|
// 'exercise_submits.checkresult'
|
||||||
|
// )
|
||||||
|
// ->leftJoin('exercise_submits', 'exercise_validations.exercisesubmitid', '=', 'exercise_submits.id')
|
||||||
|
// ->first();
|
||||||
|
|
||||||
|
return view('student/exercise/index')
|
||||||
|
->with(compact('itemsstage'))
|
||||||
|
->with(compact('filter'))
|
||||||
|
->with(compact('topic'))
|
||||||
|
// ->with(compact('result'))
|
||||||
|
->with(compact('option'));
|
||||||
|
} else {
|
||||||
|
return view('student/exercise/index');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateUrl($url)
|
||||||
|
{
|
||||||
|
$path = parse_url($url, PHP_URL_PATH);
|
||||||
|
$encoded_path = array_map('urlencode', explode('/', $path));
|
||||||
|
$url = str_replace($path, implode('/', $encoded_path), $url);
|
||||||
|
|
||||||
|
if (filter_var($url, FILTER_VALIDATE_URL)) {
|
||||||
|
$result = parse_url($url);
|
||||||
|
if (($result['scheme'] == 'https') && ($this->endsWith($result['host'], 'github.com'))) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateZipFile(Request $request)
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'zipfile' => 'required',
|
||||||
|
'comment' => 'required',
|
||||||
|
'duration' => 'required',
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg = [
|
||||||
|
'zipfile.required' => 'Zip file must not empty',
|
||||||
|
'comment.required' => 'Exercise comment must not empty',
|
||||||
|
'duration.required' => 'Duration time must not empty',
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $rules, $msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('student/exercise?topicList=' . $request->get('exercise'))
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
$userid = Auth::user()->id;
|
||||||
|
$exercise = $request->get('exercise');
|
||||||
|
$file = $request->file('zipfile');
|
||||||
|
$filename = $file->getClientOriginalName();
|
||||||
|
//
|
||||||
|
//$file = $request->file('zipfile');
|
||||||
|
if ($filename != '') {
|
||||||
|
//$array = explode('.', $path);
|
||||||
|
//$ext = strtolower(end($array));
|
||||||
|
$ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||||
|
if ($ext == "zip") {
|
||||||
|
$zipFile = $file->store('exercise_results', 'public');
|
||||||
|
|
||||||
|
if ($zipFile != '') {
|
||||||
|
$entity = new \App\ExerciseSubmit();
|
||||||
|
|
||||||
|
$entity->userid = $userid;
|
||||||
|
$entity->exercise = $exercise;
|
||||||
|
$entity->validstat = "valid";
|
||||||
|
$entity->checkresult = "waiting";
|
||||||
|
$entity->projectfile = $zipFile;
|
||||||
|
$entity->comment = $request->get('comment');
|
||||||
|
$entity->duration = $request->get('duration');
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\ExerciseTopic::find($exercise);
|
||||||
|
Session::flash('message', $data['name'] . ' Validation by Uploading Zip Project is Success');
|
||||||
|
} else {
|
||||||
|
Session::flash('message', 'Storing file ' . $request->file('zipfile') . ' was FAILED');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Session::flash('message', 'File extension is not zip -> ' . $filename . ' is wrong .' . $ext);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Session::flash('message', 'Zip File is empty');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/exercise?topicList=' . $exercise);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateGithubLink(Request $request)
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'githublink' => 'required',
|
||||||
|
'comment' => 'required',
|
||||||
|
'duration' => 'required',
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg = [
|
||||||
|
'githublink.required' => 'Github link must not empty',
|
||||||
|
'comment.required' => 'Exercise comment must not empty',
|
||||||
|
'duration.required' => 'Duration time must not empty',
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $rules, $msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('student/exercise?topicList=' . $request->get('exercise'))
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
$userid = Auth::user()->id;
|
||||||
|
$exercise = $request->get('exercise');
|
||||||
|
$link = $request->get('githublink');
|
||||||
|
//
|
||||||
|
$trimmedlink = trim($link);
|
||||||
|
if ($this->validateUrl($trimmedlink)) {
|
||||||
|
$entity = new \App\ExerciseSubmit;
|
||||||
|
|
||||||
|
$entity->userid = $userid;
|
||||||
|
$entity->exercise = $exercise;
|
||||||
|
$entity->validstat = "valid";
|
||||||
|
$entity->checkresult = "waiting";
|
||||||
|
$entity->validator = "";
|
||||||
|
$entity->comment = $request->get('comment');;
|
||||||
|
$entity->duration = $request->get('duration');;
|
||||||
|
$entity->githublink = $trimmedlink;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\ExerciseTopic::find($exercise);
|
||||||
|
Session::flash('message', $data['name'] . ' Validation by submitting GitHub link is Success');
|
||||||
|
|
||||||
|
//Session::flash('message','URL valid '.$link);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Session::flash('message', 'URL is not VALID ' . $link);
|
||||||
|
}
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/exercise?topicList=' . $exercise);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function endsWith($haystack, $needle)
|
||||||
|
{
|
||||||
|
return substr_compare($haystack, $needle, -strlen($needle)) === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
if (($request->get('action') == 'validate') && (strlen($request->submitbutton) > 5)) {
|
||||||
|
if ($request->get('option') == 'zipfile') {
|
||||||
|
return $this->validateZipFile($request);
|
||||||
|
} else if ($request->get('option') == 'github') {
|
||||||
|
return $this->validateGithubLink($request);
|
||||||
|
} else {
|
||||||
|
return Redirect::to('student/exercise?topicList=' . $request->get('exercise') . '&option=' . $request->get('option') .
|
||||||
|
'&submit=' . $request->submitbutton);
|
||||||
|
}
|
||||||
|
} else { //clicking radio button
|
||||||
|
return Redirect::to('student/exercise?topicList=' . $request->get('exercise') . '&option=' . $request->get('option'));
|
||||||
|
//'&submit='.$request->submitbutton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
57
app/Http/Controllers/ExerciseStdValidController.php
Normal file
57
app/Http/Controllers/ExerciseStdValidController.php
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class ExerciseStdValidController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
if (Auth::user()->roleid == 'student') {
|
||||||
|
$check = \App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status != 'active') return view('student/home')->with(['status' => $check->status]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$entities = \App\ExerciseSubmit::where('exercise_submits.userid', Auth::user()->id)
|
||||||
|
->select(
|
||||||
|
'exercise_submits.id',
|
||||||
|
'exercises.name',
|
||||||
|
'exercise_submits.checkstat',
|
||||||
|
'exercise_validations.report',
|
||||||
|
'exercise_submits.duration'
|
||||||
|
)
|
||||||
|
->leftJoin('exercise_validations', 'exercise_validations.exercisesubmitid', '=', 'exercise_submits.id')
|
||||||
|
->leftJoin('exercises', 'exercise_submits.exercise', '=', 'exercises.id')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return view('student/exercisevalid/index')
|
||||||
|
->with(compact('entities'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$entities = \App\ExerciseSubmit::where('exercise_submits.userid', Auth::user()->id)
|
||||||
|
->where('exercise_submits.id', $id)
|
||||||
|
->select(
|
||||||
|
'exercise_submits.id',
|
||||||
|
'exercises.name',
|
||||||
|
'exercises.singletestcode',
|
||||||
|
'exercise_submits.checkstat',
|
||||||
|
'exercise_validations.report',
|
||||||
|
'exercise_validations.duration',
|
||||||
|
'exercise_validations.created_at'
|
||||||
|
)
|
||||||
|
->leftJoin('exercise_validations', 'exercise_validations.exercisesubmitid', '=', 'exercise_submits.id')
|
||||||
|
->leftJoin('exercises', 'exercise_submits.exercise', '=', 'exercises.id')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$student = \App\User::find(Auth::user()->id);
|
||||||
|
|
||||||
|
return view('student/exercisevalid/show')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('student'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
269
app/Http/Controllers/ExerciseSubmissionController.php
Normal file
269
app/Http/Controllers/ExerciseSubmissionController.php
Normal file
|
|
@ -0,0 +1,269 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class ExerciseSubmissionController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
if (Auth::user()->roleid == 'student') {
|
||||||
|
$check = \App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status != 'active') return view('student/home')->with(['status' => $check->status]);
|
||||||
|
}
|
||||||
|
$stagelist = \App\ExerciseTopic::orderBy('stage', 'asc')->get();
|
||||||
|
$exerciselist = \App\ExerciseTopic::orderBy('name', 'asc')->get();
|
||||||
|
|
||||||
|
if ($exerciselist->count() > 0) {
|
||||||
|
|
||||||
|
// daftar stage untuk dropdown menu
|
||||||
|
$itemsstage = \App\ExerciseTopic::orderBy('stage', 'asc')
|
||||||
|
->selectRaw('stage, min(id) as id')
|
||||||
|
->groupBy('stage')
|
||||||
|
->pluck('stage', 'id');
|
||||||
|
|
||||||
|
// id stageList dari url
|
||||||
|
$filter = $request->input('stageList', $stagelist[0]['id']);
|
||||||
|
|
||||||
|
// id exerciseList dari url
|
||||||
|
$filterexercise = $request->input('exerciseList', $exerciselist[0]['id']);
|
||||||
|
|
||||||
|
// get nama stage dari $filter
|
||||||
|
$stagename = \App\ExerciseTopic::orderBy('stage', 'asc')
|
||||||
|
->where('id', $filter)
|
||||||
|
->pluck('stage');
|
||||||
|
|
||||||
|
// daftar exercise untuk dropdown menu
|
||||||
|
$itemsexercise = \App\ExerciseTopic::orderBy('id', 'asc')
|
||||||
|
->where('stage', $stagename)
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
if (!($this->checkstage($filter, $filterexercise))) {
|
||||||
|
return Redirect::to('student/exercisesubmission?stageList=' . $filter . '&exerciseList=' . $filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
$completed = \App\ExerciseSubmit::where('userid', '=', Auth::user()->id)
|
||||||
|
->where('exercise', '=', $filterexercise)
|
||||||
|
->get()->count();
|
||||||
|
|
||||||
|
$option = $request->input('option', 'github');
|
||||||
|
|
||||||
|
$stage = \App\ExerciseTopic::where('exercises.id', '=', $filter)
|
||||||
|
->select(
|
||||||
|
'exercises.id',
|
||||||
|
'exercises.stage'
|
||||||
|
)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$topic = \App\ExerciseTopic::where('exercises.stage', '=', $stage[0]['stage'])
|
||||||
|
->select(
|
||||||
|
'exercises.name'
|
||||||
|
)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$result = \App\ExerciseValidation::where('exercise_validations.userid', Auth::user()->id)
|
||||||
|
->where('exercise_submits.exercise', $filter)
|
||||||
|
->select(
|
||||||
|
'exercise_submits.checkstat',
|
||||||
|
'exercise_submits.checkresult'
|
||||||
|
)
|
||||||
|
->leftJoin('exercise_submits', 'exercise_validations.exercisesubmitid', '=', 'exercise_submits.id')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
return view('student/exercisesubmission/index')
|
||||||
|
->with(compact('itemsstage'))
|
||||||
|
->with(compact('itemsexercise'))
|
||||||
|
->with(compact('filter'))
|
||||||
|
->with(compact('filterexercise'))
|
||||||
|
->with(compact('topic'))
|
||||||
|
->with(compact('completed'))
|
||||||
|
->with(compact('result'))
|
||||||
|
->with(compact('option'));
|
||||||
|
} else {
|
||||||
|
return view('student/exercisesubmission/index');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkstage($stage, $exercise)
|
||||||
|
{
|
||||||
|
$stagename = \App\ExerciseTopic::orderBy('stage', 'asc')
|
||||||
|
->where('id', $stage)
|
||||||
|
->pluck('stage');
|
||||||
|
$exercisestage = \App\ExerciseTopic::orderBy('stage', 'asc')
|
||||||
|
->where('id', $exercise)
|
||||||
|
->pluck('stage');
|
||||||
|
|
||||||
|
if ($stagename == $exercisestage) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateUrl($url)
|
||||||
|
{
|
||||||
|
$path = parse_url($url, PHP_URL_PATH);
|
||||||
|
$encoded_path = array_map('urlencode', explode('/', $path));
|
||||||
|
$url = str_replace($path, implode('/', $encoded_path), $url);
|
||||||
|
|
||||||
|
if (filter_var($url, FILTER_VALIDATE_URL)) {
|
||||||
|
$result = parse_url($url);
|
||||||
|
if (($result['scheme'] == 'https') && ($this->endsWith($result['host'], 'github.com'))) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateZipFile(Request $request)
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'zipfile' => 'required',
|
||||||
|
'comment' => 'required',
|
||||||
|
'duration' => 'required',
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg = [
|
||||||
|
'zipfile.required' => 'Zip file must not empty',
|
||||||
|
'comment.required' => 'Exercise comment must not empty',
|
||||||
|
'duration.required' => 'Duration time must not empty',
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $rules, $msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('student/exercisesubmission?stageList=' . $request->get('stage') . '&exerciseList=' . $request->get('exercise'))
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
$userid = Auth::user()->id;
|
||||||
|
$exercise = $request->get('exercise');
|
||||||
|
$file = $request->file('zipfile');
|
||||||
|
$filename = $file->getClientOriginalName();
|
||||||
|
//
|
||||||
|
//$file = $request->file('zipfile');
|
||||||
|
if ($filename != '') {
|
||||||
|
//$array = explode('.', $path);
|
||||||
|
//$ext = strtolower(end($array));
|
||||||
|
$ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||||
|
if ($ext == "zip") {
|
||||||
|
$zipFile = $file->store('exercise_results', 'public');
|
||||||
|
|
||||||
|
if ($zipFile != '') {
|
||||||
|
$entity = new \App\ExerciseSubmit();
|
||||||
|
|
||||||
|
$entity->userid = $userid;
|
||||||
|
$entity->exercise = $exercise;
|
||||||
|
$entity->validstat = "valid";
|
||||||
|
$entity->checkresult = "waiting";
|
||||||
|
$entity->projectfile = $zipFile;
|
||||||
|
$entity->comment = $request->get('comment');
|
||||||
|
$entity->duration = $request->get('duration');
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\ExerciseTopic::find($exercise);
|
||||||
|
Session::flash('message', $data['name'] . ' Validation by Uploading Zip Project is Success');
|
||||||
|
} else {
|
||||||
|
Session::flash('message', 'Storing file ' . $request->file('zipfile') . ' was FAILED');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Session::flash('message', 'File extension is not zip -> ' . $filename . ' is wrong .' . $ext);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Session::flash('message', 'Zip File is empty');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/exercisesubmission?stageList=' . $request->get('stage') . '&exerciseList=' . $request->get('exercise'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateGithubLink(Request $request)
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'githublink' => 'required',
|
||||||
|
'comment' => 'required',
|
||||||
|
'duration' => 'required',
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg = [
|
||||||
|
'githublink.required' => 'Github link must not empty',
|
||||||
|
'comment.required' => 'Exercise comment must not empty',
|
||||||
|
'duration.required' => 'Duration time must not empty',
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $rules, $msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('student/exercisesubmission?stageList=' . $request->get('stage') . '&exerciseList=' . $request->get('exercise'))
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
$userid = Auth::user()->id;
|
||||||
|
$exercise = $request->get('exercise');
|
||||||
|
$link = $request->get('githublink');
|
||||||
|
//
|
||||||
|
$trimmedlink = trim($link);
|
||||||
|
if ($this->validateUrl($trimmedlink)) {
|
||||||
|
$entity = new \App\ExerciseSubmit;
|
||||||
|
|
||||||
|
$entity->userid = $userid;
|
||||||
|
$entity->exercise = $exercise;
|
||||||
|
$entity->validstat = "valid";
|
||||||
|
$entity->checkresult = "waiting";
|
||||||
|
$entity->comment = $request->get('comment');;
|
||||||
|
$entity->duration = $request->get('duration');;
|
||||||
|
$entity->githublink = $trimmedlink;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\ExerciseTopic::find($exercise);
|
||||||
|
Session::flash('message', $data['name'] . ' Validation by submitting GitHub link is Success');
|
||||||
|
|
||||||
|
//Session::flash('message','URL valid '.$link);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Session::flash('message', 'URL is not VALID ' . $link);
|
||||||
|
}
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/exercisesubmission?stageList=' . $request->get('stage') . '&exerciseList=' . $request->get('exercise'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function endsWith($haystack, $needle)
|
||||||
|
{
|
||||||
|
return substr_compare($haystack, $needle, -strlen($needle)) === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
if (($request->get('action') == 'validate') && (strlen($request->submitbutton) > 5)) {
|
||||||
|
if ($request->get('option') == 'zipfile') {
|
||||||
|
return $this->validateZipFile($request);
|
||||||
|
} else if ($request->get('option') == 'github') {
|
||||||
|
return $this->validateGithubLink($request);
|
||||||
|
} else {
|
||||||
|
return Redirect::to('student/exercisesubmission');
|
||||||
|
}
|
||||||
|
} else { //clicking radio button
|
||||||
|
return Redirect::to('student/exercisesubmission?stageList=' . $request->get('stage') . '&exerciseList=' . $request->get('exercise') . '&option=' . $request->get('option'));
|
||||||
|
//'&submit='.$request->submitbutton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
182
app/Http/Controllers/ExerciseTopicController.php
Normal file
182
app/Http/Controllers/ExerciseTopicController.php
Normal file
|
|
@ -0,0 +1,182 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
//use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class ExerciseTopicController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entities = \App\ExerciseTopic::orderBy('stage', 'asc')->orderBy('name', 'asc')->get();
|
||||||
|
//::all();
|
||||||
|
|
||||||
|
$data = ['entities' => $entities];
|
||||||
|
|
||||||
|
return view('admin/exercise/index')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return view('admin/exercise/create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules = [
|
||||||
|
'name' => 'required',
|
||||||
|
'stage' => 'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg = [
|
||||||
|
'name.required' => 'Exercise name must not empty',
|
||||||
|
'stage.required' => 'Learning stage must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $rules, $msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('admin/exerciseconf/create')
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$file = $request->file('testcode');
|
||||||
|
$testFile = $file->store('exercise_test_files', 'public');
|
||||||
|
|
||||||
|
$entity = new \App\ExerciseTopic();
|
||||||
|
|
||||||
|
$entity->name = $request->get('name');
|
||||||
|
$entity->stage = $request->get('stage');
|
||||||
|
$entity->desc = $request->get('desc');
|
||||||
|
$entity->projectpath = $request->get('projectpath');
|
||||||
|
$entity->packname = $request->get('packname');
|
||||||
|
$entity->androidclass = $request->get('androidclass');
|
||||||
|
$entity->testdir = $request->get('testpath');
|
||||||
|
$entity->singletestcode = $testFile;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message', 'A New Exercise Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('admin/exerciseconf');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$entity = \App\ExerciseTopic::find($id);
|
||||||
|
$x = ['topic' => $entity];
|
||||||
|
return view('admin/exercise/show')->with($x);
|
||||||
|
//return view('topics.show', array('topic' => $topic));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\ExerciseTopic::find($id);
|
||||||
|
$x = ['topic' => $entity];
|
||||||
|
return view('admin/exercise/edit')->with($x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules = [
|
||||||
|
'name' => 'required',
|
||||||
|
'stage' => 'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg = [
|
||||||
|
'name.required' => 'Topic name must not empty',
|
||||||
|
'stage.required' => 'Learning stage must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $rules, $msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('admin/exerciseconf/' . $id . '/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
$file = $request->file('testcode');
|
||||||
|
$originalname = $file->getClientOriginalName();
|
||||||
|
$testFile = $file->storeAs('exercise_test_files', $originalname, 'public');
|
||||||
|
$entity = \App\ExerciseTopic::find($id);
|
||||||
|
|
||||||
|
$entity->name = $request->get('name');
|
||||||
|
$entity->stage = $request->get('stage');
|
||||||
|
$entity->desc = $request->get('desc');
|
||||||
|
$entity->projectpath = $request->get('projectpath');
|
||||||
|
$entity->packname = $request->get('packname');
|
||||||
|
$entity->androidclass = $request->get('androidclass');
|
||||||
|
$entity->testdir = $request->get('testpath');
|
||||||
|
$entity->singletestcode = $originalname;
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message', 'Exercise with Id=' . $id . ' is changed');
|
||||||
|
return Redirect::to('admin/exerciseconf');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\ExerciseTopic::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message', 'Exercise with Id=' . $id . ' is deleted');
|
||||||
|
return Redirect::to('admin/exerciseconf');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
180
app/Http/Controllers/ExerciseValidController.php
Normal file
180
app/Http/Controllers/ExerciseValidController.php
Normal file
|
|
@ -0,0 +1,180 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class ExerciseValidController extends Controller
|
||||||
|
{
|
||||||
|
private function getListStudent($teacher)
|
||||||
|
{
|
||||||
|
return \App\User::where('users.uplink', '=', $teacher)
|
||||||
|
->join('user_submits', 'user_submits.userid', '=', 'users.id')
|
||||||
|
->join('class_members', 'class_members.student', '=', 'users.id')
|
||||||
|
->join('classrooms', 'classrooms.id', '=', 'class_members.classid')
|
||||||
|
->join('users as x', 'x.id', '=', 'users.uplink')
|
||||||
|
->select('users.id', 'users.name', 'users.email', 'users.roleid', 'classrooms.name as classname', 'x.name as teacher')
|
||||||
|
->orderBy('users.uplink', 'asc')
|
||||||
|
->orderBy('class_members.classid', 'asc')
|
||||||
|
->orderBy('users.name', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getListStudentAll()
|
||||||
|
{
|
||||||
|
return \App\User::where('users.status', '=', 'active')
|
||||||
|
|
||||||
|
->join('user_submits', 'user_submits.userid', '=', 'users.id')
|
||||||
|
->join('class_members', 'class_members.student', '=', 'users.id')
|
||||||
|
->join('classrooms', 'classrooms.id', '=', 'class_members.classid')
|
||||||
|
->join('users as x', 'x.id', '=', 'users.uplink')
|
||||||
|
->select('users.id', 'users.name', 'users.email', 'users.roleid', 'classrooms.name as classname', 'x.name as teacher')
|
||||||
|
->orderBy('users.uplink', 'asc')
|
||||||
|
->orderBy('class_members.classid', 'asc')
|
||||||
|
->orderBy('users.name', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
$student = $this->getListStudentAll();
|
||||||
|
$filter = $request->input('stdList', ($student->count() > 0) ? $student[0]['id'] : '');
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
$student = $this->getListStudent(Auth::user()->id);
|
||||||
|
$filter = $request->input('stdList', ($student->count() > 0) ? $student[0]['id'] : '');
|
||||||
|
} else { //student
|
||||||
|
$check = \App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status != 'active') return view('student/home')->with(['status' => $check->status]);
|
||||||
|
$filter = Auth::user()->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$entities = \App\StudentSubmit::where('student_submits.userid', '=', $filter)
|
||||||
|
->select(
|
||||||
|
'topics.id',
|
||||||
|
'topics.name',
|
||||||
|
'task_results_group_student.passed',
|
||||||
|
'task_results_group_student.failed',
|
||||||
|
'task_results_group_student.avg_duration',
|
||||||
|
'task_results_group_student.tot_duration',
|
||||||
|
'student_submits.checkstat',
|
||||||
|
'student_submits.checkresult',
|
||||||
|
'student_validations_pertopic.failed as vfailed',
|
||||||
|
'student_validations_pertopic.passed as vpassed'
|
||||||
|
)
|
||||||
|
->leftJoin(
|
||||||
|
'task_results_group_student',
|
||||||
|
function ($join) {
|
||||||
|
$join->on('task_results_group_student.userid', '=', 'student_submits.userid');
|
||||||
|
$join->on('task_results_group_student.topic', '=', 'student_submits.topic');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->leftJoin(
|
||||||
|
'student_validations_pertopic',
|
||||||
|
function ($join2) {
|
||||||
|
$join2->on('student_validations_pertopic.userid', '=', 'student_submits.userid');
|
||||||
|
$join2->on('student_validations_pertopic.topic', '=', 'student_submits.topic');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->join('topics', 'topics.id', '=', 'student_submits.topic')
|
||||||
|
->orderBy('topics.name', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
$data = ['entities' => $entities, 'items' => $student, 'filter' => $filter];
|
||||||
|
return view('admin/studentres/index')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
$data = ['entities' => $entities, 'items' => $student, 'filter' => $filter];
|
||||||
|
return view('teacher/studentres/index')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
$data = ['entities' => $entities];
|
||||||
|
return view('student/valid/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getDataShow($student, $id)
|
||||||
|
{
|
||||||
|
$entities = \App\ExerciseStudentResultView::where('userid', $student)
|
||||||
|
->where('id', $id)
|
||||||
|
->get();
|
||||||
|
$exercise = \App\ExerciseTopic::find($entities[0]['exerciseid']);
|
||||||
|
$user = \App\User::find($student);
|
||||||
|
$data = ['entities' => $entities, 'exercise' => $exercise, 'student' => $user];
|
||||||
|
|
||||||
|
// dd($uitestfile);
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$data = $this->getDataShow(Auth::user()->id, $id);
|
||||||
|
|
||||||
|
return view('student/uistudentres/show')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showadmin($student, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$data = $this->getDataShow($student, $id);
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('admin/exercisestudentres/show')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('teacher/uistudentres/show')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
//$data=['entities'=>$entities];
|
||||||
|
return view('student/uistudentres/show')->with($data);
|
||||||
|
}
|
||||||
|
//return view('teacher/studentres/show')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private function getFileSource($student, $topicid, $id)
|
||||||
|
{
|
||||||
|
$entities = \App\ExerciseFilesResult::where('exercise_file_results.userid', '=', $student)
|
||||||
|
->select('exercise_file_results.rscfile', 'exercise_topic_files.filename')
|
||||||
|
->join(
|
||||||
|
'exercise_topic_files',
|
||||||
|
function ($join) {
|
||||||
|
$join->on('exercise_file_results.fileid', '=', 'exercise_topic_files.id');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->where('exercise_topic_files.exercise', $topicid)
|
||||||
|
->orderBy('exercise_topic_files.id', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$topic = \App\ExerciseTopic::find($topicid);
|
||||||
|
$user = \App\User::find($student);
|
||||||
|
$data = ['entities' => $entities, 'topic' => $topic, 'student' => $user];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function showsource($student, $topicid, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$data = $this->getFileSource($student, $topicid, $id);
|
||||||
|
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('admin/exerciseuploadsrc/index')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('teacher/uploadsrc/index')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
//$data=['entities'=>$entities];
|
||||||
|
return view('student/uiuploadsrc/index')->with($data);
|
||||||
|
}
|
||||||
|
//return view('teacher/studentres/show')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
131
app/Http/Controllers/FileResultController.php
Normal file
131
app/Http/Controllers/FileResultController.php
Normal file
|
|
@ -0,0 +1,131 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class FileResultController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function create($id) {
|
||||||
|
//
|
||||||
|
$topic = \App\Topic::find($id);
|
||||||
|
$files = \App\TopicFiles::where('topic','=',$id)->get();
|
||||||
|
|
||||||
|
return view('student/fluttercourse/lfiles/create')
|
||||||
|
->with(compact('files'))
|
||||||
|
->with(compact('topic'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'rscfile'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'rscfile.required'=>'Resource File must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('student/fluttercourse/lfiles/create/'.$request->get('topic'))
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
$file = $request->file('rscfile');
|
||||||
|
$filename = $file->getClientOriginalName();
|
||||||
|
|
||||||
|
$fileinfo = \App\TopicFiles::find($request->get('fileid'));
|
||||||
|
if ($fileinfo['fileName']!=$filename) {
|
||||||
|
return Redirect::to('student/fluttercourse/lfiles/create/'.$request->get('topic'))
|
||||||
|
->withErrors("File name should be ".$fileinfo['fileName']);
|
||||||
|
} else {
|
||||||
|
$result = \App\FileResult::where('userid','=',Auth::user()->id)
|
||||||
|
->where('fileid','=',$request->get('fileid'))
|
||||||
|
->get();
|
||||||
|
if (count($result)>0) {
|
||||||
|
return Redirect::to('student/fluttercourse/lfiles/create/'.$request->get('topic'))
|
||||||
|
->withErrors('File '.$fileinfo['fileName'].' was already submitted');
|
||||||
|
} else {
|
||||||
|
$rsc=$file->store('resource','public');
|
||||||
|
$entity=new \App\FileResult;
|
||||||
|
|
||||||
|
$entity->userid=Auth::user()->id;
|
||||||
|
$entity->fileid=$request->get('fileid');
|
||||||
|
$entity->rscfile=$rsc;
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New File Result Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/fluttercourse/?topicList='.$fileinfo['topic'])->with( [ 'topic' => $request->get('topic') ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Request $request,$id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\FileResult::find($id);
|
||||||
|
|
||||||
|
$path = storage_path('app\\public\\').$entity['rscfile'];
|
||||||
|
//$path = str_replace('\\',DIRECTORY_SEPARATOR,$path);
|
||||||
|
|
||||||
|
//$dirpath = storage_path('app\public\\');
|
||||||
|
File::delete(getPath($path));
|
||||||
|
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('File Result with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('student/fluttercourse/?topicList='.$request->get('topic'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function delete($id,$topic)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\FileResult::find($id);
|
||||||
|
|
||||||
|
$path = storage_path('app\\public\\').$entity['rscfile'];
|
||||||
|
//$path = str_replace('\\',DIRECTORY_SEPARATOR,$path);
|
||||||
|
|
||||||
|
//$dirpath = storage_path('app\public\\');
|
||||||
|
File::delete($path);
|
||||||
|
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('File Result with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('student/fluttercourse/?topicList='.$topic.'&option=files');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function submit($id) {
|
||||||
|
//
|
||||||
|
$entity=new \App\StudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=Auth::user()->id;
|
||||||
|
$entity->topic=$id;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$topic = \App\Topic::find($id);
|
||||||
|
Session::flash('message','Topic '.$topic['name'].' Validation is Success');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/fluttercourse/?topicList='.$id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPath($path) {
|
||||||
|
$res = str_replace('\\',DIRECTORY_SEPARATOR,$path);
|
||||||
|
return str_replace('/',DIRECTORY_SEPARATOR,$res);
|
||||||
|
}
|
||||||
|
}
|
||||||
249
app/Http/Controllers/FlutterController.php
Normal file
249
app/Http/Controllers/FlutterController.php
Normal file
|
|
@ -0,0 +1,249 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class FlutterController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request) {
|
||||||
|
if (Auth::user()->roleid=='student/fluttercourse') {
|
||||||
|
$check=\App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status!='active') return view('student/fluttercourse/home')->with(['status'=>$check->status]);
|
||||||
|
}
|
||||||
|
$topiclist=\App\FlutterTopic::where('status','=','1')
|
||||||
|
->orderBy('name','asc')->get();
|
||||||
|
|
||||||
|
$items = \App\FlutterTopic::where('status','=','1')
|
||||||
|
->orderBy('status','desc')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
$itemslearning = \App\FlutterTopic::where('status','=','1')
|
||||||
|
->orderBy('status','desc')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->where('level','=','1')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
$filter = $request->input('topicList',$topiclist[0]['id']);
|
||||||
|
|
||||||
|
if ($filter=='0') {
|
||||||
|
$entities=\App\FlutterTask::all();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$entities = \App\FlutterTask::where('topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'tasks.id',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'tasks.topic',
|
||||||
|
'topics.name'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'topics',
|
||||||
|
'topics.id','=','tasks.topic'
|
||||||
|
)
|
||||||
|
->orderBy('tasks.taskno','asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Auth::user()->roleid=='admin') {
|
||||||
|
return view('admin/tasks/index')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('items'))
|
||||||
|
->with(compact('filter'));
|
||||||
|
} else {
|
||||||
|
$topic = \App\FlutterTopic::where('topics.id','=',$filter)
|
||||||
|
->select(
|
||||||
|
'topics.id',
|
||||||
|
'topics.name',
|
||||||
|
'topics.desc',
|
||||||
|
'learning_files.guide',
|
||||||
|
'learning_files.testfile',
|
||||||
|
'learning_files.supplement',
|
||||||
|
'learning_files.other'
|
||||||
|
)
|
||||||
|
->leftJoin('learning_files', 'learning_files.topic', '=', 'topics.id')
|
||||||
|
->first();
|
||||||
|
return view('student/fluttercourse/tasks/index')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('items'))
|
||||||
|
->with(compact('itemslearning'))
|
||||||
|
->with(compact('filter'))
|
||||||
|
->with(compact('topic'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getTopic($id){
|
||||||
|
$items = \App\FlutterTopic::find($id);
|
||||||
|
|
||||||
|
return $items['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function filterTask() {
|
||||||
|
$filters = \App\FlutterTopic::get();
|
||||||
|
$filter = \App\FlutterTopic::findOrFail(Input::get('filter_id'));
|
||||||
|
|
||||||
|
$data= \App\FlutterTask::with('topic')->where('topic', '=' , $filter->id )->latest()->get();
|
||||||
|
|
||||||
|
return View::make('admin.tasks.index',compact('filters'))->withProfiles($data)->with('title', 'filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$items = \App\FlutterTopic::pluck('name', 'id');
|
||||||
|
//echo "kljasd;lkasdl";
|
||||||
|
return view('admin/tasks/create')->with(compact('items'));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//echo "YAAANNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN";
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'taskno'=>'required',
|
||||||
|
'desc'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'taskno.required'=>'Task number must not empty',
|
||||||
|
'desc.required'=>'Description must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('admin/tasks/create')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$entity=new \App\FlutterTask;
|
||||||
|
|
||||||
|
$entity->desc=$request->get('desc');
|
||||||
|
$entity->taskno=$request->get('taskno');
|
||||||
|
$entity->topic=$request->get('topic');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New Task Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('admin/tasks');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show(Request $request, $id)
|
||||||
|
{
|
||||||
|
$entity = \App\FlutterTask::find($id);
|
||||||
|
$topic = \App\FlutterTopic::find($entity->topic);
|
||||||
|
$x=['data'=>$entity, 'topic'=>$topic];
|
||||||
|
|
||||||
|
if ($request->is('admin/*')) {
|
||||||
|
return view('admin/tasks/show')->with($x);
|
||||||
|
} else {
|
||||||
|
return view('student/fluttercourse/tasks/show')->with($x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\FlutterTask::find($id);
|
||||||
|
$x=['data'=>$entity];
|
||||||
|
$items = \App\FlutterTopic::pluck('name', 'id');
|
||||||
|
return view('admin/tasks/edit')->with($x)->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'taskno'=>'required',
|
||||||
|
'desc'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'taskno.required'=>'Task number must not empty',
|
||||||
|
'desc.required'=>'Description must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('admin/topics/'.$id.'/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$entity=\App\FlutterTask::find($id);
|
||||||
|
|
||||||
|
$entity->desc=$request->get('desc');
|
||||||
|
$entity->taskno=$request->get('taskno');
|
||||||
|
$entity->topic=$request->get('topic');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','Task with Id='.$id.' is changed');
|
||||||
|
|
||||||
|
return Redirect::to('admin/tasks');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\FlutterTask::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message','Task with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('admin/tasks');
|
||||||
|
}
|
||||||
|
}
|
||||||
131
app/Http/Controllers/FlutterFileResultController.php
Normal file
131
app/Http/Controllers/FlutterFileResultController.php
Normal file
|
|
@ -0,0 +1,131 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class FlutterFileResultController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function create($id) {
|
||||||
|
//
|
||||||
|
$topic = \App\Topic::find($id);
|
||||||
|
$files = \App\TopicFiles::where('topic','=',$id)->get();
|
||||||
|
|
||||||
|
return view('student/fluttercourse/lfiles/create')
|
||||||
|
->with(compact('files'))
|
||||||
|
->with(compact('topic'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'rscfile'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'rscfile.required'=>'Resource File must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('student/fluttercourse/lfiles/create/'.$request->get('topic'))
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
$file = $request->file('rscfile');
|
||||||
|
$filename = $file->getClientOriginalName();
|
||||||
|
|
||||||
|
$fileinfo = \App\TopicFiles::find($request->get('fileid'));
|
||||||
|
if ($fileinfo['fileName']!=$filename) {
|
||||||
|
return Redirect::to('student/fluttercourse/lfiles/create/'.$request->get('topic'))
|
||||||
|
->withErrors("File name should be ".$fileinfo['fileName']);
|
||||||
|
} else {
|
||||||
|
$result = \App\FileResult::where('userid','=',Auth::user()->id)
|
||||||
|
->where('fileid','=',$request->get('fileid'))
|
||||||
|
->get();
|
||||||
|
if (count($result)>0) {
|
||||||
|
return Redirect::to('student/fluttercourse/lfiles/create/'.$request->get('topic'))
|
||||||
|
->withErrors('File '.$fileinfo['fileName'].' was already submitted');
|
||||||
|
} else {
|
||||||
|
$rsc=$file->store('resource','public');
|
||||||
|
$entity=new \App\FileResult;
|
||||||
|
|
||||||
|
$entity->userid=Auth::user()->id;
|
||||||
|
$entity->fileid=$request->get('fileid');
|
||||||
|
$entity->rscfile=$rsc;
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New File Result Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$fileinfo['topic'])->with( [ 'topic' => $request->get('topic') ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Request $request,$id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\FileResult::find($id);
|
||||||
|
|
||||||
|
$path = storage_path('app\\public\\').$entity['rscfile'];
|
||||||
|
//$path = str_replace('\\',DIRECTORY_SEPARATOR,$path);
|
||||||
|
|
||||||
|
//$dirpath = storage_path('app\public\\');
|
||||||
|
File::delete(getPath($path));
|
||||||
|
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('File Result with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$request->get('topic'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function delete($id,$topic)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\FileResult::find($id);
|
||||||
|
|
||||||
|
$path = storage_path('app\\public\\').$entity['rscfile'];
|
||||||
|
//$path = str_replace('\\',DIRECTORY_SEPARATOR,$path);
|
||||||
|
|
||||||
|
//$dirpath = storage_path('app\public\\');
|
||||||
|
File::delete($path);
|
||||||
|
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('File Result with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$topic.'&option=files');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function submit($id) {
|
||||||
|
//
|
||||||
|
$entity=new \App\StudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=Auth::user()->id;
|
||||||
|
$entity->topic=$id;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$topic = \App\FlutterTopic::find($id);
|
||||||
|
Session::flash('message','Topic '.$topic['name'].' Validation is Success');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPath($path) {
|
||||||
|
$res = str_replace('\\',DIRECTORY_SEPARATOR,$path);
|
||||||
|
return str_replace('/',DIRECTORY_SEPARATOR,$res);
|
||||||
|
}
|
||||||
|
}
|
||||||
404
app/Http/Controllers/FlutterResultController.php
Normal file
404
app/Http/Controllers/FlutterResultController.php
Normal file
|
|
@ -0,0 +1,404 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class FlutterResultController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request) {
|
||||||
|
//$check=\App\StudentTeacher::where('student','=',Auth::user()->id);
|
||||||
|
//if ($check->count()==0) return view('student/home')->with(['count'=>$check->count()]);
|
||||||
|
$check=\App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status!='active') return view('student/fluttercourse/home')->with(['status'=>$check->status]);
|
||||||
|
|
||||||
|
$filter = $request->input('topicList','6');
|
||||||
|
if ($filter=='0') {
|
||||||
|
$entities=\App\FlutterTaskResult::where('userid','=',Auth::user()->id);
|
||||||
|
} else {
|
||||||
|
$entities = \App\FlutterTask::where('tasks.topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'task_results.id',
|
||||||
|
'task_results.taskid',
|
||||||
|
'task_results.userid',
|
||||||
|
'task_results.status',
|
||||||
|
'task_results.duration',
|
||||||
|
'task_results.comment',
|
||||||
|
'task_results.imgFile',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'tasks.topic'
|
||||||
|
)
|
||||||
|
->leftJoin('task_results', function($join)
|
||||||
|
{
|
||||||
|
$join->on('tasks.id','=','task_results.taskid')
|
||||||
|
->where('task_results.userid', '=', Auth::user()->id);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->orderBy('tasks.taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$lfiles = \App\FlutterTopicFiles::where('topic_files.topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'file_results.id',
|
||||||
|
'file_results.userid',
|
||||||
|
'file_results.rscfile',
|
||||||
|
'file_results.fileid',
|
||||||
|
'topic_files.fileName',
|
||||||
|
'topic_files.path',
|
||||||
|
'topic_files.desc'
|
||||||
|
)
|
||||||
|
->leftJoin('file_results', function($join)
|
||||||
|
{
|
||||||
|
$join->on('topic_files.id','=','file_results.fileid')
|
||||||
|
->where('file_results.userid', '=', Auth::user()->id);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->orderBy('topic_files.fileName', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$items = \App\FlutterTopic::
|
||||||
|
where('status','>=','0')
|
||||||
|
->where('androidclass','=','AndroidX')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->orderBy('level','asc')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
$valid = \App\FlutterStudentSubmit::where('userid','=',Auth::user()->id)
|
||||||
|
->where('topic','=',$filter)
|
||||||
|
->get()->count();
|
||||||
|
|
||||||
|
$option = $request->input('option','github');
|
||||||
|
|
||||||
|
$currtopic = \App\FlutterTopic::find($filter);
|
||||||
|
|
||||||
|
return view('student/fluttercourse/results/index')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('lfiles'))
|
||||||
|
->with(compact('items'))
|
||||||
|
->with(compact('filter'))
|
||||||
|
->with(compact('option'))
|
||||||
|
->with(compact('currtopic'))
|
||||||
|
->with(compact('valid'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function getTaskData($topic) {
|
||||||
|
$items = \App\FlutterTask::where('tasks.topic','=',$topic)
|
||||||
|
->select(
|
||||||
|
'tasks.id',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'topics.name'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'topics',
|
||||||
|
'topics.id','=','tasks.topic'
|
||||||
|
)
|
||||||
|
->orderBy('topics.name', 'asc')
|
||||||
|
->orderBy('tasks.taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
public function create($id)
|
||||||
|
{
|
||||||
|
$items = \App\FlutterTask::where('topic','=',$id)
|
||||||
|
->orderBy('taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
$topic = \App\FlutterTopic::find($id);
|
||||||
|
return view('student/fluttercourse/results/create')
|
||||||
|
->with(compact('topic'))
|
||||||
|
->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateByFiles($userid, $topic) {
|
||||||
|
//
|
||||||
|
$entity=new \App\FlutterStudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\FlutterTopic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation is Success');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$topic.'&option=files');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateZipFile($userid, $topic, $file, $path) {
|
||||||
|
//
|
||||||
|
//$file = $request->file('zipfile');
|
||||||
|
if ($path!='' ) {
|
||||||
|
//$array = explode('.', $path);
|
||||||
|
//$ext = strtolower(end($array));
|
||||||
|
$ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||||
|
if ($ext=="zip") {
|
||||||
|
$zipFile=$file->store('results','public');
|
||||||
|
|
||||||
|
if ($zipFile!='') {
|
||||||
|
$entity=new \App\FlutterStudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->projectfile=$zipFile;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\FlutterTopic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation by Uploading Zip Project is Success');
|
||||||
|
} else {
|
||||||
|
Session::flash('message','Storing file '.$request->file('zipfile').' was FAILED');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Session::flash('message','File extension is not zip -> '.$path.' is wrong .'.$ext);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Session::flash('message','Zip File is empty');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$topic.'&option=zipfile');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function validateGithubLink($userid, $topic, $link, $projname) {
|
||||||
|
//
|
||||||
|
$trimmedlink = trim($link);
|
||||||
|
if ($this->validateUrl($trimmedlink,$projname)) {
|
||||||
|
/*
|
||||||
|
$zipFile=$file->store('results','public');
|
||||||
|
|
||||||
|
if ($zipFile!='') {
|
||||||
|
$entity=new \App\FlutterStudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->projectfile=$zipFile;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\FlutterTopic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation is Success');
|
||||||
|
} else {
|
||||||
|
Session::flash('message','Storing file '.$request->file('zipfile').' was FAILED');
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
$entity=new \App\FlutterStudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->githublink=$trimmedlink;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\FlutterTopic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation by submitting GitHub link is Success');
|
||||||
|
|
||||||
|
//Session::flash('message','URL valid '.$link);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Session::flash('message','URL is not VALID '.$link);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$topic.'&option=github');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateUrl($url,$projname) {
|
||||||
|
$path = parse_url($url, PHP_URL_PATH);
|
||||||
|
$encoded_path = array_map('urlencode', explode('/', $path));
|
||||||
|
$url = str_replace($path, implode('/', $encoded_path), $url);
|
||||||
|
|
||||||
|
if (filter_var($url, FILTER_VALIDATE_URL)) {
|
||||||
|
$result = parse_url($url);
|
||||||
|
if ( ($result['scheme']=='https') && ($this->endsWith($result['host'],'github.com'))
|
||||||
|
&& (strpos($result['path'],$projname)) ) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function endsWith($haystack, $needle) {
|
||||||
|
return substr_compare($haystack, $needle, -strlen($needle)) === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function saveTaskResult(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'duration'=>'required',
|
||||||
|
'image'=>'required',
|
||||||
|
'comment'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'duration.required'=>'Duration time must not empty',
|
||||||
|
'image.required'=>'Evidence image file must not empty',
|
||||||
|
'comment.required'=>'Comment must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('student/fluttercourse/results/create/'.$request->get('topic'))
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$check = \App\FlutterTaskResult::where('userid','=',Auth::user()->id)
|
||||||
|
->where('taskid','=',$request->get('taskid'))
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if (sizeof($check)>0) {
|
||||||
|
$task = \App\FlutterTask::find($request->get('taskid'));
|
||||||
|
$message = 'Result of Task '.$task['desc'].' is already submitted!!';
|
||||||
|
//Session::flash('message',);
|
||||||
|
return Redirect::to('student/fluttercourse/results/create'.$request->get('topic'))->withErrors($message);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$file = $request->file('image');
|
||||||
|
$imgFile=$file->store('results','public');
|
||||||
|
|
||||||
|
$entity=new \App\FlutterTaskResult;
|
||||||
|
|
||||||
|
$comment = ($request->get('comment')==null)?'-':$request->get('comment');
|
||||||
|
|
||||||
|
$entity->userid=Auth::user()->id;
|
||||||
|
$entity->taskid=$request->get('taskid');
|
||||||
|
$entity->status=$request->get('status');
|
||||||
|
$entity->duration=$request->get('duration');
|
||||||
|
$entity->comment=$comment;
|
||||||
|
$entity->imgFile=$imgFile;
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New Task Result Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$request->get('topic'))->with( [ 'topic' => $request->get('topic') ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
if (strlen($request->get('option'))>3) {
|
||||||
|
if (($request->get('action')=='validate') && (strlen($request->submitbutton)>5)) {
|
||||||
|
if ($request->get('option')=='files') {
|
||||||
|
return $this->validateByFiles(Auth::user()->id, $request->get('topic'));
|
||||||
|
} else if ($request->get('option')=='zipfile') {
|
||||||
|
$file = $request->file('zipfile');
|
||||||
|
$filename = $file->getClientOriginalName();
|
||||||
|
return $this->validateZipFile(Auth::user()->id, $request->get('topic'), $file, $filename);
|
||||||
|
} else if ($request->get('option')=='github') {
|
||||||
|
return $this->validateGithubLink(Auth::user()->id, $request->get('topic'), $request->get('githublink'),
|
||||||
|
$request->get('projname'));
|
||||||
|
} else {
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$request->get('topic').'&option='.$request->get('option').
|
||||||
|
'&submit='.$request->submitbutton);
|
||||||
|
}
|
||||||
|
} else { //clicking radio button
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$request->get('topic').'&option='.$request->get('option'));
|
||||||
|
//'&submit='.$request->submitbutton);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { //echo $request;
|
||||||
|
return $this->saveTaskResult($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function destroy(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\FlutterTaskResult::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message','Task Result with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$request->get('topic'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\FlutterTaskResult::where('id','=',$id)->first();
|
||||||
|
$task = \App\FlutterTask::where('id','=',$entity['taskid'])->first();
|
||||||
|
return view('student/fluttercourse/results/edit')->with(compact('entity'))
|
||||||
|
->with(compact('task'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function valsub(Request $request)
|
||||||
|
{
|
||||||
|
$items = \App\FlutterTask::where('topic','=',$id)
|
||||||
|
->orderBy('taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
$topic = \App\FlutterTopic::find($id);
|
||||||
|
return view('student/fluttercourse/results/create')
|
||||||
|
->with(compact('topic'))
|
||||||
|
->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function update(Request $request, $id) {
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'duration'=>'required',
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'duration.required'=>'Duration time must not empty',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('student/fluttercourse/results/'.$id.'/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$file = $request->file('image');
|
||||||
|
|
||||||
|
$entity=\App\FlutterTaskResult::find($id);
|
||||||
|
|
||||||
|
$entity->taskid=$request->get('taskid');
|
||||||
|
$entity->status=$request->get('status');
|
||||||
|
$entity->duration=$request->get('duration');
|
||||||
|
$entity->comment=$request->get('comment');
|
||||||
|
|
||||||
|
if ($file!='') {
|
||||||
|
$imgFile=$file->store('results','public');
|
||||||
|
$entity->imgFile=$imgFile;
|
||||||
|
}
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','Task Result with Id='.$id.' is changed');
|
||||||
|
|
||||||
|
$task = \App\FlutterTask::find($request->get('taskid'));
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$task['topic']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
379
app/Http/Controllers/FlutterTaskResultController.php
Normal file
379
app/Http/Controllers/FlutterTaskResultController.php
Normal file
|
|
@ -0,0 +1,379 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class FlutterTaskResultController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request) {
|
||||||
|
$check=\App\FlutterUser::find(Auth::user()->id);
|
||||||
|
if ($check->status!='active') return view('student/fluttercourse/home')->with(['status'=>$check->status]);
|
||||||
|
|
||||||
|
$filter = $request->input('topicList','6');
|
||||||
|
if ($filter=='0') {
|
||||||
|
$entities=\App\FlutterTaskResult::where('userid','=',Auth::user()->id);
|
||||||
|
} else {
|
||||||
|
$entities = \App\FlutterTask::where('tasks.topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'task_results.id',
|
||||||
|
'task_results.taskid',
|
||||||
|
'task_results.userid',
|
||||||
|
'task_results.status',
|
||||||
|
'task_results.duration',
|
||||||
|
'task_results.comment',
|
||||||
|
'task_results.imgFile',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'tasks.topic'
|
||||||
|
)
|
||||||
|
->leftJoin('task_results', function($join)
|
||||||
|
{
|
||||||
|
$join->on('tasks.id','=','task_results.taskid')
|
||||||
|
->where('task_results.userid', '=', Auth::user()->id);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->orderBy('tasks.taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$lfiles = \App\FlutterTopicFiles::where('topic_files.topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'file_results.id',
|
||||||
|
'file_results.userid',
|
||||||
|
'file_results.rscfile',
|
||||||
|
'file_results.fileid',
|
||||||
|
'topic_files.fileName',
|
||||||
|
'topic_files.path',
|
||||||
|
'topic_files.desc'
|
||||||
|
)
|
||||||
|
->leftJoin('file_results', function($join)
|
||||||
|
{
|
||||||
|
$join->on('topic_files.id','=','file_results.fileid')
|
||||||
|
->where('file_results.userid', '=', Auth::user()->id);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->orderBy('topic_files.fileName', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$items = \App\FlutterTopic::
|
||||||
|
where('status','>=','0')
|
||||||
|
->where('androidclass','=','AndroidX')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->orderBy('level','asc')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
$valid = \App\FlutterStudentSubmit::where('userid','=',Auth::user()->id)
|
||||||
|
->where('topic','=',$filter)
|
||||||
|
->get()->count();
|
||||||
|
|
||||||
|
$option = $request->input('option','github');
|
||||||
|
|
||||||
|
$currtopic = \App\FlutterTopic::find($filter);
|
||||||
|
|
||||||
|
return view('student/fluttercourse/results/index')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('lfiles'))
|
||||||
|
->with(compact('items'))
|
||||||
|
->with(compact('filter'))
|
||||||
|
->with(compact('option'))
|
||||||
|
->with(compact('currtopic'))
|
||||||
|
->with(compact('valid'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function getTaskData($topic) {
|
||||||
|
$items = \App\FlutterTask::where('tasks.topic','=',$topic)
|
||||||
|
->select(
|
||||||
|
'tasks.id',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'topics.name'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'topics',
|
||||||
|
'topics.id','=','tasks.topic'
|
||||||
|
)
|
||||||
|
->orderBy('topics.name', 'asc')
|
||||||
|
->orderBy('tasks.taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
public function create($id)
|
||||||
|
{
|
||||||
|
$items = \App\FlutterTask::where('topic','=',$id)
|
||||||
|
->orderBy('taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
$topic = \App\FlutterTopic::find($id);
|
||||||
|
return view('student/fluttercourse/results/create')
|
||||||
|
->with(compact('topic'))
|
||||||
|
->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateByFiles($userid, $topic) {
|
||||||
|
//
|
||||||
|
$entity=new \App\FlutterStudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\FlutterTopic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation is Success');
|
||||||
|
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$topic.'&option=files');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateZipFile($userid, $topic, $file, $path) {
|
||||||
|
|
||||||
|
if ($path!='' ) {
|
||||||
|
$ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||||
|
if ($ext=="zip") {
|
||||||
|
$zipFile=$file->store('results','public');
|
||||||
|
|
||||||
|
if ($zipFile!='') {
|
||||||
|
$entity=new \App\FlutterStudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->projectfile=$zipFile;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\FlutterTopic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation by Uploading Zip Project is Success');
|
||||||
|
} else {
|
||||||
|
Session::flash('message','Storing file '.$request->file('zipfile').' was FAILED');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Session::flash('message','File extension is not zip -> '.$path.' is wrong .'.$ext);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Session::flash('message','Zip File is empty');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$topic.'&option=zipfile');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateGithubLink($userid, $topic, $link, $projname) {
|
||||||
|
//
|
||||||
|
$trimmedlink = trim($link);
|
||||||
|
if ($this->validateUrl($trimmedlink,$projname)) {
|
||||||
|
|
||||||
|
$entity=new \App\FlutterStudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->githublink=$trimmedlink;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\FlutterTopic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation by submitting GitHub link is Success');
|
||||||
|
|
||||||
|
//Session::flash('message','URL valid '.$link);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Session::flash('message','URL is not VALID '.$link);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$topic.'&option=github');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateUrl($url,$projname) {
|
||||||
|
$path = parse_url($url, PHP_URL_PATH);
|
||||||
|
$encoded_path = array_map('urlencode', explode('/', $path));
|
||||||
|
$url = str_replace($path, implode('/', $encoded_path), $url);
|
||||||
|
|
||||||
|
if (filter_var($url, FILTER_VALIDATE_URL)) {
|
||||||
|
$result = parse_url($url);
|
||||||
|
if ( ($result['scheme']=='https') && ($this->endsWith($result['host'],'github.com'))
|
||||||
|
&& (strpos($result['path'],$projname)) ) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function endsWith($haystack, $needle) {
|
||||||
|
return substr_compare($haystack, $needle, -strlen($needle)) === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function saveTaskResult(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'duration'=>'required',
|
||||||
|
'image'=>'required',
|
||||||
|
'comment'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'duration.required'=>'Duration time must not empty',
|
||||||
|
'image.required'=>'Evidence image file must not empty',
|
||||||
|
'comment.required'=>'Comment must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('student/fluttercourse/results/create/'.$request->get('topic'))
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$check = \App\FlutterTaskResult::where('userid','=',Auth::user()->id)
|
||||||
|
->where('taskid','=',$request->get('taskid'))
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if (sizeof($check)>0) {
|
||||||
|
$task = \App\FlutterTask::find($request->get('taskid'));
|
||||||
|
$message = 'Result of Task '.$task['desc'].' is already submitted!!';
|
||||||
|
//Session::flash('message',);
|
||||||
|
return Redirect::to('student/fluttercourse/results/create'.$request->get('topic'))->withErrors($message);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$file = $request->file('image');
|
||||||
|
$imgFile=$file->store('result','public');
|
||||||
|
|
||||||
|
$entity=new \App\FlutterTaskResult;
|
||||||
|
|
||||||
|
$comment = ($request->get('comment')==null)?'-':$request->get('comment');
|
||||||
|
|
||||||
|
$entity->userid=Auth::user()->id;
|
||||||
|
$entity->taskid=$request->get('taskid');
|
||||||
|
$entity->status=$request->get('status');
|
||||||
|
$entity->duration=$request->get('duration');
|
||||||
|
$entity->comment=$comment;
|
||||||
|
$entity->imgFile=$imgFile;
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New Task Result Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$request->get('topic'))->with( [ 'topic' => $request->get('topic') ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
if (strlen($request->get('option'))>3) {
|
||||||
|
if (($request->get('action')=='validate') && (strlen($request->submitbutton)>5)) {
|
||||||
|
if ($request->get('option')=='files') {
|
||||||
|
return $this->validateByFiles(Auth::user()->id, $request->get('topic'));
|
||||||
|
} else if ($request->get('option')=='zipfile') {
|
||||||
|
$file = $request->file('zipfile');
|
||||||
|
$filename = $file->getClientOriginalName();
|
||||||
|
return $this->validateZipFile(Auth::user()->id, $request->get('topic'), $file, $filename);
|
||||||
|
} else if ($request->get('option')=='github') {
|
||||||
|
return $this->validateGithubLink(Auth::user()->id, $request->get('topic'), $request->get('githublink'),
|
||||||
|
$request->get('projname'));
|
||||||
|
} else {
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$request->get('topic').'&option='.$request->get('option').
|
||||||
|
'&submit='.$request->submitbutton);
|
||||||
|
}
|
||||||
|
} else { //clicking radio button
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$request->get('topic').'&option='.$request->get('option'));
|
||||||
|
//'&submit='.$request->submitbutton);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { //echo $request;
|
||||||
|
return $this->saveTaskResult($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function destroy(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\FlutterTaskResult::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message','Task Result with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$request->get('topic'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\FlutterTaskResult::where('id','=',$id)->first();
|
||||||
|
$task = \App\FlutterTask::where('id','=',$entity['taskid'])->first();
|
||||||
|
return view('student/fluttercourse/results/edit')->with(compact('entity'))
|
||||||
|
->with(compact('task'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function valsub(Request $request)
|
||||||
|
{
|
||||||
|
$items = \App\FlutterTask::where('topic','=',$id)
|
||||||
|
->orderBy('taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
$topic = \App\FlutterTopic::find($id);
|
||||||
|
return view('student/fluttercourse/results/create')
|
||||||
|
->with(compact('topic'))
|
||||||
|
->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function update(Request $request, $id) {
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'duration'=>'required',
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'duration.required'=>'Duration time must not empty',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('student/fluttercourse/results/'.$id.'/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$file = $request->file('image');
|
||||||
|
|
||||||
|
$entity=\App\FlutterTaskResult::find($id);
|
||||||
|
|
||||||
|
$entity->taskid=$request->get('taskid');
|
||||||
|
$entity->status=$request->get('status');
|
||||||
|
$entity->duration=$request->get('duration');
|
||||||
|
$entity->comment=$request->get('comment');
|
||||||
|
|
||||||
|
if ($file!='') {
|
||||||
|
$imgFile=$file->store('results','public');
|
||||||
|
$entity->imgFile=$imgFile;
|
||||||
|
}
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','Task Result with Id='.$id.' is changed');
|
||||||
|
|
||||||
|
$task = \App\FlutterTask::find($request->get('taskid'));
|
||||||
|
return Redirect::to('student/fluttercourse/results?topicList='.$task['topic']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
48
app/Http/Controllers/HomeController.php
Normal file
48
app/Http/Controllers/HomeController.php
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
// if (Auth::user()->roleid == 'student') {
|
||||||
|
// //$check=\App\StudentTeacher::where('student','=',Auth::user()->id);
|
||||||
|
// //return view('/student/main')->with(['count'=>$check->count()]);
|
||||||
|
// $check=\App\User::find(Auth::user()->id);
|
||||||
|
// return view('/student/main')->with(['status'=>$check->status]);
|
||||||
|
// } else if (Auth::user()->roleid == 'admin') {
|
||||||
|
// return view('/admin/admin');
|
||||||
|
// } else {
|
||||||
|
// return view('/teacher/home');
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (Auth::user()->roleid == 'student') {
|
||||||
|
$check=\App\StudentTeacher::where('student','=',Auth::user()->id);
|
||||||
|
return view('/student/landingpage')->with(['count'=>$check->count()]);
|
||||||
|
} else if (Auth::user()->roleid == 'admin') {
|
||||||
|
return view('/admin/admin');
|
||||||
|
} else {
|
||||||
|
return view('/teacher/home');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
134
app/Http/Controllers/JplasDownloadController.php
Normal file
134
app/Http/Controllers/JplasDownloadController.php
Normal file
|
|
@ -0,0 +1,134 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class JplasDownloadController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
/*
|
||||||
|
$entities=\App\StudentRank::orderBy('score','desc')
|
||||||
|
->orderBy('last_submit','asc')
|
||||||
|
->offset(0)->limit(20)->get();
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
if (Auth::user()->roleid == "admin") {
|
||||||
|
return view('admin/rankview/index')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == "teacher") {
|
||||||
|
return view('teacher/rankview/index')->with($data);
|
||||||
|
} else {
|
||||||
|
return view('student/rankview/index')->with($data);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if (Auth::user()->roleid == "admin") {
|
||||||
|
|
||||||
|
} else if (Auth::user()->roleid == "teacher") {
|
||||||
|
$filter = $request->input('stdList',1);
|
||||||
|
|
||||||
|
$entities=\App\JplasResult::where('jplas_results.jplasid','=',$filter)
|
||||||
|
->select('jplas_results.id','jplas_results.filename','jplas_results.comment','jplas_results.filepath',
|
||||||
|
'jplas_results.userid as userid','std.name as stdname','classrooms.name as cname','tc.name as tcname',
|
||||||
|
'jplas_results.created_at','jplas_results.jplasid')
|
||||||
|
->join('class_members','jplas_results.userid','=','class_members.student')
|
||||||
|
->join('classrooms','classrooms.id','=','class_members.classid')
|
||||||
|
->join('users as std','std.id','=','jplas_results.userid')
|
||||||
|
->join('users as tc','tc.id','=','std.uplink')
|
||||||
|
->where('jplas_results.userid','>',5)
|
||||||
|
->orderBy('jplas_results.created_at','desc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$items = \App\JplasTopic::orderBy('id','asc')->get();
|
||||||
|
|
||||||
|
$data=['entities'=>$entities, 'items'=>$items, 'filter'=>$filter];
|
||||||
|
|
||||||
|
return view('teacher/jplasdown/index')->with($data);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$entities=\App\JplasTopic::orderBy('jplas_topics.id','asc')
|
||||||
|
->select('jplas_topics.id','jplas_topics.name','jplas_topics.packfile','jplas_topics.docfile',
|
||||||
|
'jplas_results.filename','jplas_results.comment')
|
||||||
|
->leftJoin('jplas_results',function($join) {
|
||||||
|
$join->on('jplas_topics.id','=','jplas_results.jplasid');
|
||||||
|
$join->on('jplas_results.userid','=',DB::raw("'".Auth::user()->id."'"));
|
||||||
|
})
|
||||||
|
->get();
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
|
||||||
|
return view('student/jplasdown/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create() {
|
||||||
|
$items = \App\JplasTopic::orderBy('id', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return view('student/jplasdown/create')->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'comment'=>'required',
|
||||||
|
'image'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'comment.required'=>'Comment must not empty',
|
||||||
|
'image.required'=>'Result file must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('student/jplasdown/create')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$check = \App\JplasResult::where('userid','=',Auth::user()->id)
|
||||||
|
->where('jplasid','=',$request->get('taskid'))
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$task = \App\JplasTopic::find($request->get('taskid'));
|
||||||
|
if (sizeof($check)>0) {
|
||||||
|
$entity = \App\JplasResult::find($check[0]['id']);
|
||||||
|
$message = 'The Result of Lesson '.$task['name'].' was updated!!';
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$entity=new \App\JplasResult;
|
||||||
|
$message = 'The Result of Lesson '.$task['name'].' was stored!!';
|
||||||
|
|
||||||
|
}
|
||||||
|
$file = $request->file('image');
|
||||||
|
$imgFile=$file->store('results','public');
|
||||||
|
|
||||||
|
//$entity=new \App\JplasResult;
|
||||||
|
|
||||||
|
$entity->userid=Auth::user()->id;
|
||||||
|
$entity->jplasid=$request->get('taskid');
|
||||||
|
$entity->filename=$request->file('image')->getClientOriginalName();
|
||||||
|
$entity->filepath=$imgFile;
|
||||||
|
$entity->comment=$request->get('comment');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message',$message);
|
||||||
|
|
||||||
|
return Redirect::to('student/jplasdown/');
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
197
app/Http/Controllers/LearningFileController.php
Normal file
197
app/Http/Controllers/LearningFileController.php
Normal file
|
|
@ -0,0 +1,197 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class LearningFileController extends Controller {
|
||||||
|
|
||||||
|
protected $filepath = 'public';
|
||||||
|
protected $dirname = 'learning';
|
||||||
|
|
||||||
|
|
||||||
|
public function index(Request $request) {
|
||||||
|
$entities = \App\LearningFile::select(
|
||||||
|
'learning_files.id',
|
||||||
|
'learning_files.guide',
|
||||||
|
'learning_files.testfile',
|
||||||
|
'learning_files.supplement',
|
||||||
|
'learning_files.other',
|
||||||
|
'learning_files.desc',
|
||||||
|
'topics.name'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'topics',
|
||||||
|
'topics.id','=','learning_files.topic'
|
||||||
|
)
|
||||||
|
->orderBy('topics.name','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
//$items = \App\Topic::all();
|
||||||
|
if (Auth::user()->roleid=='admin') {
|
||||||
|
return view('admin/learning/index')->with(compact('entities'));
|
||||||
|
} else {
|
||||||
|
return view('student/lfiles/index')->with(compact('entities'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$items = \App\Topic::pluck('name', 'id');
|
||||||
|
|
||||||
|
return view('admin/learning/create')->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'guide'=>'required',
|
||||||
|
'testfile'=>'required',
|
||||||
|
'supplement'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'guide.required'=>'Guide file must not empty',
|
||||||
|
'testfile.required'=>'Test file must not empty',
|
||||||
|
'supplement.required'=>'Supplement file must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('admin/learning/create')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$check = \App\LearningFile::where('topic','=',$request->get('topic'))->get();
|
||||||
|
|
||||||
|
if (sizeof($check)>0) {
|
||||||
|
$topic = \App\Topic::find($request->get('topic'));
|
||||||
|
$message = 'Learning File of '.$topic['name'].' is already exist!!';
|
||||||
|
//Session::flash('message',);
|
||||||
|
return Redirect::to('admin/learning/create')->withErrors($message);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$entity=new \App\LearningFile;
|
||||||
|
|
||||||
|
$entity->topic=$request->get('topic');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$file1=$request->file('guide')->store($this->dirname,$this->filepath);
|
||||||
|
$entity->guide=$file1;
|
||||||
|
|
||||||
|
$file2=$request->file('testfile')->store($this->dirname,$this->filepath);
|
||||||
|
$entity->testfile=$file2;
|
||||||
|
|
||||||
|
$file3=$request->file('supplement')->store($this->dirname,$this->filepath);
|
||||||
|
$entity->supplement=$file3;
|
||||||
|
|
||||||
|
$file4=$request->file('other');
|
||||||
|
if ($file4 != '') {
|
||||||
|
$file4=$request->file('other')->store($this->dirname,$this->filepath);
|
||||||
|
$entity->other=$file4;
|
||||||
|
}
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New Learning File Stored');
|
||||||
|
|
||||||
|
return Redirect::to('admin/learning');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTopic($fileid) {
|
||||||
|
$item = \App\LearningFile::find($fileid);
|
||||||
|
return $item->topic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$topic = \App\Topic::find($this->getTopic($id));
|
||||||
|
$x=['data'=>$topic];
|
||||||
|
$fileid = $id;
|
||||||
|
return view('admin/learning/edit')->with($x)->with(compact('fileid'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id) {
|
||||||
|
$entity=\App\LearningFile::find($id);
|
||||||
|
$change = false;
|
||||||
|
|
||||||
|
$dirpath = storage_path($this->dirname);
|
||||||
|
$file1 = $request->file('guide');
|
||||||
|
if ($file1!='') {
|
||||||
|
// File::delete(getPath($dirpath.$entity->guide));
|
||||||
|
$fname=$file1->store($this->dirname,$this->filepath);
|
||||||
|
$entity->guide=$fname;
|
||||||
|
$change=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$file2 = $request->file('testfile');
|
||||||
|
if ($file2!='') {
|
||||||
|
//File::delete(getPath($dirpath.$entity->testfile));
|
||||||
|
$fname=$file2->store($this->dirname,$this->filepath);
|
||||||
|
$entity->testfile=$fname;
|
||||||
|
$change=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$file3 = $request->file('supplement');
|
||||||
|
if ($file3!='') {
|
||||||
|
//File::delete(getPath($dirpath.$entity->supplement));
|
||||||
|
$fname=$file3->store($this->dirname,$this->filepath);
|
||||||
|
$entity->supplement=$fname;
|
||||||
|
$change=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$file4 = $request->file('other');
|
||||||
|
if ($file4!='') {
|
||||||
|
//File::delete(getPath($dirpath.$entity->other));
|
||||||
|
$fname=$file4->store($this->dirname,$this->filepath);
|
||||||
|
$entity->other=$fname;
|
||||||
|
$change=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($change) {
|
||||||
|
$entity->save();
|
||||||
|
Session::flash('message','A Learning File is changed');
|
||||||
|
} else {
|
||||||
|
Session::flash('message','Nothing is changed');
|
||||||
|
}
|
||||||
|
return Redirect::to('admin/learning');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\LearningFile::find($id);
|
||||||
|
/*
|
||||||
|
$dirpath = storage_path('app\public\\');
|
||||||
|
File::delete(getPath($dirpath.$entity['guide']));
|
||||||
|
File::delete(getPath($dirpath.$entity['supplement']));
|
||||||
|
File::delete(getPath($dirpath.$entity['testfiles']));
|
||||||
|
if ($entity['other']!='') {
|
||||||
|
File::delete(getPath($dirpath.$entity['other']));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message','Learning Files with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('admin/learning');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPath($path) {
|
||||||
|
$res = str_replace('\\',DIRECTORY_SEPARATOR,$path);
|
||||||
|
return str_replace('/',DIRECTORY_SEPARATOR,$res);
|
||||||
|
}
|
||||||
|
}
|
||||||
67
app/Http/Controllers/ResetPasswordController.php
Normal file
67
app/Http/Controllers/ResetPasswordController.php
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class ResetPasswordController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('admin/resetpassword/index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$email = $request->get('email');
|
||||||
|
$cekExist = \App\ResetPassword::where('email', $email)
|
||||||
|
->select('id', 'email')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if (empty($cekExist[0])) {
|
||||||
|
return Redirect::to('admin/resetpassword')
|
||||||
|
->withErrors('Email not Found!');
|
||||||
|
} else {
|
||||||
|
return $this->update($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules = [
|
||||||
|
'email' => 'required',
|
||||||
|
'newpassword' => 'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg = [
|
||||||
|
'email.required' => 'email must not empty',
|
||||||
|
'newpassword.required' => 'new password must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $rules, $msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('admin/resetpassword')
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
$updateQuery = \App\ResetPassword::where('email', $request->get('email'))
|
||||||
|
->update(['password' => Hash::make($request->get('newpassword'))]);
|
||||||
|
|
||||||
|
if ($updateQuery) {
|
||||||
|
Session::flash('message', 'Reset Password Success! Email: ' . $request->get('email') . ' Password: ' . $request->get('newpassword'));
|
||||||
|
|
||||||
|
return Redirect::to('admin/resetpassword');
|
||||||
|
} else {
|
||||||
|
return Redirect::to('admin/resetpassword')
|
||||||
|
->withErrors('Reset Password Failed!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
198
app/Http/Controllers/ResourcesController.php
Normal file
198
app/Http/Controllers/ResourcesController.php
Normal file
|
|
@ -0,0 +1,198 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class ResourcesController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$filter = $request->input('topicList','1');
|
||||||
|
|
||||||
|
if ($filter=='0') {
|
||||||
|
$entities=\App\TopicFiles::all();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
//$entities=\App\Task::where('topic','=',$filter)->get();//->join('topics','tasks.topic','=','topics.id')->firstOrFail();
|
||||||
|
|
||||||
|
|
||||||
|
$entities = \App\TopicFiles::where('topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'topic_files.id',
|
||||||
|
'topic_files.fileName',
|
||||||
|
'topic_files.path',
|
||||||
|
'topic_files.topic',
|
||||||
|
'topic_files.desc',
|
||||||
|
'topics.name'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'topics',
|
||||||
|
'topics.id','=','topic_files.topic'
|
||||||
|
)
|
||||||
|
//->where(['tasks.topic' => $filter])
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
//$items = \App\Topic::all();
|
||||||
|
$items = \App\Topic::pluck('name', 'id');
|
||||||
|
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$items];
|
||||||
|
return view('admin/resources/index')->with(compact('entities'))->with(compact('items'))->with(compact('filter'));
|
||||||
|
|
||||||
|
|
||||||
|
//return view('admin/tasks/index')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$items = \App\Topic::pluck('name', 'id');
|
||||||
|
|
||||||
|
return view('admin/resources/create')->with(compact('items'));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'filename'=>'required',
|
||||||
|
'path'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'filename.required'=>'File Name must not empty',
|
||||||
|
'path.required'=>'Folder Path must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('admin/resources/create')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$entity=new \App\TopicFiles;
|
||||||
|
|
||||||
|
$entity->fileName=$request->get('filename');
|
||||||
|
$entity->path=str_replace('\\','/',$request->get('path'));
|
||||||
|
$entity->topic=$request->get('topic');
|
||||||
|
$entity->desc=$request->get('desc');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New Topic Resource Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('admin/resources');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$entity = \App\TopicFiles::find($id);
|
||||||
|
$topic = \App\Topic::find($entity->topic);
|
||||||
|
$x=['data'=>$entity, 'topic'=>$topic];
|
||||||
|
|
||||||
|
return view('admin/resources/show')->with($x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\TopicFiles::find($id);
|
||||||
|
$x=['data'=>$entity];
|
||||||
|
$items = \App\Topic::pluck('name', 'id');
|
||||||
|
return view('admin/resources/edit')->with($x)->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'filename'=>'required',
|
||||||
|
'path'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'filename.required'=>'File Name must not empty',
|
||||||
|
'path.required'=>'Folder Path must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('admin/resources/'.$id.'/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$entity=\App\TopicFiles::find($id);
|
||||||
|
|
||||||
|
$entity->fileName=$request->get('filename');
|
||||||
|
$entity->path=str_replace('\\','/',$request->get('path'));
|
||||||
|
$entity->topic=$request->get('topic');
|
||||||
|
$entity->desc=$request->get('desc');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','Resource with Id='.$id.' is changed');
|
||||||
|
|
||||||
|
return Redirect::to('admin/resources');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\TopicFiles::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message','Resource with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('admin/resources');
|
||||||
|
}
|
||||||
|
}
|
||||||
38
app/Http/Controllers/StudentCompletenessController.php
Normal file
38
app/Http/Controllers/StudentCompletenessController.php
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class StudentCompletenessController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (Auth::user()->roleid == "admin") {
|
||||||
|
$entities=\App\StudentCompleteness::where('student_completeness.userid','>',5 )
|
||||||
|
->orderBy('student_completeness.total','desc')
|
||||||
|
->orderBy('student_completeness.teachername','asc')
|
||||||
|
->orderBy('student_completeness.name','asc')
|
||||||
|
->get();
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
|
||||||
|
return view('admin/completeness/index')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == "teacher") {
|
||||||
|
$entities=\App\StudentCompleteness::where('teacherid','=',Auth::user()->id )
|
||||||
|
->orderBy('student_completeness.total','desc')
|
||||||
|
->orderBy('student_completeness.teachername','asc')
|
||||||
|
->orderBy('student_completeness.name','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
|
||||||
|
return view('teacher/completeness/index')->with($data);
|
||||||
|
} else {
|
||||||
|
return view('student/rankview/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
65
app/Http/Controllers/StudentController.php
Normal file
65
app/Http/Controllers/StudentController.php
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class StudentController extends Controller
|
||||||
|
{
|
||||||
|
public function index() {
|
||||||
|
return view('student/main');
|
||||||
|
}
|
||||||
|
public function androidcourse() {
|
||||||
|
return view('student/androidcourse/main');
|
||||||
|
}
|
||||||
|
public function androidcoursetopic() {
|
||||||
|
return view('student/androidcourse/topic');
|
||||||
|
}
|
||||||
|
public function fluttercourse() {
|
||||||
|
return view('student/fluttercourse/main');
|
||||||
|
}
|
||||||
|
public function fluttercoursetopic() {
|
||||||
|
return view('student/fluttercourse/topic');
|
||||||
|
}
|
||||||
|
public function nodejscourse() {
|
||||||
|
return view('student/nodejscourse/main');
|
||||||
|
}
|
||||||
|
public function nodejscoursetopic() {
|
||||||
|
return view('student/nodejscourse/topic');
|
||||||
|
}
|
||||||
|
public function pythoncourse() {
|
||||||
|
return view('student/pythoncourse/main');
|
||||||
|
}
|
||||||
|
public function pythoncoursetopic() {
|
||||||
|
return view('student/pythoncourse/topic');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function asynctask() {
|
||||||
|
return view('student/androidcourse/asynctask/index');
|
||||||
|
}
|
||||||
|
public function firebase() {
|
||||||
|
return view('student/androidcourse/firebase/index');
|
||||||
|
}
|
||||||
|
|
||||||
|
// unity interface
|
||||||
|
public function unitycourse() {
|
||||||
|
return view('student/unitycourse/main');
|
||||||
|
}
|
||||||
|
public function unitycoursetest() {
|
||||||
|
return view('student/unitycourse/course/index');
|
||||||
|
}
|
||||||
|
public function unitycoursepage() {
|
||||||
|
return view('student/unitycourse/page/index');
|
||||||
|
}
|
||||||
|
//
|
||||||
|
|
||||||
|
// public function nodejscourse() {
|
||||||
|
// return view('student/nodejscourse/main');
|
||||||
|
// }
|
||||||
|
public function nodejscourseBasicHTML() {
|
||||||
|
return view('student/nodejscourse/basicHTML/index');
|
||||||
|
}
|
||||||
|
public function nodejscourseDynamicContent() {
|
||||||
|
return view('student/nodejscourse/DynamicContent/index');
|
||||||
|
}
|
||||||
|
}
|
||||||
76
app/Http/Controllers/StudentMemberController.php
Normal file
76
app/Http/Controllers/StudentMemberController.php
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class StudentMemberController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
$entities=\App\StudentTeacher::where('student_teachers.teacher','=',Auth::user()->id)
|
||||||
|
->select('users.id', 'users.name', 'users.roleid', 'users.email','student_submits_count.count','student_submits_count.topicname')
|
||||||
|
->join('users','users.id','=','student_teachers.student')
|
||||||
|
->leftJoin('student_submits_count','users.id','=','student_submits_count.userid')
|
||||||
|
->orderBy('users.name','asc')
|
||||||
|
->get();
|
||||||
|
*/
|
||||||
|
$entities=\App\User::where('users.uplink','=',Auth::user()->id)->where('users.status','=','active')
|
||||||
|
->select('users.id', 'users.name', 'users.roleid', 'users.email','student_submits_count.count')
|
||||||
|
->leftJoin('student_submits_count','users.id','=','student_submits_count.userid')
|
||||||
|
->orderBy('users.name','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
|
||||||
|
return view('teacher/member/index')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
|
||||||
|
// $teacher = Auth::user()->id;
|
||||||
|
// $entity=new \App\StudentTeacher;
|
||||||
|
|
||||||
|
// $entity->student=$id;
|
||||||
|
// $entity->teacher=$teacher;
|
||||||
|
// $entity->save();
|
||||||
|
|
||||||
|
// $user=\App\User::find($id);
|
||||||
|
// Session::flash('message','Student with name = '.$user['name'].' is assgined');
|
||||||
|
|
||||||
|
return Redirect::to('teacher/assignstudent/index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show()
|
||||||
|
{
|
||||||
|
$entities=\App\User::where('users.uplink','=',Auth::user()->id)->where('users.status','=','active')
|
||||||
|
->select('users.id', 'users.name', 'users.roleid', 'users.email','student_submits_count.count','student_submits_count.topicname')
|
||||||
|
->leftJoin('student_submits_count','users.id','=','student_submits_count.userid')
|
||||||
|
->orderBy('users.name','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
|
||||||
|
return view('teacher/member/index')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
//$entity = \App\StudentTeacher::where('student','=',$id);
|
||||||
|
//$entity->delete();
|
||||||
|
|
||||||
|
$entity = \App\User::find($id);
|
||||||
|
$entity->status='deleted';
|
||||||
|
$entity->save();
|
||||||
|
//
|
||||||
|
Session::flash('message','Student Member with Name='.$entity->name.' is deleted');
|
||||||
|
return Redirect::to('/teacher/member');
|
||||||
|
}
|
||||||
|
}
|
||||||
79
app/Http/Controllers/StudentPassedResultClassController.php
Normal file
79
app/Http/Controllers/StudentPassedResultClassController.php
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class StudentPassedResultClassController extends Controller
|
||||||
|
{
|
||||||
|
private function getListClass($teacher)
|
||||||
|
{
|
||||||
|
return \App\Classroom::where('owner', '=', $teacher)
|
||||||
|
->join('users', 'users.id', '=', 'classrooms.owner')
|
||||||
|
->select('users.name', 'classrooms.id', 'classrooms.name as classname')
|
||||||
|
->orderBy('classrooms.name', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getListClassAll()
|
||||||
|
{
|
||||||
|
return \App\Classroom::where('status', '=', 'active')
|
||||||
|
->join('users', 'users.id', '=', 'classrooms.owner')
|
||||||
|
->select('users.name', 'classrooms.id', 'classrooms.name as classname')
|
||||||
|
->orderBy('classrooms.name', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
$class = $this->getListClassAll();
|
||||||
|
$filter = $request->input('stdList', ($class->count() > 0) ? $class[0]['id'] : '');
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
$class = $this->getListClass(Auth::user()->id);
|
||||||
|
$filter = $request->input('stdList', ($class->count() > 0) ? $class[0]['id'] : '');
|
||||||
|
} else { //student
|
||||||
|
$check = \App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status != 'active') return view('student/home')->with(['status' => $check->status]);
|
||||||
|
$filter = Auth::user()->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$subsubQuery = DB::table('student_submits_view')
|
||||||
|
->select(DB::raw("userid, student AS name, count(distinct(topic)) AS passednumber, GROUP_CONCAT(concat(topic,' [',checkstat,']') ORDER BY `checkstat` SEPARATOR '\\n') AS topiclist"))
|
||||||
|
->where("checkstat", "PASSED")
|
||||||
|
->groupBy('userid')
|
||||||
|
->orderBy('topiclist', 'asc');
|
||||||
|
|
||||||
|
$entities = DB::table('class_members')
|
||||||
|
->Leftjoin('users', 'class_members.student', '=', 'users.id')
|
||||||
|
->LeftJoin('student_submits_stat', 'class_members.student', '=', 'student_submits_stat.userid')
|
||||||
|
->leftJoinSub($subsubQuery, 'B', function ($join) {
|
||||||
|
$join->on('class_members.student', '=', 'B.userid');
|
||||||
|
})
|
||||||
|
->select(DB::raw('users.id AS userid, users.name, student_submits_stat.subs_passed AS passed, student_submits_stat.subs_failed AS failed, student_submits_stat.subs_error AS error, B.topiclist'))
|
||||||
|
->where('class_members.classid', '=', $filter)
|
||||||
|
->orderBy('users.name', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// $entities = DB::table(DB::raw('(select * from `student_submits_view` order by checkstat DESC, topic ASC) AS A'))
|
||||||
|
// ->select(DB::raw("student, count(*) AS totalpassed, GROUP_CONCAT(concat(topic,' [',checkstat,']') SEPARATOR '\\n') AS topiclist"))
|
||||||
|
// ->groupBy('student')
|
||||||
|
// ->get();
|
||||||
|
|
||||||
|
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
$data = ['entities' => $entities, 'items' => $class, 'filter' => $filter];
|
||||||
|
return view('admin/studentpassedresult/index')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
$data = ['entities' => $entities, 'items' => $class, 'filter' => $filter];
|
||||||
|
return view('teacher/studentpassedresult/index')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
$data = ['entities' => $entities];
|
||||||
|
return view('student/valid/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
72
app/Http/Controllers/StudentResultClassController.php
Normal file
72
app/Http/Controllers/StudentResultClassController.php
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class StudentResultClassController extends Controller
|
||||||
|
{
|
||||||
|
private function getListClass($teacher)
|
||||||
|
{
|
||||||
|
return \App\Classroom::where('owner', '=', $teacher)
|
||||||
|
->join('users', 'users.id', '=', 'classrooms.owner')
|
||||||
|
->select('users.name', 'classrooms.id', 'classrooms.name as classname')
|
||||||
|
->orderBy('classrooms.name', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getListClassAll()
|
||||||
|
{
|
||||||
|
return \App\Classroom::where('status', '=', 'active')
|
||||||
|
->join('users', 'users.id', '=', 'classrooms.owner')
|
||||||
|
->select('users.name', 'classrooms.id', 'classrooms.name as classname')
|
||||||
|
->orderBy('classrooms.name', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
$class = $this->getListClassAll();
|
||||||
|
$filter = $request->input('stdList', ($class->count() > 0) ? $class[0]['id'] : '');
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
$class = $this->getListClass(Auth::user()->id);
|
||||||
|
$filter = $request->input('stdList', ($class->count() > 0) ? $class[0]['id'] : '');
|
||||||
|
} else { //student
|
||||||
|
$check = \App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status != 'active') return view('student/home')->with(['status' => $check->status]);
|
||||||
|
$filter = Auth::user()->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$subsubQuery = DB::table('student_submits_view')
|
||||||
|
->select(DB::raw("userid, student AS name, count(distinct(topic)) AS passednumber, GROUP_CONCAT(concat(topic,' [',checkstat,']') ORDER BY `checkstat` SEPARATOR '\\n') AS topiclist"))
|
||||||
|
->groupBy('userid');
|
||||||
|
|
||||||
|
$entities = DB::table('class_members')
|
||||||
|
->Leftjoin('users', 'class_members.student', '=', 'users.id')
|
||||||
|
->LeftJoin('student_submits_stat', 'class_members.student', '=', 'student_submits_stat.userid')
|
||||||
|
->leftJoinSub($subsubQuery, 'B', function ($join) {
|
||||||
|
$join->on('class_members.student', '=', 'B.userid');
|
||||||
|
})
|
||||||
|
->select(DB::raw('users.id AS userid, users.name, student_submits_stat.subs_passed AS passed, student_submits_stat.subs_failed AS failed, student_submits_stat.subs_error AS error, B.topiclist'))
|
||||||
|
->where('class_members.classid', '=', $filter)
|
||||||
|
->orderBy('users.name', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
$data = ['entities' => $entities, 'items' => $class, 'filter' => $filter];
|
||||||
|
return view('admin/studentclasssummary/index')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
$data = ['entities' => $entities, 'items' => $class, 'filter' => $filter];
|
||||||
|
return view('teacher/studentclasssummary/index')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
$data = ['entities' => $entities];
|
||||||
|
return view('student/valid/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
27
app/Http/Controllers/StudentResultRankController.php
Normal file
27
app/Http/Controllers/StudentResultRankController.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class StudentResultRankController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entities=\App\StudentRank::orderBy('score','desc')
|
||||||
|
->orderBy('last_submit','asc')
|
||||||
|
->offset(0)->limit(20)->get();
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
if (Auth::user()->roleid == "admin") {
|
||||||
|
return view('admin/rankview/index')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == "teacher") {
|
||||||
|
return view('teacher/rankview/index')->with($data);
|
||||||
|
} else {
|
||||||
|
return view('student/rankview/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
app/Http/Controllers/StudentResultViewController.php
Normal file
18
app/Http/Controllers/StudentResultViewController.php
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class StudentResultViewController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entities=\App\StudentResultView::orderBy('id','desc')->get();
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
return view('admin/resview/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
17
app/Http/Controllers/StudentResultViewController.php.save
Normal file
17
app/Http/Controllers/StudentResultViewController.php.save
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class StudentResultViewController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entities=\App\Topic::all();
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
return view('admin/topics/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
235
app/Http/Controllers/StudentValidController.php
Normal file
235
app/Http/Controllers/StudentValidController.php
Normal file
|
|
@ -0,0 +1,235 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class StudentValidController extends Controller
|
||||||
|
{
|
||||||
|
private function getListStudent($teacher) {
|
||||||
|
return \App\User::where('users.uplink','=',$teacher)
|
||||||
|
->join('user_submits','user_submits.userid','=','users.id')
|
||||||
|
->join('class_members','class_members.student','=','users.id')
|
||||||
|
->join('classrooms','classrooms.id','=','class_members.classid')
|
||||||
|
->join('users as x','x.id','=','users.uplink')
|
||||||
|
->select('users.id','users.name','users.email','users.roleid','classrooms.name as classname','x.name as teacher')
|
||||||
|
->orderBy('users.uplink','asc')
|
||||||
|
->orderBy('class_members.classid','asc')
|
||||||
|
->orderBy('users.name','asc')
|
||||||
|
->get();
|
||||||
|
/*
|
||||||
|
return \App\StudentSubmit::where('users.uplink','=',$teacher)
|
||||||
|
->join('users','student_submits.userid','=','users.id')
|
||||||
|
->select('users.id','users.name','users.email','users.roleid')
|
||||||
|
->orderBy('users.name','asc')
|
||||||
|
->get();
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getListStudentAll() {
|
||||||
|
/*
|
||||||
|
return \App\StudentSubmit::where('student_submits.validstat','=','valid')
|
||||||
|
->join('users','student_submits.userid','=','users.id')
|
||||||
|
->select('users.id','users.name','users.email','users.roleid')
|
||||||
|
->orderBy('users.name','asc')
|
||||||
|
->get();
|
||||||
|
*/
|
||||||
|
return \App\User::where('users.status','=','active')
|
||||||
|
|
||||||
|
->join('user_submits','user_submits.userid','=','users.id')
|
||||||
|
->join('class_members','class_members.student','=','users.id')
|
||||||
|
->join('classrooms','classrooms.id','=','class_members.classid')
|
||||||
|
->join('users as x','x.id','=','users.uplink')
|
||||||
|
->select('users.id','users.name','users.email','users.roleid','classrooms.name as classname','x.name as teacher')
|
||||||
|
->orderBy('users.uplink','asc')
|
||||||
|
->orderBy('class_members.classid','asc')
|
||||||
|
->orderBy('users.name','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
if (Auth::user()->roleid=='student') {
|
||||||
|
$check=\App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status!='active') return view('student/home')->with(['status'=>$check->status]);
|
||||||
|
$filter = Auth::user()->id;
|
||||||
|
} else {
|
||||||
|
$student = $this->getListStudent(Auth::user()->id);
|
||||||
|
$filter = $request->input('stdList',($student->count()>0)?$student[0]['id']:'');
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (Auth::user()->roleid=='admin') {
|
||||||
|
$student = $this->getListStudentAll();
|
||||||
|
$filter = $request->input('stdList',($student->count()>0)?$student[0]['id']:'');
|
||||||
|
} else if (Auth::user()->roleid=='teacher') {
|
||||||
|
$student = $this->getListStudent(Auth::user()->id);
|
||||||
|
$filter = $request->input('stdList',($student->count()>0)?$student[0]['id']:'');
|
||||||
|
} else { //student
|
||||||
|
$check=\App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status!='active') return view('student/home')->with(['status'=>$check->status]);
|
||||||
|
$filter = Auth::user()->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$entities=\App\StudentSubmit::where('student_submits.userid','=',$filter)
|
||||||
|
->select('topics.id', 'topics.name', 'task_results_group_student.passed',
|
||||||
|
'task_results_group_student.failed', 'task_results_group_student.avg_duration',
|
||||||
|
'task_results_group_student.tot_duration', 'student_submits.checkstat','student_submits.checkresult',
|
||||||
|
'student_validations_pertopic.failed as vfailed', 'student_validations_pertopic.passed as vpassed')
|
||||||
|
->leftJoin('task_results_group_student', function($join)
|
||||||
|
{
|
||||||
|
$join->on('task_results_group_student.userid','=','student_submits.userid');
|
||||||
|
$join->on('task_results_group_student.topic','=','student_submits.topic');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->leftJoin('student_validations_pertopic', function($join2)
|
||||||
|
{
|
||||||
|
$join2->on('student_validations_pertopic.userid','=','student_submits.userid');
|
||||||
|
$join2->on('student_validations_pertopic.topic','=','student_submits.topic');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->join('topics','topics.id','=','student_submits.topic')
|
||||||
|
->orderBy('topics.name','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (Auth::user()->roleid=='admin') {
|
||||||
|
$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('admin/studentres/index')->with($data);
|
||||||
|
} else if (Auth::user()->roleid=='teacher') {
|
||||||
|
$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
// dd($data);
|
||||||
|
return view('teacher/studentres/index')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
return view('student/valid/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getDataShow($student, $id) {
|
||||||
|
$entities=\App\StudentValidation::where('student_validations.userid','=',$student)
|
||||||
|
->select('tasks.taskno','tasks.desc', 'test_files.fileName', 'student_validations.status',
|
||||||
|
'student_validations.report', 'student_validations.created_at', 'student_validations.duration')
|
||||||
|
->join('test_files', function($join)
|
||||||
|
{
|
||||||
|
$join->on('student_validations.testid','=','test_files.id');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->join('tasks', function($join)
|
||||||
|
{
|
||||||
|
$join->on('tasks.id','=','test_files.taskid');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->where('tasks.topic','=',$id)
|
||||||
|
->orderBy('tasks.taskno','asc')
|
||||||
|
->orderBy('test_files.fileName','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$topic =\App\Topic::find($id);
|
||||||
|
$user = \App\User::find($student);
|
||||||
|
$data=['entities'=>$entities, 'topic'=>$topic, 'student'=>$user];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
/*
|
||||||
|
$entities=\App\StudentValidation::where('student_validations.userid','=',Auth::user()->id)
|
||||||
|
->select('tasks.taskno','tasks.desc', 'test_files.fileName', 'student_validations.status',
|
||||||
|
'student_validations.report', 'student_validations.created_at')
|
||||||
|
->join('test_files', function($join)
|
||||||
|
{
|
||||||
|
$join->on('student_validations.testid','=','test_files.id');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->join('tasks', function($join)
|
||||||
|
{
|
||||||
|
$join->on('tasks.id','=','test_files.taskid');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->where('tasks.topic','=',$id)
|
||||||
|
->orderBy('tasks.taskno','asc')
|
||||||
|
->orderBy('test_files.fileName','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$topic =\App\Topic::find($id);
|
||||||
|
*/
|
||||||
|
$data=$this->getDataShow(Auth::user()->id,$id);
|
||||||
|
|
||||||
|
return view('student/valid/show')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showteacher($student,$id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$data=$this->getDataShow($student,$id);
|
||||||
|
|
||||||
|
if (Auth::user()->roleid=='admin') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('admin/studentres/show')->with($data);
|
||||||
|
} else if (Auth::user()->roleid=='teacher') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('teacher/studentres/show')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
//$data=['entities'=>$entities];
|
||||||
|
return view('student/valid/show')->with($data);
|
||||||
|
}
|
||||||
|
//return view('teacher/studentres/show')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private function getFileSource($student, $id) {
|
||||||
|
$entities=\App\FileResult::where('file_results.userid','=',$student)
|
||||||
|
->select('file_results.id','file_results.rscfile', 'topic_files.fileName', 'topic_files.path', 'topic_files.desc')
|
||||||
|
->join('topic_files', function($join)
|
||||||
|
{
|
||||||
|
$join->on('file_results.fileid','=','topic_files.id');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->where('topic_files.topic','=',$id)
|
||||||
|
->where(function($q) {
|
||||||
|
$q->where('topic_files.fileName','like','%.java')
|
||||||
|
->orWhere('topic_files.fileName','like','%.kt')
|
||||||
|
->orWhere('topic_files.fileName','like','%.gradle')
|
||||||
|
->orWhere('topic_files.fileName','like','%.xml');
|
||||||
|
})
|
||||||
|
->orderBy('topic_files.id','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$topic =\App\Topic::find($id);
|
||||||
|
$user = \App\User::find($student);
|
||||||
|
$data=['entities'=>$entities, 'topic'=>$topic, 'student'=>$user];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function showsource($student,$id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$data=$this->getFileSource($student,$id);
|
||||||
|
|
||||||
|
if (Auth::user()->roleid=='admin') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('admin/uploadsrc/index')->with($data);
|
||||||
|
} else if (Auth::user()->roleid=='teacher') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('teacher/uploadsrc/index')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
//$data=['entities'=>$entities];
|
||||||
|
return view('student/valid/show')->with($data);
|
||||||
|
}
|
||||||
|
//return view('teacher/studentres/show')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
139
app/Http/Controllers/StudentValidController.php.save
Normal file
139
app/Http/Controllers/StudentValidController.php.save
Normal file
|
|
@ -0,0 +1,139 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class StudentValidController extends Controller
|
||||||
|
{
|
||||||
|
private function getListStudent($teacher) {
|
||||||
|
/*
|
||||||
|
return \App\StudentTeacher::where('teacher','=',$teacher)
|
||||||
|
->select('users.id','users.name','users.email')
|
||||||
|
->join('users','users.id','=','student_teachers.student')
|
||||||
|
->orderBy('users.name','asc')
|
||||||
|
->get();
|
||||||
|
*/
|
||||||
|
private function getListStudent($teacher) {
|
||||||
|
return \App\User::where('uplink','=',$teacher)
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
if (Auth::user()->roleid=='student') {
|
||||||
|
$check=\App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status!='active') return view('student/home')->with(['status'=>$check->status]);
|
||||||
|
$filter = Auth::user()->id;
|
||||||
|
} else {
|
||||||
|
$student = $this->getListStudent(Auth::user()->id);
|
||||||
|
$filter = $request->input('stdList',($student->count()>0)?$student[0]['id']:'');
|
||||||
|
}
|
||||||
|
|
||||||
|
$entities=\App\StudentSubmit::where('student_submits.userid','=',$filter)
|
||||||
|
->select('topics.id', 'topics.name', 'task_results_group_student.passed',
|
||||||
|
'task_results_group_student.failed', 'task_results_group_student.avg_duration',
|
||||||
|
'task_results_group_student.tot_duration', 'student_submits.checkstat','student_submits.checkresult',
|
||||||
|
'student_validations_pertopic.failed as vfailed', 'student_validations_pertopic.passed as vpassed')
|
||||||
|
->leftJoin('task_results_group_student', function($join)
|
||||||
|
{
|
||||||
|
$join->on('task_results_group_student.userid','=','student_submits.userid');
|
||||||
|
$join->on('task_results_group_student.topic','=','student_submits.topic');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->leftJoin('student_validations_pertopic', function($join2)
|
||||||
|
{
|
||||||
|
$join2->on('student_validations_pertopic.userid','=','student_submits.userid');
|
||||||
|
$join2->on('student_validations_pertopic.topic','=','student_submits.topic');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->join('topics','topics.id','=','student_submits.topic')
|
||||||
|
->orderBy('topics.name','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (Auth::user()->roleid=='student') {
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
return view('student/valid/index')->with($data);
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
$student = \App\StudentTeacher::where('teacher','=',Auth::user()->id)
|
||||||
|
->select('users.id','users.name','users.email')
|
||||||
|
->join('users','users.id','=','student_teachers.student')
|
||||||
|
->orderBy('users.name','asc')
|
||||||
|
->get();
|
||||||
|
*/
|
||||||
|
$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('teacher/studentres/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getDataShow($student, $id) {
|
||||||
|
$entities=\App\StudentValidation::where('student_validations.userid','=',$student)
|
||||||
|
->select('tasks.taskno','tasks.desc', 'test_files.fileName', 'student_validations.status',
|
||||||
|
'student_validations.report', 'student_validations.created_at', 'student_validations.duration')
|
||||||
|
->join('test_files', function($join)
|
||||||
|
{
|
||||||
|
$join->on('student_validations.testid','=','test_files.id');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->join('tasks', function($join)
|
||||||
|
{
|
||||||
|
$join->on('tasks.id','=','test_files.taskid');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->where('tasks.topic','=',$id)
|
||||||
|
->orderBy('tasks.taskno','asc')
|
||||||
|
->orderBy('test_files.fileName','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$topic =\App\Topic::find($id);
|
||||||
|
$user = \App\User::find($student);
|
||||||
|
$data=['entities'=>$entities, 'topic'=>$topic, 'student'=>$user];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
/*
|
||||||
|
$entities=\App\StudentValidation::where('student_validations.userid','=',Auth::user()->id)
|
||||||
|
->select('tasks.taskno','tasks.desc', 'test_files.fileName', 'student_validations.status',
|
||||||
|
'student_validations.report', 'student_validations.created_at')
|
||||||
|
->join('test_files', function($join)
|
||||||
|
{
|
||||||
|
$join->on('student_validations.testid','=','test_files.id');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->join('tasks', function($join)
|
||||||
|
{
|
||||||
|
$join->on('tasks.id','=','test_files.taskid');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->where('tasks.topic','=',$id)
|
||||||
|
->orderBy('tasks.taskno','asc')
|
||||||
|
->orderBy('test_files.fileName','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$topic =\App\Topic::find($id);
|
||||||
|
*/
|
||||||
|
$data=$this->getDataShow(Auth::user()->id,$id);
|
||||||
|
|
||||||
|
return view('student/valid/show')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showteacher($student,$id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$data=$this->getDataShow($student,$id);
|
||||||
|
|
||||||
|
return view('teacher/studentres/show')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
187
app/Http/Controllers/StudentValidController.php.save.1
Normal file
187
app/Http/Controllers/StudentValidController.php.save.1
Normal file
|
|
@ -0,0 +1,187 @@
|
||||||
|
]<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class StudentValidController extends Controller
|
||||||
|
{
|
||||||
|
private function getListStudent($teacher) {
|
||||||
|
return \App\User::where('users.uplink','=',$teacher)
|
||||||
|
->join('user_submits','user_submits.userid','=','users.id')
|
||||||
|
->join('class_members','class_members.student','=','users.id')
|
||||||
|
->join('classrooms','classrooms.id','=','class_members.classid')
|
||||||
|
->join('users as x','x.id','=','users.uplink')
|
||||||
|
->select('users.id','users.name','users.email','users.roleid','classrooms.name as classname','x.name as teacher')
|
||||||
|
->orderBy('users.uplink','asc')
|
||||||
|
->orderBy('class_members.classid','asc')
|
||||||
|
->orderBy('users.name','asc')
|
||||||
|
->get();
|
||||||
|
/*
|
||||||
|
return \App\StudentSubmit::where('users.uplink','=',$teacher)
|
||||||
|
->join('users','student_submits.userid','=','users.id')
|
||||||
|
->select('users.id','users.name','users.email','users.roleid')
|
||||||
|
->orderBy('users.name','asc')
|
||||||
|
->get();
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getListStudentAll() {
|
||||||
|
/*
|
||||||
|
return \App\StudentSubmit::where('student_submits.validstat','=','valid')
|
||||||
|
->join('users','student_submits.userid','=','users.id')
|
||||||
|
->select('users.id','users.name','users.email','users.roleid')
|
||||||
|
->orderBy('users.name','asc')
|
||||||
|
->get();
|
||||||
|
*/
|
||||||
|
return \App\User::where('users.status','=','active')
|
||||||
|
|
||||||
|
->join('user_submits','user_submits.userid','=','users.id')
|
||||||
|
->join('class_members','class_members.student','=','users.id')
|
||||||
|
->join('classrooms','classrooms.id','=','class_members.classid')
|
||||||
|
->join('users as x','x.id','=','users.uplink')
|
||||||
|
->select('users.id','users.name','users.email','users.roleid','classrooms.name as classname','x.name as teacher')
|
||||||
|
->orderBy('users.uplink','asc')
|
||||||
|
->orderBy('class_members.classid','asc')
|
||||||
|
->orderBy('users.name','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
if (Auth::user()->roleid=='student') {
|
||||||
|
$check=\App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status!='active') return view('student/home')->with(['status'=>$check->status]);
|
||||||
|
$filter = Auth::user()->id;
|
||||||
|
} else {
|
||||||
|
$student = $this->getListStudent(Auth::user()->id);
|
||||||
|
$filter = $request->input('stdList',($student->count()>0)?$student[0]['id']:'');
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (Auth::user()->roleid=='admin') {
|
||||||
|
$student = $this->getListStudentAll();
|
||||||
|
$filter = $request->input('stdList',($student->count()>0)?$student[0]['id']:'');
|
||||||
|
} else if (Auth::user()->roleid=='teacher') {
|
||||||
|
$student = $this->getListStudent(Auth::user()->id);
|
||||||
|
$filter = $request->input('stdList',($student->count()>0)?$student[0]['id']:'');
|
||||||
|
} else { //student
|
||||||
|
$check=\App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status!='active') return view('student/home')->with(['status'=>$check->status]);
|
||||||
|
$filter = Auth::user()->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$entities=\App\StudentSubmit::where('student_submits.userid','=',$filter)
|
||||||
|
->select('topics.id', 'topics.name', 'task_results_group_student.passed',
|
||||||
|
'task_results_group_student.failed', 'task_results_group_student.avg_duration',
|
||||||
|
'task_results_group_student.tot_duration', 'student_submits.checkstat','student_submits.checkresult',
|
||||||
|
'student_validations_pertopic.failed as vfailed', 'student_validations_pertopic.passed as vpassed')
|
||||||
|
->leftJoin('task_results_group_student', function($join)
|
||||||
|
{
|
||||||
|
$join->on('task_results_group_student.userid','=','student_submits.userid');
|
||||||
|
$join->on('task_results_group_student.topic','=','student_submits.topic');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->leftJoin('student_validations_pertopic', function($join2)
|
||||||
|
{
|
||||||
|
$join2->on('student_validations_pertopic.userid','=','student_submits.userid');
|
||||||
|
$join2->on('student_validations_pertopic.topic','=','student_submits.topic');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->join('topics','topics.id','=','student_submits.topic')
|
||||||
|
->orderBy('topics.name','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (Auth::user()->roleid=='admin') {
|
||||||
|
$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('admin/studentres/index')->with($data);
|
||||||
|
} else if (Auth::user()->roleid=='teacher') {
|
||||||
|
$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('teacher/studentres/index')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
return view('student/valid/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getDataShow($student, $id) {
|
||||||
|
$entities=\App\StudentValidation::where('student_validations.userid','=',$student)
|
||||||
|
->select('tasks.taskno','tasks.desc', 'test_files.fileName', 'student_validations.status',
|
||||||
|
'student_validations.report', 'student_validations.created_at', 'student_validations.duration')
|
||||||
|
->join('test_files', function($join)
|
||||||
|
{
|
||||||
|
$join->on('student_validations.testid','=','test_files.id');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->join('tasks', function($join)
|
||||||
|
{
|
||||||
|
$join->on('tasks.id','=','test_files.taskid');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->where('tasks.topic','=',$id)
|
||||||
|
->orderBy('tasks.taskno','asc')
|
||||||
|
->orderBy('test_files.fileName','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$topic =\App\Topic::find($id);
|
||||||
|
$user = \App\User::find($student);
|
||||||
|
$data=['entities'=>$entities, 'topic'=>$topic, 'student'=>$user];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
/*
|
||||||
|
$entities=\App\StudentValidation::where('student_validations.userid','=',Auth::user()->id)
|
||||||
|
->select('tasks.taskno','tasks.desc', 'test_files.fileName', 'student_validations.status',
|
||||||
|
'student_validations.report', 'student_validations.created_at')
|
||||||
|
->join('test_files', function($join)
|
||||||
|
{
|
||||||
|
$join->on('student_validations.testid','=','test_files.id');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->join('tasks', function($join)
|
||||||
|
{
|
||||||
|
$join->on('tasks.id','=','test_files.taskid');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->where('tasks.topic','=',$id)
|
||||||
|
->orderBy('tasks.taskno','asc')
|
||||||
|
->orderBy('test_files.fileName','asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$topic =\App\Topic::find($id);
|
||||||
|
*/
|
||||||
|
$data=$this->getDataShow(Auth::user()->id,$id);
|
||||||
|
|
||||||
|
return view('student/valid/show')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showteacher($student,$id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$data=$this->getDataShow($student,$id);
|
||||||
|
|
||||||
|
if (Auth::user()->roleid=='admin') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('admin/studentres/show')->with($data);
|
||||||
|
} else if (Auth::user()->roleid=='teacher') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('teacher/studentres/show')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
//$data=['entities'=>$entities];
|
||||||
|
return view('student/valid/show')->with($data);
|
||||||
|
}
|
||||||
|
//return view('teacher/studentres/show')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
10
app/Http/Controllers/SummaryController.php
Normal file
10
app/Http/Controllers/SummaryController.php
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class SummaryController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
260
app/Http/Controllers/TaskController.php
Normal file
260
app/Http/Controllers/TaskController.php
Normal file
|
|
@ -0,0 +1,260 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class TaskController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request) {
|
||||||
|
/* if (Auth::user()->roleid=='student') {
|
||||||
|
//$check=\App\StudentTeacher::where('student','=',Auth::user()->id);
|
||||||
|
//if ($check->count()==0) return view('student/home')->with(['count'=>$check->count()]);
|
||||||
|
$check=\App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status!='active') return view('student/home')->with(['status'=>$check->status]);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
$topiclist=\App\Topic::where('status','=','1')->orderBy('name','asc')->get();
|
||||||
|
|
||||||
|
$items = \App\Topic::where('status','=','1')
|
||||||
|
->orderBy('status','desc')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
$itemslearning = \App\Topic::where('status','=','1')
|
||||||
|
->orderBy('status','desc')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->where('level','=','1')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
$filter = $request->input('topicList',$topiclist[0]['id']);
|
||||||
|
|
||||||
|
if ($filter=='0') {
|
||||||
|
$entities=\App\Task::all();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
//$entities=\App\Task::where('topic','=',$filter)->get();//->join('topics','tasks.topic','=','topics.id')->firstOrFail();
|
||||||
|
|
||||||
|
|
||||||
|
$entities = \App\Task::where('topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'tasks.id',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'tasks.topic',
|
||||||
|
'topics.name'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'topics',
|
||||||
|
'topics.id','=','tasks.topic'
|
||||||
|
)
|
||||||
|
->orderBy('tasks.taskno','asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
//$items = \App\Topic::all();
|
||||||
|
$items = \App\Topic::where('status','=','1')
|
||||||
|
->orderBy('status','desc')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
*/
|
||||||
|
// if (Auth::user()->roleid=='admin') {
|
||||||
|
return view('admin/admintasks/index')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('items'))
|
||||||
|
->with(compact('filter'));
|
||||||
|
/* } else {
|
||||||
|
$topic = \App\Topic::where('topics.id','=',$filter)
|
||||||
|
->select(
|
||||||
|
'topics.id',
|
||||||
|
'topics.name',
|
||||||
|
'topics.desc',
|
||||||
|
'learning_files.guide',
|
||||||
|
'learning_files.testfile',
|
||||||
|
'learning_files.supplement',
|
||||||
|
'learning_files.other'
|
||||||
|
)
|
||||||
|
->leftJoin('learning_files', 'learning_files.topic', '=', 'topics.id')
|
||||||
|
->first();
|
||||||
|
return view('student/tasks/index')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('items'))
|
||||||
|
->with(compact('itemslearning'))
|
||||||
|
->with(compact('filter'))
|
||||||
|
->with(compact('topic'));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getTopic($id){
|
||||||
|
$items = \App\Topic::find($id);
|
||||||
|
|
||||||
|
return $items['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function filterTask() {
|
||||||
|
$filters = \App\Topic::get();
|
||||||
|
$filter = \App\Topic::findOrFail(Input::get('filter_id'));
|
||||||
|
|
||||||
|
$data= \App\Task::with('topic')->where('topic', '=' , $filter->id )->latest()->get();
|
||||||
|
|
||||||
|
return View::make('admin.tasks.index',compact('filters'))->withProfiles($data)->with('title', 'filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$items = \App\Topic::pluck('name', 'id');
|
||||||
|
//echo "kljasd;lkasdl";
|
||||||
|
return view('admin/admintasks/create')->with(compact('items'));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'taskno'=>'required',
|
||||||
|
'desc'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'taskno.required'=>'Task number must not empty',
|
||||||
|
'desc.required'=>'Description must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('admin/tasks/create')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$entity=new \App\Task;
|
||||||
|
|
||||||
|
$entity->desc=$request->get('desc');
|
||||||
|
$entity->taskno=$request->get('taskno');
|
||||||
|
$entity->topic=$request->get('topic');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New Task Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('admin/admintasks');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show(Request $request, $id)
|
||||||
|
{
|
||||||
|
$entity = \App\Task::find($id);
|
||||||
|
$topic = \App\Topic::find($entity->topic);
|
||||||
|
$x=['data'=>$entity, 'topic'=>$topic];
|
||||||
|
|
||||||
|
if ($request->is('admin/*')) {
|
||||||
|
return view('admin/tasks/show')->with($x);
|
||||||
|
} else {
|
||||||
|
return view('student/tasks/show')->with($x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\Task::find($id);
|
||||||
|
$x=['data'=>$entity];
|
||||||
|
$items = \App\Topic::pluck('name', 'id');
|
||||||
|
return view('admin/tasks/edit')->with($x)->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'taskno'=>'required',
|
||||||
|
'desc'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'taskno.required'=>'Task number must not empty',
|
||||||
|
'desc.required'=>'Description must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('admin/topics/'.$id.'/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$entity=\App\Task::find($id);
|
||||||
|
|
||||||
|
$entity->desc=$request->get('desc');
|
||||||
|
$entity->taskno=$request->get('taskno');
|
||||||
|
$entity->topic=$request->get('topic');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','Task with Id='.$id.' is changed');
|
||||||
|
|
||||||
|
return Redirect::to('admin/tasks');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\Task::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message','Task with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('admin/tasks');
|
||||||
|
}
|
||||||
|
}
|
||||||
434
app/Http/Controllers/TaskResultController.php
Normal file
434
app/Http/Controllers/TaskResultController.php
Normal file
|
|
@ -0,0 +1,434 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class TaskResultController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request) {
|
||||||
|
//$check=\App\StudentTeacher::where('student','=',Auth::user()->id);
|
||||||
|
//if ($check->count()==0) return view('student/home')->with(['count'=>$check->count()]);
|
||||||
|
$check=\App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status!='active') return view('student/home')->with(['status'=>$check->status]);
|
||||||
|
|
||||||
|
$filter = $request->input('topicList','6');
|
||||||
|
if ($filter=='0') {
|
||||||
|
$entities=\App\TaskResult::where('userid','=',Auth::user()->id);
|
||||||
|
} else {
|
||||||
|
$entities = \App\Task::where('tasks.topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'task_results.id',
|
||||||
|
'task_results.taskid',
|
||||||
|
'task_results.userid',
|
||||||
|
'task_results.status',
|
||||||
|
'task_results.duration',
|
||||||
|
'task_results.comment',
|
||||||
|
'task_results.imgFile',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'tasks.topic'
|
||||||
|
)
|
||||||
|
->leftJoin('task_results', function($join)
|
||||||
|
{
|
||||||
|
$join->on('tasks.id','=','task_results.taskid')
|
||||||
|
->where('task_results.userid', '=', Auth::user()->id);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->orderBy('tasks.taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$lfiles = \App\TopicFiles::where('topic_files.topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'file_results.id',
|
||||||
|
'file_results.userid',
|
||||||
|
'file_results.rscfile',
|
||||||
|
'file_results.fileid',
|
||||||
|
'topic_files.fileName',
|
||||||
|
'topic_files.path',
|
||||||
|
'topic_files.desc'
|
||||||
|
)
|
||||||
|
->leftJoin('file_results', function($join)
|
||||||
|
{
|
||||||
|
$join->on('topic_files.id','=','file_results.fileid')
|
||||||
|
->where('file_results.userid', '=', Auth::user()->id);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->orderBy('topic_files.fileName', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$items = \App\Topic::
|
||||||
|
where('status','>=','0')
|
||||||
|
->where('androidclass','=','AndroidX')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->orderBy('level','asc')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
$valid = \App\StudentSubmit::where('userid','=',Auth::user()->id)
|
||||||
|
->where('topic','=',$filter)
|
||||||
|
->get()->count();
|
||||||
|
|
||||||
|
$option = $request->input('option','github');
|
||||||
|
|
||||||
|
$currtopic = \App\Topic::find($filter);
|
||||||
|
|
||||||
|
return view('student/results/index')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('lfiles'))
|
||||||
|
->with(compact('items'))
|
||||||
|
->with(compact('filter'))
|
||||||
|
->with(compact('option'))
|
||||||
|
->with(compact('currtopic'))
|
||||||
|
->with(compact('valid'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function getTaskData($topic) {
|
||||||
|
$items = \App\Task::where('tasks.topic','=',$topic)
|
||||||
|
->select(
|
||||||
|
'tasks.id',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'topics.name'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'topics',
|
||||||
|
'topics.id','=','tasks.topic'
|
||||||
|
)
|
||||||
|
->orderBy('topics.name', 'asc')
|
||||||
|
->orderBy('tasks.taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
public function create($id)
|
||||||
|
{
|
||||||
|
$items = \App\Task::where('topic','=',$id)
|
||||||
|
->orderBy('taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
$topic = \App\Topic::find($id);
|
||||||
|
return view('student/results/create')
|
||||||
|
->with(compact('topic'))
|
||||||
|
->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateByFiles($userid, $topic) {
|
||||||
|
//
|
||||||
|
$entity=new \App\StudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\Topic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation is Success');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/results?topicList='.$topic.'&option=files');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateZipFile($userid, $topic, $file, $path) {
|
||||||
|
//
|
||||||
|
//$file = $request->file('zipfile');
|
||||||
|
if ($path!='' ) {
|
||||||
|
//$array = explode('.', $path);
|
||||||
|
//$ext = strtolower(end($array));
|
||||||
|
$ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||||
|
if ($ext=="zip") {
|
||||||
|
$zipFile=$file->store('results','public');
|
||||||
|
|
||||||
|
if ($zipFile!='') {
|
||||||
|
$entity=new \App\StudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->projectfile=$zipFile;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\Topic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation by Uploading Zip Project is Success');
|
||||||
|
} else {
|
||||||
|
Session::flash('message','Storing file '.$request->file('zipfile').' was FAILED');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Session::flash('message','File extension is not zip -> '.$path.' is wrong .'.$ext);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Session::flash('message','Zip File is empty');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/results?topicList='.$topic.'&option=zipfile');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function validateGithubLink($userid, $topic, $link, $projname) {
|
||||||
|
//
|
||||||
|
$trimmedlink = trim($link);
|
||||||
|
if ($this->validateUrl($trimmedlink,$projname)) {
|
||||||
|
/*
|
||||||
|
$zipFile=$file->store('results','public');
|
||||||
|
|
||||||
|
if ($zipFile!='') {
|
||||||
|
$entity=new \App\StudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->projectfile=$zipFile;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\Topic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation is Success');
|
||||||
|
} else {
|
||||||
|
Session::flash('message','Storing file '.$request->file('zipfile').' was FAILED');
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
$entity=new \App\StudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->githublink=$trimmedlink;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\Topic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation by submitting GitHub link is Success');
|
||||||
|
|
||||||
|
//Session::flash('message','URL valid '.$link);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Session::flash('message','URL is not VALID '.$link);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/results?topicList='.$topic.'&option=github');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateUrl($url,$projname) {
|
||||||
|
$path = parse_url($url, PHP_URL_PATH);
|
||||||
|
$encoded_path = array_map('urlencode', explode('/', $path));
|
||||||
|
$url = str_replace($path, implode('/', $encoded_path), $url);
|
||||||
|
|
||||||
|
if (filter_var($url, FILTER_VALIDATE_URL)) {
|
||||||
|
$result = parse_url($url);
|
||||||
|
if ( ($result['scheme']=='https') && ($this->endsWith($result['host'],'github.com'))
|
||||||
|
&& (strpos($result['path'],$projname)) ) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function endsWith($haystack, $needle) {
|
||||||
|
return substr_compare($haystack, $needle, -strlen($needle)) === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
if (strlen($request->get('option'))>3) {
|
||||||
|
if (($request->get('action')=='validate') && (strlen($request->submitbutton)>5)) {
|
||||||
|
if ($request->get('option')=='files') {
|
||||||
|
validateByFiles(Auth::user()->id, $request->get('topic'));
|
||||||
|
} else if ($request->get('option')=='zipfile') {
|
||||||
|
validateZipFile(Auth::user()->id, $request->get('topic'), $request->file('zipfile'));
|
||||||
|
} else {
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic').'&option='.$request->get('option').
|
||||||
|
'&submit='.$request->submitbutton);
|
||||||
|
}
|
||||||
|
} else { //clicking radio button
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic').'&option='.$request->get('option'));
|
||||||
|
//'&submit='.$request->submitbutton);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { //echo $request;
|
||||||
|
saveTaskResult($request);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//echo $request;
|
||||||
|
//return Redirect::to('student/results?topicList='.$request->get('topic').'&action='.$request->get('action'))
|
||||||
|
// ->withErrors("Haloowwww".$request->get('action'));
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
private function saveTaskResult(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'duration'=>'required',
|
||||||
|
'image'=>'required',
|
||||||
|
'comment'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'duration.required'=>'Duration time must not empty',
|
||||||
|
'image.required'=>'Evidence image file must not empty',
|
||||||
|
'comment.required'=>'Comment must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('student/results/create/'.$request->get('topic'))
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$check = \App\TaskResult::where('userid','=',Auth::user()->id)
|
||||||
|
->where('taskid','=',$request->get('taskid'))
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if (sizeof($check)>0) {
|
||||||
|
$task = \App\Task::find($request->get('taskid'));
|
||||||
|
$message = 'Result of Task '.$task['desc'].' is already submitted!!';
|
||||||
|
//Session::flash('message',);
|
||||||
|
return Redirect::to('student/results/create'.$request->get('topic'))->withErrors($message);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$file = $request->file('image');
|
||||||
|
$imgFile=$file->store('results','public');
|
||||||
|
|
||||||
|
$entity=new \App\TaskResult;
|
||||||
|
|
||||||
|
$comment = ($request->get('comment')==null)?'-':$request->get('comment');
|
||||||
|
|
||||||
|
$entity->userid=Auth::user()->id;
|
||||||
|
$entity->taskid=$request->get('taskid');
|
||||||
|
$entity->status=$request->get('status');
|
||||||
|
$entity->duration=$request->get('duration');
|
||||||
|
$entity->comment=$comment;
|
||||||
|
$entity->imgFile=$imgFile;
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New Task Result Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic'))->with( [ 'topic' => $request->get('topic') ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
if (strlen($request->get('option'))>3) {
|
||||||
|
if (($request->get('action')=='validate') && (strlen($request->submitbutton)>5)) {
|
||||||
|
if ($request->get('option')=='files') {
|
||||||
|
return $this->validateByFiles(Auth::user()->id, $request->get('topic'));
|
||||||
|
} else if ($request->get('option')=='zipfile') {
|
||||||
|
$file = $request->file('zipfile');
|
||||||
|
$filename = $file->getClientOriginalName();
|
||||||
|
return $this->validateZipFile(Auth::user()->id, $request->get('topic'), $file, $filename);
|
||||||
|
} else if ($request->get('option')=='github') {
|
||||||
|
return $this->validateGithubLink(Auth::user()->id, $request->get('topic'), $request->get('githublink'),
|
||||||
|
$request->get('projname'));
|
||||||
|
} else {
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic').'&option='.$request->get('option').
|
||||||
|
'&submit='.$request->submitbutton);
|
||||||
|
}
|
||||||
|
} else { //clicking radio button
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic').'&option='.$request->get('option'));
|
||||||
|
//'&submit='.$request->submitbutton);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { //echo $request;
|
||||||
|
return $this->saveTaskResult($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function destroy(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\TaskResult::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message','Task Result with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\TaskResult::where('id','=',$id)->first();
|
||||||
|
$task = \App\Task::where('id','=',$entity['taskid'])->first();
|
||||||
|
return view('student/results/edit')->with(compact('entity'))
|
||||||
|
->with(compact('task'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function valsub(Request $request)
|
||||||
|
{
|
||||||
|
$items = \App\Task::where('topic','=',$id)
|
||||||
|
->orderBy('taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
$topic = \App\Topic::find($id);
|
||||||
|
return view('student/results/create')
|
||||||
|
->with(compact('topic'))
|
||||||
|
->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function update(Request $request, $id) {
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'duration'=>'required',
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'duration.required'=>'Duration time must not empty',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('student/results/'.$id.'/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$file = $request->file('image');
|
||||||
|
|
||||||
|
$entity=\App\TaskResult::find($id);
|
||||||
|
|
||||||
|
$entity->taskid=$request->get('taskid');
|
||||||
|
$entity->status=$request->get('status');
|
||||||
|
$entity->duration=$request->get('duration');
|
||||||
|
$entity->comment=$request->get('comment');
|
||||||
|
|
||||||
|
if ($file!='') {
|
||||||
|
$imgFile=$file->store('results','public');
|
||||||
|
$entity->imgFile=$imgFile;
|
||||||
|
}
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','Task Result with Id='.$id.' is changed');
|
||||||
|
|
||||||
|
$task = \App\Task::find($request->get('taskid'));
|
||||||
|
return Redirect::to('student/results?topicList='.$task['topic']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
222
app/Http/Controllers/TaskResultController.php.save
Normal file
222
app/Http/Controllers/TaskResultController.php.save
Normal file
|
|
@ -0,0 +1,222 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class TaskResultController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request) {
|
||||||
|
//$check=\App\StudentTeacher::where('student','=',Auth::user()->id);
|
||||||
|
//if ($check->count()==0) return view('student/home')->with(['count'=>$check->count()]);
|
||||||
|
$check=\App\User::find(Auth::user()->id);
|
||||||
|
if ($check-> if ($check->status!='active') return view('student/home')->with(['status'=>$check->status]);
|
||||||
|
) return view('student/home')->with(['status'=>$check->status]);
|
||||||
|
|
||||||
|
$filter = $request->input('topicList','1');
|
||||||
|
if ($filter=='0') {
|
||||||
|
$entities=\App\TaskResult::where('userid','=',Auth::user()->id);
|
||||||
|
} else {
|
||||||
|
$entities = \App\Task::where('tasks.topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'task_results.id',
|
||||||
|
'task_results.taskid',
|
||||||
|
'task_results.userid',
|
||||||
|
'task_results.status',
|
||||||
|
'task_results.duration',
|
||||||
|
'task_results.comment',
|
||||||
|
'task_results.imgFile',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'tasks.topic'
|
||||||
|
)
|
||||||
|
->leftJoin('task_results', function($join)
|
||||||
|
{
|
||||||
|
$join->on('tasks.id','=','task_results.taskid')
|
||||||
|
->where('task_results.userid', '=', Auth::user()->id);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->orderBy('tasks.taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$lfiles = \App\TopicFiles::where('topic_files.topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'file_results.id',
|
||||||
|
'file_results.userid',
|
||||||
|
'file_results.rscfile',
|
||||||
|
'file_results.fileid',
|
||||||
|
'topic_files.fileName',
|
||||||
|
'topic_files.path',
|
||||||
|
'topic_files.desc'
|
||||||
|
)
|
||||||
|
->leftJoin('file_results', function($join)
|
||||||
|
{
|
||||||
|
$join->on('topic_files.id','=','file_results.fileid')
|
||||||
|
->where('file_results.userid', '=', Auth::user()->id);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->orderBy('topic_files.fileName', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$items = \App\Topic::pluck('name', 'id');
|
||||||
|
$valid = \App\StudentSubmit::where('userid','=',Auth::user()->id)
|
||||||
|
->where('topic','=',$filter)
|
||||||
|
->get()->count();
|
||||||
|
|
||||||
|
return view('student/results/index')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('lfiles'))
|
||||||
|
->with(compact('items'))
|
||||||
|
->with(compact('filter'))
|
||||||
|
->with(compact('valid'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTaskData($topic) {
|
||||||
|
$items = \App\Task::where('tasks.topic','=',$topic)
|
||||||
|
->select(
|
||||||
|
'tasks.id',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'topics.name'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'topics',
|
||||||
|
'topics.id','=','tasks.topic'
|
||||||
|
)
|
||||||
|
->orderBy('topics.name', 'asc')
|
||||||
|
->orderBy('tasks.taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
public function create($id)
|
||||||
|
{
|
||||||
|
$items = \App\Task::where('topic','=',$id)
|
||||||
|
->orderBy('taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
$topic = \App\Topic::find($id);
|
||||||
|
return view('student/results/create')
|
||||||
|
->with(compact('topic'))
|
||||||
|
->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'duration'=>'required',
|
||||||
|
'image'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'duration.required'=>'Duration time must not empty',
|
||||||
|
'image.required'=>'Evidence image file must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('student/results/create')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$check = \App\TaskResult::where('userid','=',Auth::user()->id)
|
||||||
|
->where('taskid','=',$request->get('taskid'))
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if (sizeof($check)>0) {
|
||||||
|
$task = \App\Task::find($request->get('taskid'));
|
||||||
|
$message = 'Result of Task '.$task['desc'].' is already submitted!!';
|
||||||
|
//Session::flash('message',);
|
||||||
|
return Redirect::to('student/results/create')->withErrors($message);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$file = $request->file('image');
|
||||||
|
$imgFile=$file->store('results','public');
|
||||||
|
|
||||||
|
$entity=new \App\TaskResult;
|
||||||
|
|
||||||
|
$entity->userid=Auth::user()->id;
|
||||||
|
$entity->taskid=$request->get('taskid');
|
||||||
|
$entity->status=$request->get('status');
|
||||||
|
$entity->duration=$request->get('duration');
|
||||||
|
$entity->comment=$request->get('comment');
|
||||||
|
$entity->imgFile=$imgFile;
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New Task Result Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic'))->with( [ 'topic' => $request->get('topic') ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\TaskResult::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message','Task Result with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\TaskResult::where('id','=',$id)->first();
|
||||||
|
$task = \App\Task::where('id','=',$entity['taskid'])->first();
|
||||||
|
return view('student/results/edit')->with(compact('entity'))
|
||||||
|
->with(compact('task'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id) {
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'duration'=>'required',
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'duration.required'=>'Duration time must not empty',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('student/results/'.$id.'/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$file = $request->file('image');
|
||||||
|
|
||||||
|
$entity=\App\TaskResult::find($id);
|
||||||
|
|
||||||
|
$entity->taskid=$request->get('taskid');
|
||||||
|
$entity->status=$request->get('status');
|
||||||
|
$entity->duration=$request->get('duration');
|
||||||
|
$entity->comment=$request->get('comment');
|
||||||
|
|
||||||
|
if ($file!='') {
|
||||||
|
$imgFile=$file->store('results','public');
|
||||||
|
$entity->imgFile=$imgFile;
|
||||||
|
}
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','Task Result with Id='.$id.' is changed');
|
||||||
|
|
||||||
|
$task = \App\Task::find($request->get('taskid'));
|
||||||
|
return Redirect::to('student/results?topicList='.$task['topic']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
290
app/Http/Controllers/TaskResultController.php.save.1
Normal file
290
app/Http/Controllers/TaskResultController.php.save.1
Normal file
|
|
@ -0,0 +1,290 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class TaskResultController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request) {
|
||||||
|
//$check=\App\StudentTeacher::where('student','=',Auth::user()->id);
|
||||||
|
//if ($check->count()==0) return view('student/home')->with(['count'=>$check->count()]);
|
||||||
|
$check=\App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status!='active') return view('student/home')->with(['status'=>$check->status]);
|
||||||
|
|
||||||
|
$filter = $request->input('topicList','1');
|
||||||
|
if ($filter=='0') {
|
||||||
|
$entities=\App\TaskResult::where('userid','=',Auth::user()->id);
|
||||||
|
} else {
|
||||||
|
$entities = \App\Task::where('tasks.topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'task_results.id',
|
||||||
|
'task_results.taskid',
|
||||||
|
'task_results.userid',
|
||||||
|
'task_results.status',
|
||||||
|
'task_results.duration',
|
||||||
|
'task_results.comment',
|
||||||
|
'task_results.imgFile',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'tasks.topic'
|
||||||
|
)
|
||||||
|
->leftJoin('task_results', function($join)
|
||||||
|
{
|
||||||
|
$join->on('tasks.id','=','task_results.taskid')
|
||||||
|
->where('task_results.userid', '=', Auth::user()->id);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->orderBy('tasks.taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$lfiles = \App\TopicFiles::where('topic_files.topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'file_results.id',
|
||||||
|
'file_results.userid',
|
||||||
|
'file_results.rscfile',
|
||||||
|
'file_results.fileid',
|
||||||
|
'topic_files.fileName',
|
||||||
|
'topic_files.path',
|
||||||
|
'topic_files.desc'
|
||||||
|
)
|
||||||
|
->leftJoin('file_results', function($join)
|
||||||
|
{
|
||||||
|
$join->on('topic_files.id','=','file_results.fileid')
|
||||||
|
->where('file_results.userid', '=', Auth::user()->id);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->orderBy('topic_files.fileName', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$items = \App\Topic::where('status','>=','0')
|
||||||
|
->where('androidclass','=','AndroidX')
|
||||||
|
->orderBy('level','asc')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
$valid = \App\StudentSubmit::where('userid','=',Auth::user()->id)
|
||||||
|
->where('topic','=',$filter)
|
||||||
|
->get()->count();
|
||||||
|
|
||||||
|
$option = $request->input('option','files');
|
||||||
|
|
||||||
|
|
||||||
|
return view('student/results/index')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('lfiles'))
|
||||||
|
->with(compact('items'))
|
||||||
|
->with(compact('filter'))
|
||||||
|
->with(compact('option'))
|
||||||
|
->with(compact('valid'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function getTaskData($topic) {
|
||||||
|
$items = \App\Task::where('tasks.topic','=',$topic)
|
||||||
|
->select(
|
||||||
|
'tasks.id',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'topics.name'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'topics',
|
||||||
|
'topics.id','=','tasks.topic'
|
||||||
|
)
|
||||||
|
->orderBy('topics.name', 'asc')
|
||||||
|
->orderBy('tasks.taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
public function create($id)
|
||||||
|
{
|
||||||
|
$items = \App\Task::where('topic','=',$id)
|
||||||
|
->orderBy('taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
$topic = \App\Topic::find($id);
|
||||||
|
return view('student/results/create')
|
||||||
|
->with(compact('topic'))
|
||||||
|
->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validateByFiles($userid, $topic) {
|
||||||
|
//
|
||||||
|
$entity=new \App\StudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\Topic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation is Success');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/results?topicList='.$topic);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
if ($request->get('action')=='validate') {
|
||||||
|
if (length($request->submitbutton)>5) { //validation
|
||||||
|
if ($request->get('option')=='files') {
|
||||||
|
validateByFiles(Auth::user()->id, $request->get('topic'));
|
||||||
|
} else if ($request->get('option')=='zipfile') {
|
||||||
|
validateByFiles(Auth::user()->id, $request->get('topic'));
|
||||||
|
} else {
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic').'&option='.$request->get('option').
|
||||||
|
'&submit='.$request->submitbutton);
|
||||||
|
}
|
||||||
|
} else { //clicking radio button
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic').'&option='.$request->get('option'));
|
||||||
|
//'&submit='.$request->submitbutton);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {//echo $request;
|
||||||
|
saveTaskResult($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function saveTaskResult(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'duration'=>'required',
|
||||||
|
'image'=>'required',
|
||||||
|
'comment'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'duration.required'=>'Duration time must not empty',
|
||||||
|
'image.required'=>'Evidence image file must not empty',
|
||||||
|
'comment.required'=>'Comment must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('student/results/create/'.$request->get('topic'))
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$check = \App\TaskResult::where('userid','=',Auth::user()->id)
|
||||||
|
->where('taskid','=',$request->get('taskid'))
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if (sizeof($check)>0) {
|
||||||
|
$task = \App\Task::find($request->get('taskid'));
|
||||||
|
$message = 'Result of Task '.$task['desc'].' is already submitted!!';
|
||||||
|
//Session::flash('message',);
|
||||||
|
return Redirect::to('student/results/create'.$request->get('topic'))->withErrors($message);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$file = $request->file('image');
|
||||||
|
$imgFile=$file->store('results','public');
|
||||||
|
|
||||||
|
$entity=new \App\TaskResult;
|
||||||
|
|
||||||
|
$comment = ($request->get('comment')==null)?'-':$request->get('comment');
|
||||||
|
|
||||||
|
$entity->userid=Auth::user()->id;
|
||||||
|
$entity->taskid=$request->get('taskid');
|
||||||
|
$entity->status=$request->get('status');
|
||||||
|
$entity->duration=$request->get('duration');
|
||||||
|
$entity->comment=$comment;
|
||||||
|
$entity->imgFile=$imgFile;
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New Task Result Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic'))->with( [ 'topic' => $request->get('topic') ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\TaskResult::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message','Task Result with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\TaskResult::where('id','=',$id)->first();
|
||||||
|
$task = \App\Task::where('id','=',$entity['taskid'])->first();
|
||||||
|
return view('student/results/edit')->with(compact('entity'))
|
||||||
|
->with(compact('task'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function valsub(Request $request)
|
||||||
|
{
|
||||||
|
$items = \App\Task::where('topic','=',$id)
|
||||||
|
->orderBy('taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
$topic = \App\Topic::find($id);
|
||||||
|
return view('student/results/create')
|
||||||
|
->with(compact('topic'))
|
||||||
|
->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function update(Request $request, $id) {
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'duration'=>'required',
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'duration.required'=>'Duration time must not empty',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('student/results/'.$id.'/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$file = $request->file('image');
|
||||||
|
|
||||||
|
$entity=\App\TaskResult::find($id);
|
||||||
|
|
||||||
|
$entity->taskid=$request->get('taskid');
|
||||||
|
$entity->status=$request->get('status');
|
||||||
|
$entity->duration=$request->get('duration');
|
||||||
|
$entity->comment=$request->get('comment');
|
||||||
|
|
||||||
|
if ($file!='') {
|
||||||
|
$imgFile=$file->store('results','public');
|
||||||
|
$entity->imgFile=$imgFile;
|
||||||
|
}
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','Task Result with Id='.$id.' is changed');
|
||||||
|
|
||||||
|
$task = \App\Task::find($request->get('taskid'));
|
||||||
|
return Redirect::to('student/results?topicList='.$task['topic']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
433
app/Http/Controllers/TaskResultController.php.save.2
Normal file
433
app/Http/Controllers/TaskResultController.php.save.2
Normal file
|
|
@ -0,0 +1,433 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class TaskResultController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request) {
|
||||||
|
//$check=\App\StudentTeacher::where('student','=',Auth::user()->id);
|
||||||
|
//if ($check->count()==0) return view('student/home')->with(['count'=>$check->count()]);
|
||||||
|
$check=\App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status!='active') return view('student/home')->with(['status'=>$check->status]);
|
||||||
|
|
||||||
|
$filter = $request->input('topicList','6');
|
||||||
|
if ($filter=='0') {
|
||||||
|
$entities=\App\TaskResult::where('userid','=',Auth::user()->id);
|
||||||
|
} else {
|
||||||
|
$entities = \App\Task::where('tasks.topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'task_results.id',
|
||||||
|
'task_results.taskid',
|
||||||
|
'task_results.userid',
|
||||||
|
'task_results.status',
|
||||||
|
'task_results.duration',
|
||||||
|
'task_results.comment',
|
||||||
|
'task_results.imgFile',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'tasks.topic'
|
||||||
|
)
|
||||||
|
->leftJoin('task_results', function($join)
|
||||||
|
{
|
||||||
|
$join->on('tasks.id','=','task_results.taskid')
|
||||||
|
->where('task_results.userid', '=', Auth::user()->id);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->orderBy('tasks.taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$lfiles = \App\TopicFiles::where('topic_files.topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'file_results.id',
|
||||||
|
'file_results.userid',
|
||||||
|
'file_results.rscfile',
|
||||||
|
'file_results.fileid',
|
||||||
|
'topic_files.fileName',
|
||||||
|
'topic_files.path',
|
||||||
|
'topic_files.desc'
|
||||||
|
)
|
||||||
|
->leftJoin('file_results', function($join)
|
||||||
|
{
|
||||||
|
$join->on('topic_files.id','=','file_results.fileid')
|
||||||
|
->where('file_results.userid', '=', Auth::user()->id);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->orderBy('topic_files.fileName', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$items = \App\Topic::where('status','>=','0')
|
||||||
|
->where('androidclass','=','AndroidX')
|
||||||
|
->orderBy('level','asc')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
$valid = \App\StudentSubmit::where('userid','=',Auth::user()->id)
|
||||||
|
->where('topic','=',$filter)
|
||||||
|
->get()->count();
|
||||||
|
|
||||||
|
$option = $request->input('option','github');
|
||||||
|
|
||||||
|
$currtopic = \App\Topic::find($filter);
|
||||||
|
|
||||||
|
return view('student/results/index')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('lfiles'))
|
||||||
|
->with(compact('items'))
|
||||||
|
->with(compact('filter'))
|
||||||
|
->with(compact('option'))
|
||||||
|
->with(compact('currtopic'))
|
||||||
|
->with(compact('valid'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function getTaskData($topic) {
|
||||||
|
$items = \App\Task::where('tasks.topic','=',$topic)
|
||||||
|
->select(
|
||||||
|
'tasks.id',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'topics.name'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'topics',
|
||||||
|
'topics.id','=','tasks.topic'
|
||||||
|
)
|
||||||
|
->orderBy('topics.name', 'asc')
|
||||||
|
->orderBy('tasks.taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
public function create($id)
|
||||||
|
{
|
||||||
|
$items = \App\Task::where('topic','=',$id)
|
||||||
|
->orderBy('taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
$topic = \App\Topic::find($id);
|
||||||
|
return view('student/results/create')
|
||||||
|
->with(compact('topic'))
|
||||||
|
->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateByFiles($userid, $topic) {
|
||||||
|
//
|
||||||
|
$entity=new \App\StudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\Topic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation is Success');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/results?topicList='.$topic.'&option=files');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateZipFile($userid, $topic, $file, $path) {
|
||||||
|
//
|
||||||
|
$filename = $file->getClientOriginalName();
|
||||||
|
|
||||||
|
//$file = $request->file('zipfile');
|
||||||
|
if ($filename!='' ) {
|
||||||
|
//$array = explode('.', $path);
|
||||||
|
//$ext = strtolower(end($array));
|
||||||
|
$ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||||
|
// if ($ext=="zip") {
|
||||||
|
$zipFile=$file->store('results','public');
|
||||||
|
|
||||||
|
if ($zipFile!='') {
|
||||||
|
$entity=new \App\StudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->projectfile=$zipFile;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\Topic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation by Uploading Zip Project is Success');
|
||||||
|
} else {
|
||||||
|
Session::flash('message','Storing file '.$request->file('zipfile').' was FAILED');
|
||||||
|
}
|
||||||
|
//} else {
|
||||||
|
// Session::flash('message','File extension is not zip -> '.$path.' -- '.$ext);
|
||||||
|
// }
|
||||||
|
} else {
|
||||||
|
Session::flash('message','Zip File is empty');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/results?topicList='.$topic.'&option=zipfile');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function validateGithubLink($userid, $topic, $link, $projname) {
|
||||||
|
//
|
||||||
|
$trimmedlink = trim($link);
|
||||||
|
if ($this->validateUrl($trimmedlink,$projname)) {
|
||||||
|
/*
|
||||||
|
$zipFile=$file->store('results','public');
|
||||||
|
|
||||||
|
if ($zipFile!='') {
|
||||||
|
$entity=new \App\StudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->projectfile=$zipFile;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\Topic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation is Success');
|
||||||
|
} else {
|
||||||
|
Session::flash('message','Storing file '.$request->file('zipfile').' was FAILED');
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
$entity=new \App\StudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->githublink=$trimmedlink;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\Topic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation by submitting GitHub link is Success');
|
||||||
|
|
||||||
|
//Session::flash('message','URL valid '.$link);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Session::flash('message','URL is not VALID '.$link);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/results?topicList='.$topic.'&option=github');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateUrl($url,$projname) {
|
||||||
|
$path = parse_url($url, PHP_URL_PATH);
|
||||||
|
$encoded_path = array_map('urlencode', explode('/', $path));
|
||||||
|
$url = str_replace($path, implode('/', $encoded_path), $url);
|
||||||
|
|
||||||
|
if (filter_var($url, FILTER_VALIDATE_URL)) {
|
||||||
|
$result = parse_url($url);
|
||||||
|
if (($result['scheme']=='https') && ($this->endsWith($result['host'],'github.com'))
|
||||||
|
&& (strpos($result['path'],$projname))) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function endsWith($haystack, $needle) {
|
||||||
|
return substr_compare($haystack, $needle, -strlen($needle)) === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
if (strlen($request->get('option'))>3) {
|
||||||
|
if (($request->get('action')=='validate') && (strlen($request->submitbutton)>5)) {
|
||||||
|
if ($request->get('option')=='files') {
|
||||||
|
validateByFiles(Auth::user()->id, $request->get('topic'));
|
||||||
|
} else if ($request->get('option')=='zipfile') {
|
||||||
|
validateZipFile(Auth::user()->id, $request->get('topic'), $request->file('zipfile'));
|
||||||
|
} else {
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic').'&option='.$request->get('option').
|
||||||
|
'&submit='.$request->submitbutton);
|
||||||
|
}
|
||||||
|
} else { //clicking radio button
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic').'&option='.$request->get('option'));
|
||||||
|
//'&submit='.$request->submitbutton);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { //echo $request;
|
||||||
|
saveTaskResult($request);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//echo $request;
|
||||||
|
//return Redirect::to('student/results?topicList='.$request->get('topic').'&action='.$request->get('action'))
|
||||||
|
// ->withErrors("Haloowwww".$request->get('action'));
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
private function saveTaskResult(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'duration'=>'required',
|
||||||
|
'image'=>'required',
|
||||||
|
'comment'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'duration.required'=>'Duration time must not empty',
|
||||||
|
'image.required'=>'Evidence image file must not empty',
|
||||||
|
'comment.required'=>'Comment must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('student/results/create/'.$request->get('topic'))
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$check = \App\TaskResult::where('userid','=',Auth::user()->id)
|
||||||
|
->where('taskid','=',$request->get('taskid'))
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if (sizeof($check)>0) {
|
||||||
|
$task = \App\Task::find($request->get('taskid'));
|
||||||
|
$message = 'Result of Task '.$task['desc'].' is already submitted!!';
|
||||||
|
//Session::flash('message',);
|
||||||
|
return Redirect::to('student/results/create'.$request->get('topic'))->withErrors($message);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$file = $request->file('image');
|
||||||
|
$imgFile=$file->store('results','public');
|
||||||
|
|
||||||
|
$entity=new \App\TaskResult;
|
||||||
|
|
||||||
|
$comment = ($request->get('comment')==null)?'-':$request->get('comment');
|
||||||
|
|
||||||
|
$entity->userid=Auth::user()->id;
|
||||||
|
$entity->taskid=$request->get('taskid');
|
||||||
|
$entity->status=$request->get('status');
|
||||||
|
$entity->duration=$request->get('duration');
|
||||||
|
$entity->comment=$comment;
|
||||||
|
$entity->imgFile=$imgFile;
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New Task Result Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic'))->with( [ 'topic' => $request->get('topic') ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
if (strlen($request->get('option'))>3) {
|
||||||
|
if (($request->get('action')=='validate') && (strlen($request->submitbutton)>5)) {
|
||||||
|
if ($request->get('option')=='files') {
|
||||||
|
return $this->validateByFiles(Auth::user()->id, $request->get('topic'));
|
||||||
|
} else if ($request->get('option')=='zipfile') {
|
||||||
|
return $this->validateZipFile(Auth::user()->id, $request->get('topic'), $request->file('zipfile'), $request->get('zipfile'));
|
||||||
|
} else if ($request->get('option')=='github') {
|
||||||
|
return $this->validateGithubLink(Auth::user()->id, $request->get('topic'), $request->get('githublink'),
|
||||||
|
$request->get('projname'));
|
||||||
|
} else {
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic').'&option='.$request->get('option').
|
||||||
|
'&submit='.$request->submitbutton);
|
||||||
|
}
|
||||||
|
} else { //clicking radio button
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic').'&option='.$request->get('option'));
|
||||||
|
//'&submit='.$request->submitbutton);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { //echo $request;
|
||||||
|
return $this->saveTaskResult($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function destroy(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\TaskResult::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message','Task Result with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\TaskResult::where('id','=',$id)->first();
|
||||||
|
$task = \App\Task::where('id','=',$entity['taskid'])->first();
|
||||||
|
return view('student/results/edit')->with(compact('entity'))
|
||||||
|
->with(compact('task'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function valsub(Request $request)
|
||||||
|
{
|
||||||
|
$items = \App\Task::where('topic','=',$id)
|
||||||
|
->orderBy('taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
$topic = \App\Topic::find($id);
|
||||||
|
return view('student/results/create')
|
||||||
|
->with(compact('topic'))
|
||||||
|
->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function update(Request $request, $id) {
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'duration'=>'required',
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'duration.required'=>'Duration time must not empty',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('student/results/'.$id.'/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$file = $request->file('image');
|
||||||
|
|
||||||
|
$entity=\App\TaskResult::find($id);
|
||||||
|
|
||||||
|
$entity->taskid=$request->get('taskid');
|
||||||
|
$entity->status=$request->get('status');
|
||||||
|
$entity->duration=$request->get('duration');
|
||||||
|
$entity->comment=$request->get('comment');
|
||||||
|
|
||||||
|
if ($file!='') {
|
||||||
|
$imgFile=$file->store('results','public');
|
||||||
|
$entity->imgFile=$imgFile;
|
||||||
|
}
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','Task Result with Id='.$id.' is changed');
|
||||||
|
|
||||||
|
$task = \App\Task::find($request->get('taskid'));
|
||||||
|
return Redirect::to('student/results?topicList='.$task['topic']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
433
app/Http/Controllers/TaskResultController.php.save.3
Normal file
433
app/Http/Controllers/TaskResultController.php.save.3
Normal file
|
|
@ -0,0 +1,433 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class TaskResultController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request) {
|
||||||
|
//$check=\App\StudentTeacher::where('student','=',Auth::user()->id);
|
||||||
|
//if ($check->count()==0) return view('student/home')->with(['count'=>$check->count()]);
|
||||||
|
$check=\App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status!='active') return view('student/home')->with(['status'=>$check->status]);
|
||||||
|
|
||||||
|
$filter = $request->input('topicList','6');
|
||||||
|
if ($filter=='0') {
|
||||||
|
$entities=\App\TaskResult::where('userid','=',Auth::user()->id);
|
||||||
|
} else {
|
||||||
|
$entities = \App\Task::where('tasks.topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'task_results.id',
|
||||||
|
'task_results.taskid',
|
||||||
|
'task_results.userid',
|
||||||
|
'task_results.status',
|
||||||
|
'task_results.duration',
|
||||||
|
'task_results.comment',
|
||||||
|
'task_results.imgFile',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'tasks.topic'
|
||||||
|
)
|
||||||
|
->leftJoin('task_results', function($join)
|
||||||
|
{
|
||||||
|
$join->on('tasks.id','=','task_results.taskid')
|
||||||
|
->where('task_results.userid', '=', Auth::user()->id);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->orderBy('tasks.taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$lfiles = \App\TopicFiles::where('topic_files.topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'file_results.id',
|
||||||
|
'file_results.userid',
|
||||||
|
'file_results.rscfile',
|
||||||
|
'file_results.fileid',
|
||||||
|
'topic_files.fileName',
|
||||||
|
'topic_files.path',
|
||||||
|
'topic_files.desc'
|
||||||
|
)
|
||||||
|
->leftJoin('file_results', function($join)
|
||||||
|
{
|
||||||
|
$join->on('topic_files.id','=','file_results.fileid')
|
||||||
|
->where('file_results.userid', '=', Auth::user()->id);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->orderBy('topic_files.fileName', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$items = \App\Topic::where('status','>=','0')
|
||||||
|
->where('androidclass','=','AndroidX')
|
||||||
|
->orderBy('level','asc')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
$valid = \App\StudentSubmit::where('userid','=',Auth::user()->id)
|
||||||
|
->where('topic','=',$filter)
|
||||||
|
->get()->count();
|
||||||
|
|
||||||
|
$option = $request->input('option','github');
|
||||||
|
|
||||||
|
$currtopic = \App\Topic::find($filter);
|
||||||
|
|
||||||
|
return view('student/results/index')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('lfiles'))
|
||||||
|
->with(compact('items'))
|
||||||
|
->with(compact('filter'))
|
||||||
|
->with(compact('option'))
|
||||||
|
->with(compact('currtopic'))
|
||||||
|
->with(compact('valid'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function getTaskData($topic) {
|
||||||
|
$items = \App\Task::where('tasks.topic','=',$topic)
|
||||||
|
->select(
|
||||||
|
'tasks.id',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'topics.name'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'topics',
|
||||||
|
'topics.id','=','tasks.topic'
|
||||||
|
)
|
||||||
|
->orderBy('topics.name', 'asc')
|
||||||
|
->orderBy('tasks.taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
$filename = $file->getClientOriginalName();
|
||||||
|
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
public function create($id)
|
||||||
|
{
|
||||||
|
$items = \App\Task::where('topic','=',$id)
|
||||||
|
->orderBy('taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
$topic = \App\Topic::find($id);
|
||||||
|
return view('student/results/create')
|
||||||
|
->with(compact('topic'))
|
||||||
|
->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateByFiles($userid, $topic) {
|
||||||
|
//
|
||||||
|
$entity=new \App\StudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\Topic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation is Success');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/results?topicList='.$topic.'&option=files');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateZipFile($userid, $topic, $file, $path) {
|
||||||
|
//
|
||||||
|
|
||||||
|
//$file = $request->file('zipfile');
|
||||||
|
if ($file!='' ) {
|
||||||
|
//$array = explode('.', $path);
|
||||||
|
//$ext = strtolower(end($array));
|
||||||
|
$ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||||
|
// if ($ext=="zip") {
|
||||||
|
$zipFile=$file->store('results','public');
|
||||||
|
|
||||||
|
if ($zipFile!='') {
|
||||||
|
$entity=new \App\StudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->projectfile=$zipFile;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\Topic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation by Uploading Zip Project is Success');
|
||||||
|
} else {
|
||||||
|
Session::flash('message','Storing file '.$request->file('zipfile').' was FAILED');
|
||||||
|
}
|
||||||
|
//} else {
|
||||||
|
// Session::flash('message','File extension is not zip -> '.$path.' -- '.$ext);
|
||||||
|
// }
|
||||||
|
} else {
|
||||||
|
Session::flash('message','Zip File is empty');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/results?topicList='.$topic.'&option=zipfile');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function validateGithubLink($userid, $topic, $link, $projname) {
|
||||||
|
//
|
||||||
|
$trimmedlink = trim($link);
|
||||||
|
if ($this->validateUrl($trimmedlink,$projname)) {
|
||||||
|
/*
|
||||||
|
$zipFile=$file->store('results','public');
|
||||||
|
|
||||||
|
if ($zipFile!='') {
|
||||||
|
$entity=new \App\StudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->projectfile=$zipFile;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\Topic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation is Success');
|
||||||
|
} else {
|
||||||
|
Session::flash('message','Storing file '.$request->file('zipfile').' was FAILED');
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
$entity=new \App\StudentSubmit;
|
||||||
|
|
||||||
|
$entity->userid=$userid;
|
||||||
|
$entity->topic=$topic;
|
||||||
|
$entity->validstat="valid";
|
||||||
|
$entity->githublink=$trimmedlink;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$data = \App\Topic::find($topic);
|
||||||
|
Session::flash('message','Topic '.$data['name'].' Validation by submitting GitHub link is Success');
|
||||||
|
|
||||||
|
//Session::flash('message','URL valid '.$link);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Session::flash('message','URL is not VALID '.$link);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/results?topicList='.$topic.'&option=github');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateUrl($url,$projname) {
|
||||||
|
$path = parse_url($url, PHP_URL_PATH);
|
||||||
|
$encoded_path = array_map('urlencode', explode('/', $path));
|
||||||
|
$url = str_replace($path, implode('/', $encoded_path), $url);
|
||||||
|
|
||||||
|
if (filter_var($url, FILTER_VALIDATE_URL)) {
|
||||||
|
$result = parse_url($url);
|
||||||
|
if (($result['scheme']=='https') && ($this->endsWith($result['host'],'github.com'))
|
||||||
|
&& (strpos($result['path'],$projname))) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function endsWith($haystack, $needle) {
|
||||||
|
return substr_compare($haystack, $needle, -strlen($needle)) === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
if (strlen($request->get('option'))>3) {
|
||||||
|
if (($request->get('action')=='validate') && (strlen($request->submitbutton)>5)) {
|
||||||
|
if ($request->get('option')=='files') {
|
||||||
|
validateByFiles(Auth::user()->id, $request->get('topic'));
|
||||||
|
} else if ($request->get('option')=='zipfile') {
|
||||||
|
validateZipFile(Auth::user()->id, $request->get('topic'), $request->file('zipfile'));
|
||||||
|
} else {
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic').'&option='.$request->get('option').
|
||||||
|
'&submit='.$request->submitbutton);
|
||||||
|
}
|
||||||
|
} else { //clicking radio button
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic').'&option='.$request->get('option'));
|
||||||
|
//'&submit='.$request->submitbutton);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { //echo $request;
|
||||||
|
saveTaskResult($request);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//echo $request;
|
||||||
|
//return Redirect::to('student/results?topicList='.$request->get('topic').'&action='.$request->get('action'))
|
||||||
|
// ->withErrors("Haloowwww".$request->get('action'));
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
private function saveTaskResult(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'duration'=>'required',
|
||||||
|
'image'=>'required',
|
||||||
|
'comment'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'duration.required'=>'Duration time must not empty',
|
||||||
|
'image.required'=>'Evidence image file must not empty',
|
||||||
|
'comment.required'=>'Comment must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('student/results/create/'.$request->get('topic'))
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$check = \App\TaskResult::where('userid','=',Auth::user()->id)
|
||||||
|
->where('taskid','=',$request->get('taskid'))
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if (sizeof($check)>0) {
|
||||||
|
$task = \App\Task::find($request->get('taskid'));
|
||||||
|
$message = 'Result of Task '.$task['desc'].' is already submitted!!';
|
||||||
|
//Session::flash('message',);
|
||||||
|
return Redirect::to('student/results/create'.$request->get('topic'))->withErrors($message);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$file = $request->file('image');
|
||||||
|
$imgFile=$file->store('results','public');
|
||||||
|
|
||||||
|
$entity=new \App\TaskResult;
|
||||||
|
|
||||||
|
$comment = ($request->get('comment')==null)?'-':$request->get('comment');
|
||||||
|
|
||||||
|
$entity->userid=Auth::user()->id;
|
||||||
|
$entity->taskid=$request->get('taskid');
|
||||||
|
$entity->status=$request->get('status');
|
||||||
|
$entity->duration=$request->get('duration');
|
||||||
|
$entity->comment=$comment;
|
||||||
|
$entity->imgFile=$imgFile;
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New Task Result Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic'))->with( [ 'topic' => $request->get('topic') ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
if (strlen($request->get('option'))>3) {
|
||||||
|
if (($request->get('action')=='validate') && (strlen($request->submitbutton)>5)) {
|
||||||
|
if ($request->get('option')=='files') {
|
||||||
|
return $this->validateByFiles(Auth::user()->id, $request->get('topic'));
|
||||||
|
} else if ($request->get('option')=='zipfile') {
|
||||||
|
return $this->validateZipFile(Auth::user()->id, $request->get('topic'), $request->file('zipfile'), $request->get('zipfile'));
|
||||||
|
} else if ($request->get('option')=='github') {
|
||||||
|
return $this->validateGithubLink(Auth::user()->id, $request->get('topic'), $request->get('githublink'),
|
||||||
|
$request->get('projname'));
|
||||||
|
} else {
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic').'&option='.$request->get('option').
|
||||||
|
'&submit='.$request->submitbutton);
|
||||||
|
}
|
||||||
|
} else { //clicking radio button
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic').'&option='.$request->get('option'));
|
||||||
|
//'&submit='.$request->submitbutton);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { //echo $request;
|
||||||
|
return $this->saveTaskResult($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function destroy(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\TaskResult::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message','Task Result with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('student/results?topicList='.$request->get('topic'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\TaskResult::where('id','=',$id)->first();
|
||||||
|
$task = \App\Task::where('id','=',$entity['taskid'])->first();
|
||||||
|
return view('student/results/edit')->with(compact('entity'))
|
||||||
|
->with(compact('task'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function valsub(Request $request)
|
||||||
|
{
|
||||||
|
$items = \App\Task::where('topic','=',$id)
|
||||||
|
->orderBy('taskno', 'asc')
|
||||||
|
->get();
|
||||||
|
$topic = \App\Topic::find($id);
|
||||||
|
return view('student/results/create')
|
||||||
|
->with(compact('topic'))
|
||||||
|
->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function update(Request $request, $id) {
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'duration'=>'required',
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'duration.required'=>'Duration time must not empty',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('student/results/'.$id.'/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$file = $request->file('image');
|
||||||
|
|
||||||
|
$entity=\App\TaskResult::find($id);
|
||||||
|
|
||||||
|
$entity->taskid=$request->get('taskid');
|
||||||
|
$entity->status=$request->get('status');
|
||||||
|
$entity->duration=$request->get('duration');
|
||||||
|
$entity->comment=$request->get('comment');
|
||||||
|
|
||||||
|
if ($file!='') {
|
||||||
|
$imgFile=$file->store('results','public');
|
||||||
|
$entity->imgFile=$imgFile;
|
||||||
|
}
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','Task Result with Id='.$id.' is changed');
|
||||||
|
|
||||||
|
$task = \App\Task::find($request->get('taskid'));
|
||||||
|
return Redirect::to('student/results?topicList='.$task['topic']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
258
app/Http/Controllers/TaskStdController.php
Normal file
258
app/Http/Controllers/TaskStdController.php
Normal file
|
|
@ -0,0 +1,258 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class TaskStdController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request) {
|
||||||
|
if (Auth::user()->roleid=='student') {
|
||||||
|
//$check=\App\StudentTeacher::where('student','=',Auth::user()->id);
|
||||||
|
//if ($check->count()==0) return view('student/home')->with(['count'=>$check->count()]);
|
||||||
|
$check=\App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status!='active') return view('student/home')->with(['status'=>$check->status]);
|
||||||
|
}
|
||||||
|
$topiclist=\App\Topic::where('status','=','1')
|
||||||
|
->orderBy('name','asc')->get();
|
||||||
|
|
||||||
|
$items = \App\Topic::where('status','=','1')
|
||||||
|
->orderBy('status','desc')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
$itemslearning = \App\Topic::where('status','=','1')
|
||||||
|
->orderBy('status','desc')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->where('level','=','1')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
$filter = $request->input('topicList',$topiclist[0]['id']);
|
||||||
|
|
||||||
|
if ($filter=='0') {
|
||||||
|
$entities=\App\Task::all();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
//$entities=\App\Task::where('topic','=',$filter)->get();//->join('topics','tasks.topic','=','topics.id')->firstOrFail();
|
||||||
|
$entities = \App\Task::where('topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'tasks.id',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'tasks.topic',
|
||||||
|
'topics.name'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'topics',
|
||||||
|
'topics.id','=','tasks.topic'
|
||||||
|
)
|
||||||
|
->orderBy('tasks.taskno','asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
//$items = \App\Topic::all();
|
||||||
|
$items = \App\Topic::where('status','=','1')
|
||||||
|
->orderBy('status','desc')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
*/
|
||||||
|
if (Auth::user()->roleid=='admin') {
|
||||||
|
return view('admin/tasks/index')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('items'))
|
||||||
|
->with(compact('filter'));
|
||||||
|
} else {
|
||||||
|
$topic = \App\Topic::where('topics.id','=',$filter)
|
||||||
|
->select(
|
||||||
|
'topics.id',
|
||||||
|
'topics.name',
|
||||||
|
'topics.desc',
|
||||||
|
'learning_files.guide',
|
||||||
|
'learning_files.testfile',
|
||||||
|
'learning_files.supplement',
|
||||||
|
'learning_files.other'
|
||||||
|
)
|
||||||
|
->leftJoin('learning_files', 'learning_files.topic', '=', 'topics.id')
|
||||||
|
->first();
|
||||||
|
return view('student/tasks/index')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('items'))
|
||||||
|
->with(compact('itemslearning'))
|
||||||
|
->with(compact('filter'))
|
||||||
|
->with(compact('topic'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getTopic($id){
|
||||||
|
$items = \App\Topic::find($id);
|
||||||
|
|
||||||
|
return $items['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function filterTask() {
|
||||||
|
$filters = \App\Topic::get();
|
||||||
|
$filter = \App\Topic::findOrFail(Input::get('filter_id'));
|
||||||
|
|
||||||
|
$data= \App\Task::with('topic')->where('topic', '=' , $filter->id )->latest()->get();
|
||||||
|
|
||||||
|
return View::make('admin.tasks.index',compact('filters'))->withProfiles($data)->with('title', 'filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$items = \App\Topic::pluck('name', 'id');
|
||||||
|
//echo "kljasd;lkasdl";
|
||||||
|
return view('admin/tasks/create')->with(compact('items'));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//echo "YAAANNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN";
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'taskno'=>'required',
|
||||||
|
'desc'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'taskno.required'=>'Task number must not empty',
|
||||||
|
'desc.required'=>'Description must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('admin/tasks/create')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$entity=new \App\Task;
|
||||||
|
|
||||||
|
$entity->desc=$request->get('desc');
|
||||||
|
$entity->taskno=$request->get('taskno');
|
||||||
|
$entity->topic=$request->get('topic');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New Task Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('admin/tasks');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show(Request $request, $id)
|
||||||
|
{
|
||||||
|
$entity = \App\Task::find($id);
|
||||||
|
$topic = \App\Topic::find($entity->topic);
|
||||||
|
$x=['data'=>$entity, 'topic'=>$topic];
|
||||||
|
|
||||||
|
if ($request->is('admin/*')) {
|
||||||
|
return view('admin/tasks/show')->with($x);
|
||||||
|
} else {
|
||||||
|
return view('student/tasks/show')->with($x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\Task::find($id);
|
||||||
|
$x=['data'=>$entity];
|
||||||
|
$items = \App\Topic::pluck('name', 'id');
|
||||||
|
return view('admin/tasks/edit')->with($x)->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'taskno'=>'required',
|
||||||
|
'desc'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'taskno.required'=>'Task number must not empty',
|
||||||
|
'desc.required'=>'Description must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('admin/topics/'.$id.'/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$entity=\App\Task::find($id);
|
||||||
|
|
||||||
|
$entity->desc=$request->get('desc');
|
||||||
|
$entity->taskno=$request->get('taskno');
|
||||||
|
$entity->topic=$request->get('topic');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','Task with Id='.$id.' is changed');
|
||||||
|
|
||||||
|
return Redirect::to('admin/tasks');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\Task::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message','Task with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('admin/tasks');
|
||||||
|
}
|
||||||
|
}
|
||||||
259
app/Http/Controllers/TaskStudentController.php
Normal file
259
app/Http/Controllers/TaskStudentController.php
Normal file
|
|
@ -0,0 +1,259 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class TaskStudentController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request) {
|
||||||
|
if (Auth::user()->roleid=='student') {
|
||||||
|
//$check=\App\StudentTeacher::where('student','=',Auth::user()->id);
|
||||||
|
//if ($check->count()==0) return view('student/home')->with(['count'=>$check->count()]);
|
||||||
|
$check=\App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status!='active') return view('student/home')->with(['status'=>$check->status]);
|
||||||
|
}
|
||||||
|
$topiclist=\App\Topic::where('status','=','1')->orderBy('name','asc')->get();
|
||||||
|
|
||||||
|
$items = \App\Topic::where('status','=','1')
|
||||||
|
->orderBy('status','desc')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
$itemslearning = \App\Topic::where('status','=','1')
|
||||||
|
->orderBy('status','desc')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->where('level','=','1')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
$filter = $request->input('topicList',$topiclist[0]['id']);
|
||||||
|
|
||||||
|
if ($filter=='0') {
|
||||||
|
$entities=\App\Task::all();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
//$entities=\App\Task::where('topic','=',$filter)->get();//->join('topics','tasks.topic','=','topics.id')->firstOrFail();
|
||||||
|
|
||||||
|
|
||||||
|
$entities = \App\Task::where('topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'tasks.id',
|
||||||
|
'tasks.taskno',
|
||||||
|
'tasks.desc',
|
||||||
|
'tasks.topic',
|
||||||
|
'topics.name'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'topics',
|
||||||
|
'topics.id','=','tasks.topic'
|
||||||
|
)
|
||||||
|
->orderBy('tasks.taskno','asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
//$items = \App\Topic::all();
|
||||||
|
$items = \App\Topic::where('status','=','1')
|
||||||
|
->orderBy('status','desc')
|
||||||
|
->orderBy('name','asc')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
*/
|
||||||
|
if (Auth::user()->roleid=='admin') {
|
||||||
|
return view('admin/tasks/index')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('items'))
|
||||||
|
->with(compact('filter'));
|
||||||
|
} else {
|
||||||
|
$topic = \App\Topic::where('topics.id','=',$filter)
|
||||||
|
->select(
|
||||||
|
'topics.id',
|
||||||
|
'topics.name',
|
||||||
|
'topics.desc',
|
||||||
|
'learning_files.guide',
|
||||||
|
'learning_files.testfile',
|
||||||
|
'learning_files.supplement',
|
||||||
|
'learning_files.other'
|
||||||
|
)
|
||||||
|
->leftJoin('learning_files', 'learning_files.topic', '=', 'topics.id')
|
||||||
|
->first();
|
||||||
|
return view('student/tasks/index')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('items'))
|
||||||
|
->with(compact('itemslearning'))
|
||||||
|
->with(compact('filter'))
|
||||||
|
->with(compact('topic'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getTopic($id){
|
||||||
|
$items = \App\Topic::find($id);
|
||||||
|
|
||||||
|
return $items['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function filterTask() {
|
||||||
|
$filters = \App\Topic::get();
|
||||||
|
$filter = \App\Topic::findOrFail(Input::get('filter_id'));
|
||||||
|
|
||||||
|
$data= \App\Task::with('topic')->where('topic', '=' , $filter->id )->latest()->get();
|
||||||
|
|
||||||
|
return View::make('admin.tasks.index',compact('filters'))->withProfiles($data)->with('title', 'filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$items = \App\Topic::pluck('name', 'id');
|
||||||
|
//echo "kljasd;lkasdl";
|
||||||
|
return view('admin/tasks/create')->with(compact('items'));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
echo "YAAANNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN";
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'taskno'=>'required',
|
||||||
|
'desc'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'taskno.required'=>'Task number must not empty',
|
||||||
|
'desc.required'=>'Description must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('admin/tasks/create')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$entity=new \App\Task;
|
||||||
|
|
||||||
|
$entity->desc=$request->get('desc');
|
||||||
|
$entity->taskno=$request->get('taskno');
|
||||||
|
$entity->topic=$request->get('topic');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New Task Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('admin/tasks');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show(Request $request, $id)
|
||||||
|
{
|
||||||
|
$entity = \App\Task::find($id);
|
||||||
|
$topic = \App\Topic::find($entity->topic);
|
||||||
|
$x=['data'=>$entity, 'topic'=>$topic];
|
||||||
|
|
||||||
|
if ($request->is('admin/*')) {
|
||||||
|
return view('admin/tasks/show')->with($x);
|
||||||
|
} else {
|
||||||
|
return view('student/tasks/show')->with($x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\Task::find($id);
|
||||||
|
$x=['data'=>$entity];
|
||||||
|
$items = \App\Topic::pluck('name', 'id');
|
||||||
|
return view('admin/tasks/edit')->with($x)->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'taskno'=>'required',
|
||||||
|
'desc'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'taskno.required'=>'Task number must not empty',
|
||||||
|
'desc.required'=>'Description must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('admin/topics/'.$id.'/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$entity=\App\Task::find($id);
|
||||||
|
|
||||||
|
$entity->desc=$request->get('desc');
|
||||||
|
$entity->taskno=$request->get('taskno');
|
||||||
|
$entity->topic=$request->get('topic');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','Task with Id='.$id.' is changed');
|
||||||
|
|
||||||
|
return Redirect::to('admin/tasks');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\Task::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message','Task with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('admin/tasks');
|
||||||
|
}
|
||||||
|
}
|
||||||
10
app/Http/Controllers/TastStudentController.php
Normal file
10
app/Http/Controllers/TastStudentController.php
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class TastStudentController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
54
app/Http/Controllers/TeacherClassMemberController.php
Normal file
54
app/Http/Controllers/TeacherClassMemberController.php
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class TeacherClassMemberController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$filter = $request->input('tchList','3');
|
||||||
|
|
||||||
|
if ($filter=='0') {
|
||||||
|
$entities=\App\TopicFiles::all();
|
||||||
|
} else {
|
||||||
|
$entities = \App\User::where('users.uplink','=',$filter)
|
||||||
|
->select(
|
||||||
|
'users.id',
|
||||||
|
'users.name',
|
||||||
|
'users.email',
|
||||||
|
'C.name as classname'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'class_members as B', 'users.id','=','B.student'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'classrooms as C', 'B.classid','=','C.id'
|
||||||
|
)
|
||||||
|
->where('users.status','=','active')
|
||||||
|
->orderBy('C.name','asc')
|
||||||
|
->orderBy('users.name','asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
$items = \App\User::where('roleid','=','teacher')->pluck('name', 'id');
|
||||||
|
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$items];
|
||||||
|
return view('admin/tmember/index')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('items'))
|
||||||
|
->with(compact('filter'));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
12
app/Http/Controllers/TeacherController.php
Normal file
12
app/Http/Controllers/TeacherController.php
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class TeacherController extends Controller
|
||||||
|
{
|
||||||
|
public function index() {
|
||||||
|
return view('teacher/home');
|
||||||
|
}
|
||||||
|
}
|
||||||
230
app/Http/Controllers/TestFilesController.php
Normal file
230
app/Http/Controllers/TestFilesController.php
Normal file
|
|
@ -0,0 +1,230 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
use File;
|
||||||
|
|
||||||
|
class TestFilesController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$filter = $request->input('topicList','1');
|
||||||
|
|
||||||
|
if ($filter=='0') {
|
||||||
|
$entities=\App\TestFiles::all();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
//$entities=\App\Task::where('topic','=',$filter)->get();//->join('topics','tasks.topic','=','topics.id')->firstOrFail();
|
||||||
|
|
||||||
|
|
||||||
|
$entities = \App\TestFiles::where('test_files.topic','=',$filter)
|
||||||
|
->select(
|
||||||
|
'test_files.id',
|
||||||
|
'test_files.taskid',
|
||||||
|
'test_files.fileName',
|
||||||
|
'test_files.content',
|
||||||
|
'topics.name',
|
||||||
|
'tasks.taskno'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'tasks',
|
||||||
|
'tasks.id','=','test_files.taskid'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'topics',
|
||||||
|
'topics.id','=','test_files.topic'
|
||||||
|
)
|
||||||
|
->orderBy('test_files.fileName','asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
//$items = \App\Topic::all();
|
||||||
|
$items = \App\Topic::pluck('name', 'id');
|
||||||
|
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$items];
|
||||||
|
return view('admin/testfiles/index')->with(compact('entities'))->with(compact('items'))->with(compact('filter'));
|
||||||
|
|
||||||
|
|
||||||
|
//return view('admin/tasks/index')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$topic = \App\Topic::find($id);
|
||||||
|
$items = \App\Task::where('topic','=',$id)->orderBy('taskno','asc')->get();
|
||||||
|
|
||||||
|
return view('admin/testfiles/create')
|
||||||
|
->with(compact('topic'))
|
||||||
|
->with(compact('items'));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'testFile'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'testFile.required'=>'Java File must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('admin/testfiles/create/'.$request->get('topic'))
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$file = $request->file('testFile');
|
||||||
|
$filename = $file->getClientOriginalName();
|
||||||
|
$strpath = 'TestFiles/'.$request->get('topic');
|
||||||
|
$testFile=$file->store('testfiles','public');
|
||||||
|
|
||||||
|
$entity=new \App\TestFiles;
|
||||||
|
|
||||||
|
$entity->taskid=$request->get('taskid');
|
||||||
|
$entity->fileName=$filename;
|
||||||
|
$entity->topic=$request->get('topic');
|
||||||
|
$entity->content=$testFile;
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New Test File Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('admin/testfiles?topicList='.$request->get('topic'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$entity = \App\TestFiles::find($id);
|
||||||
|
$task = \App\Task::find($entity->taskid);
|
||||||
|
$topic = \App\Topic::find($entity->topic);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$path = storage_path('app\\public\\').$entity->content;
|
||||||
|
//$path = str_replace('\\',DIRECTORY_SEPARATOR,$path);
|
||||||
|
$content = File::get(getPath($path));
|
||||||
|
//$content = $entity->content;
|
||||||
|
} catch (Illuminate\Contracts\Filesystem\FileNotFoundException $exception) {
|
||||||
|
//die("The file doesn't exist");
|
||||||
|
$content = 'File is not found';
|
||||||
|
}
|
||||||
|
|
||||||
|
$x=['data'=>$entity, 'topic'=>$topic, 'task'=>$task, 'content'=>$content];
|
||||||
|
return view('admin/testfiles/show')->with($x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\TestFiles::find($id);
|
||||||
|
$x=['data'=>$entity];
|
||||||
|
$items = \App\Topic::pluck('name', 'id');
|
||||||
|
return view('admin/testfiles/edit')->with($x)->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id) {
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'testno'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'testno.required'=>'Test number must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('admin/testfiles/'.$id.'/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$file = $request->file('testFile');
|
||||||
|
|
||||||
|
$entity=\App\TestFiles::find($id);
|
||||||
|
|
||||||
|
$entity->testno=$request->get('testno');
|
||||||
|
if ($file!='') {
|
||||||
|
$filename = $file->getClientOriginalName();
|
||||||
|
$strpath = 'TestFiles/'.$request->get('topic');
|
||||||
|
$testFile=$file->store('testfiles','public');
|
||||||
|
|
||||||
|
$entity->fileName=$filename;
|
||||||
|
$entity->content=$testFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
$entity->topic=$request->get('topic');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','Test File with Id='.$id.' is changed');
|
||||||
|
|
||||||
|
return Redirect::to('admin/testfiles');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\TestFiles::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message','Test File with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('admin/testfiles');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPath($path) {
|
||||||
|
$res = str_replace('\\',DIRECTORY_SEPARATOR,$path);
|
||||||
|
return str_replace('/',DIRECTORY_SEPARATOR,$res);
|
||||||
|
}
|
||||||
|
}
|
||||||
172
app/Http/Controllers/TopicController.php
Normal file
172
app/Http/Controllers/TopicController.php
Normal file
|
|
@ -0,0 +1,172 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
//use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class TopicController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entities=\App\Topic::orderBy('name','asc')->orderBy('status', 'asc')->get();
|
||||||
|
//::all();
|
||||||
|
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
|
||||||
|
return view('admin/topics/index')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return view('admin/topics/create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'name'=>'required',
|
||||||
|
'stage'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'name.required'=>'Topic name must not empty',
|
||||||
|
'stage.required'=>'Learning stage must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('admin/topics/create')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$entity=new \App\Topic;
|
||||||
|
|
||||||
|
$name=$request->get('name');
|
||||||
|
|
||||||
|
$entity->name=$name;
|
||||||
|
$entity->stage=$request->get('stage');
|
||||||
|
$entity->desc=$request->get('desc');
|
||||||
|
$entity->packname=$request->get('packname');
|
||||||
|
$entity->projectpath=$request->get('projectpath');
|
||||||
|
$entity->topiccode=substr($name,0,2);
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New Topic Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('admin/topics');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$entity = \App\Topic::find($id);
|
||||||
|
$x=['topic'=>$entity];
|
||||||
|
return view('admin/topics/show')->with($x);
|
||||||
|
//return view('topics.show', array('topic' => $topic));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\Topic::find($id);
|
||||||
|
$x=['topic'=>$entity];
|
||||||
|
return view('admin/topics/edit')->with($x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request,$id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'name'=>'required',
|
||||||
|
'stage'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'name.required'=>'Topic name must not empty',
|
||||||
|
'stage.required'=>'Learning stage must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('admin/topics/'.$id.'/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$entity=\App\Topic::find($id);
|
||||||
|
|
||||||
|
$entity->name=$request->get('name');
|
||||||
|
$entity->stage=$request->get('stage');
|
||||||
|
$entity->desc=$request->get('desc');
|
||||||
|
$entity->packname=$request->get('packname');
|
||||||
|
$entity->projectpath=$request->get('projectpath');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','Topic with Id='.$id.' is changed');
|
||||||
|
return Redirect::to('admin/topics');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\Topic::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message','Topic with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('admin/topics');
|
||||||
|
}
|
||||||
|
}
|
||||||
182
app/Http/Controllers/UiDetailController.php
Normal file
182
app/Http/Controllers/UiDetailController.php
Normal file
|
|
@ -0,0 +1,182 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class UiDetailController extends Controller
|
||||||
|
{
|
||||||
|
private function getListStudent($teacher)
|
||||||
|
{
|
||||||
|
return \App\User::where('users.uplink', '=', $teacher)
|
||||||
|
->join('user_submits', 'user_submits.userid', '=', 'users.id')
|
||||||
|
->join('class_members', 'class_members.student', '=', 'users.id')
|
||||||
|
->join('classrooms', 'classrooms.id', '=', 'class_members.classid')
|
||||||
|
->join('users as x', 'x.id', '=', 'users.uplink')
|
||||||
|
->select('users.id', 'users.name', 'users.email', 'users.roleid', 'classrooms.name as classname', 'x.name as teacher')
|
||||||
|
->orderBy('users.uplink', 'asc')
|
||||||
|
->orderBy('class_members.classid', 'asc')
|
||||||
|
->orderBy('users.name', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getListStudentAll()
|
||||||
|
{
|
||||||
|
return \App\User::where('users.status', '=', 'active')
|
||||||
|
|
||||||
|
->join('user_submits', 'user_submits.userid', '=', 'users.id')
|
||||||
|
->join('class_members', 'class_members.student', '=', 'users.id')
|
||||||
|
->join('classrooms', 'classrooms.id', '=', 'class_members.classid')
|
||||||
|
->join('users as x', 'x.id', '=', 'users.uplink')
|
||||||
|
->select('users.id', 'users.name', 'users.email', 'users.roleid', 'classrooms.name as classname', 'x.name as teacher')
|
||||||
|
->orderBy('users.uplink', 'asc')
|
||||||
|
->orderBy('class_members.classid', 'asc')
|
||||||
|
->orderBy('users.name', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
$student = $this->getListStudentAll();
|
||||||
|
$filter = $request->input('stdList', ($student->count() > 0) ? $student[0]['id'] : '');
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
$student = $this->getListStudent(Auth::user()->id);
|
||||||
|
$filter = $request->input('stdList', ($student->count() > 0) ? $student[0]['id'] : '');
|
||||||
|
} else { //student
|
||||||
|
$check = \App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status != 'active') return view('student/home')->with(['status' => $check->status]);
|
||||||
|
$filter = Auth::user()->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$entities = \App\StudentSubmit::where('student_submits.userid', '=', $filter)
|
||||||
|
->select(
|
||||||
|
'topics.id',
|
||||||
|
'topics.name',
|
||||||
|
'task_results_group_student.passed',
|
||||||
|
'task_results_group_student.failed',
|
||||||
|
'task_results_group_student.avg_duration',
|
||||||
|
'task_results_group_student.tot_duration',
|
||||||
|
'student_submits.checkstat',
|
||||||
|
'student_submits.checkresult',
|
||||||
|
'student_validations_pertopic.failed as vfailed',
|
||||||
|
'student_validations_pertopic.passed as vpassed'
|
||||||
|
)
|
||||||
|
->leftJoin(
|
||||||
|
'task_results_group_student',
|
||||||
|
function ($join) {
|
||||||
|
$join->on('task_results_group_student.userid', '=', 'student_submits.userid');
|
||||||
|
$join->on('task_results_group_student.topic', '=', 'student_submits.topic');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->leftJoin(
|
||||||
|
'student_validations_pertopic',
|
||||||
|
function ($join2) {
|
||||||
|
$join2->on('student_validations_pertopic.userid', '=', 'student_submits.userid');
|
||||||
|
$join2->on('student_validations_pertopic.topic', '=', 'student_submits.topic');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->join('topics', 'topics.id', '=', 'student_submits.topic')
|
||||||
|
->orderBy('topics.name', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
$data = ['entities' => $entities, 'items' => $student, 'filter' => $filter];
|
||||||
|
return view('admin/studentres/index')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
$data = ['entities' => $entities, 'items' => $student, 'filter' => $filter];
|
||||||
|
return view('teacher/studentres/index')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
$data = ['entities' => $entities];
|
||||||
|
return view('student/valid/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getDataShow($student, $id)
|
||||||
|
{
|
||||||
|
$entities = \App\UiStudentResultView::where('userid', $student)
|
||||||
|
->where('id', $id)
|
||||||
|
->get();
|
||||||
|
$uitestfile = \App\UiTestFiles::where('uitopicid', $entities[0]['uitopicid'])->get();
|
||||||
|
$topic = \App\UiTopics::find($entities[0]['uitopicid']);
|
||||||
|
$user = \App\User::find($student);
|
||||||
|
$data = ['entities' => $entities, 'testfile' => $uitestfile, 'topic' => $topic, 'student' => $user];
|
||||||
|
|
||||||
|
// dd($uitestfile);
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$data = $this->getDataShow(Auth::user()->id, $id);
|
||||||
|
|
||||||
|
return view('student/valid/show')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showadmin($student, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$data = $this->getDataShow($student, $id);
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('admin/uistudentres/show')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('teacher/uistudentres/show')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
//$data=['entities'=>$entities];
|
||||||
|
return view('student/valid/show')->with($data);
|
||||||
|
}
|
||||||
|
//return view('teacher/studentres/show')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private function getFileSource($student, $topicid, $id)
|
||||||
|
{
|
||||||
|
$entities = \App\UiFileResults::where('ui_file_results.userid', '=', $student)
|
||||||
|
->select('ui_file_results.codefile', 'ui_topic_files.filename')
|
||||||
|
->join(
|
||||||
|
'ui_topic_files',
|
||||||
|
function ($join) {
|
||||||
|
$join->on('ui_file_results.uicodeid', '=', 'ui_topic_files.id');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->where('ui_topic_files.uitopicid', $topicid)
|
||||||
|
->where('ui_file_results.uisubmitid', $id)
|
||||||
|
->orderBy('ui_topic_files.id', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$topic = \App\UiTopics::find($topicid);
|
||||||
|
$user = \App\User::find($student);
|
||||||
|
$data = ['entities' => $entities, 'topic' => $topic, 'student' => $user];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function showsource($student, $topicid, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$data = $this->getFileSource($student, $topicid, $id);
|
||||||
|
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('admin/uiuploadsrc/index')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('teacher/uiuploadsrc/index')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
//$data=['entities'=>$entities];
|
||||||
|
return view('student/uistudentres/show')->with($data);
|
||||||
|
}
|
||||||
|
//return view('teacher/studentres/show')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
116
app/Http/Controllers/UiFeedbackController.php
Normal file
116
app/Http/Controllers/UiFeedbackController.php
Normal file
|
|
@ -0,0 +1,116 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class UiFeedbackController extends Controller
|
||||||
|
{
|
||||||
|
public function create($id)
|
||||||
|
{
|
||||||
|
$userid = Auth::user()->id;
|
||||||
|
$taskid = $id;
|
||||||
|
$result = \App\UiTaskResult::where('userid', $userid)
|
||||||
|
->select('id', 'duration', 'comment')
|
||||||
|
->where('taskid', $taskid)
|
||||||
|
->get();
|
||||||
|
return view('student/uifeedback/create')
|
||||||
|
->with(compact('result'))
|
||||||
|
->with(compact('taskid'));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function saveTaskResult(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules = [
|
||||||
|
'duration' => 'required',
|
||||||
|
'comment' => 'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg = [
|
||||||
|
'duration.required' => 'Duration time must not empty',
|
||||||
|
'comment.required' => 'Comment must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $rules, $msg);
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('student/uifeedback/' . $request->get('topic'))
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
$entity = new \App\UiTaskResult();
|
||||||
|
|
||||||
|
$comment = ($request->get('comment') == null) ? '-' : $request->get('comment');
|
||||||
|
|
||||||
|
$entity->userid = Auth::user()->id;
|
||||||
|
$entity->taskid = $request->get('topic');
|
||||||
|
$entity->duration = $request->get('duration');
|
||||||
|
$entity->comment = $comment;
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message', 'A New Task Result Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('student/uifeedback/' . $request->get('topic'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$userid = Auth::user()->id;
|
||||||
|
$taskid = $request->get('topic');;
|
||||||
|
$result = \App\UiTaskResult::where('userid', $userid)
|
||||||
|
->select('id', 'duration', 'comment')
|
||||||
|
->where('taskid', $taskid)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if (empty($result[0])) {
|
||||||
|
return $this->saveTaskResult($request);
|
||||||
|
} else {
|
||||||
|
return $this->update($request, $result[0]['id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules = [
|
||||||
|
'duration' => 'required',
|
||||||
|
'comment' => 'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg = [
|
||||||
|
'duration.required' => 'Duration time must not empty',
|
||||||
|
'comment.required' => 'Comment must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $rules, $msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('student/uifeedback/' . $request->get('topic'))
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
$entity = \App\UiTaskResult::find($id);
|
||||||
|
|
||||||
|
$comment = ($request->get('comment') == null) ? '-' : $request->get('comment');
|
||||||
|
|
||||||
|
$entity->duration = $request->get('duration');
|
||||||
|
$entity->comment = $comment;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message', 'Task Result for UI topic ' . $request->get('topic') . ' is changed');
|
||||||
|
|
||||||
|
return Redirect::to('student/uifeedback/' . $request->get('topic'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
74
app/Http/Controllers/UiResultClassController.php
Normal file
74
app/Http/Controllers/UiResultClassController.php
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class UiResultClassController extends Controller
|
||||||
|
{
|
||||||
|
private function getListClass($teacher)
|
||||||
|
{
|
||||||
|
return \App\Classroom::where('owner', '=', $teacher)
|
||||||
|
->join('users', 'users.id', '=', 'classrooms.owner')
|
||||||
|
->select('users.name', 'classrooms.id', 'classrooms.name as classname')
|
||||||
|
->orderBy('classrooms.name', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getListClassAll()
|
||||||
|
{
|
||||||
|
return \App\Classroom::where('status', '=', 'active')
|
||||||
|
->join('users', 'users.id', '=', 'classrooms.owner')
|
||||||
|
->select('users.name', 'classrooms.id', 'classrooms.name as classname')
|
||||||
|
->orderBy('classrooms.name', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
$class = $this->getListClassAll();
|
||||||
|
$filter = $request->input('stdList', ($class->count() > 0) ? $class[0]['id'] : '');
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
$class = $this->getListClass(Auth::user()->id);
|
||||||
|
$filter = $request->input('stdList', ($class->count() > 0) ? $class[0]['id'] : '');
|
||||||
|
} else { //student
|
||||||
|
$check = \App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status != 'active') return view('student/home')->with(['status' => $check->status]);
|
||||||
|
$filter = Auth::user()->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$subsubQuery = DB::table('ui_student_submits_view')
|
||||||
|
->select(DB::raw('userid, student AS name, count(distinct(topic)) AS passednumber, GROUP_CONCAT(distinct(topic) SEPARATOR "\n") AS topiclist'))
|
||||||
|
->where('checkstat', '=', 'PASSED')
|
||||||
|
->groupBy('userid');
|
||||||
|
|
||||||
|
$entities = DB::table('class_members')
|
||||||
|
->Leftjoin('users', 'class_members.student', '=', 'users.id')
|
||||||
|
->leftJoinSub($subsubQuery, 'B', function ($join) {
|
||||||
|
$join->on('class_members.student', '=', 'B.userid');
|
||||||
|
})
|
||||||
|
->select(DB::raw('users.id AS userid, users.name, B.passednumber, B.topiclist'))
|
||||||
|
->where('class_members.classid', '=', $filter)
|
||||||
|
->orderBy('users.name', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$topiccount = \App\UiTopics::where('status', '=', '1')
|
||||||
|
->count('id');
|
||||||
|
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
$data = ['entities' => $entities, 'topiccount' => $topiccount, 'items' => $class, 'filter' => $filter];
|
||||||
|
return view('admin/uiclasssummary/index')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
$data = ['entities' => $entities, 'topiccount' => $topiccount, 'items' => $class, 'filter' => $filter];
|
||||||
|
return view('teacher/uiclasssummary/index')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
$data = ['entities' => $entities];
|
||||||
|
return view('student/valid/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
86
app/Http/Controllers/UiResultController.php
Normal file
86
app/Http/Controllers/UiResultController.php
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class UiResultController extends Controller
|
||||||
|
{
|
||||||
|
private function getListStudent($teacher)
|
||||||
|
{
|
||||||
|
return \App\User::where('users.uplink', '=', $teacher)
|
||||||
|
->join('user_submits', 'user_submits.userid', '=', 'users.id')
|
||||||
|
->join('class_members', 'class_members.student', '=', 'users.id')
|
||||||
|
->join('classrooms', 'classrooms.id', '=', 'class_members.classid')
|
||||||
|
->join('users as x', 'x.id', '=', 'users.uplink')
|
||||||
|
->select('users.id', 'users.name', 'users.email', 'users.roleid', 'classrooms.name as classname', 'x.name as teacher')
|
||||||
|
->orderBy('users.uplink', 'asc')
|
||||||
|
->orderBy('class_members.classid', 'asc')
|
||||||
|
->orderBy('users.name', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getListStudentAll()
|
||||||
|
{
|
||||||
|
return \App\User::where('users.status', '=', 'active')
|
||||||
|
|
||||||
|
->join('user_submits', 'user_submits.userid', '=', 'users.id')
|
||||||
|
->join('class_members', 'class_members.student', '=', 'users.id')
|
||||||
|
->join('classrooms', 'classrooms.id', '=', 'class_members.classid')
|
||||||
|
->join('users as x', 'x.id', '=', 'users.uplink')
|
||||||
|
->select('users.id', 'users.name', 'users.email', 'users.roleid', 'classrooms.name as classname', 'x.name as teacher')
|
||||||
|
->orderBy('users.uplink', 'asc')
|
||||||
|
->orderBy('class_members.classid', 'asc')
|
||||||
|
->orderBy('users.name', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
$student = $this->getListStudentAll();
|
||||||
|
$filter = $request->input('stdList', ($student->count() > 0) ? $student[0]['id'] : '');
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
$student = $this->getListStudent(Auth::user()->id);
|
||||||
|
$filter = $request->input('stdList', ($student->count() > 0) ? $student[0]['id'] : '');
|
||||||
|
} else { //student
|
||||||
|
$check = \App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status != 'active') return view('student/home')->with(['status' => $check->status]);
|
||||||
|
$filter = Auth::user()->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$subsubQuery = DB::table('ui_student_submits')
|
||||||
|
->select(DB::raw('uitopic AS uitopicnow,Count(id) as jumlah_submit, max(checkresult) as checkresult, max(checkstat) AS checkstat, max(created_at) AS createdate'))
|
||||||
|
->where('userid', '=', $filter)
|
||||||
|
->groupBy('uitopicnow');
|
||||||
|
|
||||||
|
$entities = DB::table('ui_topics')
|
||||||
|
->leftJoinSub($subsubQuery, 'B', function ($join) {
|
||||||
|
$join->on('ui_topics.id', '=', 'B.uitopicnow');
|
||||||
|
})
|
||||||
|
->where('ui_topics.status', '=', '1')
|
||||||
|
->select(DB::raw('ui_topics.id, name, jumlah_submit, checkresult AS checkresult, UPPER(checkstat) AS checkstat'))
|
||||||
|
->distinct()
|
||||||
|
->orderBy('ui_topics.id', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
$data = ['entities' => $entities, 'items' => $student, 'filter' => $filter];
|
||||||
|
return view('admin/uisummaryres/index')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
$data = ['entities' => $entities, 'items' => $student, 'filter' => $filter];
|
||||||
|
return view('teacher/uisummaryres/index')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
$data = ['entities' => $entities];
|
||||||
|
return view('student/valid/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
46
app/Http/Controllers/UiResultViewController.php
Normal file
46
app/Http/Controllers/UiResultViewController.php
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
|
||||||
|
class UiResultViewController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
$entities = \App\UiStudentResultView::orderBy('id', 'desc')->get();
|
||||||
|
$data = ['entities' => $entities];
|
||||||
|
return view('admin/uiresview/index')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
$entities = \App\UiStudentResultView::orderBy('id', 'desc')
|
||||||
|
->where('teacher', Auth::user()->name)
|
||||||
|
->get();
|
||||||
|
$data = ['entities' => $entities];
|
||||||
|
return view('teacher/uiresview/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showhistory($student, $topicid)
|
||||||
|
{
|
||||||
|
$entities = \App\UiStudentResultView::where('userid', $student)
|
||||||
|
->where('uitopicid', $topicid)
|
||||||
|
->orderBy('id', 'DESC')->get();
|
||||||
|
|
||||||
|
$topic = \App\UiTopics::find($topicid);
|
||||||
|
$user = \App\User::find($student);
|
||||||
|
$data = ['entities' => $entities, 'topic' => $topic, 'student' => $user];
|
||||||
|
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
return view('admin/uiresview/show')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
return view('teacher/uiresview/show')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
44
app/Http/Controllers/UiStudentResultViewController.php
Normal file
44
app/Http/Controllers/UiStudentResultViewController.php
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class UiStudentResultViewController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$subsubQuery = DB::table('ui_student_submits')
|
||||||
|
->select(DB::raw('uitopic AS uitopicnow,max(checkstat) AS checkstatnow, max(created_at) AS createdate'))
|
||||||
|
->where('userid', '=', Auth::user()->id)
|
||||||
|
->groupBy('uitopicnow');
|
||||||
|
|
||||||
|
$entitiesresult = DB::table('ui_topics')
|
||||||
|
->leftJoinSub($subsubQuery, 'B', function ($join) {
|
||||||
|
$join->on('ui_topics.id', '=', 'B.uitopicnow');
|
||||||
|
})
|
||||||
|
->where('ui_topics.status', '=', '1')
|
||||||
|
->select(DB::raw('ui_topics.id, name, description, LOWER(checkstatnow) AS checkstatnow'))
|
||||||
|
->distinct()
|
||||||
|
->orderBy('ui_topics.id', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$entities = \App\UiStudentResultView::where('userid', Auth::user()->id)
|
||||||
|
->orderBy('id', 'desc')->get();
|
||||||
|
|
||||||
|
$data = ['entities' => $entities];
|
||||||
|
|
||||||
|
$topiccount = \App\UiTopics::count('id');
|
||||||
|
|
||||||
|
return view('student/uiresview/index')
|
||||||
|
->with(compact('entities'))
|
||||||
|
->with(compact('topiccount'))
|
||||||
|
->with(compact('entitiesresult'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
182
app/Http/Controllers/UiStudentValidController.php
Normal file
182
app/Http/Controllers/UiStudentValidController.php
Normal file
|
|
@ -0,0 +1,182 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class UiStudentValidController extends Controller
|
||||||
|
{
|
||||||
|
private function getListStudent($teacher)
|
||||||
|
{
|
||||||
|
return \App\User::where('users.uplink', '=', $teacher)
|
||||||
|
->join('user_submits', 'user_submits.userid', '=', 'users.id')
|
||||||
|
->join('class_members', 'class_members.student', '=', 'users.id')
|
||||||
|
->join('classrooms', 'classrooms.id', '=', 'class_members.classid')
|
||||||
|
->join('users as x', 'x.id', '=', 'users.uplink')
|
||||||
|
->select('users.id', 'users.name', 'users.email', 'users.roleid', 'classrooms.name as classname', 'x.name as teacher')
|
||||||
|
->orderBy('users.uplink', 'asc')
|
||||||
|
->orderBy('class_members.classid', 'asc')
|
||||||
|
->orderBy('users.name', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getListStudentAll()
|
||||||
|
{
|
||||||
|
return \App\User::where('users.status', '=', 'active')
|
||||||
|
|
||||||
|
->join('user_submits', 'user_submits.userid', '=', 'users.id')
|
||||||
|
->join('class_members', 'class_members.student', '=', 'users.id')
|
||||||
|
->join('classrooms', 'classrooms.id', '=', 'class_members.classid')
|
||||||
|
->join('users as x', 'x.id', '=', 'users.uplink')
|
||||||
|
->select('users.id', 'users.name', 'users.email', 'users.roleid', 'classrooms.name as classname', 'x.name as teacher')
|
||||||
|
->orderBy('users.uplink', 'asc')
|
||||||
|
->orderBy('class_members.classid', 'asc')
|
||||||
|
->orderBy('users.name', 'asc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
$student = $this->getListStudentAll();
|
||||||
|
$filter = $request->input('stdList', ($student->count() > 0) ? $student[0]['id'] : '');
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
$student = $this->getListStudent(Auth::user()->id);
|
||||||
|
$filter = $request->input('stdList', ($student->count() > 0) ? $student[0]['id'] : '');
|
||||||
|
} else { //student
|
||||||
|
$check = \App\User::find(Auth::user()->id);
|
||||||
|
if ($check->status != 'active') return view('student/home')->with(['status' => $check->status]);
|
||||||
|
$filter = Auth::user()->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$entities = \App\StudentSubmit::where('student_submits.userid', '=', $filter)
|
||||||
|
->select(
|
||||||
|
'topics.id',
|
||||||
|
'topics.name',
|
||||||
|
'task_results_group_student.passed',
|
||||||
|
'task_results_group_student.failed',
|
||||||
|
'task_results_group_student.avg_duration',
|
||||||
|
'task_results_group_student.tot_duration',
|
||||||
|
'student_submits.checkstat',
|
||||||
|
'student_submits.checkresult',
|
||||||
|
'student_validations_pertopic.failed as vfailed',
|
||||||
|
'student_validations_pertopic.passed as vpassed'
|
||||||
|
)
|
||||||
|
->leftJoin(
|
||||||
|
'task_results_group_student',
|
||||||
|
function ($join) {
|
||||||
|
$join->on('task_results_group_student.userid', '=', 'student_submits.userid');
|
||||||
|
$join->on('task_results_group_student.topic', '=', 'student_submits.topic');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->leftJoin(
|
||||||
|
'student_validations_pertopic',
|
||||||
|
function ($join2) {
|
||||||
|
$join2->on('student_validations_pertopic.userid', '=', 'student_submits.userid');
|
||||||
|
$join2->on('student_validations_pertopic.topic', '=', 'student_submits.topic');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->join('topics', 'topics.id', '=', 'student_submits.topic')
|
||||||
|
->orderBy('topics.name', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
$data = ['entities' => $entities, 'items' => $student, 'filter' => $filter];
|
||||||
|
return view('admin/studentres/index')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
$data = ['entities' => $entities, 'items' => $student, 'filter' => $filter];
|
||||||
|
return view('teacher/studentres/index')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
$data = ['entities' => $entities];
|
||||||
|
return view('student/valid/index')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getDataShow($student, $id)
|
||||||
|
{
|
||||||
|
$entities = \App\UiStudentResultView::where('userid', $student)
|
||||||
|
->where('id', $id)
|
||||||
|
->get();
|
||||||
|
$uitestfile = \App\UiTestFiles::where('uitopicid', $entities[0]['uitopicid'])->get();
|
||||||
|
$topic = \App\UiTopics::find($entities[0]['uitopicid']);
|
||||||
|
$user = \App\User::find($student);
|
||||||
|
$data = ['entities' => $entities, 'testfile' => $uitestfile, 'topic' => $topic, 'student' => $user];
|
||||||
|
|
||||||
|
// dd($uitestfile);
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$data = $this->getDataShow(Auth::user()->id, $id);
|
||||||
|
|
||||||
|
return view('student/uistudentres/show')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showstudent($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$data = $this->getDataShow(Auth::user()->id, $id);
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('admin/uistudentres/show')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('teacher/uistudentres/show')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
//$data=['entities'=>$entities];
|
||||||
|
return view('student/uistudentres/show')->with($data);
|
||||||
|
}
|
||||||
|
//return view('teacher/studentres/show')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private function getFileSource($student, $topicid, $id)
|
||||||
|
{
|
||||||
|
$entities = \App\UiFileResults::where('ui_file_results.userid', '=', $student)
|
||||||
|
->select('ui_file_results.codefile', 'ui_topic_files.filename')
|
||||||
|
->join(
|
||||||
|
'ui_topic_files',
|
||||||
|
function ($join) {
|
||||||
|
$join->on('ui_file_results.uicodeid', '=', 'ui_topic_files.id');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->where('ui_topic_files.uitopicid', $topicid)
|
||||||
|
->where('ui_file_results.uisubmitid', $id)
|
||||||
|
->orderBy('ui_topic_files.id', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$topic = \App\UiTopics::find($topicid);
|
||||||
|
$user = \App\User::find($student);
|
||||||
|
$data = ['entities' => $entities, 'topic' => $topic, 'student' => $user];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function showsource($topicid, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$data = $this->getFileSource(Auth::user()->id, $topicid, $id);
|
||||||
|
|
||||||
|
if (Auth::user()->roleid == 'admin') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('admin/uiuploadsrc/index')->with($data);
|
||||||
|
} else if (Auth::user()->roleid == 'teacher') {
|
||||||
|
//$data=['entities'=>$entities, 'items'=>$student, 'filter'=>$filter];
|
||||||
|
return view('teacher/uploadsrc/index')->with($data);
|
||||||
|
} else { //as student
|
||||||
|
//$data=['entities'=>$entities];
|
||||||
|
return view('student/uiuploadsrc/index')->with($data);
|
||||||
|
}
|
||||||
|
//return view('teacher/studentres/show')->with($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
195
app/Http/Controllers/UiTestFilesController.php
Normal file
195
app/Http/Controllers/UiTestFilesController.php
Normal file
|
|
@ -0,0 +1,195 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
use File;
|
||||||
|
|
||||||
|
class UiTestFilesController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$entities = \App\UiTestFiles::join('ui_topics', 'ui_test_files.uitopicid', '=', 'ui_topics.id')
|
||||||
|
->select(
|
||||||
|
'ui_test_files.id',
|
||||||
|
'ui_test_files.uitopicid',
|
||||||
|
'ui_test_files.testfile',
|
||||||
|
'ui_test_files.filename',
|
||||||
|
'ui_topics.name',
|
||||||
|
'ui_topics.description'
|
||||||
|
)
|
||||||
|
->orderBy('ui_test_files.uitopicid', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return view('admin/uitestfiles/index')->with(compact('entities'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$topics = \App\UiTopics::all();
|
||||||
|
return view('admin/uitestfiles/create')
|
||||||
|
->with(compact('topics'));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules = [
|
||||||
|
'testFile' => 'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg = [
|
||||||
|
'testFile.required' => 'Test File must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $rules, $msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('admin/uitestfiles/create/')
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
$file = $request->file('testFile');
|
||||||
|
$filename = $file->getClientOriginalName();
|
||||||
|
$testFile = $file->storeAs('/public/uitestfiles', Str::uuid().'.html');
|
||||||
|
//$testFile = $file->store('uitestfiles', 'public');
|
||||||
|
$maxId = DB::table('ui_test_files')->max('id');
|
||||||
|
|
||||||
|
$entity = new \App\UiTestFiles();
|
||||||
|
|
||||||
|
$entity->id = $maxId + 1;
|
||||||
|
$entity->uitopicid = $request->get('taskid');
|
||||||
|
$entity->filename = $filename;
|
||||||
|
$entity->testfile = str_replace('public/', '', $testFile);
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message', 'A New Test File Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('admin/uitestfiles/');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$entity = \App\UiTestFiles::find($id);
|
||||||
|
$topic = \App\UiTopics::find($entity->uitopicid);
|
||||||
|
|
||||||
|
$x = ['data' => $entity, 'topic' => $topic];
|
||||||
|
return view('admin/uitestfiles/show')->with($x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
//$entity = \App\TestFiles::find($id);
|
||||||
|
//$x = ['data' => $entity];
|
||||||
|
//$items = \App\Topic::pluck('name', 'id');
|
||||||
|
//return view('admin/testfiles/edit')->with($x)->with(compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//NOT USED (TIDAK DIGUNAKAN)
|
||||||
|
$rules = [
|
||||||
|
'testno' => 'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg = [
|
||||||
|
'testno.required' => 'Test number must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $rules, $msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('admin/testfiles/' . $id . '/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
$file = $request->file('testFile');
|
||||||
|
|
||||||
|
$entity = \App\TestFiles::find($id);
|
||||||
|
|
||||||
|
$entity->testno = $request->get('testno');
|
||||||
|
if ($file != '') {
|
||||||
|
$filename = $file->getClientOriginalName();
|
||||||
|
$strpath = 'TestFiles/' . $request->get('topic');
|
||||||
|
$testFile = $file->store('testfiles', 'public');
|
||||||
|
|
||||||
|
$entity->fileName = $filename;
|
||||||
|
$entity->content = $testFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
$entity->topic = $request->get('topic');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message', 'Test File with Id=' . $id . ' is changed');
|
||||||
|
|
||||||
|
return Redirect::to('admin/testfiles');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\UiTestFiles::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message', 'Test File with Id=' . $id . ' is deleted');
|
||||||
|
return Redirect::to('admin/uitestfiles');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPath($path)
|
||||||
|
{
|
||||||
|
$res = str_replace('\\', DIRECTORY_SEPARATOR, $path);
|
||||||
|
return str_replace('/', DIRECTORY_SEPARATOR, $res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
204
app/Http/Controllers/UiTopicController.php
Normal file
204
app/Http/Controllers/UiTopicController.php
Normal file
|
|
@ -0,0 +1,204 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
|
||||||
|
//use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class UiTopicController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$entities = \App\UiTopics::orderBy('level', 'asc')->get();
|
||||||
|
|
||||||
|
$data = ['entities' => $entities];
|
||||||
|
|
||||||
|
return view('admin/uitopic/index')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return view('admin/uitopic/create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules = [
|
||||||
|
'name' => 'required',
|
||||||
|
'guideFile' => 'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg = [
|
||||||
|
'name.required' => 'Topic name must not empty',
|
||||||
|
'guideFile.required' => 'Guide file must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $rules, $msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('admin/uitopic/create')
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
//mengisi UI_TOPICS
|
||||||
|
$file = $request->file('guideFile');
|
||||||
|
$filePath = $file->store('uilearningfile', 'public');
|
||||||
|
|
||||||
|
$entity = new \App\UiTopics;
|
||||||
|
$entity->id = \App\UiTopics::max('id') + 1;
|
||||||
|
$entity->level = $request->get('level');
|
||||||
|
$entity->name = $request->get('name');
|
||||||
|
$entity->note = $request->get('note');
|
||||||
|
$entity->projectname = $request->get('projectname');
|
||||||
|
$entity->projectpath = $request->get('projectpath');
|
||||||
|
$entity->packname = $request->get('packname');
|
||||||
|
$entity->description = $request->get('description');
|
||||||
|
$entity->guidepath = $filePath;
|
||||||
|
$entity->status = $request->get('status');
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
$xmlName = ['activity_main.xml', 'colors.xml', 'strings.xml'];
|
||||||
|
$pathfile = ['app/src/main/res/layout/', 'app/src/main/res/values/', 'app/src/main/res/values/'];
|
||||||
|
|
||||||
|
//mengisi UI_TOPIC_FILES
|
||||||
|
for ($i = 0; $i < 3; $i++) {
|
||||||
|
$entity = new \App\UiTopicFiles;
|
||||||
|
$nextid = \App\UiTopicFiles::max('id') + 1;
|
||||||
|
|
||||||
|
$entity->id = $nextid;
|
||||||
|
$entity->uitopicid = \App\UiTopics::max('id');
|
||||||
|
$entity->filename = $xmlName[$i];
|
||||||
|
$entity->location = $pathfile[$i];
|
||||||
|
$entity->codeno = $nextid;
|
||||||
|
|
||||||
|
$entity->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
Session::flash('message', 'A New Topic Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('admin/uitopic');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show(Request $request, $id)
|
||||||
|
{
|
||||||
|
$entity = \App\UiTopics::find($id);
|
||||||
|
|
||||||
|
$x = ['uitopic' => $entity];
|
||||||
|
|
||||||
|
return view('admin/uitopic/show')->with($x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\UiTopics::find($id);
|
||||||
|
$x = ['uitopic' => $entity];
|
||||||
|
return view('admin/uitopic/edit')->with($x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules = [
|
||||||
|
'name' => 'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg = [
|
||||||
|
'name.required' => 'Topic name must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $rules, $msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('admin/uitopic/' . $id . '/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
$entity = \App\UiTopics::find($id);
|
||||||
|
$file = $request->file('guideFile');
|
||||||
|
|
||||||
|
$entity->level = $request->get('level');
|
||||||
|
$entity->name = $request->get('name');
|
||||||
|
$entity->note = $request->get('note');
|
||||||
|
$entity->projectname = $request->get('projectname');
|
||||||
|
$entity->projectpath = $request->get('projectpath');
|
||||||
|
$entity->packname = $request->get('packname');
|
||||||
|
$entity->description = $request->get('description');
|
||||||
|
if (!is_null($file)) {
|
||||||
|
$filePath = $file->store('uilearningfile', 'public');
|
||||||
|
$entity->guidepath = $filePath;
|
||||||
|
}
|
||||||
|
$entity->status = $request->get('status');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message', 'UiTopic with Id=' . $id . ' is changed');
|
||||||
|
return Redirect::to('admin/uitopic');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\UiTopics::find($id);
|
||||||
|
$uitopicfiles = \App\UiTopicFiles::where('uitopicid', '=', $id);
|
||||||
|
$entity->delete();
|
||||||
|
$uitopicfiles->delete();
|
||||||
|
Session::flash('message', 'Topic with Id=' . $id . ' and Ui Codes with UiTopicId=' . $id . ' is deleted');
|
||||||
|
return Redirect::to('admin/uitopic');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
177
app/Http/Controllers/UiTopicController_backup.php
Normal file
177
app/Http/Controllers/UiTopicController_backup.php
Normal file
|
|
@ -0,0 +1,177 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
//use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class UiTopicController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entities=\App\UiTopic::orderBy('level','asc')->get();
|
||||||
|
//::all();
|
||||||
|
|
||||||
|
$data=['entities'=>$entities];
|
||||||
|
|
||||||
|
return view('admin/uitopic/index')->with($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return view('admin/uitopics/create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'name'=>'required',
|
||||||
|
'level'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'name.required'=>'Topic name must not empty',
|
||||||
|
'level.required'=>'Learning level must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('admin/topics/create')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$entity=new \App\UiTopic;
|
||||||
|
|
||||||
|
//$entity->name=$request->get('name');
|
||||||
|
|
||||||
|
$entity->level = $request->get('level');
|
||||||
|
$entity->name = $request->get('name');
|
||||||
|
$entity->projectname = $request->get('projectname');
|
||||||
|
$entity->projectpath = $request->get('projectpath');
|
||||||
|
$entity->packname = $request->get('packname');
|
||||||
|
$entity->description = $request->get('description');
|
||||||
|
$entity->guidepath = $request->get('guidepath');
|
||||||
|
$entity->status = $request->get('status');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','A New Topic Stored');
|
||||||
|
|
||||||
|
//return "Add new topic is success";
|
||||||
|
return Redirect::to('admin/uitopics');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$entity = \App\UiTopic::find($id);
|
||||||
|
$x=['topic'=>$entity];
|
||||||
|
return view('admin/uitopics/show')->with($x);
|
||||||
|
//return view('topics.show', array('topic' => $topic));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\UiTopic::find($id);
|
||||||
|
$x=['topic'=>$entity];
|
||||||
|
return view('admin/uitopics/edit')->with($x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request,$id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$rules =[
|
||||||
|
'name'=>'required',
|
||||||
|
'level'=>'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg=[
|
||||||
|
'name.required'=>'Topic name must not empty',
|
||||||
|
'level.required'=>'Learning level must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$validator=Validator::make($request->all(),$rules,$msg);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return Redirect::to('admin/uitopics/'.$id.'/edit')
|
||||||
|
->withErrors($validator);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$entity=\App\UiTopic::find($id);
|
||||||
|
|
||||||
|
$entity->level = $request->get('level');
|
||||||
|
$entity->name = $request->get('name');
|
||||||
|
$entity->projectname = $request->get('projectname');
|
||||||
|
$entity->projectpath = $request->get('projectpath');
|
||||||
|
$entity->packname = $request->get('packname');
|
||||||
|
$entity->description = $request->get('description');
|
||||||
|
$entity->guidepath = $request->get('guidepath');
|
||||||
|
$entity->status = $request->get('status');
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
Session::flash('message','Topic with Id='.$id.' is changed');
|
||||||
|
return Redirect::to('admin/uitopics');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$entity = \App\Topic::find($id);
|
||||||
|
$entity->delete();
|
||||||
|
Session::flash('message','Topic with Id='.$id.' is deleted');
|
||||||
|
return Redirect::to('admin/topics');
|
||||||
|
}
|
||||||
|
}
|
||||||
255
app/Http/Controllers/UiTopicStdController.php
Normal file
255
app/Http/Controllers/UiTopicStdController.php
Normal file
|
|
@ -0,0 +1,255 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Response;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
//use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class UiTopicStdController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// $entities = \App\UiTopics::where('status', '=', '1')
|
||||||
|
// ->get();
|
||||||
|
|
||||||
|
$subQuery = DB::table('ui_student_submits')
|
||||||
|
->where('userid', '=', Auth::user()->id)
|
||||||
|
->where('checkstat', '=', 'PASSED');
|
||||||
|
|
||||||
|
$entities = DB::table('ui_topics')
|
||||||
|
->leftJoinSub($subQuery, 'B', function ($join) {
|
||||||
|
$join->on('ui_topics.id', '=', 'B.uitopic');
|
||||||
|
})
|
||||||
|
->where('ui_topics.status', '=', '1')
|
||||||
|
->select('ui_topics.id', 'name', 'description', 'checkstat')
|
||||||
|
->distinct()
|
||||||
|
->orderBy('ui_topics.id', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$data = ['entities' => $entities];
|
||||||
|
|
||||||
|
return view('student/uitasks/index')
|
||||||
|
->with(compact('entities'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return view('admin/uitopic/create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
// SUBMIT TASK PADA student/uitasks/(id)
|
||||||
|
$rules = [
|
||||||
|
'MainActivity' => 'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
$msg = [
|
||||||
|
'MainActivity.required' => 'MainActivity.xml must not empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $rules, $msg);
|
||||||
|
|
||||||
|
//jika data ada yang kosong
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
//refresh halaman
|
||||||
|
return Redirect::to('student/uitasks/' . $request->get('id'))
|
||||||
|
->withErrors($validator);
|
||||||
|
} else {
|
||||||
|
$codebox = array();
|
||||||
|
$codebox[0] = $request->get('MainActivity');
|
||||||
|
$codebox[1] = $request->get('Color');
|
||||||
|
$codebox[2] = $request->get('String');
|
||||||
|
|
||||||
|
//save UiStudentSubmits data to variable
|
||||||
|
$this->insertUiStudentSubmits($request->get('id'));
|
||||||
|
//insert data to UiStudentValidations
|
||||||
|
// $this->insertUiStudentValidations($request, $UiStudentSubmitID);
|
||||||
|
//insert data to UiFileResults
|
||||||
|
$this->insertUiFileResults($codebox, $request);
|
||||||
|
|
||||||
|
//jika berhasil lempar pesan ini
|
||||||
|
Session::flash('message', 'Task were successfully submitted');
|
||||||
|
|
||||||
|
//dialihkan ke .../student/uitasks/(id)
|
||||||
|
return Redirect::to('student/uitasks/' . $request->get('id'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function insertUiStudentSubmits($topicid)
|
||||||
|
{
|
||||||
|
# code...
|
||||||
|
$entity = new \App\UiStudentSubmits;
|
||||||
|
$maxId = DB::table('ui_student_submits')->max('id');
|
||||||
|
|
||||||
|
$entity->id = $maxId + 1;
|
||||||
|
$entity->userid = Auth::user()->id;
|
||||||
|
$entity->uitopic = $topicid;
|
||||||
|
$entity->checkresult = "-";
|
||||||
|
$entity->save();
|
||||||
|
|
||||||
|
return $maxId + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function insertUiStudentValidations($request, $UIStudentSubmit)
|
||||||
|
{
|
||||||
|
# code...
|
||||||
|
$testFiles = \App\UiTestFiles::where('uitopicid', '=', $request->get('id'))
|
||||||
|
->orderBy('id')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($testFiles as $ts) {
|
||||||
|
$entity = new \App\UiStudentValidations();
|
||||||
|
|
||||||
|
$maxId = DB::table('ui_student_validations')->max('id');
|
||||||
|
|
||||||
|
$entity->id = $maxId + 1;
|
||||||
|
$entity->userid = Auth::user()->id;
|
||||||
|
$entity->testid = $ts['id'];
|
||||||
|
$entity->submitid = $UIStudentSubmit;
|
||||||
|
$entity->report = "-";
|
||||||
|
$entity->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function insertUiFileResults($codebox, $request)
|
||||||
|
{
|
||||||
|
$index = 0;
|
||||||
|
|
||||||
|
foreach ($codebox as $textareas) {
|
||||||
|
# code...
|
||||||
|
$entity = new \App\UiFileResults;
|
||||||
|
|
||||||
|
// filter data for uisubmitid column (based userid & uitopic)
|
||||||
|
$uisubmitid_filter = \App\UiStudentSubmits::where('userid', '=', Auth::user()->id)
|
||||||
|
->where('uitopic', '=', $request->get('id'))
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->take(1)
|
||||||
|
->get();
|
||||||
|
$maxId = DB::table('ui_file_results')->max('id');
|
||||||
|
$uisubmitid_id = $uisubmitid_filter[0]['id'];
|
||||||
|
$uitopicfilesid = \App\UiTopicFiles::where('uitopicid', '=', $request->get('id'))
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// create file with random name (using uuid()) for codefile column
|
||||||
|
$filename = Str::uuid();
|
||||||
|
File::put(storage_path('app/public/uiresource/' . $filename . '.txt'), $textareas);
|
||||||
|
$file_path = ('uiresource/' . $filename . '.txt');
|
||||||
|
|
||||||
|
//Insert data to table
|
||||||
|
$entity->id = $maxId + 1;
|
||||||
|
$entity->userid = Auth::user()->id;
|
||||||
|
$entity->uisubmitid = $uisubmitid_id;
|
||||||
|
$entity->uicodeid = $uitopicfilesid[$index]['codeno'];;
|
||||||
|
$entity->codefile = $file_path;
|
||||||
|
$entity->save();
|
||||||
|
$index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
//cek status topic yang dibuka
|
||||||
|
$entity = \App\UiTopics::where('id', '=', $id)
|
||||||
|
->select('status')
|
||||||
|
->get();
|
||||||
|
if (!((empty($entity[0]) ? 0 : $entity[0]['status']) == 1)) {
|
||||||
|
Session::flash('alert', 'Topic name with id=' . $id . ' is not allowed to open!');
|
||||||
|
return Redirect::to('student/uitasks/');
|
||||||
|
}
|
||||||
|
|
||||||
|
$entity = \App\UiTopics::find($id);
|
||||||
|
$idUser = Auth::user()->id;
|
||||||
|
$numberOfTries = \App\UiStudentSubmits::where('userid', '=', $idUser)
|
||||||
|
->where('uitopic', '=', $id)
|
||||||
|
->count('userid');
|
||||||
|
|
||||||
|
//Data untuk Result
|
||||||
|
$submitDataStatus = \App\UiStudentResultView::where('ui_student_submits_view.userid', '=', $idUser)
|
||||||
|
->select(
|
||||||
|
'ui_student_submits_view.id',
|
||||||
|
'ui_student_submits_view.uitopicid',
|
||||||
|
'ui_student_submits_view.topic',
|
||||||
|
'ui_student_submits_view.checkstat',
|
||||||
|
'ui_student_submits_view.report'
|
||||||
|
)
|
||||||
|
->where('ui_student_submits_view.uitopicid', '=', $id)
|
||||||
|
->orderBy('ui_student_submits_view.created_at', 'desc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// ambil data student submit untuk Button Submits
|
||||||
|
$studentSubmit = \App\UiStudentSubmits::where('userid', '=', $idUser)
|
||||||
|
->where('uitopic', '=', $id)
|
||||||
|
->orderBy('created_at', 'desc')
|
||||||
|
->take(1)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
//ambil data untuk tombol next
|
||||||
|
$nextTopic = \App\UiTopics::where('id', '>', $id)
|
||||||
|
->select('id')
|
||||||
|
->where('status', '=', '1')
|
||||||
|
->orderBy('id', 'ASC')
|
||||||
|
->take(1)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
//ambil data untuk tombol previous
|
||||||
|
$previousTopic = \App\UiTopics::where('id', '<', $id)
|
||||||
|
->select('id')
|
||||||
|
->where('status', '=', '1')
|
||||||
|
->orderBy('id', 'DESC')
|
||||||
|
->take(1)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$x = ['data' => $entity, 'nextid' => (empty($nextTopic[0]) ? 0 : $nextTopic[0]['id']), 'previousid' => (empty($previousTopic[0]) ? 0 : $previousTopic[0]['id']), 'numberOfTries' => $numberOfTries, 'entities' => $submitDataStatus, 'stdSubmit' => $studentSubmit];
|
||||||
|
|
||||||
|
return view('student/uitasks/show')->with($x);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getDataSourceFiles($submitid)
|
||||||
|
{
|
||||||
|
$idUser = Auth::user()->id;
|
||||||
|
$entities = \App\UiFileResults::where('ui_file_results.userid', '=', $idUser)
|
||||||
|
->select('ui_file_results.codefile')
|
||||||
|
->where('ui_file_results.uisubmitid', $submitid)
|
||||||
|
->orderBy('ui_file_results.id', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$data = ['fileSources' => $entities];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
10
app/Http/Controllers/UploadSourceController.php
Normal file
10
app/Http/Controllers/UploadSourceController.php
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class UploadSourceController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
491
app/Http/Controllers/python/ExercisePythonController.php
Normal file
491
app/Http/Controllers/python/ExercisePythonController.php
Normal file
|
|
@ -0,0 +1,491 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\python;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class ExercisePythonController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
// Menampilkan halaman utama, list topik pembelajaran python
|
||||||
|
public function index() {
|
||||||
|
|
||||||
|
// laravel
|
||||||
|
$python_topics = [];
|
||||||
|
|
||||||
|
$topik = DB::table('python_topics')->get();
|
||||||
|
foreach ( $topik AS $isi_topik ) {
|
||||||
|
|
||||||
|
// data percobaan
|
||||||
|
$percobaan = DB::table("python_percobaan")->where("id_topik", $isi_topik->id_topik);
|
||||||
|
|
||||||
|
$totalPercobaan = $percobaan->count();
|
||||||
|
$totalPassed = 0;
|
||||||
|
$dt_percobaan = $percobaan->get();
|
||||||
|
|
||||||
|
if ( $totalPercobaan > 0 ) {
|
||||||
|
|
||||||
|
foreach ( $dt_percobaan AS $isi_percobaan ) {
|
||||||
|
|
||||||
|
// ambil data student validation
|
||||||
|
$where = array(
|
||||||
|
|
||||||
|
'userid' => Auth::id(),
|
||||||
|
'id_percobaan' => $isi_percobaan->id_percobaan,
|
||||||
|
);
|
||||||
|
$dt_validation = DB::table("python_students_validation")->where($where)->count();
|
||||||
|
|
||||||
|
// apakah sudah selesai ?
|
||||||
|
if ( $dt_validation == 1 ) {
|
||||||
|
|
||||||
|
$totalPassed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
array_push( $python_topics, array(
|
||||||
|
|
||||||
|
'totalPercobaan' => $totalPercobaan,
|
||||||
|
'totalPassed' => $totalPassed,
|
||||||
|
'isi' => $isi_topik
|
||||||
|
) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('student.python_task.uitask', compact('python_topics'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Menampilkan halaman detail topik pembelajaran (detail percobaan)
|
||||||
|
public function detail_percobaan( $id_topik ){
|
||||||
|
|
||||||
|
$infotopik = DB::table('python_topics')->where('id_topik', $id_topik)->first();
|
||||||
|
$percobaan = DB::table('python_percobaan')->where('id_topik', $id_topik)->get();
|
||||||
|
|
||||||
|
// auth
|
||||||
|
$id = Auth::id();
|
||||||
|
$pengerjaan = DB::table('python_students_validation')->where('userid', $id)->get();
|
||||||
|
|
||||||
|
|
||||||
|
return view('student.python_task.uitask_detail', compact('percobaan', 'infotopik','pengerjaan'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Menampilkan halaman pengerjaan (teks editor)
|
||||||
|
public function teks_editor( $id_percobaan){
|
||||||
|
|
||||||
|
$percobaan = DB::table('python_percobaan')->where('id_percobaan', $id_percobaan)->first();
|
||||||
|
$id_topik = $percobaan->id_topik;
|
||||||
|
|
||||||
|
$infotopik = DB::table('python_topics')->where('id_topik', $id_topik)->first();
|
||||||
|
|
||||||
|
$data['infotopik'] = $infotopik;
|
||||||
|
$data['percobaan'] = $percobaan;
|
||||||
|
|
||||||
|
|
||||||
|
// $paginate = DB::table('python_percobaan');
|
||||||
|
|
||||||
|
//Sebelumnya
|
||||||
|
$previous = DB::table('python_percobaan')->where('id_percobaan', '<', $id_percobaan)->orderBy('id_percobaan', "desc");
|
||||||
|
|
||||||
|
//Selanjutnya
|
||||||
|
$next = DB::table('python_percobaan')->where('id_percobaan', '>', $id_percobaan)->orderBy('id_percobaan', "asc");
|
||||||
|
|
||||||
|
$btn_previous = "javascript:;";
|
||||||
|
$btn_next = "javascript:;";
|
||||||
|
|
||||||
|
if ( $previous->count() > 0 ) {
|
||||||
|
|
||||||
|
$previous = $previous->first();
|
||||||
|
$btn_previous = url('student/python/pengerjaan/'. $previous->id_percobaan);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $next->count() > 0 ) {
|
||||||
|
|
||||||
|
$next = $next->first();
|
||||||
|
$btn_next = url('student/python/pengerjaan/'. $next->id_percobaan);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$data['previous'] = $btn_previous;
|
||||||
|
$data['next'] = $btn_next;
|
||||||
|
|
||||||
|
return view('student.python_task.uipengerjaan', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Untuk mengcompile code jawaban mahasiswa
|
||||||
|
function compiler( Request $request ) {
|
||||||
|
|
||||||
|
// source code dari user
|
||||||
|
$textEditor = $request->get('code'); // source code mahasiswa
|
||||||
|
$id_topik = $request->get('id_topik');
|
||||||
|
$id_percobaan = $request->get('id_percobaan');
|
||||||
|
// $time = $request->get('time');
|
||||||
|
|
||||||
|
|
||||||
|
// ambil data percobaan berdasarkan id_percobaan
|
||||||
|
// untuk mengambil filetest dan lokasi package unittest
|
||||||
|
$dt_percobaan = DB::table('python_percobaan')->where('id_percobaan', $id_percobaan)->first();
|
||||||
|
|
||||||
|
|
||||||
|
// file name (nama file)
|
||||||
|
$fileName = uniqid().'_'.strtotime("now");
|
||||||
|
|
||||||
|
// lokasi penyimpanan
|
||||||
|
$filePath = "python-resources/unittest/jawaban/". $fileName . '.py';
|
||||||
|
|
||||||
|
// file terbuat
|
||||||
|
$programFile = fopen($filePath, "w");
|
||||||
|
|
||||||
|
// write code di file
|
||||||
|
fwrite($programFile, $textEditor);
|
||||||
|
fclose($programFile);
|
||||||
|
|
||||||
|
// kondisi apabila file + codding error atau tidak ?
|
||||||
|
// memanggil fungsi check error
|
||||||
|
$cek_error = $this->check_error( $filePath );
|
||||||
|
$statusSintax = false;
|
||||||
|
|
||||||
|
// 0 -> tidak ada error ([1] = status)
|
||||||
|
// 0 -> tidak error
|
||||||
|
if ( $cek_error[1] == 0 ) {
|
||||||
|
|
||||||
|
//ambil direktory
|
||||||
|
$packageDirectory = "jawaban.". $fileName;
|
||||||
|
$fileUnittest = $dt_percobaan->filetest;
|
||||||
|
|
||||||
|
$unittest = "python-resources/unittest/". $fileUnittest;
|
||||||
|
|
||||||
|
$output = shell_exec("C:\Users\TOSHIBA\AppData\Local\Programs\Python\Python39\python.exe ".$unittest." ".$packageDirectory." ".$fileName." --verbose 2>&1");
|
||||||
|
|
||||||
|
|
||||||
|
$validation_detail = "";
|
||||||
|
$status = "";
|
||||||
|
|
||||||
|
// split output
|
||||||
|
$dataTest = explode("Error", $output);
|
||||||
|
// cek string data test memilik nilai OK
|
||||||
|
// cek status passed atau failed = Menetukan sttus
|
||||||
|
if ( count($dataTest) > 1 ) {
|
||||||
|
|
||||||
|
// $validation_detail = $output;
|
||||||
|
$status = "FAILED";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$status = "PASSED";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// pembuatan poin error ceklist per unit tetsing
|
||||||
|
$validation_detail = "";
|
||||||
|
$dt_output = explode("|", $output);
|
||||||
|
|
||||||
|
//[0] tidak usah di test
|
||||||
|
$title = $dt_output[0];
|
||||||
|
$isi = "";
|
||||||
|
// urutan itu mengetahui pemisah (cuklekan)
|
||||||
|
foreach ( $dt_output AS $urutan => $isi_error ) {
|
||||||
|
|
||||||
|
if ( $urutan != 0 ) {
|
||||||
|
|
||||||
|
// pisah string
|
||||||
|
$string = explode(" ", $isi_error);
|
||||||
|
$responseError = explode("-", $isi_error);
|
||||||
|
|
||||||
|
$fungsiTes = $responseError[0]; // passed
|
||||||
|
$statusTes = $responseError[1]; // failed
|
||||||
|
|
||||||
|
$pisahStatusTes = explode(" ", $statusTes);
|
||||||
|
|
||||||
|
// data diolah lagi
|
||||||
|
$cekExeption = explode(" ", $statusTes);
|
||||||
|
// Untuk error nama variabel
|
||||||
|
if ( in_array("no", $cekExeption) ) {
|
||||||
|
|
||||||
|
$statusTes = $statusTes;
|
||||||
|
$icon = '<i class="fa fa-code" style="color: danger"></i>';
|
||||||
|
$status = "FAILED";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// cek error unit testing
|
||||||
|
$hapusSpasiPesan = rtrim($pisahStatusTes[0]);
|
||||||
|
$hapusSpasiPesan = ltrim($hapusSpasiPesan);
|
||||||
|
if ( $hapusSpasiPesan[1] == "F" ) {
|
||||||
|
|
||||||
|
$icon = '<i class="fa fa-times" style="color: red"></i>';
|
||||||
|
|
||||||
|
$statusTes = explode(": ", $statusTes)[1];
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$icon = '<i class="fa fa-check" style="color: green"></i>';
|
||||||
|
// $statusTes = implode(",", $cekExeption);
|
||||||
|
// $statusTes = var_dump( $cekExeption );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// echo $fungsiTes;
|
||||||
|
// echo $statusTes.' '.$fungsiTes;
|
||||||
|
// echo '<hr>';
|
||||||
|
$isi .= $icon." ".$fungsiTes ." : ". $statusTes .'<br>';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// echo $pisahStatusTes[0].' '. strlen( $pisahStatusTes[0] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$validation_detail = $title .'<br>'. $isi;
|
||||||
|
|
||||||
|
// Output tanpa dicleaning
|
||||||
|
// $validation_detail = $output
|
||||||
|
|
||||||
|
// mempersiapkan data validation
|
||||||
|
$dataSubmit = array(
|
||||||
|
|
||||||
|
'id_topic' => $id_topik,
|
||||||
|
'id_percobaan' => $id_percobaan,
|
||||||
|
'userid' => Auth::id(),
|
||||||
|
'checkstat' => $status,
|
||||||
|
'checkresult' => $validation_detail,
|
||||||
|
);
|
||||||
|
|
||||||
|
//Menambah id berdasarkan yang ada sebelumnya
|
||||||
|
$id_submit = DB::table('python_students_submit')->insertGetId( $dataSubmit );
|
||||||
|
|
||||||
|
// Validasi -> Masuk tabel validasi
|
||||||
|
// status passed ?
|
||||||
|
$statusPassed = false;
|
||||||
|
if ( $status == "PASSED" ) {
|
||||||
|
|
||||||
|
$statusPassed = true;
|
||||||
|
|
||||||
|
$where = array(
|
||||||
|
|
||||||
|
'userid' => Auth::id(),
|
||||||
|
'id_percobaan' => $id_percobaan,
|
||||||
|
'status' => $status,
|
||||||
|
);
|
||||||
|
|
||||||
|
$dataValidation = array(
|
||||||
|
|
||||||
|
'userid' => Auth::id(),
|
||||||
|
'id_percobaan' => $id_percobaan,
|
||||||
|
'status' => $status,
|
||||||
|
'report' => $textEditor,
|
||||||
|
'file_submitted' => $fileName,
|
||||||
|
// 'time' => $time
|
||||||
|
);
|
||||||
|
|
||||||
|
$cekStatusPassed = DB::table('python_students_validation')->where( $where )->get();
|
||||||
|
// 0 tidak ada
|
||||||
|
if ( count( $cekStatusPassed ) == 0 ) {
|
||||||
|
|
||||||
|
// sisipkan id_submit kedalam variabel $dataValidation
|
||||||
|
$dataValidation['id_submit'] = $id_submit;
|
||||||
|
|
||||||
|
// insert
|
||||||
|
DB::table('python_students_validation')->insert( $dataValidation );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$statusSintax = true;
|
||||||
|
|
||||||
|
// cek apakah status PASSED ?
|
||||||
|
// $cekValidationPassed = DB::table('python_validation_sub')
|
||||||
|
|
||||||
|
$where = array(
|
||||||
|
|
||||||
|
'id_topic' => $id_topik,
|
||||||
|
'id_percobaan' => $id_percobaan,
|
||||||
|
'userid' => Auth::id()
|
||||||
|
);
|
||||||
|
$jmlPercobaanSubmit = DB::table("python_students_submit")->where( $where )->count();
|
||||||
|
|
||||||
|
echo json_encode(['status' => $statusSintax, 'data' => $statusPassed, 'jml' => $jmlPercobaanSubmit]);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
echo json_encode(['status' => $statusSintax, 'statusPercobaan' => false, 'data' => $cek_error[0]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// tampil data validation
|
||||||
|
public function dataValidation(Request $request) {
|
||||||
|
|
||||||
|
$isi_tabel = "";
|
||||||
|
|
||||||
|
$userid = Auth::id();
|
||||||
|
$id_topik = $request->id_topik;
|
||||||
|
$id_percobaan = $request->id_percobaan;
|
||||||
|
|
||||||
|
// cari data submit berdasarkan userid + id_topik dan id_percobaan
|
||||||
|
$cari = array(
|
||||||
|
|
||||||
|
'id_topic' => $id_topik,
|
||||||
|
'id_percobaan' => $id_percobaan,
|
||||||
|
'userid' => $userid
|
||||||
|
);
|
||||||
|
|
||||||
|
$cekData = DB::table('python_students_submit')->where($cari)->orderBy('created_at', 'desc')->get();
|
||||||
|
|
||||||
|
$status = false;
|
||||||
|
$statusPassed = false;
|
||||||
|
|
||||||
|
if ( count($cekData) > 0 ) {
|
||||||
|
|
||||||
|
// uipengerjaan
|
||||||
|
$status = true;
|
||||||
|
|
||||||
|
$urutan = count( $cekData );
|
||||||
|
foreach ( $cekData AS $isi_kolom ) {
|
||||||
|
|
||||||
|
$arr = explode("\n",$isi_kolom->checkresult);
|
||||||
|
|
||||||
|
// dt_topik
|
||||||
|
$topikBerdasarkanId = DB::table('python_topics')->where('id_topik', $isi_kolom->id_topic)->first();
|
||||||
|
|
||||||
|
$label = "";
|
||||||
|
if ( $isi_kolom->checkstat == "PASSED" ) {
|
||||||
|
|
||||||
|
$label = '<label class="badge badge-success">PASSED</label>';
|
||||||
|
$statusPassed = true;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$label = '<label class="badge badge-danger">FAILED</label>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$isi_tabel .= '<tr>
|
||||||
|
<td>Uji - '.($urutan).'<br><small><b>'.date('d.m.Y H.i', strtotime($isi_kolom->created_at)).'</b></small></td>
|
||||||
|
<td>'.$topikBerdasarkanId->nama.'</td>
|
||||||
|
<td> '.$isi_kolom->checkresult.' </td>
|
||||||
|
<td>'.$label.'</td>
|
||||||
|
</tr>';
|
||||||
|
$urutan--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
echo json_encode([
|
||||||
|
|
||||||
|
'status' => $status,
|
||||||
|
'statusPassed' => $statusPassed,
|
||||||
|
'data' => $isi_tabel
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function check_error( $filePath ) {
|
||||||
|
|
||||||
|
// mengeksekusi file tapi nduduhi lek error opo enggak ?
|
||||||
|
// 1 -> error
|
||||||
|
// 0 -> gak error
|
||||||
|
exec('python '.$filePath.' 2>&1', $output, $status);
|
||||||
|
return [$output, $status];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TAMPIlAN FEEDBACK
|
||||||
|
function feedback ( $id_topik, $id_percobaan ){
|
||||||
|
|
||||||
|
$percobaan = DB::table('python_percobaan')->where('id_percobaan', $id_percobaan)->first();
|
||||||
|
$id_topik = $percobaan->id_topik;
|
||||||
|
|
||||||
|
$infotopik = DB::table('python_topics')->where('id_topik', $id_topik)->first();
|
||||||
|
|
||||||
|
$data['infotopik'] = $infotopik;
|
||||||
|
$data['percobaan'] = $percobaan;
|
||||||
|
$data['id_percobaan'] = $id_percobaan;
|
||||||
|
|
||||||
|
return view('student.python_feedback.feedback', $data);
|
||||||
|
|
||||||
|
// $data['id_topik'] = $id_topik;
|
||||||
|
// $data['id_percobaan'] = $id_percobaan;
|
||||||
|
|
||||||
|
// return view('student.python_feedback.feedback', $data);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// feeback submit
|
||||||
|
public function feedback_submit( Request $request ){
|
||||||
|
|
||||||
|
$id_topik = $request->id_topik;
|
||||||
|
$id_percobaan = $request->id_percobaan;
|
||||||
|
$komentar = $request->komentar;
|
||||||
|
// $tingkatan = $request->tingkatan;
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
|
||||||
|
'userid' => Auth::id(),
|
||||||
|
'id_topik' => $id_topik,
|
||||||
|
'id_percobaan' => $id_percobaan,
|
||||||
|
// 'tingkatan' => $tingkatan,
|
||||||
|
'comment' => $komentar
|
||||||
|
);
|
||||||
|
|
||||||
|
// eksekusi insert
|
||||||
|
DB::table('python_feedback')->insert( $data );
|
||||||
|
|
||||||
|
return redirect('student/python/pengerjaan/'. $id_percobaan);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// submit history
|
||||||
|
public function submit_history( $id_topik, $id_percobaan ) {
|
||||||
|
|
||||||
|
$where = array(
|
||||||
|
|
||||||
|
'id_percobaan' => $id_percobaan,
|
||||||
|
'userid' => Auth::id()
|
||||||
|
);
|
||||||
|
$cek = DB::table("python_students_validation")->where( $where )->get();
|
||||||
|
|
||||||
|
|
||||||
|
$totalPercobaan = DB::table('python_students_submit')->where( $where )->count();
|
||||||
|
|
||||||
|
$statusPassed = false;
|
||||||
|
$historyTextEditor = "";
|
||||||
|
foreach ( $cek AS $isi ) {
|
||||||
|
|
||||||
|
if ( $isi->status == "PASSED" ) {
|
||||||
|
|
||||||
|
$statusPassed = true;
|
||||||
|
$historyTextEditor = $isi->report;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
|
||||||
|
'validasi' => $cek,
|
||||||
|
'submit' => $totalPercobaan,
|
||||||
|
'statusPassed' => $statusPassed,
|
||||||
|
'hist_texteditor' => $historyTextEditor
|
||||||
|
);
|
||||||
|
|
||||||
|
echo json_encode( $data );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user