Commit 280a8daa authored by Adarsh's avatar Adarsh

minor

parent 1a0dea61
......@@ -11,6 +11,7 @@ $postData = file_get_contents("php://input");
if(isset($postData) && !empty($postData)){
$request = json_decode($postData);
$title = trim($request->title);
$username = trim($request->username); //string
$statement = trim($request->statement); //string
......@@ -21,7 +22,7 @@ if(isset($postData) && !empty($postData)){
$stime = trim($request->start_time); //string
$etime = trim($request->end_time)
$sql = "INSERT INTO questions($title,$username,$statement,$tc1,$out1,$tc2,$out2,$stime,$etime)";
$sql = "INSERT INTO questions(title,username,statement,tc1,out1,tc2,out2,stime,etime) VALUES ('$title','$username','$statement','$tc1','$out1','$tc2','$out2','$stime','$etime')";
if($result = $mysqli->query($sql)){
$msg = "question uploaded";
......
......@@ -5,7 +5,7 @@
<div class="loginPopup">
<div class="formPopup" id="popupForm">
<form class="formContainer" (ngSubmit) = "submitForm()">
<form class="formContainer" id="quesform" (ngSubmit) = "submitForm()">
<input type="text" id="title" placeholder="Problem Title" name="title" [(ngModel)]="questiontoPost.title" required>
<textarea id="statement" placeholder="Problem Statement" rows="8" cols="80" required></textarea>
......
......@@ -70,8 +70,15 @@ export class HomeComponent implements OnInit {
};
}
submitForm(): void {
this.questionService.uploadQues(this.questiontoPost);
submitForm() {
this.questionService.uploadQues(this.questiontoPost).subscribe(
(event: any) => {
if (typeof (event) === 'object') {
this.questiontoPost = null;
(document.getElementById('quesform') as HTMLInputElement).value = '';
}
}
);
this.resetForm();
this.closeForm();
}
......
......@@ -15,8 +15,8 @@ export class QuestionService {
constructor(private http: HttpClient) { }
uploadQues(ques: Question): void {
this.http.post(this.uploadUrl, ques);
uploadQues(ques): Observable<any> {
return this.http.post(this.uploadUrl, ques);
}
getQues(): Observable<any[]> {
......
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