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
08f56200
Commit
08f56200
authored
Dec 08, 2020
by
Adarsh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get ques complete
parent
0563df13
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
46 deletions
+40
-46
backend/questions/get_questions.php
backend/questions/get_questions.php
+23
-44
src/app/home/home.component.ts
src/app/home/home.component.ts
+17
-2
No files found.
backend/questions/get_questions.php
View file @
08f56200
...
@@ -8,51 +8,30 @@ header("Content-Type: application/json; charset=UTF-8");
...
@@ -8,51 +8,30 @@ header("Content-Type: application/json; charset=UTF-8");
include_once
(
"../database.php"
);
include_once
(
"../database.php"
);
if
(
$_SERVER
[
'REQUEST_METHOD'
]
===
'$_GET'
){
$sql2
=
"SELECT * FROM questions"
;
$sql1
=
"SELECT Now()"
;
$currtime
=
$mysqli
->
query
(
$sql1
);
$data
=
array
();
// $sql2 = "SELECT * FROM questions WHERE stime <= $currtime and etime >= $currtime";
$sql2
=
"SELECT * FROM questions"
;
if
(
$result
=
$mysqli
->
query
(
$sql2
)){
$data
=
[];
$i
=
0
;
if
(
$result
=
$mysqli
->
query
(
$sql2
)){
while
(
$row
=
mysqli_fetch_assoc
(
$result
)){
$i
=
0
;
$data
[
$i
][
'title'
]
=
$row
[
'title'
];
while
(
$row
=
mysql_fetch_assoc
(
$result
)){
$data
[
$i
][
'username'
]
=
$row
[
'username'
];
$data
[
$i
][
'statement'
]
=
$row
[
'statement'
];
$data
[
$i
][
'title'
]
=
$row
[
'title'
];
$data
[
$i
][
'tc1'
]
=
$row
[
'tc1'
];
$data
[
$i
][
'username'
]
=
$row
[
'username'
];
$data
[
$i
][
'out1'
]
=
$row
[
'out1'
];
$data
[
$i
][
'statement'
]
=
$row
[
'statement'
];
$data
[
$i
][
'tc2'
]
=
$row
[
'tc2'
];
$data
[
$i
][
'tc1'
]
=
$row
[
'tc1'
];
$data
[
$i
][
'out2'
]
=
$row
[
'out2'
];
$data
[
$i
][
'out1'
]
=
$row
[
'out1'
];
$data
[
$i
][
'stime'
]
=
$row
[
'stime'
];
$data
[
$i
][
'tc2'
]
=
$row
[
'tc2'
];
$data
[
$i
][
'etime'
]
=
$row
[
'etime'
];
$data
[
$i
][
'out2'
]
=
$row
[
'out2'
];
$i
++
;
$data
[
$i
][
'stime'
]
=
$row
[
'stime'
];
$data
[
$i
][
'etime'
]
=
$row
[
'etime'
];
$i
++
;
}
echo
json_encode
(
$data
);
}
else
{
http_response_code
(
404
);
}
}
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)){
// while($row = mysql_fetch_assoc($request)){
// array_push($data,$row);
// }
// echo json_encode($data);
// }
// else{
// http_response_code(404);
// }
// }
?>
?>
src/app/home/home.component.ts
View file @
08f56200
...
@@ -28,6 +28,7 @@ export class HomeComponent implements OnInit {
...
@@ -28,6 +28,7 @@ export class HomeComponent implements OnInit {
};
};
questions
:
Question
[];
questions
:
Question
[];
ques_final
:
Question
[]
=
[];
errorMessage
:
any
;
errorMessage
:
any
;
constructor
(
private
dataService
:
ApiService
,
constructor
(
private
dataService
:
ApiService
,
...
@@ -43,10 +44,24 @@ export class HomeComponent implements OnInit {
...
@@ -43,10 +44,24 @@ export class HomeComponent implements OnInit {
this
.
questionService
.
getQues
()
this
.
questionService
.
getQues
()
.
subscribe
(
data
=>
{
.
subscribe
(
data
=>
{
this
.
questions
=
data
;
this
.
questions
=
data
;
// console.log(this.questions);
this
.
organizeQues
();
},
},
error
=>
this
.
errorMessage
=
<
any
>
error
);
error
=>
this
.
errorMessage
=
<
any
>
error
);
}
organizeQues
():
void
{
this
.
questions
.
forEach
(
element
=>
{
let
d
=
new
Date
();
let
s
=
new
Date
(
element
.
stime
);
let
e
=
new
Date
(
element
.
etime
);
if
(
s
<
d
&&
e
>
d
)
{
this
.
ques_final
.
push
(
element
);
}
});
console
.
log
(
this
.
questions
);
// console.log(this.ques_final
);
}
}
getProblems
():
void
{
getProblems
():
void
{
...
...
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