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
d313153d
Commit
d313153d
authored
Dec 08, 2020
by
Adarsh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get questions debug
parent
423753be
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
26 deletions
+22
-26
backend/database.php
backend/database.php
+3
-3
backend/questions/get_questions.php
backend/questions/get_questions.php
+8
-18
src/app/home/home.component.ts
src/app/home/home.component.ts
+9
-3
src/app/question.service.ts
src/app/question.service.ts
+2
-2
No files found.
backend/database.php
View file @
d313153d
<?php
header
(
"Access-Control-Allow-Origin: *"
);
header
(
'Access-Control-Allow-Credentials: true'
);
header
(
"Access-Control-Allow-Methods: PUT, GET, POST, DELETE"
);
header
(
"Access-Control-Allow-Methods: PUT, GET, POST, DELETE
, OPTIONS
"
);
header
(
"Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"
);
header
(
"Content-Type: application/json; charset=UTF-8"
);
...
...
@@ -12,6 +12,6 @@
$mysqli
=
new
mysqli
(
$db_host
,
$db_username
,
$db_password
,
$db_name
);
if
(
$mysqli
->
connect_error
)
{
die
(
'Error : ('
.
$mysqli
->
connect_errno
.
') '
.
$mysqli
->
connect_error
);
}
die
(
'Error : ('
.
$mysqli
->
connect_errno
.
') '
.
$mysqli
->
connect_error
);
}
?>
\ No newline at end of file
backend/questions/get_questions.php
View file @
d313153d
...
...
@@ -8,13 +8,14 @@ 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"
;
$data
=
[];
if
(
$result
=
mysqli
->
query
(
$sql2
)){
if
(
$result
=
$
mysqli
->
query
(
$sql2
)){
$i
=
0
;
while
(
$row
=
mysql_fetch_assoc
(
$result
)){
...
...
@@ -35,28 +36,17 @@ include_once("../database.php");
else
{
http_response_code
(
404
);
}
}
// if($_SERVER['REQUEST_METHOD'] === 'GET'){
// 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++;
// if($result = $mysqli->query($sql2)){
// while($row = mysql_fetch_assoc($request)){
// array_push($data,$row);
// }
// echo json_encode($data);
// }
...
...
src/app/home/home.component.ts
View file @
d313153d
...
...
@@ -26,7 +26,9 @@ export class HomeComponent implements OnInit {
stime
:
""
,
etime
:
""
};
questions
:
any
[];
questions
:
Question
[];
errorMessage
:
any
;
constructor
(
private
dataService
:
ApiService
,
private
problemService
:
ProblemService
,
...
...
@@ -39,8 +41,12 @@ export class HomeComponent implements OnInit {
this
.
getProblems
();
this
.
questionService
.
getQues
()
.
subscribe
(
questions
=>
this
.
questions
=
questions
);
// console.log(this.questions);
.
subscribe
(
data
=>
{
this
.
questions
=
data
;
},
error
=>
this
.
errorMessage
=
<
any
>
error
);
console
.
log
(
this
.
questions
);
}
getProblems
():
void
{
...
...
src/app/question.service.ts
View file @
d313153d
...
...
@@ -20,8 +20,8 @@ export class QuestionService {
return
this
.
http
.
post
(
this
.
uploadUrl
,
ques
);
}
getQues
():
Observable
<
any
[]
>
{
return
this
.
http
.
get
<
any
[]
>
(
this
.
getUrl
);
getQues
():
Observable
<
Question
[]
>
{
return
this
.
http
.
get
<
Question
[]
>
(
this
.
getUrl
);
}
}
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