-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
1983 lines (1585 loc) · 78.5 KB
/
Copy pathMain.java
File metadata and controls
1983 lines (1585 loc) · 78.5 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Main implements ActionListener {
//ALL FRAMES
public static JFrame maineMenuFrame;
public static JFrame createTeacherFrame;
public static JFrame accountCreatedTeacherFrame;
public static JFrame teacherLogInFrame;
public static JFrame teacherMenuFrame;
public static JFrame addCourseFrame;
public static JFrame teacherQuizMenuFrame;
public static JFrame createQuizFrame;
public static JFrame multipleChoiceQuizFrame;
public static JFrame trueOrFalseQuizFrame;
public static JFrame addAnotherQuestionFrame;
public static JFrame editQuizFrame;
public static JFrame editTeacherAccountFrame;
public static JFrame editTeachAccountDoneFrame;
public static JFrame createStudentFrame;
public static JFrame accountCreatedStudentFrame;
public static JFrame studentLogInFrame;
public static JFrame studentMenuFrame;
public static JFrame chooseCourseForTakeQuizFrame;
public static JFrame whichQuizToTakeFrame;
public static JFrame quizStudentTakesFrame1;
public static JFrame quizSubmittedFrame;
public static JFrame viewGradedQuizFrame;
public static JFrame editStudentAccountFrame;
public static JFrame editStudentAccountDoneFrame;
public static JFrame questionForEditQuizFrame;
public static JFrame deleteQuizFrame;
public static JFrame quizDeletedFrame;
public static JFrame viewStudentQuizSubmissionsFrame;
public static JFrame stuGradedQuizFrame;
//ALL PANELS
public static JPanel maineMenuPanel;
public static JPanel createTeacherPanel;
public static JPanel accountCreatedTeacherPanel;
public static JPanel teacherLogInPanel;
public static JPanel teacherMenuPanel;
public static JPanel addCoursePanel;
public static JPanel teacherQuizMenuPanel;
public static JPanel createQuizPanel;
public static JPanel multipleChoiceQuizPanel;
public static JPanel trueOrFalseQuizPanel;
public static JPanel addAnotherQuestionPanel;
public static JPanel editQuizPanel;
public static JPanel editTeacherAccountPanel;
public static JPanel editTeachAccountDonePanel;
public static JPanel createStudentPanel;
public static JPanel accountCreatedStudentPanel;
public static JPanel studentLogInPanel;
public static JPanel studentMenuPanel;
public static JPanel chooseCourseForTakeQuizPanel;
public static JPanel whichQuizToTakePanel;
public static JPanel quizStudentTakesPanel1;
public static JPanel quizSubmittedPanel;
public static JPanel viewGradedQuizPanel;
public static JPanel editStudentAccountPanel;
public static JPanel editStudentAccountDonePanel;
public static JPanel questionForEditQuizPanel;
public static JPanel deleteQuizPanel;
public static JPanel quizDeletedPanel;
public static JPanel viewStudentQuizSubmissionsPanel;
public static JPanel stuGradedQuizPanel;
//TEACHER VARIABLES
public static JButton createTeacherButton;
public static JButton createStudentButton;
public static JButton loginTeacherButton;
public static JButton loginStudentButton;
public static JButton saveButton;
public static JLabel createTeacherLabel;
public static JLabel teacherNameLabel;
public static JTextField teacherNameText;
public static JLabel teacherUsernameLabel;
public static JTextField teacherUsernameText;
public static JLabel teacherPasswordLabel;
public static JTextField teacherPasswordText;
public static JButton createTeacherAccountButton;
public static JButton createTeacherAccountBackButton;
public static JLabel teacherAccountCreatedLabel;
public static JButton teacherLogInButton;
public static JLabel welcomeTeachersLabel;
public static JLabel teacherLogInUsernameLabel;
public static JLabel teacherLogInPasswordLabel;
public static JTextField teacherLogInUsernameText;
public static JTextField teacherLogInPasswordText;
public static JButton teacherLogInBackButton;
public static JLabel addCourseLabel;
public static JButton yesCourseButton;
public static JButton noCourseButton;
public static JLabel enterCourseNameLabel;
public static JTextField enterCourseNameText;
public static JButton createCourseButton;
public static JButton addCourseBackButton;
public static JButton createQuizButton;
public static JButton editQuizButton;
public static JButton deleteQuizButton;
public static JButton viewStudentQuizSubmissionsButton;
public static JButton editTeacherAccountButton;
public static JButton teacherQuizMenuBackButton;
public static JLabel nameOfQuizLabel;
public static JTextField nameOfQuizText;
public static JLabel formatOfQuizLabel;
public static JButton formatOfQuiz1Button;
public static JButton formatOfQuiz2Button;
public static JButton createQuizBackButton;
public static JLabel questionOneMCLabel;
public static JTextField questionOneMCText;
public static JLabel optionOneMCLabel;
public static JTextField optionOneMCText;
public static JLabel optionTwoMCLabel;
public static JTextField optionTwoMCText;
public static JLabel optionThreeMCLabel;
public static JTextField optionThreeMCText;
public static JLabel optionFourMCLabel;
public static JTextField optionFourMCText;
public static JLabel correctAnsChoiceMCLabel;
public static JTextField correctAnsChoiceMCText;
public static JLabel pointValueMCLabel;
public static JTextField pointValueMCText;
public static JButton addQuestionMCButton;
public static JButton multipleChoiceQuizBackButton;
public static JLabel questionOneTFLabel;
public static JTextField questionOneTFText;
public static JLabel optionOneTFLabel;
public static JLabel optionTwoTFLabel;
public static JLabel correctAnsChoiceTFLabelChoice;
public static JTextField correctAnsChoiceTFText;
public static JLabel pointValueTFLabel;
public static JTextField pointValueTFText;
public static JButton addQuestionTFButton;
public static JLabel addAnotherQuestionLabel;
public static JButton yesAnotherQuestionButton;
public static JButton noAnotherQuestionButton;
public static JButton deleteTheQuizButton;
public static JLabel deleteQuizLabel;
public static JButton quizDeletedBackButton;
public static JLabel chooseCourseForViewStuSubmissLabel;
public static JLabel chooseStudForViewStuSubmissLabel;
public static JLabel chooseQuizForViewStuSubmissLabel;
public static JButton viewStudSubmissionsViewButton;
public static JLabel editTeachAccountLabel;
public static JLabel editedTeachNameLabel;
public static JTextField editedTeachNameText;
public static JLabel editedTeachUsernameLabel;
public static JTextField editedTeachUsernameText;
public static JLabel editedTeachPasswordLabel;
public static JTextField editedTeachPasswordText;
public static JButton updateTeachAccountButton;
public static JButton editTeachAccountBackButton;
public static JButton editAccountDoneBackButton;
public static JLabel editCourseLabel;
public static JLabel editQuizLabel;
public static JLabel editQuestionLabel;
public static JLabel optionOneEditLabel;
public static JLabel optionTwoEditLabel;
public static JLabel optionThreeEditLabel;
public static JLabel optionFourEditLabel;
public static JButton saveEditQuizButton;
public static JTextField editPointValueMCText;
public static JTextField editCorrectAnsChoiceMCText;
public static JTextField editOptionOneMCText;
public static JTextField editOptionTwoMCText;
public static JTextField editOptionThreeMCText;
public static JTextField editOptionFourMCText;
public static JTextField editQuestionOneMCText;
public static JTextArea showsStuGradedQuizText;
//STUDENT VARIABLES
public static JLabel createStudentLabel;
public static JLabel studentNameLabel;
public static JTextField studentNameText;
public static JLabel studentUsernameLabel;
public static JTextField studentUsernameText;
public static JLabel studentPasswordLabel;
public static JTextField studentPasswordText;
public static JButton createStudentAccountButton;
public static JButton createStudentAccountBackButton;
public static JLabel studentAccountCreatedLabel;
public static JButton studentLogInButton;
public static JLabel welcomeStudentsLabel;
public static JLabel studentLogInUsernameLabel;
public static JTextField studentLogInUsernameText;
public static JLabel studentLogInPasswordLabel;
public static JTextField studentLogInPasswordText;
public static JButton studentLogInBackButton;
public static JButton takeQuizButton;
public static JLabel studentChooseCourseLabel;
public static JLabel chooseCourseTitleLabel;
public static JButton courseChoosenForQuizNextButton;
public static JLabel chooseQuizTakeTitleLabel;
public static JLabel studentChooseQuizLabel;
public static JButton quizChoosenNextButton;
public static JLabel questionOneTitleLabel;
public static JLabel questionOneStuQuizLabel;
public static JTextField questionOneStuAns;
public static JLabel typeInAnswerLabel;
public static JLabel optionOneMC;
public static JLabel optionTwoMC;
public static JLabel optionThreeMC;
public static JLabel optionFourMC;
public static JButton quizStuTakesNextButton;
public static JLabel quizSubmittedLabel;
public static JButton quizDoneBackToStuMenuButton;
public static JLabel viewGradedQuizTitleLabel;
public static JButton viewGradedQuizButton;
public static JLabel whichGradedQuizToViewLabel;
public static JButton viewQuizButton;
public static JLabel stuGradedQuizLabel;
public static JButton stuGradedQuizScreenBackButton;
public static JButton editStudentAccountButton;
public static JButton studentLogOutButton;
public static JLabel editStuAccountLabel;
public static JLabel editedStuNameLabel;
public static JTextField editedStuNameText;
public static JLabel editedStuUsernameLabel;
public static JTextField editedStuUsernameText;
public static JLabel editedStuPasswordLabel;
public static JTextField editedStuPasswordText;
public static JButton updateStuAccountButton;
public static JButton editStuAccountBackButton;
public static JButton nextForEditQuiz;
//COMMON VARIABLES
public static JLabel accountUpdatedLabel;
public static JLabel lsmToolLabel;
public static void main(String[] args) {
//mainMenu();
//createTeacher();
//accountCreatedTeacher();
//teacherLogIn();
//teacherMenu();
//addCourse();
//teacherQuizMenu();
//editStudentAccount();
//createQuiz();
//editQuiz();
//deleteQuiz();
//viewStudentQuizSubmissions();
//multipleChoiceQuiz();
//trueOrFalseQuiz();
//editTeacherAccount();
//createStudent();
//accountCreatedStudent();
//studentLogIn();
//studentMenu();
//chooseCourseForTakeQuiz();
//whichQuizToTake();
//quizStudentTakes();
//viewGradedQuiz();
showsStuGradedQuiz();
//editStudentAccount();
}
public static void mainMenu() {
maineMenuFrame = new JFrame();
maineMenuPanel = new JPanel();
maineMenuFrame.setSize(400, 300);
maineMenuFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
maineMenuFrame.add(maineMenuPanel);
lsmToolLabel = new JLabel("Welcome to Learning System Management Tool!");
lsmToolLabel.setBounds(50, 20, 500, 25);
maineMenuPanel.add(lsmToolLabel);
createTeacherButton = new JButton("Create Teacher");
createTeacherButton.setBounds(120, 50, 150, 25);
createTeacherButton.addActionListener(new Main());
maineMenuPanel.add(createTeacherButton);
createTeacherButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
maineMenuFrame.setVisible(false);
maineMenuFrame.dispose();
createTeacher();
}
});
createStudentButton = new JButton("Create Student");
createStudentButton.setBounds(120, 80, 150, 25);
createStudentButton.addActionListener(new Main());
maineMenuPanel.add(createStudentButton);
createStudentButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
maineMenuFrame.setVisible(false);
maineMenuFrame.dispose();
createStudent();
}
});
loginTeacherButton = new JButton("Login Teacher");
loginTeacherButton.setBounds(120, 110, 150, 25);
loginTeacherButton.addActionListener(new Main());
maineMenuPanel.add(loginTeacherButton);
loginTeacherButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
maineMenuFrame.setVisible(false);
maineMenuFrame.dispose();
teacherLogIn();
}
});
loginStudentButton = new JButton("Login Student");
loginStudentButton.setBounds(120, 140, 150, 25);
loginStudentButton.addActionListener(new Main());
maineMenuPanel.add(loginStudentButton);
loginStudentButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
maineMenuFrame.setVisible(false);
maineMenuFrame.dispose();
studentLogIn();
}
});
saveButton = new JButton("Save and Exit");
saveButton.setBounds(120, 170, 150, 25);
saveButton.addActionListener(new Main());
maineMenuPanel.add(saveButton);
saveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//call the save data methods
}
});
maineMenuPanel.setLayout(null);
maineMenuFrame.setVisible(true);
}
public static void createTeacher() {
createTeacherFrame = new JFrame();
createTeacherPanel = new JPanel();
createTeacherFrame.setSize(400, 300);
createTeacherFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
createTeacherFrame.add(createTeacherPanel);
createTeacherPanel.setLayout(null);
createTeacherLabel = new JLabel("Create a teacher account");
createTeacherLabel.setBounds(120, 20, 200, 25);
createTeacherPanel.add(createTeacherLabel);
teacherNameLabel = new JLabel("First & Last Name:");
teacherNameLabel.setBounds(20, 50, 150, 25);
createTeacherPanel.add(teacherNameLabel);
teacherNameText = new JTextField(20);
teacherNameText.setBounds(150, 50, 165, 25);
createTeacherPanel.add(teacherNameText);
teacherUsernameLabel = new JLabel("Username:");
teacherUsernameLabel.setBounds(20, 80, 80, 25);
createTeacherPanel.add(teacherUsernameLabel);
teacherUsernameText = new JTextField(20);
teacherUsernameText.setBounds(150, 80, 165, 25);
createTeacherPanel.add(teacherUsernameText);
teacherPasswordLabel = new JLabel("Password:");
teacherPasswordLabel.setBounds(20, 110, 80, 25);
createTeacherPanel.add(teacherPasswordLabel);
teacherPasswordText = new JTextField(20);
teacherPasswordText.setBounds(150, 110, 165, 25);
createTeacherPanel.add(teacherPasswordText);
createTeacherAccountButton = new JButton("Create Account");
createTeacherAccountButton.setBounds(160, 150, 150, 25);
createTeacherAccountButton.addActionListener(new Main());
createTeacherPanel.add(createTeacherAccountButton);
JLabel invalidName = new JLabel();
createTeacherAccountButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String returnValue = checkSpaceForTeacherName(teacherNameText);
if(returnValue.equals("Success")) {
createTeacherFrame.setVisible(false);
createTeacherFrame.dispose();
accountCreatedTeacher();
}
else {
invalidName.setText(returnValue);
invalidName.setBounds(30, 180, 250, 20);
createTeacherPanel.add(invalidName);
createTeacherPanel.repaint();
}
}
});
createTeacherAccountBackButton = new JButton("Back");
createTeacherAccountBackButton.setBounds(30, 150, 110, 25);
createTeacherAccountBackButton.addActionListener(new Main());
createTeacherPanel.add(createTeacherAccountBackButton);
createTeacherAccountBackButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mainMenu();
}
});
createTeacherFrame.setVisible(true);
}
// Sample invalid input check
public static String checkSpaceForTeacherName(JTextField teacherNameText) {
try {
if(teacherNameText.getText().contains(" ") )
return "Success";
else
return "Enter a space for first and last name";
} catch (NumberFormatException e) {
return "Something went wrong Please re-enter all fields!!";
}
}
public static void accountCreatedTeacher() {
accountCreatedTeacherFrame = new JFrame();
createTeacherPanel = new JPanel();
accountCreatedTeacherFrame.setSize(400, 300);
accountCreatedTeacherFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
accountCreatedTeacherFrame.add(createTeacherPanel);
createTeacherPanel.setLayout(null);
teacherAccountCreatedLabel = new JLabel("Account successfully created!");
teacherAccountCreatedLabel.setBounds(110, 20, 200, 25);
createTeacherPanel.add(teacherAccountCreatedLabel);
teacherLogInButton = new JButton("Log In");
teacherLogInButton.setBounds(150, 70, 90, 25);
teacherLogInButton.addActionListener(new Main());
createTeacherPanel.add(teacherLogInButton);
teacherLogInButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
teacherLogIn();
}
});
createTeacherPanel.setLayout(null);
accountCreatedTeacherFrame.setVisible(true);
}
public static void teacherLogIn() {
teacherLogInFrame = new JFrame();
teacherLogInPanel = new JPanel();
teacherLogInFrame.setSize(400, 300);
teacherLogInFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
teacherLogInFrame.add(teacherLogInPanel);
teacherLogInPanel.setLayout(null);
welcomeTeachersLabel = new JLabel("Welcome teachers!");
welcomeTeachersLabel.setBounds(140, 20, 150, 25);
teacherLogInPanel.add(welcomeTeachersLabel);
teacherLogInUsernameLabel = new JLabel("Username:");
teacherLogInUsernameLabel.setBounds(20, 50, 80, 25);
teacherLogInPanel.add(teacherLogInUsernameLabel);
teacherLogInPasswordLabel = new JLabel("Password:");
teacherLogInPasswordLabel.setBounds(20, 80, 80, 25);
teacherLogInPanel.add(teacherLogInPasswordLabel);
teacherLogInUsernameText = new JTextField(20);
teacherLogInUsernameText.setBounds(100, 50, 165, 25);
teacherLogInPanel.add(teacherLogInUsernameText);
teacherLogInPasswordText = new JTextField(20);
teacherLogInPasswordText.setBounds(100, 80, 165, 25);
teacherLogInPanel.add(teacherLogInPasswordText);
teacherLogInButton = new JButton("Login");
teacherLogInButton.setBounds(150, 120, 80, 25);
teacherLogInButton.addActionListener(new Main());
teacherLogInPanel.add(teacherLogInButton);
teacherLogInButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
teacherLogInFrame.setVisible(false);
teacherLogInFrame.dispose();
teacherCourseMenu();
}
});
teacherLogInBackButton = new JButton("Back");
teacherLogInBackButton.setBounds(30, 120, 110, 25);
teacherLogInBackButton.addActionListener(new Main());
teacherLogInPanel.add(teacherLogInBackButton);
teacherLogInBackButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mainMenu();
}
});
teacherLogInFrame.setVisible(true);
}
public static void teacherCourseMenu() {
teacherMenuFrame = new JFrame();
teacherMenuPanel = new JPanel();
teacherMenuFrame.setSize(400, 300);
teacherMenuFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
teacherMenuFrame.add(teacherMenuPanel);
addCourseLabel = new JLabel("Do you want to add a course?");
addCourseLabel.setBounds(80, 20, 200, 25);
teacherMenuPanel.add(addCourseLabel);
yesCourseButton = new JButton("Yes");
yesCourseButton.setBounds(120, 50, 80, 25);
yesCourseButton.addActionListener(new Main());
teacherMenuPanel.add(yesCourseButton);
yesCourseButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
teacherMenuFrame.setVisible(false);
teacherMenuFrame.dispose();
addCourse();
}
});
noCourseButton = new JButton("No");
noCourseButton.setBounds(120, 80, 80, 25);
noCourseButton.addActionListener(new Main());
teacherMenuPanel.add(noCourseButton);
//if teacher doesn't want to create a course
noCourseButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mainMenu();
}
});
teacherMenuPanel.setLayout(null);
teacherMenuFrame.setVisible(true);
}
public static void addCourse() {
addCourseFrame = new JFrame();
addCoursePanel = new JPanel();
addCourseFrame.setSize(400, 300);
addCourseFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
addCourseFrame.add(addCoursePanel);
// if yes to adding a course
// PATHWAY IS
enterCourseNameLabel = new JLabel("Enter Course Name:");
enterCourseNameLabel.setBounds(130, 20, 200, 25);
addCoursePanel.add(enterCourseNameLabel);
enterCourseNameText = new JTextField(50);
enterCourseNameText.setBounds(120, 50, 165, 25);
addCoursePanel.add(enterCourseNameText);
createCourseButton = new JButton("Create Course");
createCourseButton.setBounds(180, 80, 140, 25);
createCourseButton.addActionListener(new Main());
addCoursePanel.add(createCourseButton);
createCourseButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
addCourseFrame.setVisible(false);
addCourseFrame.dispose();
teacherQuizMenu();
}
});
addCourseBackButton = new JButton("Back");
addCourseBackButton.setBounds(60, 80, 80, 25);
addCourseBackButton.addActionListener(new Main());
addCoursePanel.add(addCourseBackButton);
addCourseBackButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
addCourseFrame.setVisible(false);
addCourseFrame.dispose();
teacherCourseMenu();
}
});
addCoursePanel.setLayout(null);
addCourseFrame.setVisible(true);
}
public static void teacherQuizMenu() {
teacherQuizMenuFrame = new JFrame();
teacherQuizMenuPanel = new JPanel();
teacherQuizMenuFrame.setSize(400, 300);
teacherQuizMenuFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
teacherQuizMenuFrame.add(teacherQuizMenuPanel);
lsmToolLabel = new JLabel("Learning System Management Tool");
lsmToolLabel.setBounds(90, 20, 500, 25);
teacherQuizMenuPanel.add(lsmToolLabel);
createQuizButton = new JButton("Create a Quiz");
createQuizButton.setBounds(80, 50, 250, 25);
createQuizButton.addActionListener(new Main());
teacherQuizMenuPanel.add(createQuizButton);
createQuizButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
teacherQuizMenuFrame.setVisible(false);
teacherQuizMenuFrame.dispose();
createQuiz();
}
});
editQuizButton = new JButton("Edit Quiz");
editQuizButton.setBounds(80, 80, 250, 25);
editQuizButton.addActionListener(new Main());
teacherQuizMenuPanel.add(editQuizButton);
editQuizButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
teacherQuizMenuFrame.setVisible(false);
teacherQuizMenuFrame.dispose();
editQuiz();
}
});
deleteQuizButton = new JButton("Delete Quiz");
deleteQuizButton.setBounds(80, 110, 250, 25);
deleteQuizButton.addActionListener(new Main());
teacherQuizMenuPanel.add(deleteQuizButton);
deleteQuizButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
teacherQuizMenuFrame.setVisible(false);
teacherQuizMenuFrame.dispose();
deleteQuiz();
}
});
viewStudentQuizSubmissionsButton = new JButton("View Student Quiz Submissions");
viewStudentQuizSubmissionsButton.setBounds(80, 140, 250, 25);
viewStudentQuizSubmissionsButton.addActionListener(new Main());
teacherQuizMenuPanel.add(viewStudentQuizSubmissionsButton);
viewStudentQuizSubmissionsButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
teacherQuizMenuFrame.setVisible(false);
teacherQuizMenuFrame.dispose();
viewStudentQuizSubmissions();
}
});
editTeacherAccountButton = new JButton("Edit Account");
editTeacherAccountButton.setBounds(80, 170, 250, 25);
editTeacherAccountButton.addActionListener(new Main());
teacherQuizMenuPanel.add(editTeacherAccountButton);
editTeacherAccountButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
teacherQuizMenuFrame.setVisible(false);
teacherQuizMenuFrame.dispose();
editTeacherAccount();
}
});
teacherQuizMenuBackButton = new JButton("Back");
teacherQuizMenuBackButton.setBounds(30, 200, 110, 25);
teacherQuizMenuBackButton.addActionListener(new Main());
teacherQuizMenuPanel.add(teacherQuizMenuBackButton);
teacherQuizMenuBackButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
teacherQuizMenuFrame.setVisible(false);
teacherQuizMenuFrame.dispose();
addCourse();
}
});
teacherQuizMenuPanel.setLayout(null);
teacherQuizMenuFrame.setVisible(true);
}
public static int qno = 1;
public static void createQuiz() {
createQuizFrame = new JFrame();
createQuizPanel = new JPanel();
createQuizFrame.setSize(400, 300);
createQuizFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
createQuizFrame.add(createQuizPanel);
lsmToolLabel = new JLabel("Create a Quiz");
lsmToolLabel.setBounds(130, 20, 500, 25);
createQuizPanel.add(lsmToolLabel);
nameOfQuizLabel = new JLabel("Name of Quiz:");
nameOfQuizLabel.setBounds(20, 50, 150, 25);
createQuizPanel.add(nameOfQuizLabel);
nameOfQuizText = new JTextField(20);
nameOfQuizText.setBounds(120, 50, 125, 25);
createQuizPanel.add(nameOfQuizText);
formatOfQuizLabel = new JLabel("Format of Quiz:");
formatOfQuizLabel.setBounds(20, 90, 150, 25);
createQuizPanel.add(formatOfQuizLabel);
formatOfQuiz1Button = new JButton("Multiple-Choice");
formatOfQuiz1Button.setBounds(80, 130, 190, 25);
formatOfQuiz1Button.addActionListener(new Main());
createQuizPanel.add(formatOfQuiz1Button);
formatOfQuiz1Button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
createQuizFrame.setVisible(false);
createQuizFrame.dispose();
multipleChoiceQuiz();
}
});
formatOfQuiz2Button = new JButton("True/False");
formatOfQuiz2Button.setBounds(80, 160, 190, 25);
formatOfQuiz2Button.addActionListener(new Main());
createQuizPanel.add(formatOfQuiz2Button);
formatOfQuiz2Button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
createQuizFrame.setVisible(false);
createQuizFrame.dispose();
trueOrFalseQuiz();
}
});
createQuizBackButton = new JButton("Back");
createQuizBackButton.setBounds(30, 190, 110, 25);
createQuizBackButton.addActionListener(new Main());
createQuizPanel.add(createQuizBackButton);
createQuizBackButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
createQuizFrame.setVisible(false);
createQuizFrame.dispose();
teacherQuizMenu();
}
});
createQuizPanel.setLayout(null);
createQuizFrame.setVisible(true);
}
public static void multipleChoiceQuiz() {
multipleChoiceQuizFrame = new JFrame();
multipleChoiceQuizPanel = new JPanel();
multipleChoiceQuizFrame.setSize(400, 320);
multipleChoiceQuizFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
multipleChoiceQuizFrame.add(multipleChoiceQuizPanel);
lsmToolLabel = new JLabel("Name of Quiz: "); // + show name of quiz);
lsmToolLabel.setBounds(130, 20, 500, 25);
multipleChoiceQuizPanel.add(lsmToolLabel);
questionOneMCLabel = new JLabel("Type in Question "+qno+" : ");
questionOneMCLabel.setBounds(20, 50, 160, 25);
multipleChoiceQuizPanel.add(questionOneMCLabel);
questionOneMCText = new JTextField(20);
questionOneMCText.setBounds(210, 50, 165, 25);
multipleChoiceQuizPanel.add(questionOneMCText);
optionOneMCLabel = new JLabel("Option 1:");
optionOneMCLabel.setBounds(20, 80, 80, 25);
multipleChoiceQuizPanel.add(optionOneMCLabel);
optionOneMCText = new JTextField(20);
optionOneMCText.setBounds(210, 80, 165, 25);
multipleChoiceQuizPanel.add(optionOneMCText);
optionTwoMCLabel = new JLabel("Option 2:");
optionTwoMCLabel.setBounds(20, 110, 80, 25);
multipleChoiceQuizPanel.add(optionTwoMCLabel);
optionTwoMCText = new JTextField(20);
optionTwoMCText.setBounds(210, 110, 165, 25);
multipleChoiceQuizPanel.add(optionTwoMCText);
optionThreeMCLabel = new JLabel("Option 3:");
optionThreeMCLabel.setBounds(20, 140, 80, 25);
multipleChoiceQuizPanel.add(optionThreeMCLabel);
optionThreeMCText = new JTextField(20);
optionThreeMCText.setBounds(210, 140, 165, 25);
multipleChoiceQuizPanel.add(optionThreeMCText);
optionFourMCLabel = new JLabel("Option 4:");
optionFourMCLabel.setBounds(20, 170, 80, 25);
multipleChoiceQuizPanel.add(optionFourMCLabel);
optionFourMCText = new JTextField(20);
optionFourMCText.setBounds(210, 170, 165, 25);
multipleChoiceQuizPanel.add(optionFourMCText);
correctAnsChoiceMCLabel = new JLabel("Enter correct answer choice:");
correctAnsChoiceMCLabel.setBounds(20, 200, 250, 25);
multipleChoiceQuizPanel.add(correctAnsChoiceMCLabel);
correctAnsChoiceMCText = new JTextField(20);
correctAnsChoiceMCText.setBounds(210, 200, 165, 25);
multipleChoiceQuizPanel.add(correctAnsChoiceMCText);
pointValueMCLabel = new JLabel("Enter the point value:");
pointValueMCLabel.setBounds(20, 230, 250, 25);
multipleChoiceQuizPanel.add(pointValueMCLabel);
pointValueMCText = new JTextField(20);
pointValueMCText.setBounds(210, 230, 165, 25);
multipleChoiceQuizPanel.add(pointValueMCText);
//adds the questions
addQuestionMCButton = new JButton("Add Question");
addQuestionMCButton.setBounds(210, 260, 150, 25);
addQuestionMCButton.addActionListener(new Main());
multipleChoiceQuizPanel.add(addQuestionMCButton);
// once the add question button is clicked, we need to add the question to the list of questions for that specific quiz
// calls the method that displays the screen and asks if the user wants to add another question or not
addQuestionMCButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
multipleChoiceQuizFrame.setVisible(false);
multipleChoiceQuizFrame.dispose();
addAnotherQuestion(0);
}
});
multipleChoiceQuizBackButton = new JButton("Back");
multipleChoiceQuizBackButton.setBounds(30, 290, 110, 25);
multipleChoiceQuizBackButton.addActionListener(new Main());
multipleChoiceQuizPanel.add(multipleChoiceQuizBackButton);
multipleChoiceQuizBackButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
multipleChoiceQuizFrame.setVisible(false);
multipleChoiceQuizFrame.dispose();
createQuiz();
}
});
multipleChoiceQuizPanel.setLayout(null);
multipleChoiceQuizFrame.setVisible(true);
}
public static void trueOrFalseQuiz() {
trueOrFalseQuizFrame = new JFrame();
trueOrFalseQuizPanel = new JPanel();
trueOrFalseQuizFrame.setSize(400, 320);
trueOrFalseQuizFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
trueOrFalseQuizFrame.add(trueOrFalseQuizPanel);
lsmToolLabel = new JLabel("Name of Quiz: "); // + show name of quiz);
lsmToolLabel.setBounds(130, 20, 500, 25);
trueOrFalseQuizPanel.add(lsmToolLabel);
questionOneTFLabel = new JLabel("Type in Question "+qno+" : ");
questionOneTFLabel.setBounds(20, 50, 160, 25);
trueOrFalseQuizPanel.add(questionOneTFLabel);
questionOneTFText = new JTextField(20);
questionOneTFText.setBounds(210, 50, 165, 25);
trueOrFalseQuizPanel.add(questionOneTFText);
optionOneTFLabel = new JLabel("1) True");
optionOneTFLabel.setBounds(20, 80, 80, 25);
trueOrFalseQuizPanel.add(optionOneTFLabel);
optionTwoTFLabel = new JLabel("2) False");
optionTwoTFLabel.setBounds(20, 110, 80, 25);
trueOrFalseQuizPanel.add(optionTwoTFLabel);
correctAnsChoiceTFLabelChoice = new JLabel("Enter correct answer choice (True or False):");
correctAnsChoiceTFLabelChoice.setBounds(20, 140, 320, 25);
trueOrFalseQuizPanel.add(correctAnsChoiceTFLabelChoice);
correctAnsChoiceTFText = new JTextField(20);
correctAnsChoiceTFText.setBounds(300, 140, 90, 25);
trueOrFalseQuizPanel.add(correctAnsChoiceTFText);
pointValueTFLabel = new JLabel("Enter the point value:");
pointValueTFLabel.setBounds(20, 170, 250, 25);
trueOrFalseQuizPanel.add(pointValueTFLabel);
pointValueTFText = new JTextField(20);
pointValueTFText.setBounds(300, 170, 90, 25);
trueOrFalseQuizPanel.add(pointValueTFText);
//adds the questions
addQuestionTFButton = new JButton("Add Question");
addQuestionTFButton.setBounds(120, 210, 150, 25);
addQuestionTFButton.addActionListener(new Main());
trueOrFalseQuizPanel.add(addQuestionTFButton);
// once the add question button is clicked, we need to add the question to the list of questions for that specific quiz
// calls the method that displays the screen and asks if the user wants to add another question or not
addQuestionTFButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
trueOrFalseQuizFrame.setVisible(false);
trueOrFalseQuizFrame.dispose();
addAnotherQuestion(1);
}
});
trueOrFalseQuizPanel.setLayout(null);
trueOrFalseQuizFrame.setVisible(true);
}
public static void addAnotherQuestion(int type) {
addAnotherQuestionFrame = new JFrame();
addAnotherQuestionPanel = new JPanel();
addAnotherQuestionFrame.setSize(400, 300);
addAnotherQuestionFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
addAnotherQuestionFrame.add(addAnotherQuestionPanel);
addAnotherQuestionLabel = new JLabel("Do you want to add another question?");
addAnotherQuestionLabel.setBounds(70, 20, 280, 25);
addAnotherQuestionPanel.add(addAnotherQuestionLabel);
yesAnotherQuestionButton = new JButton("Yes");
yesAnotherQuestionButton.setBounds(110, 50, 80, 25);
yesAnotherQuestionButton.addActionListener(new Main());
addAnotherQuestionPanel.add(yesAnotherQuestionButton);
//if the user wants to add another question, display the screen of the question, options, correct answer and point value again
//this time however, it should say type in question 2
//call whichever type of quiz based on the format of the quiz
yesAnotherQuestionButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(type == 0) {
qno++;
multipleChoiceQuiz();
}
else {
qno++;
trueOrFalseQuiz();
}
}
});
// if the user doesn't want to add another question
noAnotherQuestionButton = new JButton("No");
noAnotherQuestionButton.setBounds(200, 50, 80, 25);
noAnotherQuestionButton.addActionListener(new Main());
addAnotherQuestionPanel.add(noAnotherQuestionButton);
// save the quiz if the user doesn't want to add another question
noAnotherQuestionButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
teacherCourseMenu();
}
});
addAnotherQuestionPanel.setLayout(null);
addAnotherQuestionFrame.setVisible(true);
}
public static void editQuiz() {
editQuizFrame = new JFrame();
editQuizPanel = new JPanel();
editQuizFrame.setSize(400, 300);
editQuizFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
editQuizFrame.add(editQuizPanel);
lsmToolLabel = new JLabel("Edit a Quiz");
lsmToolLabel.setBounds(160, 20, 500, 25);
editQuizPanel.add(lsmToolLabel);