-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCreatMockInterviewController.java
More file actions
93 lines (78 loc) · 3.23 KB
/
CreatMockInterviewController.java
File metadata and controls
93 lines (78 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package jobinterviewpreparationsystem;
import java.net.URL;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.TreeMap;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.TextField;
import javafx.scene.text.Text;
import jobinterviewpreparationsystem.DB.DatabaseHandler;
public class CreatMockInterviewController {
@FXML
private TextField questionTextField; // Single TextField to input the question
/**
* This method is triggered when the Confirm button is pressed.
* It will handle any logic related to creating a mock interview.
*/
@FXML
private void handleConfirmButton(ActionEvent event) {
// You can handle the mock interview creation logic here
// For now, just show a confirmation message
String message = "Mock Created!";
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Mock Interview Created");
alert.setHeaderText("Mock Interview Created Successfully");
alert.setContentText(message);
alert.showAndWait();
}
/**
* This method is triggered when the Add Question button is pressed.
* It adds the question entered in the TextField to the question bank.
*/
@FXML
private void handleAddQuestionButton(ActionEvent event) {
// Get the text entered in the question text field
String questionText = questionTextField.getText().trim();
// Validate that the question text is not empty
if (questionText.isEmpty()) {
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Input Error");
alert.setHeaderText("Invalid Input");
alert.setContentText("Please enter a valid question.");
alert.showAndWait();
return;
}
// Create a new DatabaseHandler object to interact with the database
DatabaseHandler dbHandler = new DatabaseHandler();
boolean success = dbHandler.addQuestion(questionText);
// Show success or error message based on the result of adding the question
if (success) {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Success");
alert.setHeaderText("Question Added");
alert.setContentText("The question has been added to the question bank.");
alert.showAndWait();
// Clear the text field after adding the question
questionTextField.clear();
} else {
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Database Error");
alert.setHeaderText("Failed to Add Question");
alert.setContentText("There was an error saving the question.");
alert.showAndWait();
}
}
/**
* This method is triggered when the Go Back button is pressed.
* It navigates back to the Mentor screen.
*/
@FXML
private void handleGoBackButton(ActionEvent event) {
// Navigate back to the Mentor screen (adjust the method based on your implementation)
JobInterviewPreparationSystem.showMentorScreen();
}
}