Commit 93b64d57 authored by Ayush's avatar Ayush

Minor fix

parent bf95b9eb
...@@ -11,35 +11,24 @@ if (isset($postData) && !empty($postData)) { ...@@ -11,35 +11,24 @@ if (isset($postData) && !empty($postData)) {
$lang = trim($request->language); $lang = trim($request->language);
$path = '../users/' . $username . '/' . trim($request->path) . '/' . $filename . $lang; $path = '../users/' . $username . '/' . trim($request->path) . '/' . $filename . $lang;
// if (file_exists($path)) { $sql1 = "SELECT n_files from users where username = '$username'";
// $msg = "file already exists"; $sql2 = "UPDATE users SET n_files = n_files+1 WHERE username = '$username'";
// clearstatcache(); $result = mysqli_query($mysqli, $sql1)->fetch_all()[0];
// echo json_encode($msg); if ($result == 10) {
// } $msg = "maximum limit(10) reached";
// else { echo json_encode($msg);
// $sql1 = "SELECT n_files from userdata where username = $username"; } else {
// $sql2 = "UPDATE userdata SET n_files = n_files+1 WHERE username = $username "; if (mysqli_query($mysqli, $sql2)) {
// $result = mysqli_query($mysqli, $sql1); $myfile = fopen($path, "w");
// if($result == 10){ fwrite($myfile, $data);
// $msg = "maximum limit(10) reached"; fclose($myfile);
// echo json_encode($msg);
// }
// else{
// if($result = mysqli_query($mysqli, $sql2)) {
$myfile = fopen($path, "w");
fwrite($myfile, $data);
fclose($myfile);
$msg = "file successfully uploaded";
clearstatcache();
echo json_encode($msg);
// }
// else{
// http_response_code(404);
// }
// }
// }
$msg = "file successfully uploaded";
clearstatcache();
echo json_encode($msg);
} else {
http_response_code(404);
}
}
} }
?> ?>
...@@ -39,7 +39,7 @@ export class HomeComponent implements OnInit { ...@@ -39,7 +39,7 @@ export class HomeComponent implements OnInit {
this.getProblems(); this.getProblems();
// this.questionService.getQues() // this.questionService.getQues()
// .subscribe(questions => this.questions = questions); // .subscribe(questions => this.questions = questions);
// console.log(this.questions); // console.log(this.questions);
} }
...@@ -49,11 +49,11 @@ export class HomeComponent implements OnInit { ...@@ -49,11 +49,11 @@ export class HomeComponent implements OnInit {
} }
openForm(): void { openForm(): void {
document.getElementById("popupForm").style.display = "block"; document.getElementById('popupForm').style.display = 'block';
} }
closeForm(): void { closeForm(): void {
document.getElementById("popupForm").style.display = "none"; document.getElementById('popupForm').style.display = 'none';
} }
resetForm(): void { resetForm(): void {
...@@ -71,15 +71,18 @@ export class HomeComponent implements OnInit { ...@@ -71,15 +71,18 @@ export class HomeComponent implements OnInit {
} }
submitForm() { submitForm() {
this.questiontoPost.start_time = this.questiontoPost.start_time.split('T').join(' ');
this.questiontoPost.end_time = this.questiontoPost.end_time.split('T').join(' ');
this.questionService.uploadQues(this.questiontoPost).subscribe( this.questionService.uploadQues(this.questiontoPost).subscribe(
(event: any) => { (event: any) => {
if (typeof (event) === 'object') { if (typeof (event) === 'object') {
this.questiontoPost = null; this.questiontoPost = null;
(document.getElementById('quesform') as HTMLInputElement).value = ''; (document.getElementById('quesform') as HTMLInputElement).value = '';
} }
this.resetForm();
this.closeForm();
} }
); );
this.resetForm();
this.closeForm();
} }
} }
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