Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sfcode
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush
sfcode
Commits
423753be
Commit
423753be
authored
Dec 08, 2020
by
Adarsh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug
parent
9056dccb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
83 additions
and
43 deletions
+83
-43
backend/questions/get_questions.php
backend/questions/get_questions.php
+46
-6
backend/questions/question_save.php
backend/questions/question_save.php
+6
-6
src/app/home/home.component.html
src/app/home/home.component.html
+6
-6
src/app/home/home.component.ts
src/app/home/home.component.ts
+16
-16
src/app/question.service.ts
src/app/question.service.ts
+3
-3
src/app/question.ts
src/app/question.ts
+6
-6
No files found.
backend/questions/get_questions.php
View file @
423753be
...
...
@@ -8,21 +8,61 @@ header("Content-Type: application/json; charset=UTF-8");
include_once
(
"../database.php"
);
if
(
$_SERVER
[
'REQUEST_METHOD'
]
===
'GET'
){
$sql1
=
"SELECT Now()"
;
$currtime
=
$mysqli
->
query
(
$sql1
);
$sql2
=
"SELECT * FROM questions WHERE stime <=
$currtime
and etime >=
$currtime
"
;
// $sql2 = "SELECT * FROM questions WHERE stime <= $currtime and etime >= $currtime";
$sql2
=
"SELECT * FROM questions"
;
$data
=
[];
if
(
$result
=
mysqli
->
query
(
$sql2
)){
while
(
$row
=
mysql_fetch_assoc
(
$request
)){
array_push
(
$data
,
$row
);
$i
=
0
;
while
(
$row
=
mysql_fetch_assoc
(
$result
)){
$data
[
$i
][
'title'
]
=
$row
[
'title'
];
$data
[
$i
][
'username'
]
=
$row
[
'username'
];
$data
[
$i
][
'statement'
]
=
$row
[
'statement'
];
$data
[
$i
][
'tc1'
]
=
$row
[
'tc1'
];
$data
[
$i
][
'out1'
]
=
$row
[
'out1'
];
$data
[
$i
][
'tc2'
]
=
$row
[
'tc2'
];
$data
[
$i
][
'out2'
]
=
$row
[
'out2'
];
$data
[
$i
][
'stime'
]
=
$row
[
'stime'
];
$data
[
$i
][
'etime'
]
=
$row
[
'etime'
];
$i
++
;
}
echo
json_encode
(
$data
);
}
else
{
http_response_code
(
404
);
}
}
// if($_SERVER['REQUEST_METHOD'] === 'GET'){
// $sql1 = "SELECT Now()";
// $currtime = $mysqli->query($sql1);
// $sql2 = "SELECT * FROM questions WHERE stime <= $currtime and etime >= $currtime";
// $data = [];
// if($result = mysqli->query($sql2)){
// $i = 0;
// while($row = mysql_fetch_assoc($result)){
// $data[$i]['title'] = $row['title'];
// $data[$i]['username'] = $row['username'];
// $data[$i]['statement'] = $row['statement'];
// $data[$i]['tc1'] = $row['tc1'];
// $data[$i]['out1'] = $row['out1'];
// $data[$i]['tc2'] = $row['tc2'];
// $data[$i]['out2'] = $row['out2'];
// $data[$i]['stime'] = $row['stime'];
// $data[$i]['etime'] = $row['etime'];
// $i++;
// }
// echo json_encode($data);
// }
// else{
// http_response_code(404);
// }
// }
?>
backend/questions/question_save.php
View file @
423753be
...
...
@@ -15,12 +15,12 @@ if(isset($postData) && !empty($postData)){
$title
=
trim
(
$request
->
title
);
$username
=
trim
(
$request
->
username
);
//string
$statement
=
trim
(
$request
->
statement
);
//string
$tc1
=
trim
(
$request
->
tc1
_inp
);
$out1
=
trim
(
$request
->
tc1_out
);
$tc2
=
trim
(
$request
->
tc2
_inp
);
$out2
=
trim
(
$request
->
tc2_out
);
$stime
=
trim
(
$request
->
st
art_t
ime
);
//string
$etime
=
trim
(
$request
->
e
nd_
time
);
$tc1
=
trim
(
$request
->
tc1
);
$out1
=
trim
(
$request
->
out1
);
$tc2
=
trim
(
$request
->
tc2
);
$out2
=
trim
(
$request
->
out2
);
$stime
=
trim
(
$request
->
stime
);
//string
$etime
=
trim
(
$request
->
etime
);
$sql
=
"INSERT INTO questions(title,username,statement,tc1,out1,tc2,out2,stime,etime) VALUES ('
$title
','
$username
','
$statement
','
$tc1
','
$out1
','
$tc2
','
$out2
','
$stime
','
$etime
')"
;
...
...
src/app/home/home.component.html
View file @
423753be
...
...
@@ -9,13 +9,13 @@
<input
type=
"text"
id=
"title"
placeholder=
"Problem Title"
name=
"title"
[(ngModel)]=
"questiontoPost.title"
required
>
<textarea
id=
"statement"
placeholder=
"Problem Statement"
name=
"statement"
rows=
"8"
cols=
"80"
[(ngModel)]=
"questiontoPost.statement"
required
></textarea>
<textarea
id=
"tc1_i"
cols=
"30"
rows=
"8"
name=
"tc1"
placeholder=
"Testcase1 Input"
style=
"margin-right: 20px;"
[(ngModel)]=
"questiontoPost.tc1
_inp
"
></textarea>
<textarea
id=
"tc2_i"
cols=
"30"
rows=
"8"
name=
"tc2"
placeholder=
"Testcase2 Input"
style=
"margin-left: 20px;"
[(ngModel)]=
"questiontoPost.tc2
_inp
"
></textarea>
<textarea
id=
"tc1_o"
cols=
"30"
rows=
"4"
name=
"out1"
placeholder=
"Testcase1 Output"
style=
"margin-right: 20px;"
[(ngModel)]=
"questiontoPost.
tc1_out
"
></textarea>
<textarea
id=
"tc2_o"
cols=
"30"
rows=
"4"
name=
"out2"
placeholder=
"Testcase2 Output"
style=
"margin-left: 20px;"
[(ngModel)]=
"questiontoPost.
tc2_out
"
></textarea>
<textarea
id=
"tc1_i"
cols=
"30"
rows=
"8"
name=
"tc1"
placeholder=
"Testcase1 Input"
style=
"margin-right: 20px;"
[(ngModel)]=
"questiontoPost.tc1"
></textarea>
<textarea
id=
"tc2_i"
cols=
"30"
rows=
"8"
name=
"tc2"
placeholder=
"Testcase2 Input"
style=
"margin-left: 20px;"
[(ngModel)]=
"questiontoPost.tc2"
></textarea>
<textarea
id=
"tc1_o"
cols=
"30"
rows=
"4"
name=
"out1"
placeholder=
"Testcase1 Output"
style=
"margin-right: 20px;"
[(ngModel)]=
"questiontoPost.
out1
"
></textarea>
<textarea
id=
"tc2_o"
cols=
"30"
rows=
"4"
name=
"out2"
placeholder=
"Testcase2 Output"
style=
"margin-left: 20px;"
[(ngModel)]=
"questiontoPost.
out2
"
></textarea>
<input
type=
"datetime-local"
name=
"stime"
id=
"start_time"
[(ngModel)]=
"questiontoPost.st
art_t
ime"
>
<input
type=
"datetime-local"
name=
"etime"
id=
"end_time"
[(ngModel)]=
"questiontoPost.e
nd_
time"
>
<input
type=
"datetime-local"
name=
"stime"
id=
"start_time"
[(ngModel)]=
"questiontoPost.stime"
>
<input
type=
"datetime-local"
name=
"etime"
id=
"end_time"
[(ngModel)]=
"questiontoPost.etime"
>
<button
type=
"submit"
class=
"btn"
(click) =
"submitForm()"
>
Submit
</button>
<button
type=
"button"
class=
"btn cancel"
(click) =
"closeForm()"
>
Close
</button>
...
...
src/app/home/home.component.ts
View file @
423753be
...
...
@@ -19,12 +19,12 @@ export class HomeComponent implements OnInit {
title
:
""
,
username
:
""
,
statement
:
""
,
tc1
_inp
:
""
,
tc1_out
:
""
,
tc2
_inp
:
""
,
tc2_out
:
""
,
st
art_t
ime
:
""
,
e
nd_
time
:
""
tc1
:
""
,
out1
:
""
,
tc2
:
""
,
out2
:
""
,
stime
:
""
,
etime
:
""
};
questions
:
any
[];
...
...
@@ -37,9 +37,9 @@ export class HomeComponent implements OnInit {
this
.
user
=
JSON
.
parse
(
this
.
dataService
.
getToken
());
this
.
questiontoPost
.
username
=
this
.
user
.
username
;
this
.
getProblems
();
// this.questionService.getQues()
// .subscribe(questions => this.questions = questions);
this
.
questionService
.
getQues
()
.
subscribe
(
questions
=>
this
.
questions
=
questions
);
// console.log(this.questions);
}
...
...
@@ -61,18 +61,18 @@ export class HomeComponent implements OnInit {
title
:
""
,
username
:
this
.
user
.
username
,
statement
:
""
,
tc1
_inp
:
""
,
tc1_out
:
""
,
tc2
_inp
:
""
,
tc2_out
:
""
,
st
art_t
ime
:
""
,
e
nd_
time
:
""
tc1
:
""
,
out1
:
""
,
tc2
:
""
,
out2
:
""
,
stime
:
""
,
etime
:
""
};
}
submitForm
()
{
this
.
questiontoPost
.
st
art_time
=
this
.
questiontoPost
.
start_
time
.
split
(
'
T
'
).
join
(
'
'
);
this
.
questiontoPost
.
e
nd_time
=
this
.
questiontoPost
.
end_
time
.
split
(
'
T
'
).
join
(
'
'
);
this
.
questiontoPost
.
st
ime
=
this
.
questiontoPost
.
s
time
.
split
(
'
T
'
).
join
(
'
'
);
this
.
questiontoPost
.
e
time
=
this
.
questiontoPost
.
e
time
.
split
(
'
T
'
).
join
(
'
'
);
this
.
questionService
.
uploadQues
(
this
.
questiontoPost
).
subscribe
(
(
event
:
any
)
=>
{
if
(
typeof
(
event
)
===
'
object
'
)
{
...
...
src/app/question.service.ts
View file @
423753be
...
...
@@ -10,13 +10,13 @@ import { Question } from './question';
export
class
QuestionService
{
uploadUrl
=
"
http://localhost/sfcode/backend/questions/question_save.php
/
"
;
getUrl
=
"
http://localhost/sfcode/backend/questions/get_questions.php
/
"
;
uploadUrl
=
"
http://localhost/sfcode/backend/questions/question_save.php
"
;
getUrl
=
"
http://localhost/sfcode/backend/questions/get_questions.php
"
;
constructor
(
private
http
:
HttpClient
)
{
}
uploadQues
(
ques
:
Question
):
Observable
<
any
>
{
console
.
log
(
ques
);
//
console.log(ques);
return
this
.
http
.
post
(
this
.
uploadUrl
,
ques
);
}
...
...
src/app/question.ts
View file @
423753be
...
...
@@ -2,10 +2,10 @@ export interface Question {
title
:
string
;
username
:
string
;
statement
:
string
;
tc1
_inp
:
string
;
tc1_out
:
string
;
tc2
_inp
:
string
;
tc2_out
:
string
;
st
art_t
ime
:
string
;
e
nd_
time
:
string
;
tc1
:
string
;
out1
:
string
;
tc2
:
string
;
out2
:
string
;
stime
:
string
;
etime
:
string
;
}
\ No newline at end of file
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