Commit 423753be authored by Adarsh's avatar Adarsh

debug

parent 9056dccb
......@@ -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);
// }
// }
?>
......@@ -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->start_time); //string
$etime = trim($request->end_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')";
......
......@@ -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.start_time">
<input type="datetime-local" name="etime" id="end_time" [(ngModel)]="questiontoPost.end_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>
......
......@@ -19,12 +19,12 @@ export class HomeComponent implements OnInit {
title: "",
username: "",
statement: "",
tc1_inp: "",
tc1_out: "",
tc2_inp: "",
tc2_out: "",
start_time: "",
end_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: "",
start_time: "",
end_time: ""
tc1: "",
out1: "",
tc2: "",
out2: "",
stime: "",
etime: ""
};
}
submitForm() {
this.questiontoPost.start_time = this.questiontoPost.start_time.split('T').join(' ');
this.questiontoPost.end_time = this.questiontoPost.end_time.split('T').join(' ');
this.questiontoPost.stime = this.questiontoPost.stime.split('T').join(' ');
this.questiontoPost.etime = this.questiontoPost.etime.split('T').join(' ');
this.questionService.uploadQues(this.questiontoPost).subscribe(
(event: any) => {
if (typeof (event) === 'object') {
......
......@@ -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);
}
......
......@@ -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;
start_time: string;
end_time: string;
tc1: string;
out1: string;
tc2: string;
out2: string;
stime: string;
etime: string;
}
\ No newline at end of file
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