Commit 1a0dea61 authored by Adarsh's avatar Adarsh

minor

parent 7761765d
<?php <?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-Headers: Origin, X-Requested-With, Content-Type, Accept");
header("Content-Type: application/json; charset=UTF-8");
include_once("database.php"); include_once("database.php");
if($_SERVER['REQUEST_METHOD'] === 'GET')){ if($_SERVER['REQUEST_METHOD'] === 'GET'){
$sql1 = "SELECT Now()"; $sql1 = "SELECT Now()";
$currtime = $mysqli->query($sql1); $currtime = $mysqli->query($sql1);
$sql2 = "SELECT * FROM questions WHERE stime <= $currtime and etime >= $currtime"; $sql2 = "SELECT * FROM questions WHERE stime <= $currtime and etime >= $currtime";
......
<?php <?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-Headers: Origin, X-Requested-With, Content-Type, Accept");
header("Content-Type: application/json; charset=UTF-8");
include_once("database.php"); include_once("database.php");
$postData = file_get_contents("php://input"); $postData = file_get_contents("php://input");
...@@ -22,7 +28,7 @@ if(isset($postData) && !empty($postData)){ ...@@ -22,7 +28,7 @@ if(isset($postData) && !empty($postData)){
echo json_encode($msg); echo json_encode($msg);
} }
else{ else{
$msg = "title already exists"; $msg = "question already exists";
echo json_encode($msg); echo json_encode($msg);
} }
......
...@@ -26,6 +26,7 @@ export class HomeComponent implements OnInit { ...@@ -26,6 +26,7 @@ export class HomeComponent implements OnInit {
start_time: "", start_time: "",
end_time: "" end_time: ""
}; };
questions: any[];
constructor(private dataService: ApiService, constructor(private dataService: ApiService,
private problemService: ProblemService, private problemService: ProblemService,
...@@ -36,6 +37,10 @@ export class HomeComponent implements OnInit { ...@@ -36,6 +37,10 @@ export class HomeComponent implements OnInit {
this.user = JSON.parse(this.dataService.getToken()); this.user = JSON.parse(this.dataService.getToken());
this.questiontoPost.username = this.user.username; this.questiontoPost.username = this.user.username;
this.getProblems(); this.getProblems();
// this.questionService.getQues()
// .subscribe(questions => this.questions = questions);
// console.log(this.questions);
} }
getProblems(): void { getProblems(): void {
...@@ -66,7 +71,6 @@ export class HomeComponent implements OnInit { ...@@ -66,7 +71,6 @@ export class HomeComponent implements OnInit {
} }
submitForm(): void { submitForm(): void {
this.questionService.uploadQues(this.questiontoPost); this.questionService.uploadQues(this.questiontoPost);
this.resetForm(); this.resetForm();
this.closeForm(); this.closeForm();
......
...@@ -19,8 +19,8 @@ export class QuestionService { ...@@ -19,8 +19,8 @@ export class QuestionService {
this.http.post(this.uploadUrl, ques); this.http.post(this.uploadUrl, ques);
} }
getQues(): Observable<Question[]> { getQues(): Observable<any[]> {
return this.http.get<Question[]>(this.getUrl); return this.http.get<any[]>(this.getUrl);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment