-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGradeAssignmentController.java
More file actions
64 lines (57 loc) · 2.03 KB
/
GradeAssignmentController.java
File metadata and controls
64 lines (57 loc) · 2.03 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
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class GradeAssignmentController {
@FXML
private GridPane grid;
@FXML
public void initialize() {
ArrayList<Assignment> arr = LearningSystem.assignments;
System.out.println(arr.size());
for (int i = 0; i < arr.size(); i++) {
final int ind = i;
Label l = new Label();
l.setText(String.format("%d", arr.get(i).getStudentId()));
Label c = new Label();
c.setText(String.format("%s", arr.get(i).getComments()));
Button btn = new Button();
btn.setText(String.format("Assignment - %d", arr.get(i).getStudentId()));
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
String filePath = arr.get(ind).getFileAddress();
try {
File file = new File(filePath);
if (file.exists()) {
Desktop.getDesktop().open(file);
}
} catch (IOException e) {
System.err.println(e);
}
}
});
grid.add(l, 0, i + 1);
grid.add(c, 1, i + 1);
grid.add(btn, 2, i + 1);
}
}
@FXML
void homeAct(ActionEvent event) throws Exception {
Stage stage = (Stage) grid.getScene().getWindow();
Parent root = FXMLLoader.load(getClass().getResource("InstructorDashboard.fxml"));
Scene scene = new Scene(root);
stage.setTitle("LMS");
stage.setScene(scene);
}
}