Commit 1a0dea61 authored by Adarsh's avatar Adarsh

minor

parent 7761765d
<?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");
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";
......
<?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");
$postData = file_get_contents("php://input");
......@@ -22,7 +28,7 @@ if(isset($postData) && !empty($postData)){
echo json_encode($msg);
}
else{
$msg = "title already exists";
$msg = "question already exists";
echo json_encode($msg);
}
......
......@@ -26,6 +26,7 @@ export class HomeComponent implements OnInit {
start_time: "",
end_time: ""
};
questions: any[];
constructor(private dataService: ApiService,
private problemService: ProblemService,
......@@ -36,6 +37,10 @@ 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);
// console.log(this.questions);
}
getProblems(): void {
......@@ -66,7 +71,6 @@ export class HomeComponent implements OnInit {
}
submitForm(): void {
this.questionService.uploadQues(this.questiontoPost);
this.resetForm();
this.closeForm();
......
......@@ -19,8 +19,8 @@ export class QuestionService {
this.http.post(this.uploadUrl, ques);
}
getQues(): Observable<Question[]> {
return this.http.get<Question[]>(this.getUrl);
getQues(): Observable<any[]> {
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