Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
K
kiaisoft_training
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TTS Tran Viet Anh
kiaisoft_training
Commits
f9f788cf
Commit
f9f788cf
authored
Oct 30, 2022
by
TTS Tran Viet Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch 'feature/form-validation' into 'upload-form-layout'"
This reverts merge request
!2
parent
e712df26
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
184 deletions
+52
-184
FormController.php
app/Http/Controllers/FormController.php
+3
-4
UploadFormRequest.php
app/Http/Requests/UploadFormRequest.php
+0
-53
layout.blade.php
resources/views/layout.blade.php
+0
-5
test.blade.php
resources/views/test.blade.php
+29
-0
upload-form.blade.php
resources/views/upload-form.blade.php
+17
-119
web.php
routes/web.php
+3
-3
No files found.
app/Http/Controllers/FormController.php
View file @
f9f788cf
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
namespace
App\Http\Controllers
;
namespace
App\Http\Controllers
;
use
App\Http\Requests\UploadFormRequest
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Log
;
use
Illuminate\Support\Facades\Log
;
...
@@ -25,7 +24,7 @@ public function index()
...
@@ -25,7 +24,7 @@ public function index()
*/
*/
public
function
create
()
public
function
create
()
{
{
return
view
(
'upload-form'
);
//
}
}
/**
/**
...
@@ -34,9 +33,9 @@ public function create()
...
@@ -34,9 +33,9 @@ public function create()
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\Response
*/
*/
public
function
store
(
UploadForm
Request
$request
)
public
function
store
(
Request
$request
)
{
{
return
view
(
'upload-form'
);
//
}
}
/**
/**
...
...
app/Http/Requests/UploadFormRequest.php
deleted
100644 → 0
View file @
e712df26
<?php
namespace
App\Http\Requests
;
use
Illuminate\Foundation\Http\FormRequest
;
class
UploadFormRequest
extends
FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public
function
authorize
()
{
return
true
;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public
function
rules
()
{
return
[
'category'
=>
[
'required'
],
'question'
=>
[
'required'
,
'mimes:pdf'
],
'answer'
=>
[
'required'
,
'mimes:pdf'
],
'name'
=>
[
'required'
],
'fee'
=>
[
'required'
,
'integer'
],
'level'
=>
[
'required'
],
'time'
=>
[
'required'
,
'integer'
],
'numberOfQuestion'
=>
[
'required'
,
'integer'
],
];
}
public
function
messages
()
{
return
[
'category.required'
=>
'Hãy chọn danh mục!'
,
'question.mimes'
=>
'chỉ có thể upload file pdf'
,
'answer.mimes'
=>
'chỉ có thể upload file pdf'
,
'name.required'
=>
'Hãy nhập tên đề thi'
,
'fee.required'
=>
'Hãy nhập phí thi'
,
'fee.integer'
=>
'Hãy nhập phí thi bằng một số'
,
'level.required'
=>
'Hãy chọn mức độ'
,
'time.required'
=>
'Hãy nhập thời gian thi'
,
'time.integer'
=>
'Hãy nhập số phút thi bằng số'
,
'numberOfQuestion.required'
=>
'Hãy nhập số câu hỏi'
,
'numberOfQuestion.integer'
=>
'Hãy nhập số câu hỏi bằng số'
,
];
}
}
resources/views/layout.blade.php
View file @
f9f788cf
...
@@ -20,11 +20,6 @@
...
@@ -20,11 +20,6 @@
href=
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.css"
>
href=
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.css"
>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.min.js"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.min.js"
></script>
{{-- jquery --}}
<script
src=
"//code.jquery.com/jquery-1.11.3.min.js"
></script>
<script
type=
"text/javascript"
src=
"http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.min.js"
>
</script>
<title>
Document
</title>
<title>
Document
</title>
</head>
</head>
...
...
resources/views/test.blade.php
0 → 100644
View file @
f9f788cf
<div
class=
"col-2"
>
<label
for=
""
>
Điền đáp án đúng:
</label>
</div>
<div
class=
"col-5"
style=
"overflow:scroll"
>
<div
class=
"rows"
>
<div
class=
"col-12"
>
<b
id=
"countAnswer"
>
/ {{ request('numberOfQuestion') }}
</b>
</div>
</div>
@for ($i = 1; $i
<
=
request
('
numberOfQuestion
');
$
i
++)
<
ul
>
<li>
<b>
{{ $i }}
</b>
A.
<input
name=
"{{ $i }}"
class=
"radio"
id=
"A{{ $i }}"
type=
"radio"
value=
"A"
onclick=
"handleClick(this)"
/>
B.
<input
name=
"{{ $i }}"
class=
"radio"
id=
"B{{ $i }}"
type=
"radio"
value=
"B"
onclick=
"handleClick(this)"
/>
C.
<input
name=
"{{ $i }}"
class=
"radio"
id=
"C{{ $i }}"
type=
"radio"
value=
"C"
onclick=
"handleClick(this)"
/>
D.
<input
name=
"{{ $i }}"
class=
"radio"
id=
"D{{ $i }}"
type=
"radio"
value=
"D"
onclick=
"handleClick(this)"
/>
</li>
</ul>
@endfor
</div>
resources/views/upload-form.blade.php
View file @
f9f788cf
...
@@ -7,15 +7,13 @@
...
@@ -7,15 +7,13 @@
</
div
>
</
div
>
</
nav
>
</
nav
>
<
div
class
=
"container"
>
<
div
class
=
"container"
>
<
form
action
=
"{{ route('upload') }}"
method
=
"post"
enctype
=
"multipart/form"
id
=
"uploadForm"
>
<
form
action
=
""
>
@
csrf
<
div
class
=
"row"
>
<
div
class
=
"row"
>
<
div
class
=
"col-2"
>
<
div
class
=
"col-2"
>
<
label
for
=
""
>
Danh
mục
:</
label
>
<
label
for
=
""
>
Danh
mục
:</
label
>
</
div
>
</
div
>
<
div
class
=
"col-10"
>
<
div
class
=
"col-10"
>
<
select
name
=
"category"
class
=
"form-control @error('category') is-invalid @enderror"
required
>
<
select
name
=
"category"
class
=
"form-control"
>
<
option
value
=
""
>--
Chọn
danh
mục
--</
option
>
<
option
value
=
"1"
>
danh
mục
1
</
option
>
<
option
value
=
"1"
>
danh
mục
1
</
option
>
<
option
value
=
"2"
>
danh
mục
2
</
option
>
<
option
value
=
"2"
>
danh
mục
2
</
option
>
<
option
value
=
"3"
>
danh
mục
3
</
option
>
<
option
value
=
"3"
>
danh
mục
3
</
option
>
...
@@ -23,11 +21,6 @@
...
@@ -23,11 +21,6 @@
<
option
value
=
"5"
>
danh
mục
5
</
option
>
<
option
value
=
"5"
>
danh
mục
5
</
option
>
</
select
>
</
select
>
</
div
>
</
div
>
@
error
(
'category'
)
<
div
class
=
"alert alert-danger"
role
=
"alert"
>
{{
$message
}}
</
div
>
@
enderror
</
div
>
</
div
>
<
div
class
=
"row"
>
<
div
class
=
"row"
>
...
@@ -36,34 +29,22 @@
...
@@ -36,34 +29,22 @@
</
div
>
</
div
>
<
div
class
=
"col-2"
>
<
div
class
=
"col-2"
>
<
label
class
=
"file"
for
=
"question"
>
Chọn
file
</
label
>
<
label
class
=
"file"
for
=
"question"
>
Chọn
file
</
label
>
<
input
type
=
"file"
name
=
"question"
class
=
"@error('question') is-invalid @enderror"
id
=
"question"
<
input
type
=
"file"
name
=
"question"
id
=
"question"
hidden
/>
hidden
/>
</
div
>
</
div
>
<
div
class
=
"col-8"
>
<
div
class
=
"col-8"
>
<
p
class
=
"file"
>
(
Chỉ
chọn
file
PDF
)
</
p
>
<
p
class
=
"file"
>
(
Chỉ
chọn
file
PDF
)
</
p
>
</
div
>
</
div
>
@
error
(
'question'
)
<
div
class
=
"alert alert-danger"
role
=
"alert"
>
{{
$message
}}
</
div
>
@
enderror
<
div
class
=
"col-2"
>
<
div
class
=
"col-2"
>
<
label
for
=
""
>
Tệp
lời
giải
:</
label
>
<
label
for
=
""
>
Tệp
lời
giải
:</
label
>
</
div
>
</
div
>
<
div
class
=
"col-2"
>
<
div
class
=
"col-2"
>
<
label
class
=
"file"
for
=
"answer"
>
Chọn
file
</
label
>
<
label
class
=
"file"
for
=
"answer"
>
Chọn
file
</
label
>
<
input
type
=
"file"
name
=
"answer"
class
=
"@error('answer') is-invalid @enderror"
id
=
"answer"
<
input
type
=
"file"
name
=
"answer"
id
=
"answer"
hidden
/>
hidden
/>
</
div
>
</
div
>
<
div
class
=
"col-8"
>
<
div
class
=
"col-8"
>
<
p
class
=
"file"
>
(
Chỉ
chọn
file
PDF
)
</
p
>
<
p
class
=
"file"
>
(
Chỉ
chọn
file
PDF
)
</
p
>
</
div
>
</
div
>
@
error
(
'answer'
)
<
div
class
=
"alert alert-danger"
role
=
"alert"
>
{{
$message
}}
</
div
>
@
enderror
</
div
>
</
div
>
<
div
class
=
"row"
>
<
div
class
=
"row"
>
...
@@ -71,20 +52,14 @@
...
@@ -71,20 +52,14 @@
<
label
for
=
""
>
Tên
đề
thi
:</
label
>
<
label
for
=
""
>
Tên
đề
thi
:</
label
>
</
div
>
</
div
>
<
div
class
=
"col-10"
>
<
div
class
=
"col-10"
>
<
input
type
=
"text"
id
=
"name"
name
=
"name"
value
=
"{{ old('name') }}"
<
input
type
=
"text"
id
=
"name"
name
=
"name"
class
=
"form-control"
/>
class
=
"form-control @error('name') is-invalid @enderror"
required
/>
</
div
>
</
div
>
@
error
(
'name'
)
<
div
class
=
"alert alert-danger"
role
=
"alert"
>
{{
$message
}}
</
div
>
@
enderror
<
div
class
=
"col-2"
>
<
div
class
=
"col-2"
>
<
label
for
=
""
>
Giới
thiệu
:</
label
>
<
label
for
=
""
>
Giới
thiệu
:</
label
>
</
div
>
</
div
>
<
div
class
=
"col-10"
>
<
div
class
=
"col-10"
>
<
textarea
style
=
"height:100px ;"
name
=
"introduction"
class
=
"form-control"
value
=
"{{ old('introduction') }}"
></
textarea
>
<
textarea
style
=
"height:100px ;"
name
=
"introduction"
class
=
"form-control"
></
textarea
>
</
div
>
</
div
>
<
div
class
=
"col-2"
>
<
div
class
=
"col-2"
>
...
@@ -92,7 +67,7 @@ class="form-control @error('name') is-invalid @enderror" required />
...
@@ -92,7 +67,7 @@ class="form-control @error('name') is-invalid @enderror" required />
</
div
>
</
div
>
<
div
class
=
"col-10"
>
<
div
class
=
"col-10"
>
<
input
type
=
"text"
name
=
"keyWord"
class
=
"form-control"
data
-
role
=
"tagsinput"
<
input
type
=
"text"
name
=
"keyWord"
class
=
"form-control"
data
-
role
=
"tagsinput"
value
=
"{{ old('keyWord') }}"
placeholder
=
"+ Thêm từ khóa"
/>
placeholder
=
"+ Thêm từ khóa"
/>
</
div
>
</
div
>
</
div
>
</
div
>
...
@@ -101,59 +76,34 @@ class="form-control @error('name') is-invalid @enderror" required />
...
@@ -101,59 +76,34 @@ class="form-control @error('name') is-invalid @enderror" required />
<
label
for
=
""
>
Phí
thi
:</
label
>
<
label
for
=
""
>
Phí
thi
:</
label
>
</
div
>
</
div
>
<
div
class
=
"col-10"
>
<
div
class
=
"col-10"
>
<
input
type
=
"text"
id
=
"fee"
name
=
"fee"
value
=
"{{ old('fee') }}"
<
input
type
=
"text"
id
=
"fee"
name
=
"fee"
class
=
"form-control"
placeholder
=
"đ"
/>
class
=
"form-control @error('fee') is-invalid @enderror"
placeholder
=
"đ"
required
/>
</
div
>
</
div
>
@
error
(
'fee'
)
<
div
class
=
"alert alert-danger"
role
=
"alert"
>
{{
$message
}}
</
div
>
@
enderror
<
div
class
=
"col-2"
>
<
div
class
=
"col-2"
>
<
label
for
=
""
>
Mức
độ
:</
label
>
<
label
for
=
""
>
Mức
độ
:</
label
>
</
div
>
</
div
>
<
div
class
=
"col-10"
>
<
div
class
=
"col-10"
>
<
select
name
=
"level"
id
=
"level"
class
=
"form-control @error('level') is-invalid @enderror"
<
select
name
=
"level"
id
=
"level"
class
=
"form-control"
>
required
>
<
option
value
=
"0"
>--
Chọn
mức
độ
--</
option
>
<
option
value
=
""
>--
Chọn
mức
độ
--</
option
>
<
option
value
=
"1"
>
Dễ
</
option
>
<
option
value
=
"1"
>
Dễ
</
option
>
<
option
value
=
"2"
>
Khó
</
option
>
<
option
value
=
"2"
>
Khó
</
option
>
</
select
>
</
select
>
</
div
>
</
div
>
@
error
(
'level'
)
<
div
class
=
"alert alert-danger"
role
=
"alert"
>
{{
$message
}}
</
div
>
@
enderror
<
div
class
=
"col-2"
>
<
div
class
=
"col-2"
>
<
label
for
=
""
>
Thời
gian
thi
:</
label
>
<
label
for
=
""
>
Thời
gian
thi
:</
label
>
</
div
>
</
div
>
<
div
class
=
"col-10"
>
<
div
class
=
"col-10"
>
<
input
type
=
"number"
min
=
"0"
id
=
"time"
name
=
"time"
value
=
"{{ old('time') }}"
<
input
type
=
"number"
id
=
"time"
name
=
"time"
class
=
"form-control"
placeholder
=
"phút"
/>
class
=
"form-control @error('time') is-invalid @enderror"
placeholder
=
"phút"
required
/>
</
div
>
</
div
>
@
error
(
'time'
)
<
div
class
=
"alert alert-danger"
role
=
"alert"
>
{{
$message
}}
</
div
>
@
enderror
<
div
class
=
"col-2"
>
<
div
class
=
"col-2"
>
<
label
for
=
""
>
Số
câu
hỏi
:</
label
>
<
label
for
=
""
>
Số
câu
hỏi
:</
label
>
</
div
>
</
div
>
<
div
class
=
"col-10"
>
<
div
class
=
"col-10"
>
<
input
type
=
"number"
min
=
"0"
name
=
"numberOfQuestion"
id
=
"numberOfQuestion"
<
input
type
=
"number"
name
=
"numberOfQuestion"
id
=
"numberOfQuestion"
class
=
"form-control"
value
=
"{{ old('numberOfQuestion') }}"
placeholder
=
"câu"
/>
class
=
"form-control @error('numberOfQuestion') is-invalid @enderror"
placeholder
=
"câu"
required
/>
</
div
>
</
div
>
@
error
(
'numberOfQuestion'
)
<
div
class
=
"alert alert-danger"
role
=
"alert"
>
{{
$message
}}
</
div
>
@
enderror
</
div
>
</
div
>
<
div
class
=
"row"
id
=
"questionForm"
>
<
div
class
=
"row"
id
=
"questionForm"
>
...
@@ -177,58 +127,6 @@ class="form-control @error('numberOfQuestion') is-invalid @enderror" placeholder
...
@@ -177,58 +127,6 @@ class="form-control @error('numberOfQuestion') is-invalid @enderror" placeholder
}
}
});
});
});
});
//check file type
$
(
"#question,#answer"
)
.
change
(
function
()
{
var
fileExtension
=
[
'pdf'
];
if
(
$
.
inArray
(
$
(
this
)
.
val
()
.
split
(
'.'
)
.
pop
()
.
toLowerCase
(),
fileExtension
)
==
-
1
)
{
alert
(
"Chỉ có thể chọn file "
+
fileExtension
.
join
(
', '
));
}
});
//validate form
$
(
"#uploadForm"
)
.
validate
({
rules
:
{
category
:
"required"
,
name
:
"required"
,
fee
:
{
required
:
true
,
number
:
true
,
min
:
2
}
level
:
"required"
,
numberOfQuestion
:
{
required
:
true
,
number
:
true
,
min
:
2
},
time
:
{
required
:
true
,
number
:
true
,
min
:
2
},
},
messages
:
{
category
:
'Hãy chọn danh mục!'
,
name
:
'Hãy nhập tên đề thi'
,
fee
:
{
required
:
'Hãy nhập phí thi'
,
number
:
'Hãy nhập phí thi bằng một số'
,
min
:
'Phí thi không được nhỏ hơn 0'
},
level
:
'Hãy chọn mức độ'
,
time
:
{
required
:
'Hãy nhập thời gian thi'
,
number
:
'Hãy nhập thời gian thi bằng một số'
,
min
:
'Thời gian thi không được nhỏ hơn 0'
},
numberOfQuestion
:
{
required
:
'Hãy nhập số câu hỏi'
,
number
:
'Hãy nhập số câu hỏi bằng một số'
,
min
:
'Số câu hỏi không được nhỏ hơn 0'
},
}
});
})
})
</
script
>
</
script
>
@
endsection
@
endsection
routes/web.php
View file @
f9f788cf
...
@@ -14,8 +14,8 @@
...
@@ -14,8 +14,8 @@
|
|
*/
*/
Route
::
get
(
'/'
,[
FormController
::
class
,
'create'
])
->
name
(
'uploadForm'
);
Route
::
get
(
'/'
,
function
()
{
return
view
(
'upload-form'
);
});
Route
::
get
(
'/questionForm'
,
[
FormController
::
class
,
'showQuestionForm'
])
->
name
(
'questionForm'
);
Route
::
get
(
'/questionForm'
,
[
FormController
::
class
,
'showQuestionForm'
])
->
name
(
'questionForm'
);
Route
::
post
(
'/upload'
,[
FormController
::
class
,
'store'
])
->
name
(
'upload'
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment