Game Code
Game Code
Class: ThymeleafConfig
package io.flappybird.configration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.thymeleaf.spring6.SpringTemplateEngine;
import org.thymeleaf.spring6.templateresolver.SpringResourceTemplateResolver;
import org.thymeleaf.templatemode.TemplateMode;
@Configuration
public class ThymeleafConfig {
@Bean
public SpringTemplateEngine templateEngine() {
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setTemplateResolver(templateResolver());
return templateEngine;
}
@Bean
public SpringResourceTemplateResolver templateResolver() {
SpringResourceTemplateResolver templateResolver = new
SpringResourceTemplateResolver();
templateResolver.setPrefix("classpath:/templates/");
templateResolver.setSuffix(".html");
templateResolver.setTemplateMode(TemplateMode.HTML);
return templateResolver;
}
}
Class: GameController
package io.flappybird.controller.game;
import io.flappybird.game.App;
import io.flappybird.game.Game;
import io.flappybird.model.*;
import io.flappybird.service.*;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
1
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.io.*;
import java.util.List;
@Controller
@RequestMapping("/game")
public class GameController {
@Autowired
QuestionService questionService;
@Autowired
private QuizService quizService;
@Autowired
private PlayGameService playGameService;
@Autowired
private TopicService topicService;
private int highScore = 0;
@GetMapping("/playGame")
public String playGame(RedirectAttributes redirectAttributes,Model model) throws
Exception {
List<TopicDDLReq> topicDDLReq= quizService.bindTopicList("DD1");
model.addAttribute("topics", topicDDLReq);
Game game = new Game();
int hs = game.findHighScore();
SessionManager.getInstance().setHighestScore(hs);
ScoreReq scoreReq = playGameService.bindScore();
System.out.println("getHighestScore>>>"+scoreReq.getHighestScore()+
"getRecentScore>>>"+scoreReq.getRecentScore());
model.addAttribute("scoreReq", scoreReq);
return "game/startGame";
}
@GetMapping("/readMe")
@ResponseBody
public String readMe() {
StringBuilder readMeContent = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new FileReader("ReadMe.txt"))) {
String line;
while ((line = reader.readLine()) != null) {
readMeContent.append(line).append("<br/>"); // Append each line and add line
break
}
2
} catch (Exception e) {
e.printStackTrace(); // Handle exceptions appropriately
return "Error loading instructions.";
}
return readMeContent.toString(); // Return the full content as a string
}
@GetMapping("/deleteHighestScore")
public String deleteHighestScore(RedirectAttributes redirectAttributes) throws Exception {
System.out.println("deleteHighestScore Calling>>>>>>>>>>>>>>");
try {
while (file.getFilePointer() < file.length()) {
int score = file.readInt();
System.out.println("deleteHighestScore Calling>>>>>>score>>>>>>>>" + score);
if (score != SessionManager.getInstance().getHighestScore()) {
tempFile.writeInt(score); // Write to temporary file
}
}
} finally {
file.close();
tempFile.close();
}
if (oldFile.delete()) {
newFile.renameTo(oldFile);
} else {
throw new Exception("Failed to delete old highscores file");
}
3
SessionManager.getInstance().setQuestions(questionReqs);
model.addAttribute("userName", userName);
App app;
if(! SessionManager.getInstance().isGameOpen()) {
app=new App();
app.startGame();
SessionManager.getInstance().setGameOpen(true);
}
else {
String resultMessage="Game Already Open Pl";
redirectAttributes.addFlashAttribute("delMsg", resultMessage);
return "student/studentMenu";
}
@GetMapping("/quizzes/{topicId}")
@ResponseBody
public List<QuizDDLReq> getQuizzesForTopic(@PathVariable("topicId") int topicId) {
System.out.println("topicId>>>>>>>>>>>>>"+topicId);
List<QuizDDLReq> quizDDLReq= quizService.getQuizListByTopics("DD3",topicId);
System.out.println("quizDDLReq>>>>>>>>>>>>>"+quizDDLReq);
return quizDDLReq;
}
@GetMapping("/questions/{quizId}")
@ResponseBody
public List<QuestionsReq> bindQuestionsInfo(@PathVariable("quizId") int quizId) {
SessionManager.getInstance().setQuizIdS(0);//default value
SessionManager.getInstance().setQuizIdS(quizId);//default value
return
questionService.bindQuestionsInfo("DG2",SessionManager.getInstance().getUserId(),quizId)
;
}
//Start Game
@PostMapping("/startGame")
public String startGame( @RequestBody PlayGameReq playGameReq,
RedirectAttributes redirectAttributes,BindingResult bindingResult) {
System.out.println("playGameReq");
String resultMsg=playGameService.startGame(playGameReq);
int userTypeId = SessionManager.getInstance().getUserTypeId();//1: student,3:Teacher
if(resultMsg.equals("SUCCESS"))
{
//
}
else{
redirectAttributes.addFlashAttribute("errorMsg", resultMsg);
4
}
return "redirect:/game/startGame";
}
//End Game
@PostMapping("/endGame")
public String endGame( @RequestBody PlayGameReq playGameReq, RedirectAttributes
redirectAttributes) {
String resultMsg = playGameService.endGame(playGameReq);
if (resultMsg.equals("SUCCESS")) {
} else {
redirectAttributes.addFlashAttribute("errorMsg", resultMsg);
}
return "redirect:/game/startGame";
}
}
Class: StudentController
package io.flappybird.controller.student;
import com.fasterxml.jackson.databind.ext.Java7Handlers;
import io.flappybird.model.*;
import io.flappybird.service.SessionManager;
import io.flappybird.service.StudentService;
import io.flappybird.service.TopicService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.util.List;
@Controller
@RequestMapping("/student")
public class StudentController {
@Autowired
private StudentService studentService;
@Autowired
private TopicService topicService;
@GetMapping("/achievements")
public String achievements(Model model) {
int userId = SessionManager.getInstance().getUserId();
AchievementsReq achievementsReq= studentService.bindAchievements("ACH",userId);
model.addAttribute("achievementsReq", achievementsReq);
return "student/achievements";
}
@GetMapping("/studentMenu")
public String studentMenu(Model model) {
String userName= SessionManager.getInstance().getUsername();
5
model.addAttribute("userName", userName);
return "student/studentMenu";
}
@PostMapping("/InsertStudent")
public String saveStudent(@ModelAttribute StudentReq student, RedirectAttributes
redirectAttributes) {
redirectAttributes.addFlashAttribute("message", "Student added successfully!");
return "redirect:/students";
}
@GetMapping("/bindStudentInfo")
public String bindStudentInfo(Model model) {
List<StudentReq> studentReq= studentService.bindStudentInfo("DG1");
model.addAttribute("students", studentReq);
return "student/Student";
}
@GetMapping("/studentPerformance")
public String studentPerformance(Model model) {
int userId = SessionManager.getInstance().getUserId();
List<TopicStatusReq> topicStatusReq= topicService.topicsStatus("SPS",userId);
model.addAttribute("topicStatusReq", topicStatusReq);
return "student/studentPerformance";
}
@GetMapping("/topicsStatus")
public String topicsStatus(Model model) {
int userId = SessionManager.getInstance().getUserId();
List<TopicStatusReq> topicStatusReq= topicService.topicsStatus("STS",userId);
model.addAttribute("topicStatusReq", topicStatusReq);
return "student/topicsStatus";
}
@GetMapping("/updateStudentProfile")
public String updateStudentProfile(Model model) {
int userId = SessionManager.getInstance().getUserId();
UpdateStudentProfileReq updateStudentProfileReq =
studentService.getStudentByUserId(userId);
List<GradeMasterReq> gradeMasterReqs= studentService.bindDdlGrade("DD1");
List<GenderMasterReq> genderMasterReqs= studentService.bindDdlGender("DD2");
model.addAttribute("updateStudentProfileReq", updateStudentProfileReq);
model.addAttribute("updateStudentProfileReqBind", new UpdateStudentProfileReq());
model.addAttribute("grades", gradeMasterReqs);
model.addAttribute("genders", genderMasterReqs);
return "student/updateStudentProfile";
}
@PostMapping("/updateStudentProfile")
public String updateStudentProfile(@Valid @ModelAttribute UpdateStudentProfileReq
updateStudentProfileReq, RedirectAttributes redirectAttributes) {
String resultMsg = studentService.updateStudentProfile(updateStudentProfileReq);
if (resultMsg.equals("SUCCESS")) {
redirectAttributes.addFlashAttribute("message", "Student Profile Updated successfully!");
} else {
redirectAttributes.addFlashAttribute("errorMsg", resultMsg);
}
6
return "redirect:/student/updateStudentProfile";
}
@GetMapping("/new")
public String createStudentForm(Model model) {
model.addAttribute("student", new StudentReq());
List<GradeMasterReq> gradeMasters=studentService.bindDdlGrade("DD1");
model.addAttribute("grades", gradeMasters);
return "create_student";
}
@GetMapping("/edit/{id}")
public String editStudentForm(@PathVariable("id") int id, Model model) {
StudentReq students = studentService.getStudentId("GET",id);
List<GradeMasterReq> gradeMasters=studentService.bindDdlGrade("DD1");
model.addAttribute("grades", gradeMasters);
model.addAttribute("student", students);
return "user/studentInfo";
}
@PostMapping("/update")
public String updateStudent(@ModelAttribute StudentReq student, RedirectAttributes
redirectAttributes) {
redirectAttributes.addFlashAttribute("message", "Student updated successfully!");
return "redirect:/students";
}
@GetMapping("/delete/{id}")
public String deleteStudent(@PathVariable("id") Integer id, RedirectAttributes
redirectAttributes,Model model) {
String resultMessage= studentService.deleteStudendInfo("DAC",id);
redirectAttributes.addFlashAttribute("delMsg", resultMessage);
return "redirect:/user/studentInfo";
}
@GetMapping("/grade")
public String getGrades(Model model) {
model.addAttribute("grades", studentService.bindDdlGrade("DD1"));
return "students";
}
Class: QuestionController
package io.flappybird.controller.teacher;
import io.flappybird.model.PlayGameReq;
import io.flappybird.model.QuestionsReq;
import io.flappybird.service.PlayGameService;
import io.flappybird.service.QuestionService;
import io.flappybird.service.SessionManager;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
7
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/question")
public class QuestionController {
@Autowired
private QuestionService questionService;
@Autowired
private PlayGameService playGameService;
@GetMapping
public String bindQuestionInfo(Model model) {
return "Question";
}
@PostMapping("/next")
public QuestionsReq getNextQuestion(HttpSession session) {
List<QuestionsReq> questions = SessionManager.getInstance().getQuestions();
Integer currentQuestionIndex = SessionManager.getInstance().getCurrentQuestionIndex();
if (questions != null && currentQuestionIndex < questions.size()) {
QuestionsReq nextQuestion = questions.get(currentQuestionIndex);
// Increment index for the next call
SessionManager.getInstance().setCurrentQuestionIndex(currentQuestionIndex + 1);
return nextQuestion;
}
return null; // No more questions
}
@PostMapping("/submitAnswer")
public void submitAnswer(@RequestParam String selectedAnswer, HttpSession session) {
List<QuestionsReq> questions = (List<QuestionsReq>) session.getAttribute("questions");
Integer currentQuestionIndex = (Integer) session.getAttribute("currentQuestionIndex");
Integer score = (Integer) session.getAttribute("score");
if (currentQuestionIndex > 0) {
QuestionsReq currentQuestion = questions.get(currentQuestionIndex - 1);
if (String.valueOf(currentQuestion.getAnswer()).equals(selectedAnswer)) {
score++;
}
session.setAttribute("score", score);
}
}
@PostMapping("/startGame")
public String startGame( @RequestBody PlayGameReq playGameReq) {
System.out.println("playGameReq");
String resultMsg=playGameService.startGame(playGameReq);
8
//
}
else{
}
return "Yes";
}
}
Class: QuizController
package io.flappybird.controller.teacher;
import io.flappybird.model.QuizReq;
import io.flappybird.service.QuizService;
import io.flappybird.service.TopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Controller
@RequestMapping("/quizs")
public class QuizController {
@Autowired
private QuizService quizService;
@Autowired
private TopicService topicService;
@GetMapping
public String bindQuizInfo(Model model) {
List<QuizReq> quizReq= quizService.bindQuizInfo("DG1");
model.addAttribute("quizzes", quizReq);
return "teacher/Quiz";
}
}
Class: TeacherController
package io.flappybird.controller.teacher;
import io.flappybird.model.*;
import io.flappybird.service.*;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.util.List;
9
@Controller
@RequestMapping("/teacher")
public class TeacherController {
@Autowired
private TeacherService teacherService;
@Autowired
private TopicService topicService;
@Autowired
private StudentService studentService;
@Autowired
private QuestionService questionService;
@GetMapping("/teacherMenu")
public String teacherMenu(Model model) {
String userName= SessionManager.getInstance().getUsername();
model.addAttribute("userName", userName);
return "teacher/teacherMenu";
}
@GetMapping("/quiz")
public String quiz(Model model) {
model.addAttribute("user", new UserReq());
return "teacher/quiz";
}
@PostMapping("/quiz")
public String quiz(@ModelAttribute StudentReq student, RedirectAttributes redirectAttributes) {
redirectAttributes.addFlashAttribute("message", "Student added successfully!");
return "teacher/quiz";
}
@GetMapping("/question")
public String question(Model model) {
@GetMapping("/questions/{quizId}")
@ResponseBody
public List<QuestionReq> getTopicsForStudentList(@PathVariable("quizId") int quizId) {
return
questionService.bindQuestionInfo("DG1",SessionManager.getInstance().getUserId(),quizId);
}
@GetMapping("/topics/{studentId}")
@ResponseBody
public List<TopicStatusReq> topicsStatus(@PathVariable("studentId") int studentId) {
return topicService.topicsStatus("SPS",studentId);
10
}
@GetMapping("/studentWisePerformance")
public String studentWisePerformance(Model model) {
int userId = SessionManager.getInstance().getUserId();
List<StudentDDLReq> StudentDDLReq= studentService.bindStudentList("DD3");
model.addAttribute("students", StudentDDLReq);
return "teacher/studentWisePerformance";
}
@PostMapping("/studentWisePerformance")
public String studentWisePerformance(@PathVariable("id") int id, Model model) {
List<TopicStatusReq> topicStatusReq= topicService.topicsStatus("SPS",id);
return "teacher/studentWisePerformance";
}
@GetMapping("/updateTeacherProfile")
public String updateTeacherProfile(Model model) {
int userId = SessionManager.getInstance().getUserId();
UpdateTeacherProfileReq updateTeacherProfileReq=
teacherService.getTeacherByUserId(userId);
List<GenderMasterReq> genderMasterReqs= studentService.bindDdlGender("DD2");
model.addAttribute("updateTeacherProfileReq", updateTeacherProfileReq);
model.addAttribute("genders", genderMasterReqs);
return "teacher/updateTeacherProfile";
}
@PostMapping("/updateTeacherProfile")
public String updateTeacherProfile(@Valid @ModelAttribute UpdateTeacherProfileReq
updateTeacherProfileReq, RedirectAttributes redirectAttributes) {
System.out.println("st===Before
updateStudentProfile==============>"+updateTeacherProfileReq);
String resultMsg = teacherService.updateTeacherProfile(updateTeacherProfileReq);
if (resultMsg.equals("SUCCESS")) {
redirectAttributes.addFlashAttribute("message", "Teacher Profile Updated successfully!");
} else {
redirectAttributes.addFlashAttribute("errorMsg", resultMsg);
} return "teacher/updateTeacherProfile";
}
@GetMapping
public String bindTeacherInfo(Model model) {
return "teacher/Teacher";
}
Class: TopicController
package io.flappybird.controller.teacher;
import io.flappybird.service.TopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
11
@RequestMapping("/topic")
public class TopicController {
@Autowired
private TopicService topicService;
@PostMapping("/add")
public String addTopic(@RequestParam String topicName, @RequestParam Integer userId) {
return topicService.addTopic(topicName, userId);
}
@PutMapping("/update")
public String updateTopic(@RequestParam Integer topicId, @RequestParam String topicName,
@RequestParam Integer isActive) {
return topicService.updateTopic(topicId, topicName, isActive);
}
@DeleteMapping("/deactivate/{id}")
public String deactivateTopic(@PathVariable("id") Integer topicId) {
return topicService.deactivateTopic(topicId);
}
}
Class: HomeController
package io.flappybird.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class HomeController {
@GetMapping("/")
public String home() {
return "redirect:user/login"; // Name of the Thymeleaf template (without .html)
}
}
Class: App
package io.flappybird.game;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.*;
import io.flappybird.model.PlayGameReq;
import io.flappybird.service.SessionManager;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
@Component
public class App {
12
private int currentScore = 0;
public static int WIDTH = 500;
public static int HEIGHT = 520;
public static JFrame frame;
13
frame.addKeyListener(keyboard);
Class: Bird
package io.flappybird.game;
import java.awt.Image;
import java.awt.event.KeyEvent;
import java.awt.geom.AffineTransform;
public int x;
public int y;
public int width;
public int height;
public Bird() {
x = 100;
y = 150;
14
yvel = 0;
width = 45;
height = 32;
gravity = 0.5;
jumpDelay = 0;
rotation = 0.0;
dead = false;
keyboard = Keyboard.getInstance();
}
if (jumpDelay > 0)
jumpDelay--;
y += (int)yvel;
}
if (image == null) {
image = Util.loadImage("src/main/resources/static/bird.png");
}
r.image = image;
return r;
}
}
Class: Game
15
package io.flappybird.game;
import io.flappybird.model.PlayGameReq;
import io.flappybird.model.QuestionAsk;
import io.flappybird.model.QuestionsReq;
import io.flappybird.service.SessionManager;
import org.springframework.web.client.RestTemplate;
import javax.swing.*;
import java.awt.event.KeyEvent;
import java.io.*;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
public Game() {
keyboard = Keyboard.getInstance();
restart();
16
}
public static synchronized Game getInstance() {
if (instance == null) {
instance = new Game();
}
return instance;
}
if (!started)
return;
watchForPause();
watchForReset();
if (paused)
return;
bird.update();
if (gameover)
return;
movePipes();
checkForCollisions();
}
17
}
if (pipeDelay < 0) {
pipeDelay = PIPE_DELAY;
Pipe northPipe = null;
Pipe southPipe = null;
18
// Look for pipes off the screen
for (Pipe pipe : pipes) {
if (pipe.x - pipe.width < 0) {
if (northPipe == null) {
northPipe = pipe;
} else if (southPipe == null) {
southPipe = pipe;
break;
}
}
}
if (northPipe == null) {
Pipe pipe = new Pipe("north");
pipes.add(pipe);
northPipe = pipe;
} else {
northPipe.reset();
}
if (southPipe == null) {
Pipe pipe = new Pipe("south");
pipes.add(pipe);
southPipe = pipe;
} else {
southPipe.reset();
}
19
file.writeBoolean(false);
file.close();
}
public int findHighScore() throws Exception {
RandomAccessFile file = new RandomAccessFile("highscores.dat", "r");
int highestScore = Integer.MIN_VALUE; // Start with the lowest possible value
while (file.getFilePointer() < file.length()) {
int score = file.readInt();
if (score > highestScore) {
highestScore = score;
}
}
List<Integer> highScores = new ArrayList<>();
RandomAccessFile file1 = new RandomAccessFile("highscores.dat", "r");
try {
while (file1.getFilePointer() < file1.length()) {
int score = file1.readInt();
highScores.add(score);
}
} finally {
file1.close();
}
20
gameover = true;
bird.dead = true;
addHighScore(score);
SessionManager.getInstance().setRecentScore(score);
RestTemplate restTemplate = new RestTemplate();
//
String url = "http://localhost:8080/game/endGame";
PlayGameReq playGameReq=new
PlayGameReq(SessionManager.getInstance().getQuizIdS(),
SessionManager.getInstance().getCorrectAnswer(),"Current
Quiz",SessionManager.getInstance().getUserId(),"127.0.01");
System.out.println("playGameReq========"+playGameReq);
String questions = restTemplate.postForObject(url, playGameReq, String.class);
SessionManager.getInstance().setCurrentQuestionIndex(0);//Start From first Question
SessionManager.getInstance().setCorrectAnswer(0);//SET Correct Answer COUNT =0
} else if (pipe.x == bird.x && pipe.orientation.equalsIgnoreCase("south")) {
if(qCount>9)
{
addHighScore(score);
SessionManager.getInstance().setRecentScore(score);
//Write code to stop from app file if totalQuestion=10 then stopString url =
"http://localhost:8080/game/endGame";
PlayGameReq playGameReq=new
PlayGameReq(SessionManager.getInstance().getQuizIdS(),
SessionManager.getInstance().getCorrectAnswer(),"Current
Quiz",SessionManager.getInstance().getUserId(),"127.0.01");
System.out.println("playGameReq========"+playGameReq);
RestTemplate restTemplate = new RestTemplate();
String url = "http://localhost:8080/game/endGame";
String questions = restTemplate.postForObject(url, playGameReq, String.class);
SessionManager.getInstance().setCurrentQuestionIndex(0);//Start From first Question
SessionManager.getInstance().setCorrectAnswer(0);//SET Correct Answer COUNT =0
SessionManager.getInstance().setGameOpen(false);
JOptionPane.showMessageDialog(null,
"Quiz Completed!",
"Game Over",
JOptionPane.OK_OPTION);
App.frameDispose();
int hs=findHighScore();
SessionManager.getInstance().setHighestScore(hs);
}
score++;
if (score%2==0){
showNextQuestion();
qCount=qCount+1;
}
}
}
21
// Ground + Bird collision
if (bird.y + bird.height > App.HEIGHT - 80) {
gameover = true;
addHighScore(score);
SessionManager.getInstance().setRecentScore(score);
bird.y = App.HEIGHT - 80 - bird.height;
RestTemplate restTemplate = new RestTemplate();
String url = "http://localhost:8080/game/endGame";
PlayGameReq playGameReq=new
PlayGameReq(SessionManager.getInstance().getQuizIdS(),
SessionManager.getInstance().getCorrectAnswer(),"Current
Quiz",SessionManager.getInstance().getUserId(),"127.0.01");
System.out.println("playGameReq========"+playGameReq);
String questions = restTemplate.postForObject(url, playGameReq, String.class);
SessionManager.getInstance().setCurrentQuestionIndex(0);//Start From first Question
SessionManager.getInstance().setCorrectAnswer(0);//SET Correct Answer COUNT =0
}
}
private void showNextQuestion() {
RestTemplate restTemplate = new RestTemplate();
String url = "http://localhost:8080/question/next";
QuestionsReq questions = restTemplate.postForObject(url, score, QuestionsReq.class);
System.out.println(questions.toString());
showQuestion(questions);
}
private boolean hasGameExceededDuration() {
if (startTime == null) {
return false;
}
Duration elapsedTime = Duration.between(startTime, LocalDateTime.now());
return elapsedTime.toMinutes() >= GAME_DURATION_MINUTES;
}
private void showQuestion(QuestionsReq questions) {
paused = true;
// Example question and options
System.out.println(questions.toString());
String question = questions.getQuestionDescription();
String option1 = questions.getOptionA();
String option2 = questions.getOptionB();
String option3 = questions.getOptionC();
String option4 = questions.getOptionD();
String option5 = questions.getOptionE();
String ans = String.valueOf(questions.getAnswer());
22
questionFrame.addSubmitListener(new QuestionFrame.SubmitListener() {
@Override
public void onSubmit(String selectedOption) {
System.out.println("selectedOption"+selectedOption);
paused = false;
}
});
}
private boolean hasQuestionTimeExpired() {
if (questionStartTime == null) {
return false;
}
Duration elapsedTime = Duration.between(questionStartTime, LocalDateTime.now());
return elapsedTime.getSeconds() >= QUESTION_TIME_LIMIT_SECONDS;
}
Class: GamePanel
package io.flappybird.game;
import javax.swing.*;
import java.awt.*;
public GamePanel() {
this.game = Game.getInstance();
new Thread(this).start();
}
g2D.setColor(Color.BLACK);
23
if (!game.started) {
g2D.setFont(new Font("TimesRoman", Font.PLAIN, 20));
g2D.drawString("Press SPACE to start", 150, 240);
} else {
g2D.setFont(new Font("TimesRoman", Font.PLAIN, 24));
g2D.drawString(Integer.toString(game.score), 10, 465);
}
if (game.gameover) {
g2D.setFont(new Font("TimesRoman", Font.PLAIN, 20));
g2D.drawString("Press R to restart", 150, 240);
}
}
Class: Keyboard
package io.flappybird.game;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
private Keyboard() {
keys = new boolean[256];
}
if (instance == null) {
instance = new Keyboard();
}
return instance;
24
}
return false;
}
}
Class: Pipe
package io.flappybird.game;
import java.awt.Image;
public class Pipe {
public int x;
public int y;
public int width;
public int height;
public int speed = 3;
if (orientation.equals("south")) {
25
y = -(int)(Math.random() * 120) - height / 2;
}
}
public boolean collides(int _x, int _y, int _width, int _height) {
int margin = 2;
return false;
}
if (image == null) {
image = Util.loadImage("src/main/resources/static/pipe-" + orientation + ".png");
}
r.image = image;
return r;
}
}
Class: QuestionFrame
package io.flappybird.game;
import io.flappybird.service.SessionManager;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
26
private JRadioButton option1Button;
private JRadioButton option2Button;
private JRadioButton option3Button;
private JRadioButton option4Button;
private JRadioButton option5Button;
private ButtonGroup optionGroup;
private JButton submitButton;
public QuestionFrame(String question, String option1, String option2, String option3, String option4,
String option5,String correctAnswer) {
setTitle("Answer the Question");
setSize(400, 300);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setLocationRelativeTo(null);
this.correctAnswer = correctAnswer;
System.out.println("correctAnswer "+correctAnswer);
initComponents(question, option1, option2, option3, option4,option5);
layoutComponents();
setVisible(true);
}
private void initComponents(String question, String option1, String option2, String option3, String
option4,String option5) {
questionLabel = new JLabel(question);
option1Button = new JRadioButton(option1);
option2Button = new JRadioButton(option2);
option3Button = new JRadioButton(option3);
option4Button = new JRadioButton(option4);
option5Button = new JRadioButton(option5);
27
if (option1Button.isSelected()) {
selectedOption = option1Button.getText();
} else if (option2Button.isSelected()) {
selectedOption = option2Button.getText();
} else if (option3Button.isSelected()) {
selectedOption = option3Button.getText();
} else if (option4Button.isSelected()) {
selectedOption = option4Button.getText();
}else if (option5Button.isSelected()) {
selectedOption = option5Button.getText();
}
if (selectedOption == null) {
JOptionPane.showMessageDialog(null, "Please Select Answer");
//submitListener.onSubmit(null); // Notify incorrect answer
return;
}
if (selectedOption.equalsIgnoreCase(correctAnswer)) {
submitListener.onSubmit(selectedOption); // Notify correct answer
int cAnsCount=SessionManager.getInstance().getCorrectAnswer();
cAnsCount=cAnsCount+1;
SessionManager.getInstance().setCorrectAnswer(cAnsCount);//SET Correct Answer
COUNT =0
} else {
JOptionPane.showMessageDialog(null, "Wrong Answer");
submitListener.onSubmit(null); // Notify incorrect answer
}
Class: Render
28
package io.flappybird.game;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.geom.AffineTransform;
public Render() {
}
Class: AchievementsReq
package io.flappybird.model;
import lombok.Data;
import lombok.ToString;
@ToString
@Data
public class AchievementsReq {
private int totalTrophies;
private int totalCertificates;
29
}
Class: GenderMasterReq
package io.flappybird.model;
import jakarta.persistence.*;
import lombok.Data;
import lombok.ToString;
@ToString
@Data
@Entity
@Table(name = "GenderMaster")
public class GenderMasterReq {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "genderid")
private int genderId;
@Column(name = "gender")
private String gender;
@Column(name = "isactive")
private boolean isActive;
Class: GradeMasterReq
package io.flappybird.model;
import jakarta.persistence.*;
import lombok.Data;
import lombok.ToString;
@ToString
@Data
@Entity
@Table(name = "GradeMaster")
public class GradeMasterReq {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "gradeid")
private int gradeId;
30
@Column(name = "grade")
private String grade;
@Column(name = "isactive")
private boolean isActive;
Class: LoginHistoryReq
package io.flappybird.model;
import lombok.Data;
import lombok.ToString;
import java.util.Date;
@ToString
@Data
public class LoginHistoryReq {
private String firstName;
private String loginId;
private String password;
private String userTypeName;
private Date loginDate;
private Date logoutDate;
private double totalDuration;
Class: PlayGameReq
package io.flappybird.model;
import lombok.Data;
import lombok.ToString;
@ToString
@Data
public class PlayGameReq {
31
private int quizId;
private int correctAns;
private String quizName;
private int userId;
private String ipAddress;
public PlayGameReq(int quizId, int correctAns, String quizName, int userId, String ipAddress) {
this.quizId = quizId;
this.correctAns = correctAns;
this.quizName = quizName;
this.userId = userId;
this.ipAddress = ipAddress;
32
}
public PlayGameReq() {
}
}
Class: QuestionAsk
package io.flappybird.model;
import lombok.Data;
import lombok.ToString;
@ToString
@Data
public class QuestionAsk {
33
this.op3 = op3;
}
public QuestionAsk() {
}
@Override
public String toString() {
return "QuestionAsk [qName=" + qName + ", op1=" + op1 + ", op2=" + op2 + ", op3=" + op3 + ",
op4=" + op4 +", op5=" + op5 + ", ans=" + ans + "]";
}
Class: QuestionDTOReq
package io.flappybird.model;
import lombok.Data;
@Data
public class QuestionDTOReq {
Class: QuestionsReq
34
package io.flappybird.model;
import lombok.Data;
import lombok.ToString;
import java.util.Date;
@Data
@ToString
public class QuestionsReq {
private int questionId;
private int quizId;
private String questionDescription;
private String questionHint;
private String optionA;
private String optionB;
private String optionC;
private String optionD;
private String optionE;
private String answer;
private int qSno;
private Date transDate;
private Boolean isActive;
private int userId;
public Boolean getActive() {
return isActive;
}
public void setActive(Boolean active) {
isActive = active;
}
35
this.questionDescription = questionDescription;
}
36
return answer;
}
public QuestionsReq(int questionId, int quizId, String questionDescription, String questionHint, String
optionA, String optionB, String optionC, String optionD, String optionE, String answer, int qSno, Date
transDate, Boolean isActive, int userId) {
this.questionId = questionId;
this.quizId = quizId;
this.questionDescription = questionDescription;
this.questionHint = questionHint;
this.optionA = optionA;
this.optionB = optionB;
this.optionC = optionC;
this.optionD = optionD;
this.optionE = optionE;
this.answer = answer;
this.qSno = qSno;
this.transDate = transDate;
this.isActive = isActive;
this.userId = userId;
}
public QuestionsReq() {
}
}
37
Class: QuizDDLReq
package io.flappybird.model;
import lombok.Data;
import lombok.ToString;
@ToString
@Data
Class: QuizReq
package io.flappybird.model;
import lombok.Data;
import lombok.ToString;
import java.util.Date;
@ToString
@Data
public class QuizReq {
private int quizId;
private String quizName;
private String teacherName;
private String topicName;
private String levelName;
private int totalQuestions;
private int maxMarks;
private int minMarks;
private int duration;
private boolean isActive;
private String ipAddress;
private Date transDate;
private int userId;
public QuizReq(int quizId, String quizName, String teacherName, String topicName, String
levelName, int totalQuestions, int maxMarks, int minMarks, int duration, boolean isActive, String
ipAddress, Date transDate, int userId) {
this.quizId = quizId;
this.quizName = quizName;
this.teacherName = teacherName;
38
this.topicName = topicName;
this.levelName = levelName;
this.totalQuestions = totalQuestions;
this.maxMarks = maxMarks;
this.minMarks = minMarks;
this.duration = duration;
this.isActive = isActive;
this.ipAddress = ipAddress;
this.transDate = transDate;
this.userId = userId;
}
}
Class: ScoreReq
package io.flappybird.model;
import lombok.Data;
import lombok.ToString;
@ToString
@Data
public class ScoreReq {
private int highestScore;
private int recentScore;
package io.flappybird.model;
import jakarta.persistence.Column;
39
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.ToString;
@ToString
@Data
Class: StudentDTO
package io.flappybird.model;
import lombok.Data;
import lombok.ToString;
import java.time.LocalDateTime;
@Data
@ToString
public class StudentDTO {
private Integer studentId;
private String surname;
private String firstName;
private Integer gradeId;
private String grade;
private String emailId;
private Integer age;
private Integer genderId;
private String gender;
private String mobileNo;
private Integer totalTrophies;
private Integer totalCertificates;
private String ipAddress;
private LocalDateTime transDate;
private Boolean isActive;
private Integer userId;
public StudentDTO(Integer studentId, String surname, String firstName, Integer gradeId, String
grade, String emailId, Integer age,
Integer genderId,String gender, String mobileNo, Integer totalTrophies, Integer
totalCertificates,
String ipAddress, LocalDateTime transDate, Boolean isActive, Integer userId) {
this.studentId = studentId;
40
this.surname = surname;
this.firstName = firstName;
this.gradeId = gradeId;
this.grade = grade;
this.emailId = emailId;
this.age = age;
this.genderId = genderId;
this.gender = gender;
this.mobileNo = mobileNo;
this.totalTrophies = totalTrophies;
this.totalCertificates = totalCertificates;
this.ipAddress = ipAddress;
this.transDate = transDate;
this.isActive = isActive;
this.userId = userId;
}
Class: StudentReq
package io.flappybird.model;
import jakarta.persistence.*;
import lombok.Data;
import lombok.ToString;
import java.time.LocalDate;
@ToString
@Data
@Entity
public class StudentReq {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "studentid")
private int studentId;
@Column(name = "surname")
private String surName;
@Column(name = "firstname")
private String firstName;
@Column(name = "age")
private int age;
@Column(name = "genderid")
private int genderId;
@Column(name = "gender")
private String gender;
@Column(name = "gradeid")
private int gradeId;
41
@Column(name = "grade")
private String grade;
@Column(name = "emailid")
private String emailId;
@Column(name = "mobileno")
private String mobileNo;
@Column(name = "totaltrophies")
private int totalTrophies;
@Column(name = "totalcertificates")
private int totalCertificates;
// private boolean status;
@Column(name = "ipaddress")
private String ipAddress;
@Column(name = "transdate")
private LocalDate transDate;
@Column(name = "isactive")
private Boolean isActive;
@Column(name = "userid",nullable = true)
private Integer userId;
Class: TeacherReq
package io.flappybird.model;
import jakarta.persistence.*;
import lombok.Data;
import lombok.ToString;
import java.time.LocalDate;
@ToString
@Data
@Entity
public class TeacherReq {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "teacherid")
private int teacherId;
@Column(name = "surname")
private String surName;
@Column(name = "firstname")
private String firstName;
@Column(name = "age")
42
private int age;
@Column(name = "genderid")
private int genderId;
@Column(name = "gender")
private String gender;
@Column(name = "emailid")
private String emailId;
@Column(name = "mobileno")
private String mobileNo;
@Column(name = "ipaddress")
private String ipAddress;
@Column(name = "transdate")
private LocalDate transDate;
@Column(name = "isactive")
private Boolean isActive;
@Column(name = "userid",nullable = true)
private Integer userId;
Class: TopicDDLReq
package io.flappybird.model;
import jakarta.persistence.*;
import lombok.Data;
import lombok.ToString;
import java.time.LocalDate;
@ToString
@Data
@Entity
public class TeacherReq {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "teacherid")
private int teacherId;
@Column(name = "surname")
private String surName;
@Column(name = "firstname")
private String firstName;
@Column(name = "age")
private int age;
@Column(name = "genderid")
43
private int genderId;
@Column(name = "gender")
private String gender;
@Column(name = "emailid")
private String emailId;
@Column(name = "mobileno")
private String mobileNo;
@Column(name = "ipaddress")
private String ipAddress;
@Column(name = "transdate")
private LocalDate transDate;
@Column(name = "isactive")
private Boolean isActive;
@Column(name = "userid",nullable = true)
private Integer userId;
Class: TopicReq
package io.flappybird.model;
import lombok.Data;
@Data
public class TopicReq {
private int topicId;
private String topicName;
private int isActive;
private int userId;
44
public int getIsActive() {
return isActive;
}
Class: TopicStatusReq
package io.flappybird.model;
import lombok.Data;
@Data
public class TopicReq {
private int topicId;
private String topicName;
private int isActive;
private int userId;
public int getTopicId() {
return topicId;
}
public void setTopicId(int topicId) {
this.topicId = topicId;
}
public String getTopicName() {
return topicName;
45
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
public int getIsActive() {
return isActive;
}
public void setIsActive(int isActive) {
this.isActive = isActive;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
}
Class: TopicStatusReq
package io.flappybird.model;
import lombok.Data;
import lombok.ToString;
import java.util.Date;
@ToString
@Data
public class TopicStatusReq {
private String topicName;
private String quizName;
private String teacherName;
private int totalQuestions;
private int maxMarks;
private int minMarks;
private int duration;
private Date playDate;
private Date startTime;
private Date endTime;
private String accuracy;
private String result;
46
this.maxMarks = maxMarks;
this.minMarks = minMarks;
this.duration = duration;
this.playDate = playDate;
this.startTime = startTime;
this.endTime = endTime;
this.accuracy = accuracy;
this.result = result;
}
}
Class: UpdateStudentProfileReq
package io.flappybird.model;
import lombok.Data;
import lombok.ToString;
import java.util.Date;
@ToString
@Data
public class UpdateStudentProfileReq {
private String surname;
private String firstName;
private int genderId;
private String gender;
private String emailId;
private String mobile;
private int age;
private int gradeId;
private String grade;
private int userId;
public UpdateStudentProfileReq() {
47
public String getSurname() {
return surname;
}
48
public void setAge(int age) {
this.age = age;
}
Class: UpdateTeacherProfileReq
package io.flappybird.model;
import lombok.Data;
import lombok.ToString;
import java.util.Date;
@ToString
@Data
public class UpdateTeacherProfileReq {
private String surname;
private String firstName;
private int genderId;
private String gender;
private String emailId;
private String mobile;
public UpdateTeacherProfileReq() {
49
}
50
this.emailId = emailId;
}
Class: UserDetailsDTOReq
package io.flappybird.model;
51
}
Class: UserReq
package io.flappybird.model;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.ToString;
@Data
@ToString
public class UserReq {
52
@Pattern(regexp = "^(?=.*[0-9])(?=.*[!@#$%^&*]).{8,}$", message = "Password must contain at
least one numeric and one special character")
private String password;
53
}
54
}
Class: UserSignUpReq
package io.flappybird.model;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.ToString;
@Data
@ToString
public class UserSignUpReq {
@NotEmpty(message = "User Type is required")
private int userTypeId;
55
public String getSurname() {
return surname;
}
56
public void setConfirmPassword(String confirmPassword) {
this.confirmPassword = confirmPassword;
}
Class: MD5HashUtil
package io.flappybird.service;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
Class: PlayGameService
package io.flappybird.service;
import io.flappybird.model.PlayGameReq;
import io.flappybird.model.ScoreReq;
import io.flappybird.repo.PlayGameRepo;
import jakarta.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
57
@Service
@Transactional
public String startGame(PlayGameReq playGameReq) {
String result =
playGameRepo.startGame("INS",playGameReq.getQuizId(),playGameReq.getCorrectAns(),
SessionManager.getInstance().getUserId(), SessionManager.getInstance().getIp());
return result;
}
@Transactional
public String endGame(PlayGameReq playGameReq) {
String result =
playGameRepo.endGame("UPD",playGameReq.getQuizId(),playGameReq.getCorrectAns(),
SessionManager.getInstance().getUserId(), SessionManager.getInstance().getIp());
return result;
}
@Transactional
public ScoreReq bindScore() {
ScoreReq scoreReq = null;
int highestScore =SessionManager.getInstance().getHighestScore();
int recentScore =SessionManager.getInstance().getRecentScore();
scoreReq = new ScoreReq(highestScore,recentScore);
return scoreReq;
}
Class: QuestionFrame
package io.flappybird.service;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
58
private String selectedOption;
public QuestionFrame(String question, String option1, String option2, String option3, String option4,
String correctAnswer) {
setTitle("Answer the Question");
setSize(400, 300);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setLocationRelativeTo(null);
this.correctAnswer = correctAnswer;
setVisible(true);
}
private void initComponents(String question, String option1, String option2, String option3, String
option4) {
questionLabel = new JLabel(question);
option1Button = new JRadioButton(option1);
option2Button = new JRadioButton(option2);
option3Button = new JRadioButton(option3);
option4Button = new JRadioButton(option4);
59
if (selectedOption.equalsIgnoreCase(correctAnswer)) {
submitListener.onSubmit(selectedOption); // Notify correct answer
} else {
JOptionPane.showMessageDialog(null, "Answer is incorrect. Game over!");
submitListener.onSubmit(null); // Notify incorrect answer
}
Class: QuestionService
package io.flappybird.service;
import io.flappybird.model.*;
import io.flappybird.repo.QuestionRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@Service
public class QuestionService {
@Autowired(required = true)
public QuestionService(QuestionRepo questionRepo) {
this.questionRepo = questionRepo;
}
@Transactional
60
public List<QuestionReq> bindQuestionInfo(String mode,int userId,int quizId)
{
List<?> result =
questionRepo.bindQuestionInfo(mode,quizId,0,null,null,null,null,null,null,null,null,true,SessionManager
.getInstance().getIp(),userId);
List<QuestionReq> questionList = new ArrayList<>();
61
SessionManager.getInstance().setTotQ((int) row[0]);
SessionManager.getInstance().setDurationPerQ((int) row[1]);
SessionManager.getInstance().setTotDuration((int) row[2]);
}
else {
throw new IllegalArgumentException("Error Found: " + Arrays.toString(row));
}
} else {
throw new ClassCastException("Error Found: " + obj.getClass());
}
}
List<?> result =
questionRepo.bindQuestionsInfo(mode,quizId,0,null,null,null,null,null,null,null,null,true,SessionManag
er.getInstance().getIp(),userId);
List<QuestionsReq> questionList = new ArrayList<>();
62
@Transactional
public List<QuizDDLReq> bindQuizList(String Mode){
List<?> result=questionRepo.bindQuizList(Mode);
List<QuizDDLReq> quizList = new ArrayList<>();
for (Object obj : result) {
if (obj instanceof Object[]) {
Object[] row = (Object[]) obj;
if (row.length >= 1) {
int quizId = (int) row[0];
String quizName = (String) row[1];
Class: QuizService
package io.flappybird.service;
import io.flappybird.model.QuizDDLReq;
import io.flappybird.model.QuizReq;
import io.flappybird.model.TopicDDLReq;
import io.flappybird.repo.QuizRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@Service
public class QuizService {
@Autowired
private QuizRepo quizRepo;
@Transactional
public List<TopicDDLReq> bindTopicList(String Mode){
List<?> result=quizRepo.bindTopicList(Mode);
List<TopicDDLReq> topicList = new ArrayList<>();
for (Object obj : result) {
if (obj instanceof Object[]) {
Object[] row = (Object[]) obj;
63
if (row.length >= 1) {
int topicId = (int) row[0];
String topicName = (String) row[1];
TopicDDLReq topicDDLReq = new TopicDDLReq(topicId, topicName);
topicList.add(topicDDLReq);
}
else {
throw new IllegalArgumentException("Error Found: " + Arrays.toString(row));
}
} else {
throw new ClassCastException("Error Found: " + obj.getClass());
}
}
System.out.println(topicList.toString());
return topicList;
}
@Transactional
public List<QuizDDLReq> getQuizListByTopics(String mode,int topicId) {
List<?>
result=quizRepo.getQuizListByTopics(mode,0,null,0,topicId,0,0,true,SessionManager.getInstance().ge
tIp(),1);
List<QuizDDLReq> quizList = new ArrayList<>();
for (Object obj : result) {
if (obj instanceof Object[]) {
Object[] row = (Object[]) obj;
if (row.length >= 1) {
int quizId = (int) row[0];
String quizName = (String) row[1];
@Transactional
public List<QuizReq> bindQuizInfo(String Mode){
64
if (obj instanceof Object[]) {
Object[] row = (Object[]) obj;
if (row.length >= 12) {
int quizId = (int) row[0];
String quizName = (String) row[1];
String teacherName = (String) row[2];
String topicName = (String) row[3];
String levelName = (String) row[4];
int totalQuestions = (int) row[5];
int maxMarks = (int) row[6];
int minMarks = (int) row[7];
int duration = (int) row[8];
boolean isActive = (boolean) row[9];
String ipAddress = (String) row[10];
Date transDate = (Date) row[11];
int userId = (int) row[12];
}
}
Class: SessionManager
package io.flappybird.service;
import io.flappybird.model.QuestionsReq;
import java.util.List;
65
private int quizIdS=0;
private int totQ=0;
private int durationPerQ=0;
private int totDuration=0;
private SessionManager() {
66
public void setUsername(String username) {
this.username = username;
}
67
public void setTotDuration(int totDuration) {
this.totDuration = totDuration;
}
68
this.ip=null;
}
}
Class: StudentService
package io.flappybird.service;
import io.flappybird.model.*;
import io.flappybird.repo.GenderMasterRepo;
import io.flappybird.repo.GradeMasterRepo;
import io.flappybird.repo.StudentRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
@Service
public class StudentService {
@Autowired
private StudentRepo studentRepo;
@Autowired
private GradeMasterRepo gradeMasterRepo;
@Autowired
private GenderMasterRepo genderMasterRepo;
@Transactional
public List<StudentDDLReq> bindStudentList(String Mode){
List<?> result=studentRepo.bindStudentList(Mode);
List<StudentDDLReq> studentDDLReqList = new ArrayList<>();
for (Object obj : result) {
if (obj instanceof Object[]) {
Object[] row = (Object[]) obj;
if (row.length >= 1) {
int studentId = (int) row[0];
String studenName = (String) row[1];
StudentDDLReq studentDDLReqs = new StudentDDLReq(studentId, studenName);
studentDDLReqList.add(studentDDLReqs);
}
else {
throw new IllegalArgumentException("Error Found: " + Arrays.toString(row));
}
} else {
throw new ClassCastException("Error Found: " + obj.getClass());
}
}
System.out.println(studentDDLReqList.toString());
return studentDDLReqList;
69
}
@Transactional
public UpdateStudentProfileReq getStudentByUserId(int userId) {
List<?> result = studentRepo.getStudentByUserId("GET",
0,"","","",1,1,1,"","",0,0,true,SessionManager.getInstance().getIp(), userId);
UpdateStudentProfileReq updateStudentProfileReq=null;
for (Object obj : result) {
if (obj instanceof Object[]) {
Object[] row = (Object[]) obj;
if (row.length >= 10) {
String surname = (String) row[0];
String firstName = (String) row[1];
int GenderId = (int) row[2];
String gender = (String) row[3];
String emailId = (String) row[4];
String mobile = (String) row[5];
int age = (int) row[6];
int gradeId = (int) row[7];
String grade = (String) row[8];
int retrievedUserId = (int) row[9];
updateStudentProfileReq = new UpdateStudentProfileReq(surname, firstName, GenderId,
gender,emailId,mobile, age,gradeId, grade,retrievedUserId);
}
else {
throw new IllegalArgumentException("Error Found: " + Arrays.toString(row));
}
} else {
throw new ClassCastException("Error Found: " + obj.getClass());
}
}
return updateStudentProfileReq;
}
@Transactional
public String updateStudentProfile(UpdateStudentProfileReq updateStudentProfileReq){
String strResult=
studentRepo.updateStudentProfile("UPD",0,updateStudentProfileReq.getSurname(),updateStudentPr
ofileReq.getFirstName(),"",updateStudentProfileReq.getAge(),Integer.parseInt(updateStudentProfileR
eq.getGender()),Integer.parseInt(updateStudentProfileReq.getGrade()),updateStudentProfileReq.getE
mailId(),updateStudentProfileReq.getMobile(),0,0,true,SessionManager.getInstance().getIp(),
SessionManager.getInstance().getUserId());
return strResult;
}
@Transactional
public AchievementsReq bindAchievements(String mode,int userId) {
List<?> result = studentRepo.bindAchievements(mode,0,"","","",1,1,1,"","",1,1,true,"", userId);
AchievementsReq achievementsReq = null;
70
int totalCertificates = (int) row[1];
achievementsReq = new AchievementsReq(totalTrophies, totalCertificates);
}
else {
throw new IllegalArgumentException("Error Found: " + Arrays.toString(row));
}
} else {
throw new ClassCastException("Error Found: " + obj.getClass());
}
}
return achievementsReq;
}
@Transactional
public StudentReq getStudentId(String mode, int studentId) {
StudentReq students=studentRepo.getStudentId(mode,studentId,"","","",1,1,1,"","",1,1,true,"",2);
return students; // or throw an exception if preferred
}
@Transactional
public List<StudentReq> bindStudentInfo(String mode){
List<StudentReq> students=studentRepo.bindStudentInfo(mode);
return students;
}
@Transactional
public List<GradeMasterReq> bindDdlGrade(String Mode){
List<GradeMasterReq> gradeMasters=gradeMasterRepo.bindDdlGrade(Mode);
return gradeMasters;
}
@Transactional
public List<GenderMasterReq> bindDdlGender(String Mode){
List<GenderMasterReq> genderMasters=genderMasterRepo.bindDdlGender(Mode);
return genderMasters;
}
@Transactional
public String deleteStudendInfo(String mode, Integer studentId){
String strResult= studentRepo.deleteStudentInfo(mode,studentId,"","","",1,1,1,"","",1,1,true,"",2);
return strResult;
}
}
Class: TeacherService
package io.flappybird.service;
import io.flappybird.model.UpdateTeacherProfileReq;
import io.flappybird.repo.TeacherRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
71
import java.util.List;
@Service
public class TeacherService {
@Autowired
private TeacherRepo teacherRepo;
@Transactional
public UpdateTeacherProfileReq getTeacherByUserId(int userId) {
List<?> result = teacherRepo.getTeacherByUserId("GET",
0,"","","",1,1,"","",true,SessionManager.getInstance().getIp(),userId);
UpdateTeacherProfileReq updateTeacherProfileReq=null;
for (Object obj : result) {
if (obj instanceof Object[]) {
Object[] row = (Object[]) obj;
if (row.length >= 8) {
String surname = (String) row[0];
String firstName = (String) row[1];
int genderId = (int) row[2];
String gender = (String) row[3];
String emailId = (String) row[4];
String mobile = (String) row[5];
int age = (int) row[6];
int retrievedUserId = (int) row[7];
updateTeacherProfileReq = new UpdateTeacherProfileReq(surname, firstName, genderId,
gender,emailId,mobile, age,retrievedUserId);
}
else {
throw new IllegalArgumentException("Error Found: " + Arrays.toString(row));
}
} else {
throw new ClassCastException("Error Found: " + obj.getClass());
}
}
return updateTeacherProfileReq;
}
@Transactional
public String updateTeacherProfile(UpdateTeacherProfileReq updateTeacherProfileReq){
String strResult=
teacherRepo.updateTeacherProfile("UPD",0,updateTeacherProfileReq.getSurname(),updateTeacherP
rofileReq.getFirstName(),"",updateTeacherProfileReq.getAge(),Integer.parseInt(updateTeacherProfile
Req.getGender()),updateTeacherProfileReq.getEmailId(),updateTeacherProfileReq.getMobile(),true,S
essionManager.getInstance().getIp(), SessionManager.getInstance().getUserId());
System.out.println(strResult);
return strResult;
}
}
Class: TopicService
package io.flappybird.service;
import io.flappybird.model.*;
72
import io.flappybird.repo.TopicRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@Service
public class TopicService {
@Autowired
private TopicRepo topicRepo;
@Transactional
public List<TopicStatusReq> topicsStatus(String mode, int userId) {
List<?> result = topicRepo.topicsStatus(mode,0,null,true,userId);
List<TopicStatusReq> topicStatusReqList = new ArrayList<>();
73
@Transactional
public List<TopicReq> getTopicsList(String mode) {
return topicRepo.getTopicsList(mode);
}
@Transactional
public List<TopicReq> getAllTopics() {
return null;//topicRepo.getAllTopics();
}
Class: UserService
package io.flappybird.service;
import io.flappybird.model.LoginHistoryReq;
import io.flappybird.model.UserReq;
import io.flappybird.model.UserSignUpReq;
import io.flappybird.repo.UserRepo;
import jakarta.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@Service
public class UserService {
@Autowired
private UserRepo userRepo;
//@Transactional
public String signUpUser(UserSignUpReq user) {
MD5HashUtil md5HashUtil = new MD5HashUtil();
74
String result =
userRepo.signUpUser("REG",user.getUserTypeId(),user.getSurname(),user.getFirstName(),user.getG
enderId(),user.getMobile(), user.getEmail(),md5HashUtil.md5(user.getPassword()),
SessionManager.getInstance().getIp());
return result;
}
@Transactional
public String loginUser(UserReq user) {
MD5HashUtil md5HashUtil = new MD5HashUtil();
String loginResult =userRepo.loginUser("LOG",user.getUserId(),user.getUserTypeId(),
user.getEmail().trim(), md5HashUtil.md5(user.getPassword()), SessionManager.getInstance().getIp());
if(loginResult.equals("SUCCESS")) {
int uid=userRepo.getLoginUserId("UID",user.getUserId(),user.getUserTypeId(),
user.getEmail().trim(), user.getPassword(), SessionManager.getInstance().getIp());
String userName=userRepo.getLoginUserName("LUN",user.getUserId(),user.getUserTypeId(),
user.getEmail().trim(), user.getPassword(), SessionManager.getInstance().getIp());
SessionManager.getInstance().setUserId(uid);
SessionManager.getInstance().setUsername(userName);
SessionManager.getInstance().setLoginId(user.getEmail().trim());
SessionManager.getInstance().setUserTypeId(user.getUserTypeId());
}
return loginResult;
}
@Transactional
public String logOutUser(UserReq user) {
String result = userRepo.logOutUser("OUT",user.getUserId(),user.getUserTypeId(),
user.getEmail(), user.getPassword(), SessionManager.getInstance().getIp());
return result; // Will return 'Success!' or appropriate error message
}
@Transactional
public String changePassword(UserReq user) {
MD5HashUtil md5HashUtil = new MD5HashUtil();
String result =
userRepo.changePassword("UPD",0,0,user.getEmail(),md5HashUtil.md5(user.getPassword()),Sessio
nManager.getInstance().getIp());
return result; // Will return 'Success!' or appropriate error message
}
@Transactional
public List<LoginHistoryReq> bindLoginHistory(String mode, int userId) {
List<?> result = userRepo.bindLoginHistory(mode,userId);
List<LoginHistoryReq> loginHistoryList = new ArrayList<>();
75
Date loginDate = (Date) row[4];
Date logoutDate = (Date) row[5];
double totalDuration = (double) row[6];
Interface: GenderMasterRepo
package io.flappybird.repo;
import io.flappybird.model.GenderMasterReq;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.query.Procedure;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface GenderMasterRepo extends JpaRepository<GenderMasterReq,Integer> {
@Procedure("StudentInfo")
List<GenderMasterReq> bindDdlGender(String mode);
}
Interface: GradeMasterRepo
package io.flappybird.repo;
import io.flappybird.model.GradeMasterReq;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.query.Procedure;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface GradeMasterRepo extends JpaRepository<GradeMasterReq,Integer> {
@Procedure("StudentInfo")
List<GradeMasterReq> bindDdlGrade(String mode);
}
76
Interface: PlayGameRepo
package io.flappybird.repo;
import io.flappybird.model.UserDetailsEntityReq;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.query.Procedure;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
@Repository
public interface PlayGameRepo extends JpaRepository<UserDetailsEntityReq, Long> {
@Procedure(procedureName = "PlayGame")
String startGame(
@Param("Mode") String mode,
@Param("IQuizId") int quizId,
@Param("ICorrectAns") int correctAns,
@Param("IUserId") int userId,
@Param("IIPAddress") String ipAddress);
@Procedure(procedureName = "PlayGame")
String endGame(
@Param("Mode") String mode,
@Param("IQuizId") int quizId,
@Param("ICorrectAns") int correctAns,
@Param("IUserId") int userId,
@Param("IIPAddress") String ipAddress);
}
Interface: QuestionRepo
package io.flappybird.repo;
import io.flappybird.model.GenderMasterReq;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.query.Procedure;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface QuestionRepo extends JpaRepository<GenderMasterReq,Long> {
@Procedure(procedureName = "QuestionInfo")
List getQuizInfo(
@Param("IMode") String mode,
@Param("IQuizId") Integer quizId,
@Param("IQuestionId") Integer questionId,
@Param("IQuestionDescription") String questionDescription,
@Param("IQuestionHint") String questionHint,
@Param("IOptionA") String optionA,
@Param("IOptionB") String optionB,
77
@Param("IOptionC") String optionC,
@Param("IOptionD") String optionD,
@Param("IOptionE") String optionE,
@Param("IAnswer") String answer,
@Param("IisActive") Boolean isActive,
@Param("IIPAddress") String iPAddress,
@Param("IUserId") Integer userId
);
@Procedure(procedureName = "QuestionInfo")
List bindQuestionInfo(
@Param("IMode") String mode,
@Param("IQuizId") Integer quizId,
@Param("IQuestionId") Integer questionId,
@Param("IQuestionDescription") String questionDescription,
@Param("IQuestionHint") String questionHint,
@Param("IOptionA") String optionA,
@Param("IOptionB") String optionB,
@Param("IOptionC") String optionC,
@Param("IOptionD") String optionD,
@Param("IOptionE") String optionE,
@Param("IAnswer") String answer,
@Param("IisActive") Boolean isActive,
@Param("IIPAddress") String iPAddress,
@Param("IUserId") Integer userId
);
@Procedure(procedureName = "QuestionInfo")
List bindQuestionsInfo(
@Param("IMode") String mode,
@Param("IQuizId") Integer quizId,
@Param("IQuestionId") Integer questionId,
@Param("IQuestionDescription") String questionDescription,
@Param("IQuestionHint") String questionHint,
@Param("IOptionA") String optionA,
@Param("IOptionB") String optionB,
@Param("IOptionC") String optionC,
@Param("IOptionD") String optionD,
@Param("IOptionE") String optionE,
@Param("IAnswer") String answer,
@Param("IisActive") Boolean isActive,
@Param("IIPAddress") String iPAddress,
@Param("IUserId") Integer userId
);
@Procedure(procedureName = "QuestionInfo")
List bindQuizList(String mode);
Interface: QuizRepo
78
package io.flappybird.repo;
import io.flappybird.model.UserDetailsEntityReq;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.query.Procedure;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface QuizRepo<E> extends JpaRepository<UserDetailsEntityReq, Long> {
@Procedure("QuizInfo")
List bindTopicList(String mode);
@Procedure("QuizInfo")
List bindQuizInfo(String mode);
@Procedure(procedureName = "QuizInfo")
List getQuizListByTopics(
@Param("Mode") String mode,
@Param("IQuizId") Integer quizId,
@Param("IQuizName") String quizName,
@Param("ITeacherId") Integer teacherId,
@Param("ITopicId") Integer topicId,
@Param("ILevelId") Integer levelId,
@Param("ITotalQuestions") Integer totalQuestions,
@Param("IisActive") Boolean isActive,
@Param("IIPAddress") String iPAddress,
@Param("IUserId") Integer userId
);
Interface: StudentRepo
package io.flappybird.repo;
import io.flappybird.model.StudentReq;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.query.Procedure;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface StudentRepo extends JpaRepository<StudentReq,Integer> {
@Procedure("StudentInfo")
List<StudentReq> bindStudentInfo(String mode);
@Procedure("StudentInfo")
List bindStudentList(String mode);
@Procedure(procedureName = "StudentInfo")
List getStudentByUserId(
79
@Param("Mode") String mode,
@Param("IStudentId") Integer studentId,
@Param("ISurname") String surName,
@Param("IfirstName") String firstName,
@Param("IPwd") String pwd,
@Param("IAge") Integer age,
@Param("IGenderId") Integer genderId,
@Param("IGradeId") Integer gradeId,
@Param("IEmailId") String emailId,
@Param("IMobileNo") String mobileNo,
@Param("ITotalTrophies") Integer totalTrophies,
@Param("ItotalCertificates") Integer totalCertificates,
@Param("IisActive") Boolean isActive,
@Param("IIPAddress") String ipAddress,
@Param("IUserId") Integer userId
);
@Procedure(procedureName = "StudentInfo")
String updateStudentProfile(
@Param("Mode") String mode,
@Param("IStudentId") Integer studentId,
@Param("ISurname") String surName,
@Param("IfirstName") String firstName,
@Param("IPwd") String pwd,
@Param("IAge") Integer age,
@Param("IGenderId") Integer genderId,
@Param("IGradeId") Integer gradeId,
@Param("IEmailId") String emailId,
@Param("IMobileNo") String mobileNo,
@Param("ITotalTrophies") Integer totalTrophies,
@Param("ItotalCertificates") Integer totalCertificates,
@Param("IisActive") Boolean isActive,
@Param("IIPAddress") String ipAddress,
@Param("IUserId") Integer userId
);
@Procedure(procedureName = "StudentInfo")
List bindAchievements(
@Param("Mode") String mode,
@Param("IStudentId") Integer studentId,
@Param("ISurname") String surName,
@Param("IfirstName") String firstName,
@Param("IPwd") String pwd,
@Param("IAge") Integer age,
@Param("IGenderId") Integer genderId,
@Param("IGradeId") Integer gradeId,
@Param("IEmailId") String emailId,
@Param("IMobileNo") String mobileNo,
@Param("ITotalTrophies") Integer totalTrophies,
@Param("ItotalCertificates") Integer totalCertificates,
@Param("IisActive") Boolean isActive,
@Param("IIPAddress") String ipAddress,
@Param("IUserId") Integer userId
);
80
@Procedure(procedureName = "StudentInfo")
StudentReq getStudentId(
@Param("Mode") String mode,
@Param("IStudentId") Integer studentId,
@Param("ISurname") String surName,
@Param("IfirstName") String firstName,
@Param("IPwd") String pwd,
@Param("IAge") Integer age,
@Param("IGenderId") Integer genderId,
@Param("IGradeId") Integer gradeId,
@Param("IEmailId") String emailId,
@Param("IMobileNo") String mobileNo,
@Param("ITotalTrophies") Integer totalTrophies,
@Param("ItotalCertificates") Integer totalCertificates,
@Param("IisActive") Boolean isActive,
@Param("IIPAddress") String ipAddress,
@Param("IUserId") Integer userId
);
@Procedure(procedureName = "StudentInfo")
String deleteStudentInfo(
@Param("Mode") String mode,
@Param("IStudentId") Integer studentId,
@Param("ISurname") String surName,
@Param("IfirstName") String firstName,
@Param("IPwd") String pwd,
@Param("IAge") Integer age,
@Param("IGenderId") Integer genderId,
@Param("IGradeId") Integer gradeId,
@Param("IEmailId") String emailId,
@Param("IMobileNo") String mobileNo,
@Param("ITotalTrophies") Integer totalTrophies,
@Param("ItotalCertificates") Integer totalCertificates,
@Param("IisActive") Boolean isActive,
@Param("IIPAddress") String ipAddress,
@Param("IUserId") Integer userId
);
Interface: TeacherRepo
package io.flappybird.repo;
import io.flappybird.model.TeacherReq;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.query.Procedure;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
81
import java.util.List;
@Repository
public interface TeacherRepo extends JpaRepository<TeacherReq, Integer>{
@Procedure(procedureName = "TeacherInfo")
List getTeacherByUserId(
@Param("Mode") String mode,
@Param("ITeacherId") Integer teacherId,
@Param("ISurname") String surName,
@Param("IFirstName") String firstName,
@Param("IPwd") String pwd,
@Param("IAge") Integer age,
@Param("IGenderId") Integer genderId,
@Param("IEmailId") String emailId,
@Param("IMobileNo") String mobileNo,
@Param("IisActive") Boolean isActive,
@Param("IIPAddress") String ipAddress,
@Param("IUserId") Integer userId
);
@Procedure(procedureName = "TeacherInfo")
String updateTeacherProfile(
@Param("Mode") String mode,
@Param("ITeacherId") Integer teacherId,
@Param("ISurname") String surName,
@Param("IFirstName") String firstName,
@Param("IPwd") String pwd,
@Param("IAge") Integer age,
@Param("IGenderId") Integer genderId,
@Param("IEmailId") String emailId,
@Param("IMobileNo") String mobileNo,
@Param("IisActive") Boolean isActive,
@Param("IIPAddress") String ipAddress,
@Param("IUserId") Integer userId
);
}
Interface: TopicRepo
package io.flappybird.repo;
import io.flappybird.model.UserDetailsEntityReq;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.query.Procedure;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface TopicRepo <E> extends JpaRepository<UserDetailsEntityReq, Long> {
@Procedure("TopicInfo")
List bindStudentList(String mode);
@Procedure(procedureName = "TopicInfo")
82
List topicsStatus(
@Param("Mode") String mode,
@Param("ITopicId") Integer topicId,
@Param("ITopicName") String topicName,
@Param("IisActive") Boolean isActive,
@Param("IUserId") Integer userId
);
@Procedure("QuizInfo")
List getTopicsList(String mode);
Interface: UserRepo
package io.flappybird.repo;
import io.flappybird.model.UserDetailsEntityReq;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.query.Procedure;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface UserRepo extends JpaRepository<UserDetailsEntityReq, Long> {
@Procedure(procedureName = "SignUpInfo")
String signUpUser(
@Param("IMode") String mode,
@Param("IUserTypeId") int userTypeId,
@Param("ISurname") String surName,
@Param("IFirstName") String firstName,
@Param("IGenderId") int genderId,
@Param("IMobileNo") String mobileNo,
@Param("IEmailId") String emailId,
@Param("IPwd") String pwd,
@Param("IIPAddress") String ipAddress);
@Procedure(procedureName = "LoginInfo")
String loginUser(
@Param("IMode") String mode,
@Param("IUserId") int userId,
@Param("IUserTypeId") int userTypeId,
@Param("ILoginId") String loginId,
@Param("IPwd") String password,
@Param("IIPAddress") String ipAddress);
@Procedure(procedureName = "LoginInfo")
int getLoginUserId(
@Param("IMode") String mode,
@Param("IUserId") int userId,
@Param("IUserTypeId") int userTypeId,
@Param("ILoginId") String loginId,
@Param("IPwd") String password,
@Param("IIPAddress") String ipAddress);
83
@Procedure(procedureName = "LoginInfo")
String getLoginUserName(
@Param("IMode") String mode,
@Param("IUserId") int userId,
@Param("IUserTypeId") int userTypeId,
@Param("ILoginId") String loginId,
@Param("IPwd") String password,
@Param("IIPAddress") String ipAddress);
@Procedure(procedureName = "LoginInfo")
String logOutUser(
@Param("IMode") String mode,
@Param("IUserId") int userId,
@Param("IUserTypeId") int userTypeId,
@Param("ILoginId") String loginId,
@Param("IPwd") String password,
@Param("IIPAddress") String ipAddress);
@Procedure(procedureName = "LoginInfo")
String changePassword(
@Param("IMode") String mode,
@Param("IUserId") int userId,
@Param("IUserTypeId") int userTypeId,
@Param("ILoginId") String loginId,
@Param("IPwd") String password,
@Param("IIPAddress") String ipAddress);
@Procedure("LoginInfo")
List bindLoginHistory(String mode, int userId);
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Start Game Page</title>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="stylesheet" th:href="@{/css/login.css}" />
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
.container {
width: 100%;
max-width: 500px;
84
margin: 40px auto;
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
margin-bottom: 20px;
color: #333;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
.form-group input[type="text"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;
}
.form-group select {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;
}
.form-group button {
width: 100%;
padding: 12px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
font-size: 16px;
}
.form-group button:hover {
background-color: #45a049;
}
85
/* Responsive Styles */
@media (max-width: 768px) {
.form-group button {
font-size: 14px;
}
}
h2 {
font-size: 24px;
}
.form-group select {
padding: 8px;
}
}
#playButton:disabled {
background-color: #ccc; /* Gray color for disabled state */
color: #666; /* Faded text color */
cursor: not-allowed; /* Change cursor to indicate it's not clickable */
}
#playButton {
background-color: #007bff; /* Primary color */
color: white; /* Text color */
border: none;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
border-radius: 5px; /* Rounded corners */
transition: background-color 0.3s; /* Smooth transition */
}
#playButton:hover:not(:disabled) {
background-color: #0056b3; /* Darker shade on hover */
}
#readMeButton {
background-color: #007bff; /* Primary color */
color: white; /* Text color */
border: none;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
border-radius: 5px; /* Rounded corners */
transition: background-color 0.3s; /* Smooth transition */
}
86
</style>
<script th:inline="javascript">
document.addEventListener("DOMContentLoaded", function() {
var message = [[${delMsg}]] ? [[${delMsg}]] : '';
if (message) {
Swal.fire({
title: 'Message',
text: message,
icon: 'info',
confirmButtonText: 'OKK'
});
}
});
</script>
<script>
$(document).ready(function() {
$('#topicName').change(function() {
var topicId = $(this).val();
if (topicId) {
$.ajax({
url: '/game/quizzes/' + topicId,
method: 'GET',
success: function(data) {
var quizList = $('#quizList');
quizList.empty(); // Clear existing options
quizList.append('<option value="" disabled selected>Select Quiz</option>'); // Add
default option
$('#quizList').change(function() {
checkSelection(); // Recheck the selections after quiz change
});
});
87
function checkSelection() {
const topicSelect = document.getElementById('topicName');
const quizSelect = document.getElementById('quizList');
const playButton = document.getElementById('playButton');
function playGame() {
const quizSelect = document.getElementById('quizList');
const selectedQuizId = quizSelect.value;
function deleteHighestScore() {
window.location.href = '/game/deleteHighestScore';
}
function readMe() {
const instructionsDiv = $('#instructions');
88
}
}
</script>
</head>
<body>
<div class="container">
<form class="game-form" th:object="${scoreReq}">
<h2>Play Game</h2>
<div class="form-group">
<label for="highestScore">Highest Score</label>
<input type="text" id="highestScore" name="highestScore" th:field="*{highestScore}" disabled>
</div>
<div class="form-group">
<label for="recentScore">Recent Score</label>
<input type="text" id="recentScore" name="recentScore" th:field="*{recentScore}" disabled>
</div>
<div class="form-group">
<label for="topicName">Topic Name</label>
<select id="topicName" name="topicName">
<option value="" disabled selected>Select Topic</option>
<option th:each="topic : ${topics}"
th:value="${topic.topicId}"
th:text="${topic.topicName}"></option>
</select>
</div>
<div class="form-group">
<label for="quizList">Quiz</label>
<select id="quizList" name="quiz">
<option value="" disabled selected>Select Quiz</option>
<!-- Options will be dynamically inserted here -->
</select>
</div>
<div class="form-group">
<button id="playButton" type="button" onclick="playGame()" disabled>Play Game</button>
</div>
<div class="form-group">
<button type="button" onclick="window.location.href='/student/studentMenu'">Back to
Home</button>
</div>
<div class="form-group">
<button id="readMeButton" type="button" onclick="readMe();">Game Instructions</button>
</div>
<div id="instructions" style="display:none;"></div>
</form>
</div>
</body>
89
</html>
th:text="${topic.topicName}"></option>
</select>
</div>
<div class="form-group">
<label for="quizList">Quiz</label>
<select id="quizList" name="quiz">
<option value="" disabled selected>Select Quiz</option>
<!-- Options will be dynamically inserted here -->
</select>
</div>
<div class="form-group">
<button id="playButton" type="button" onclick="playGame()"
disabled>Play Game</button>
</div>
<div class="form-group">
<button type="button"
onclick="window.location.href='/student/studentMenu'">Back to Home</button>
</div>
<div class="form-group">
<button id="readMeButton" type="button" onclick="readMe();">Game
Instructions</button>
</div>
<div id="instructions" style="display:none;"></div>
</form>
</div>
</body>
</html>
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Students Details</title>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<!-- Add Font Awesome -->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"
integrity="sha512-Fo3rlrZj/k6qn5olB6x8aTA6TpzD4A1L/5t+fdh8j9A+T9I1KuPiCMGrxQGq+lSklcq1Td/
wWc5qWm21ClxaGA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
90
<style>
/* Basic styling */
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}
.container {
width: 100%;
max-width: 1200px;
margin: 20px auto;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
margin-bottom: 20px;
}
.form-group {
display: flex;
flex-wrap: wrap;
margin-bottom: 15px;
}
.form-group label {
flex: 0 0 25%;
padding: 10px;
}
.form-group input,
.form-group select {
flex: 1;
padding: 10px;
margin-right: 10px;
}
.form-group input[type="submit"] {
background-color: #4CAF50;
91
color: white;
border: none;
cursor: pointer;
flex: 0 0 100%;
}
.form-group input[type="submit"]:hover {
background-color: #45a049;
}
.form-group button {
padding: 10px;
background-color: #f44336;
color: white;
border: none;
cursor: pointer;
}
.form-group button:hover {
background-color: #d32f2f;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
table, th, td {
border: 1px solid #ddd;
}
th, td {
padding: 12px;
text-align: left;
}
th {
background-color: #4CAF50;
color: white;
}
92
background-color: #f0f0f0; /* Light gray background */
border: 1px solid #ccc; /* Light border */
border-radius: 5px;
padding: 8px;
margin: 0 5px;
cursor: pointer;
font-size: 18px;
display: inline-block;
color: #333; /* Icon color */
transition: background-color 0.3s ease;
}
.icon-btn.edit {
color: #4CAF50; /* Green for edit */
}
.icon-btn.delete {
color: #f44336; /* Red for delete */
}
.icon-btn:hover {
background-color: #ddd; /* Slight background color change on hover */
}
/* Responsive */
@media screen and (max-width: 768px) {
.form-group label {
flex: 0 0 100%;
}
.form-group input,
.form-group select {
flex: 1 0 100%;
}
}
</style>
<script th:inline="javascript">
93
var message = [[${delMsg}]] ? [[${delMsg}]] : '';
if (message) {
Swal.fire({
title: 'Message',
text: message,
icon: 'info',
confirmButtonText: 'OK'
});
}
</script>
</head>
<body>
<div class="container">
<h1>Students Details</h1>
<table border="1">
<thead>
<tr>
<th>S.No</th>
<th>Surname</th>
<th>FirstName</th>
<th>Age</th>
<th>Gender</th>
<th>Grade</th>
<th>Email ID</th>
<th>Mobile No</th>
<th>Trophies</th>
<th>Certificates</th>
<!-- <th class="hidden-column">IP Address</th> <!– Make invisible
–>-->
<th> Reg.Date </th>
<th>isActive</th>
<th>Action</th>
<!-- <th class="hidden-column">User ID</th> <!– Make invisible
–>-->
</tr>
</thead>
<tbody>
<tr th:each="student, stat : ${students}">
<td th:text="${stat.index + 1}"></td>
<td th:text="${student.surName}"></td>
<td th:text="${student.firstName}"></td>
<td th:text="${student.age}"></td>
<td th:text="${student.gender}"></td>
<td th:text="${student.grade}"></td>
94
<td th:text="${student.emailId}"></td>
<td th:text="${student.mobileNo}"></td>
<td th:text="${student.totalTrophies}"></td>
<td th:text="${student.totalCertificates}"></td>
<!-- <td th:text="${student.ipAddress}" class="hidden-column"></td> <!–
Invisible –>-->
<td th:text="${student.transDate}"></td>
<td th:text="${student.isActive} ? 'Yes' : 'No'"></td>
<!-- <td th:text="${student.userId}" class="hidden-column"></td> <!– Invisible
–>-->
<td>
<a th:href="@{/students/edit/{id}(id=${student.studentId})}">
<button class="icon-btn edit">
<i class="fas fa-edit"></i>
</button>
</a>
<a th:href="@{/students/delete/{id}(id=${student.studentId})}" onclick="return confirm('Are
you sure?');">
<button class="icon-btn delete">
<i class="fas fa-trash"></i>
</button>
</a>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Home Page</title>
<link rel="stylesheet" th:href="@{/css/home.css}" />
<style>
body {
font-family: Arial, sans-serif;
95
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
.home-container {
width: 100%;
max-width: 600px;
margin: 40px auto;
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
margin-bottom: 20px;
color: #333;
}
.home-form {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 15px; /* Adding gap for consistent spacing */
}
.form-group {
flex: 1 1 48%;
margin-bottom: 15px;
}
.form-group.full-width {
flex: 1 1 100%;
}
.form-group button {
width: 100%;
padding: 12px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
96
border-radius: 5px;
font-size: 16px;
}
.form-group button:hover {
background-color: #45a049;
}
.user-name {
text-align: center;
font-size: 20px;
font-weight: bold;
color: #555;
margin-bottom: 20px;
}
/* Responsive Adjustments */
@media (max-width: 768px) {
.form-group {
flex: 1 1 100%;
margin-bottom: 10px;
}
.form-group button {
font-size: 14px;
padding: 10px;
}
}
h2 {
font-size: 24px;
}
.form-group button {
font-size: 14px;
padding: 8px;
}
}
97
font-size: 12px;
padding: 6px;
}
}
</style>
</head>
<body>
<div class="home-container">
<form class="home-form">
<div class="user-name" th:text="'Welcome, ' + ${userName} + ' '" ></div>
<div class="form-group full-width">
<h2>Main Menu</h2>
</div>
<div class="form-group full-width">
<button type="button" onclick="window.location.href='/game/playGame'">Start Game</button>
</div>
<div class="form-group">
<button type="button" onclick="window.location.href='/student/studentPerformance'">Student
Performance</button>
</div>
<div class="form-group">
<button type="button" onclick="window.location.href='/user/loginHistory'">Login
History</button>
</div>
98
</div>
<div class="form-group full-width">
<button type="button" onclick="window.location.href='/user/logOut'">Logout</button>
</div>
</form>
</div>
</body>
</html>
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Student Performance Details</title>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<!-- Add Font Awesome -->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"
integrity="sha512-Fo3rlrZj/k6qn5olB6x8aTA6TpzD4A1L/5t+fdh8j9A+T9I1KuPiCMGrxQGq+lSklcq1Td/
wWc5qWm21ClxaGA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<style>
/* Basic styling */
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}
.container {
width: 100%;
max-width: 1200px;
margin: 20px auto;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
99
margin-bottom: 20px;
}
.form-group-back button {
width: 100%;
padding: 12px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
font-size: 16px;
}
.form-group-back button:hover {
background-color: #45a049;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
table, th, td {
border: 1px solid #ddd;
}
th, td {
padding: 12px;
text-align: left;
}
th {
background-color: #4CAF50;
color: white;
}
/* Pagination styles */
.pagination {
margin-top: 20px;
text-align: center;
display: flex;
justify-content: center;
100
align-items: center;
}
.pagination a.disabled {
background-color: #ddd;
color: #888;
cursor: not-allowed;
}
.pagination span {
background-color: #4CAF50;
cursor: default;
}
.pagination a:hover:not(.disabled) {
background-color: #45a049;
}
/* Responsive */
@media screen and (max-width: 768px) {
.form-group label {
flex: 0 0 100%;
}
.form-group input,
.form-group select {
flex: 1 0 100%;
}
}
</style>
</head>
<body>
101
<div class="container">
<h1>Student Performance Details</h1>
<div class="form-group-back">
<button type="button" onclick="window.location.href='/student/studentMenu'">Back to
Home</button>
</div>
102
<!-- Pagination buttons will be dynamically generated here -->
</div>
</div>
<script>
const rowsPerPage = 10;
const table = document.getElementById('performanceTable');
const pagination = document.getElementById('pagination');
const rows = table.getElementsByTagName('tbody')[0].getElementsByTagName('tr');
const totalRows = rows.length;
const totalPages = Math.ceil(totalRows / rowsPerPage);
let currentPage = 1;
function displayPage(page) {
currentPage = page;
const startRow = (page - 1) * rowsPerPage;
const endRow = startRow + rowsPerPage;
updatePagination();
}
function updatePagination() {
pagination.innerHTML = '';
// Previous button
const prevBtn = document.createElement('a');
prevBtn.innerHTML = 'Previous';
if (currentPage > 1) {
prevBtn.onclick = () => displayPage(currentPage - 1);
} else {
prevBtn.classList.add('disabled');
}
pagination.appendChild(prevBtn);
103
// Next button
const nextBtn = document.createElement('a');
nextBtn.innerHTML = 'Next';
if (currentPage < totalPages) {
nextBtn.onclick = () => displayPage(currentPage + 1);
} else {
nextBtn.classList.add('disabled');
}
pagination.appendChild(nextBtn);
}
</body>
</html>
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Topic Wise Status Details</title>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<!-- Add Font Awesome -->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"
integrity="sha512-Fo3rlrZj/k6qn5olB6x8aTA6TpzD4A1L/5t+fdh8j9A+T9I1KuPiCMGrxQGq+lSklcq1Td/
wWc5qWm21ClxaGA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<style>
/* Basic styling */
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}
.container {
width: 100%;
max-width: 1200px;
margin: 20px auto;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
104
h2 {
text-align: center;
margin-bottom: 20px;
}
.form-group {
display: flex;
flex-wrap: wrap;
margin-bottom: 15px;
}
.form-group label {
flex: 0 0 25%;
padding: 10px;
}
.form-group input,
.form-group select {
flex: 1;
padding: 10px;
margin-right: 10px;
}
.form-group input[type="submit"] {
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
flex: 0 0 100%;
}
.form-group input[type="submit"]:hover {
background-color: #45a049;
}
.form-group button {
padding: 10px;
background-color: #f44336;
color: white;
border: none;
cursor: pointer;
}
.form-group button:hover {
background-color: #d32f2f;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
105
}
table, th, td {
border: 1px solid #ddd;
}
th, td {
padding: 12px;
text-align: left;
}
th {
background-color: #4CAF50;
color: white;
}
.icon-btn.edit {
color: #4CAF50; /* Green for edit */
}
.icon-btn.delete {
color: #f44336; /* Red for delete */
}
.icon-btn:hover {
background-color: #ddd; /* Slight background color change on hover */
}
/* Responsive */
@media screen and (max-width: 768px) {
.form-group label {
flex: 0 0 100%;
106
}
.form-group input,
.form-group select {
flex: 1 0 100%;
}
}
.form-group-back button {
width: 100%;
padding: 12px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
font-size: 16px;
}
.form-group-back button:hover {
background-color: #45a049;
}
/* Pagination styles */
.pagination {
margin-top: 20px;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}
.pagination a.disabled {
background-color: #ddd;
color: #888;
cursor: not-allowed;
}
.pagination span {
background-color: #4CAF50;
cursor: default;
}
107
.pagination a:hover:not(.disabled) {
background-color: #45a049;
}
/* Responsive */
@media screen and (max-width: 768px) {
.form-group label {
flex: 0 0 100%;
}
.form-group input,
.form-group select {
flex: 1 0 100%;
}
}
</style>
<script th:inline="javascript">
var message = [[${delMsg}]] ? [[${delMsg}]] : '';
if (message) {
Swal.fire({
title: 'Message',
text: message,
icon: 'info',
confirmButtonText: 'OK'
});
}
</script>
</head>
<body>
<div class="container">
<h1>Topic Wise Status Details</h1>
<div class="form-group-back">
<button type="button" onclick="window.location.href='/student/studentMenu'">Back to
Home</button>
</div>
<table class="table table-bordered" id="topicStatusTable">
<thead>
<tr>
<th>S.No</th>
<!-- <th>Topic Name</th>-->
<th>Topic-Quiz Name</th>
<th>Created By</th>
<th>Questions</th>
<th>Max M.</th>
<th>Min M.</th>
<th>Minutes</th>
<th>Date</th>
<th>Start Time</th>
<th>End Time</th>
<th>Accuracy</th>
<th>Result</th>
108
</tr>
</thead>
<tbody>
<tr th:each="topic,stat : ${topicStatusReq}">
<td th:text="${stat.index + 1}"></td>
<!-- <td th:text="${topic.topicName}"></td>-->
<td th:text="${topic.quizName}"></td>
<td th:text="${topic.teacherName}"></td>
<td th:text="${topic.totalQuestions}"></td>
<td th:text="${topic.maxMarks}"></td>
<td th:text="${topic.minMarks}"></td>
<td th:text="${topic.duration}"></td>
<td th:text="${#dates.format(topic.playDate, 'dd-MM-yyyy')}"></td>
<td th:text="${#dates.format(topic.startTime, 'HH:mm:ss')}"></td>
<td th:text="${#dates.format(topic.endTime, 'HH:mm:ss')}"></td>
<td th:text="${topic.accuracy}"></td>
<td th:text="${topic.result}"></td>
</tr>
</tbody>
</table>
<script>
const rowsPerPage = 10;
const table = document.getElementById('topicStatusTable');
const pagination = document.getElementById('pagination');
const rows = table.getElementsByTagName('tbody')[0].getElementsByTagName('tr');
const totalRows = rows.length;
const totalPages = Math.ceil(totalRows / rowsPerPage);
let currentPage = 1;
function displayPage(page) {
currentPage = page;
const startRow = (page - 1) * rowsPerPage;
const endRow = startRow + rowsPerPage;
updatePagination();
}
function updatePagination() {
pagination.innerHTML = '';
109
// Previous button
const prevBtn = document.createElement('a');
prevBtn.innerHTML = 'Previous';
if (currentPage > 1) {
prevBtn.onclick = () => displayPage(currentPage - 1);
} else {
prevBtn.classList.add('disabled');
}
pagination.appendChild(prevBtn);
// Next button
const nextBtn = document.createElement('a');
nextBtn.innerHTML = 'Next';
if (currentPage < totalPages) {
nextBtn.onclick = () => displayPage(currentPage + 1);
} else {
nextBtn.classList.add('disabled');
}
pagination.appendChild(nextBtn);
}
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Topic Wise Status Details</title>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<!-- Add Font Awesome -->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"
integrity="sha512-Fo3rlrZj/k6qn5olB6x8aTA6TpzD4A1L/5t+fdh8j9A+T9I1KuPiCMGrxQGq+lSklcq1Td/
wWc5qWm21ClxaGA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<style>
/* Basic styling */
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
110
}
.container {
width: 100%;
max-width: 1200px;
margin: 20px auto;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
margin-bottom: 20px;
}
.form-group {
display: flex;
flex-wrap: wrap;
margin-bottom: 15px;
}
.form-group label {
flex: 0 0 25%;
padding: 10px;
}
.form-group input,
.form-group select {
flex: 1;
padding: 10px;
margin-right: 10px;
}
.form-group input[type="submit"] {
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
flex: 0 0 100%;
}
.form-group input[type="submit"]:hover {
background-color: #45a049;
}
.form-group button {
padding: 10px;
background-color: #f44336;
color: white;
border: none;
cursor: pointer;
111
}
.form-group button:hover {
background-color: #d32f2f;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
table, th, td {
border: 1px solid #ddd;
}
th, td {
padding: 12px;
text-align: left;
}
th {
background-color: #4CAF50;
color: white;
}
.icon-btn.edit {
color: #4CAF50; /* Green for edit */
}
.icon-btn.delete {
color: #f44336; /* Red for delete */
}
.icon-btn:hover {
background-color: #ddd; /* Slight background color change on hover */
}
112
/* Specific styling for IP Address and User ID */
.hidden-column {
font-size: 10px;
visibility: hidden;
}
/* Responsive */
@media screen and (max-width: 768px) {
.form-group label {
flex: 0 0 100%;
}
.form-group input,
.form-group select {
flex: 1 0 100%;
}
}
.form-group-back button {
width: 100%;
padding: 12px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
font-size: 16px;
}
.form-group-back button:hover {
background-color: #45a049;
}
/* Pagination styles */
.pagination {
margin-top: 20px;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}
.pagination a.disabled {
113
background-color: #ddd;
color: #888;
cursor: not-allowed;
}
.pagination span {
background-color: #4CAF50;
cursor: default;
}
.pagination a:hover:not(.disabled) {
background-color: #45a049;
}
/* Responsive */
@media screen and (max-width: 768px) {
.form-group label {
flex: 0 0 100%;
}
.form-group input,
.form-group select {
flex: 1 0 100%;
}
}
</style>
<script th:inline="javascript">
var message = [[${delMsg}]] ? [[${delMsg}]] : '';
if (message) {
Swal.fire({
title: 'Message',
text: message,
icon: 'info',
confirmButtonText: 'OK'
});
}
</script>
</head>
<body>
<div class="container">
<h1>Topic Wise Status Details</h1>
<div class="form-group-back">
<button type="button" onclick="window.location.href='/student/studentMenu'">Back to
Home</button>
</div>
<table class="table table-bordered" id="topicStatusTable">
<thead>
<tr>
<th>S.No</th>
<!-- <th>Topic Name</th>-->
<th>Topic-Quiz Name</th>
114
<th>Created By</th>
<th>Questions</th>
<th>Max M.</th>
<th>Min M.</th>
<th>Minutes</th>
<th>Date</th>
<th>Start Time</th>
<th>End Time</th>
<th>Accuracy</th>
<th>Result</th>
</tr>
</thead>
<tbody>
<tr th:each="topic,stat : ${topicStatusReq}">
<td th:text="${stat.index + 1}"></td>
<!-- <td th:text="${topic.topicName}"></td>-->
<td th:text="${topic.quizName}"></td>
<td th:text="${topic.teacherName}"></td>
<td th:text="${topic.totalQuestions}"></td>
<td th:text="${topic.maxMarks}"></td>
<td th:text="${topic.minMarks}"></td>
<td th:text="${topic.duration}"></td>
<td th:text="${#dates.format(topic.playDate, 'dd-MM-yyyy')}"></td>
<td th:text="${#dates.format(topic.startTime, 'HH:mm:ss')}"></td>
<td th:text="${#dates.format(topic.endTime, 'HH:mm:ss')}"></td>
<td th:text="${topic.accuracy}"></td>
<td th:text="${topic.result}"></td>
</tr>
</tbody>
</table>
<script>
const rowsPerPage = 10;
const table = document.getElementById('topicStatusTable');
const pagination = document.getElementById('pagination');
const rows = table.getElementsByTagName('tbody')[0].getElementsByTagName('tr');
const totalRows = rows.length;
const totalPages = Math.ceil(totalRows / rowsPerPage);
let currentPage = 1;
function displayPage(page) {
currentPage = page;
const startRow = (page - 1) * rowsPerPage;
const endRow = startRow + rowsPerPage;
115
for (let i = 0; i < totalRows; i++) {
rows[i].style.display = (i >= startRow && i < endRow) ? '' : 'none';
}
updatePagination();
}
function updatePagination() {
pagination.innerHTML = '';
// Previous button
const prevBtn = document.createElement('a');
prevBtn.innerHTML = 'Previous';
if (currentPage > 1) {
prevBtn.onclick = () => displayPage(currentPage - 1);
} else {
prevBtn.classList.add('disabled');
}
pagination.appendChild(prevBtn);
// Next button
const nextBtn = document.createElement('a');
nextBtn.innerHTML = 'Next';
if (currentPage < totalPages) {
nextBtn.onclick = () => displayPage(currentPage + 1);
} else {
nextBtn.classList.add('disabled');
}
pagination.appendChild(nextBtn);
}
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Quiz Question Details</title>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"
116
integrity="sha512-Fo3rlrZj/k6qn5olB6x8aTA6TpzD4A1L/5t+fdh8j9A+T9I1KuPiCMGrxQGq+lSklcq1Td/
wWc5qWm21ClxaGA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
/* General Styles */
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}
.container {
max-width: 1200px;
margin: 20px auto;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
margin-bottom: 20px;
}
/* Form Group */
.form-group {
margin-bottom: 15px;
}
.form-group select {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
/* Back Button */
.form-group-back button {
width: 100%;
padding: 12px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
font-size: 16px;
transition: background-color 0.3s;
}
.form-group-back button:hover {
background-color: #45a049;
117
}
/* Table Styling */
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th, td {
padding: 12px;
text-align: left;
border: 1px solid #ddd;
}
th {
background-color: #4CAF50;
color: white;
}
/* Responsive Design */
@media screen and (max-width: 768px) {
th, td {
font-size: 14px;
padding: 8px;
}
.form-group-back button {
font-size: 14px;
padding: 10px;
}
}
</style>
<script th:inline="javascript">
var message = [[${delMsg}]] ? [[${delMsg}]] : '';
if (message) {
Swal.fire({
title: 'Message',
text: message,
icon: 'info',
confirmButtonText: 'OK'
});
}
</script>
<script>
$(document).ready(function() {
$('#quizSelect').change(function() {
var quizId = $(this).val();
if (quizId) {
$.ajax({
118
url: '/teacher/questions/' + quizId,
method: 'GET',
success: function(data) {
var questionsBody = $('#questionsBody');
questionsBody.empty(); // Clear existing rows
$('#questionsTable').show(); // Show the table
119
</div>
<table id="questionsTable" style="display:none;">
<thead>
<tr>
<th>S.No</th>
<th>Question</th>
<th>Question Hint</th>
<th>Option A</th>
<th>Option B</th>
<th>Option C</th>
<th>Option D</th>
<th>Option E</th>
<th>Answer</th>
</tr>
</thead>
<tbody id="questionsBody">
<!-- Rows will be dynamically inserted here -->
</tbody>
</table>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Update Profile Details Page</title>
<link rel="stylesheet" th:href="@{/css/login.css}" />
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
.student-container {
width: 100%;
max-width: 600px;
margin: auto;
background-color: white;
padding: 20px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
120
.student-form {
display: flex;
flex-wrap: wrap;
}
.form-group {
flex: 0 0 48%;
margin: 10px 1%;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group select {
width: 100%;
padding: 10px;
margin-top: 5px;
border: 1px solid #ccc;
border-radius: 5px;
}
.form-group label {
display: block;
font-weight: bold;
margin-bottom: 5px;
}
.student-form button {
width: 100%;
padding: 15px;
margin-top: 20px;
background-color: #4CAF50;
border: none;
color: white;
cursor: pointer;
border-radius: 5px;
font-size: 16px;
}
.student-form button:hover {
background-color: #45a049;
}
.full-width {
flex: 0 0 100%;
}
h2 {
text-align: center;
width: 100%;
margin-bottom: 20px;
}
121
.radio-group {
display: flex;
gap: 10px;
padding: 10px 0;
}
.radio-group input {
margin-right: 5px;
}
/* Modal styles */
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 300px;
text-align: center;
}
.modal-content button {
padding: 10px 20px;
border: none;
background-color: #4CAF50;
color: white;
cursor: pointer;
border-radius: 5px;
}
.modal-content button:hover {
background-color: #45a049;
}
.error-message {
color: red;
}
/* Responsive Styles */
122
@media (max-width: 768px) {
.form-group {
flex: 0 0 100%;
margin: 10px 0;
}
.student-form button {
padding: 12px;
font-size: 14px;
}
.radio-group {
flex-direction: column;
align-items: flex-start;
}
}
h2 {
font-size: 24px;
}
.student-form button {
font-size: 14px;
}
.form-group input[type="text"],
.form-group input[type="password"] {
padding: 8px;
}
}
</style>
</head>
<script th:inline="javascript">
document.addEventListener("DOMContentLoaded", function() {
// General message (success or info)
var message = [[${message}]] ? [[${message}]] : '';
// Error message
var errorMsg = [[${errorMsg}]] ? [[${errorMsg}]] : '';
if (message) {
Swal.fire({
title: 'Message',
text: message,
icon: 'info',
confirmButtonText: 'OK'
123
});
}
if (errorMsg) {
Swal.fire({
title: 'Error',
text: errorMsg,
icon: 'error',
confirmButtonText: 'OK'
});
}
});
</script>
<body>
<div class="student-container">
<form class="student-form" th:action="@{/student/updateStudentProfile}" method="post"
th:object="${updateStudentProfileReq}">
<h2 class="full-width">Student Profile</h2>
<div class="form-group">
<label for="surname">Surname:</label>
<input type="text" id="surname" name="surname" th:field="*{surname}" required>
</div>
<div class="form-group">
<label for="firstName">First Name:</label>
<input type="text" id="firstName" name="firstName" th:field="*{firstName}" required>
</div>
<div class="form-group">
<label for="genderId">Gender:</label>
<select id="genderId" name="genderId" th:field="*{gender}" th:value="*{genderId}" required>
<option value="" disabled selected>Select grade</option>
<option th:each="gender : ${genders}" th:value="${gender.genderId}"
th:text="${gender.gender}"></option>
</select>
</div>
<div class="form-group">
<label for="mobile">Mobile:</label>
<input type="text" id="mobile" name="mobile" maxlength="10" th:field="*{mobile}" required>
</div>
<div class="form-group">
<label for="emailId">Email:</label>
<input type="text" id="emailId" name="emailId" th:field="*{emailId}" required>
</div>
<div class="form-group">
<label for="age">Age:</label>
124
<input type="text" id="age" name="age" maxlength="2" th:field="*{age}" required>
</div>
<div class="form-group">
<label for="gradeId">Grade:</label>
<select id="gradeId" name="gradeId" th:field="*{grade}" required>
<option value="" disabled selected>Select grade</option>
<option th:each="grade : ${grades}" th:value="${grade.gradeId}"
th:text="${grade.grade}"></option>
</select>
</div>
<div class="form-group">
<input type="hidden" id="userId" name="userId" th:field="*{userId}" required>
</div>
<div class="form-group full-width">
<button type="submit">Update</button>
</div>
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Quiz Details</title>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<!-- Add Font Awesome -->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"
integrity="sha512-Fo3rlrZj/k6qn5olB6x8aTA6TpzD4A1L/5t+fdh8j9A+T9I1KuPiCMGrxQGq+lSklcq1Td/
wWc5qWm21ClxaGA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<style>
/* Basic styling */
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}
.container {
width: 100%;
max-width: 1200px;
125
margin: 20px auto;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
margin-bottom: 20px;
}
.form-group {
display: flex;
flex-wrap: wrap;
margin-bottom: 15px;
}
.form-group label {
flex: 0 0 25%;
padding: 10px;
}
.form-group input,
.form-group select {
flex: 1;
padding: 10px;
margin-right: 10px;
}
.form-group input[type="submit"] {
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
flex: 0 0 100%;
}
.form-group input[type="submit"]:hover {
background-color: #45a049;
}
.form-group button {
padding: 10px;
background-color: #f44336;
color: white;
border: none;
cursor: pointer;
}
.form-group button:hover {
background-color: #d32f2f;
}
126
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
table, th, td {
border: 1px solid #ddd;
}
th, td {
padding: 12px;
text-align: left;
}
th {
background-color: #4CAF50;
color: white;
}
.icon-btn.edit {
color: #4CAF50; /* Green for edit */
}
.icon-btn.delete {
color: #f44336; /* Red for delete */
}
.icon-btn:hover {
background-color: #ddd; /* Slight background color change on hover */
}
127
/* Responsive */
@media screen and (max-width: 768px) {
.form-group label {
flex: 0 0 100%;
}
.form-group input,
.form-group select {
flex: 1 0 100%;
}
}
.form-group-back button {
width: 100%;
padding: 12px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
font-size: 16px;
}
.form-group-back button:hover {
background-color: #45a049;
}
</style>
<script th:inline="javascript">
var message = [[${delMsg}]] ? [[${delMsg}]] : '';
if (message) {
Swal.fire({
title: 'Message',
text: message,
icon: 'info',
confirmButtonText: 'OK'
});
}
</script>
</head>
<body>
<div class="container">
<h1>Quiz Details</h1>
<div class="form-group-back">
<button type="button" onclick="window.location.href='/teacher/teacherMenu'">Back to
Home</button>
</div>
<table class="table table-bordered">
<thead>
<tr>
<th>S.No</th>
<th>Quiz Name</th>
<th>Teacher Name</th>
128
<th>Total Questions</th>
<th>Max Marks</th>
<th>Min Marks</th>
<th>Duration</th>
<th>Is Active</th>
<th>Created On</th>
</tr>
</thead>
<tbody>
<tr th:each="quiz,stat : ${quizzes}">
<td th:text="${stat.index + 1}"></td>
<td th:text="${quiz.quizName}"></td>
<td th:text="${quiz.teacherName}"></td>
<td th:text="${quiz.totalQuestions}"></td>
<td th:text="${quiz.maxMarks}"></td>
<td th:text="${quiz.minMarks}"></td>
<td th:text="${quiz.duration}"></td>
<td th:text="${quiz.isActive}"></td>
<td th:text="${#dates.format(quiz.transDate, 'dd-MM-yyyy')}"></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Student Wise Performance Details</title>
<!-- Add Font Awesome -->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"
integrity="sha512-Fo3rlrZj/k6qn5olB6x8aTA6TpzD4A1L/5t+fdh8j9A+T9I1KuPiCMGrxQGq+lSklcq1Td/
wWc5qWm21ClxaGA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style>
/* Basic styling */
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}
.container {
width: 100%;
max-width: 1200px;
129
margin: 20px auto;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
margin-bottom: 20px;
}
h2 {
text-align: center;
margin-bottom: 20px;
}
/* Form Group */
.form-group {
margin-bottom: 15px;
}
.form-group select {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
/* Back Button */
.form-group-back button {
width: 100%;
padding: 12px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
font-size: 16px;
transition: background-color 0.3s;
}
.form-group-back button:hover {
background-color: #45a049;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
table, th, td {
border: 1px solid #ddd;
}
130
th, td {
padding: 12px;
text-align: left;
}
th {
background-color: #4CAF50;
color: white;
}
.icon-btn.edit {
color: #4CAF50; /* Green for edit */
}
.icon-btn.delete {
color: #f44336; /* Red for delete */
}
.icon-btn:hover {
background-color: #ddd; /* Slight background color change on hover */
}
/* Responsive */
@media screen and (max-width: 768px) {
.form-group label {
flex: 0 0 100%;
}
.form-group input,
.form-group select {
flex: 1 0 100%;
131
}
}
.form-group-back button {
width: 100%;
padding: 12px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
font-size: 16px;
}
.form-group-back button:hover {
background-color: #45a049;
}
.pagination {
display: flex;
justify-content: center;
margin-top: 20px;
}
.pagination button {
padding: 10px;
margin: 0 5px;
border: none;
background-color: #4CAF50;
color: white;
cursor: pointer;
border-radius: 5px;
transition: background-color 0.3s;
}
.pagination button:disabled {
background-color: #ccc;
cursor: not-allowed;
}
.pagination span {
align-self: center;
margin: 0 10px;
}
#deleteButton {
width: 100%;
background-color: #ff4d4d; /* Red color */
color: white; /* Text color */
border: none;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
border-radius: 5px; /* Rounded corners */
transition: background-color 0.3s; /* Smooth transition */
132
}
</style>
<script>
$(document).ready(function() {
$('#studentSelect').change(function() {
var studentId = $(this).val();
// alert(studentId);
if (studentId) {
$.ajax({
url: '/teacher/topics/' + studentId,
method: 'GET',
success: function(data) {
var topicsBody = $('#topicsBody');
topicsBody.empty(); // Clear existing rows
topicsBody.append('<tr>' +
'<td>' + (index + 1) + '</td>' +
'<td>' + topic.quizName + '</td>' +
'<td>' + topic.teacherName + '</td>' +
'<td>' + topic.totalQuestions + '</td>' +
'<td>' + topic.maxMarks + '</td>' +
'<td>' + topic.minMarks + '</td>' +
'<td>' + topic.duration + '</td>' +
'<td>' + new Date(topic.playDate).toLocaleDateString('en-GB') + '</td>' +
'<td>' + new Date(topic.startTime).toLocaleTimeString('en-GB') + '</td>' +
'<td>' + new Date(topic.endTime).toLocaleTimeString('en-GB') + '</td>' +
'<td>' + topic.accuracy + '</td>' +
'<td>' + topic.result + '</td>' +
'</tr>');
});
}
});
} else {
$('#topicsBody').empty(); // Clear if no student is selected
}
});
});
$(document).ready(function() {
const rowsPerPage = 10; // Set the number of rows per page
let currentPage = 1;
let topics = []; // Store the topics fetched from the server
$('#studentSelect').change(function() {
var studentId = $(this).val();
if (studentId) {
133
$.ajax({
url: '/teacher/topics/' + studentId,
method: 'GET',
success: function(data) {
topics = data; // Store the data for pagination
renderTable(); // Render the table with the first page
}
});
} else {
$('#topicsBody').empty(); // Clear if no student is selected
}
});
function renderTable() {
const start = (currentPage - 1) * rowsPerPage;
const end = start + rowsPerPage;
const paginatedTopics = topics.slice(start, end);
updatePagination();
}
function updatePagination() {
$('#pageInfo').text(`Page ${currentPage} of ${Math.ceil(topics.length / rowsPerPage)}`);
$('#prevBtn').prop('disabled', currentPage === 1);
$('#nextBtn').prop('disabled', currentPage === Math.ceil(topics.length / rowsPerPage));
}
$('#prevBtn').click(function() {
if (currentPage > 1) {
currentPage--;
renderTable();
}
134
});
$('#nextBtn').click(function() {
if (currentPage < Math.ceil(topics.length / rowsPerPage)) {
currentPage++;
renderTable();
}
});
});
</script>
<script th:inline="javascript">
document.addEventListener("DOMContentLoaded", function() {
var message = [[${message}]] ? [[${message}]] : '';
if (message) {
Swal.fire({
title: 'Message',
text: message,
icon: 'info',
confirmButtonText: 'OK'
});
}
});
function deleteHighestScore() {
window.location.href = `/game/deleteHighestScore`;
}
</script>
</head>
<body>
<div class="container">
<h1>Student Performance Details</h1>
<div class="form-group-back">
<button type="button" onclick="window.location.href='/teacher/teacherMenu'">Back to
Home</button>
</div>
<div class="form-group">
<label></label>
</div>
<div class="form-group">
<button type="button" id="deleteButton" onclick="deleteHighestScore()">Delete Highest
Score</button>
</div>
<div class="form-group">
<label></label>
</div>
<div class="form-group">
<label for="studentSelect">Student:</label>
<select id="studentSelect" name="studentId">
135
<option th:each="student : ${students}"
th:value="${student.studentId}"
th:text="${student.studentName}"></option>
</select>
</div>
<table class="table table-bordered">
<thead>
<tr>
<th>S.No</th>
<th>Topic-Quiz Name</th>
<th>Created By</th>
<th>Questions</th>
<th>Max M.</th>
<th>Min M.</th>
<th>Minutes</th>
<th>Date</th>
<th>Start Time</th>
<th>End Time</th>
<th>Accuracy</th>
<th>Result</th>
</tr>
</thead>
<tbody id="topicsBody">
<!-- Rows will be dynamically inserted here -->
</tbody>
</table>
<div class="pagination">
<button id="prevBtn" disabled>Previous</button>
<span id="pageInfo"></span>
<button id="nextBtn">Next</button>
</div>
</div>
<!--</div>-->
</body>
</html>
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Teachers Details</title>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<!-- Add Font Awesome -->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"
integrity="sha512-Fo3rlrZj/k6qn5olB6x8aTA6TpzD4A1L/5t+fdh8j9A+T9I1KuPiCMGrxQGq+lSklcq1Td/
wWc5qWm21ClxaGA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<style>
/* Basic styling */
136
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}
.container {
width: 100%;
max-width: 1200px;
margin: 20px auto;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
margin-bottom: 20px;
}
.form-group {
display: flex;
flex-wrap: wrap;
margin-bottom: 15px;
}
.form-group label {
flex: 0 0 25%;
padding: 10px;
}
.form-group input,
.form-group select {
flex: 1;
padding: 10px;
margin-right: 10px;
}
.form-group input[type="submit"] {
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
flex: 0 0 100%;
}
.form-group input[type="submit"]:hover {
background-color: #45a049;
}
.form-group button {
137
padding: 10px;
background-color: #f44336;
color: white;
border: none;
cursor: pointer;
}
.form-group button:hover {
background-color: #d32f2f;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
table, th, td {
border: 1px solid #ddd;
}
th, td {
padding: 12px;
text-align: left;
}
th {
background-color: #4CAF50;
color: white;
}
.icon-btn.edit {
color: #4CAF50; /* Green for edit */
}
.icon-btn.delete {
color: #f44336; /* Red for delete */
}
138
.icon-btn:hover {
background-color: #ddd; /* Slight background color change on hover */
}
/* Responsive */
@media screen and (max-width: 768px) {
.form-group label {
flex: 0 0 100%;
}
.form-group input,
.form-group select {
flex: 1 0 100%;
}
}
.form-group-back button {
width: 100%;
padding: 12px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
font-size: 16px;
}
.form-group-back button:hover {
background-color: #45a049;
}
</style>
<script th:inline="javascript">
var message = [[${delMsg}]] ? [[${delMsg}]] : '';
if (message) {
Swal.fire({
title: 'Message',
text: message,
icon: 'info',
confirmButtonText: 'OK'
});
}
</script>
</head>
<body>
<div class="container">
<h1>Teachers Details</h1>
139
<div class="form-group-back">
<button type="button" onclick="window.location.href='/teacher/teacherMenu'">Back to
Home</button>
</div>
<table border="1">
<thead>
<tr>
<th>S.No</th>
<th>Surname</th>
<th>FirstName</th>
<th>Age</th>
<th>Gender</th>
<th>Email ID</th>
<th>Mobile No</th>
<th> Reg.Date </th>
<th>isActive</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr th:each="teacher, stat : ${teachers}">
<td th:text="${stat.index + 1}"></td>
<td th:text="${teacher.surName}"></td>
<td th:text="${teacher.firstName}"></td>
<td th:text="${teacher.age}"></td>
<td th:text="${teacher.gender}"></td>
<td th:text="${student.emailId}"></td>
<td th:text="${student.mobileNo}"></td>
<td th:text="${student.transDate}"></td>
<td th:text="${student.isActive} ? 'Yes' : 'No'"></td>
<td>
<a th:href="@{/students/edit/{id}(id=${teacher.teacherId})}">
<button class="icon-btn edit">
<i class="fas fa-edit"></i>
</button>
</a>
<a th:href="@{/students/delete/{id}(id=${teacher.teacherId})}" onclick="return confirm('Are
you sure?');">
<button class="icon-btn delete">
<i class="fas fa-trash"></i>
</button>
</a>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
140
HTML Template: TeacherMenu
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Teacher Home Page</title>
<link rel="stylesheet" th:href="@{/css/home.css}" />
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
.home-container {
width: 100%;
max-width: 600px;
margin: 40px auto;
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
margin-bottom: 20px;
color: #333;
}
.home-form {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 15px; /* Adding gap for consistent spacing */
}
.form-group {
flex: 1 1 48%;
margin-bottom: 15px;
}
.form-group.full-width {
flex: 1 1 100%;
}
.form-group button {
width: 100%;
padding: 12px;
141
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
font-size: 16px;
}
.form-group button:hover {
background-color: #45a049;
}
.user-name {
text-align: center;
font-size: 20px;
font-weight: bold;
color: #555;
margin-bottom: 20px;
}
/* Responsive Adjustments */
@media (max-width: 768px) {
.form-group {
flex: 1 1 100%;
margin-bottom: 10px;
}
.form-group button {
font-size: 14px;
padding: 10px;
}
}
h2 {
font-size: 24px;
}
.form-group button {
font-size: 14px;
padding: 8px;
}
}
142
}
</style>
</head>
<body>
<div class="home-container">
<form class="home-form">
<div class="user-name" th:text="'Welcome, ' + ${userName} + ' '"></div>
<div class="form-group full-width">
<h2>Main Menu</h2>
</div>
<div class="form-group">
<button type="button" onclick="window.location.href='/quizs'">Quiz Info</button>
</div>
</form>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
143
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Update Profile Details Page</title>
<link rel="stylesheet" th:href="@{/css/login.css}" />
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
.teacher-container {
width: 100%;
max-width: 600px;
margin: auto;
background-color: white;
padding: 20px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
.teacher-form {
display: flex;
flex-wrap: wrap;
}
.form-group {
flex: 0 0 48%;
margin: 10px 1%;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group select {
width: 100%;
padding: 10px;
margin-top: 5px;
border: 1px solid #ccc;
border-radius: 5px;
}
.form-group label {
display: block;
font-weight: bold;
margin-bottom: 5px;
}
.teacher-form button {
width: 100%;
padding: 15px;
144
margin-top: 20px;
background-color: #4CAF50;
border: none;
color: white;
cursor: pointer;
border-radius: 5px;
font-size: 16px;
}
.teacher-form button:hover {
background-color: #45a049;
}
.full-width {
flex: 0 0 100%;
}
h2 {
text-align: center;
width: 100%;
margin-bottom: 20px;
}
.radio-group {
display: flex;
gap: 10px;
padding: 10px 0;
}
.radio-group input {
margin-right: 5px;
}
/* Modal styles */
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
145
width: 80%;
max-width: 300px;
text-align: center;
}
.modal-content button {
padding: 10px 20px;
border: none;
background-color: #4CAF50;
color: white;
cursor: pointer;
border-radius: 5px;
}
.modal-content button:hover {
background-color: #45a049;
}
.error-message {
color: red;
}
/* Responsive Styles */
@media (max-width: 768px) {
.form-group {
flex: 0 0 100%;
margin: 10px 0;
}
.teacher-form button {
padding: 12px;
font-size: 14px;
}
.radio-group {
flex-direction: column;
align-items: flex-start;
}
}
h2 {
font-size: 24px;
}
.teacher-form button {
font-size: 14px;
}
146
.form-group input[type="text"],
.form-group input[type="password"] {
padding: 8px;
}
}
</style>
<script th:inline="javascript">
document.addEventListener("DOMContentLoaded", function() {
// General message (success or info)
var message = [[${message}]] ? [[${message}]] : '';
// Error message
var errorMsg = [[${errorMsg}]] ? [[${errorMsg}]] : '';
if (message) {
Swal.fire({
title: 'Message',
text: message,
icon: 'info',
confirmButtonText: 'OK'
});
}
if (errorMsg) {
Swal.fire({
title: 'Error',
text: errorMsg,
icon: 'error',
confirmButtonText: 'OK'
});
}
});
</script>
</head>
<body>
<div class="teacher-container">
<form class="teacher-form" th:action="@{/teacher/updateTeacherProfile}" method="post"
th:object="${updateTeacherProfileReq}">
<h2 class="full-width">Teacher Profile</h2>
<div class="form-group">
<label for="surname">Surname:</label>
<input type="text" id="surname" name="surname" th:field="*{surname}" required>
</div>
<div class="form-group">
<label for="firstName">First Name:</label>
<input type="text" id="firstName" name="firstName" th:field="*{firstName}" required>
</div>
<div class="form-group">
147
<label for="genderId">Gender:</label>
<select id="genderId" name="genderId" th:field="*{gender}" th:value="*{genderId}" required>
<option value="" disabled selected>Select grade</option>
<option th:each="gender : ${genders}" th:value="${gender.genderId}"
th:text="${gender.gender}"></option>
</select>
</div>
<div class="form-group">
<label for="mobile">Mobile:</label>
<input type="text" id="mobile" name="mobile" maxlength="10" th:field="*{mobile}" required>
</div>
<div class="form-group">
<label for="emailId">Email:</label> <input type="text" id="emailId" name="emailId"
th:field="*{emailId}" required>
</div>
<div class="form-group">
<label for="age">Age:</label>
<input type="text" id="age" name="age" maxlength="2" th:field="*{age}" required>
</div>
<div class="form-group full-width">
<button type="submit">Update</button>
</div>
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Page</title>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<link rel="stylesheet" th:href="@{/css/login.css}" />
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
148
.login-container {
width: 100%;
max-width: 400px;
margin: 40px auto;
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
margin-bottom: 20px;
color: #333;
}
.radio-group {
display: flex;
justify-content: space-around;
margin-bottom: 20px;
}
.radio-group label {
margin-right: 10px;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
.form-group input[type="text"],
.form-group input[type="password"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;
}
.form-group button {
width: 100%;
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
149
border-radius: 5px;
font-size: 16px;
}
.form-group button:hover {
background-color: #45a049;
}
/* Responsive Styles */
@media (max-width: 768px) {
.radio-group {
flex-direction: column;
align-items: flex-start;
}
.radio-group label {
margin-bottom: 10px;
}
.form-group button {
font-size: 14px;
}
}
h2 {
font-size: 24px;
}
.form-group input[type="text"],
.form-group input[type="password"] {
padding: 8px;
}
}
</style>
<script th:inline="javascript">
document.addEventListener("DOMContentLoaded", function() {
var message = [[${errorMsg}]] ? [[${errorMsg}]] : '';
if (message) {
Swal.fire({
title: 'Message',
text: message,
icon: 'info',
confirmButtonText: 'OK'
});
}
});
150
</script>
</head>
<body>
<div class="login-container">
<form class="login-form" th:action="@{/user/login}" method="post" th:object="${user}">
<h2>Login Here</h2>
<div class="radio-group">
<label><input type="radio" name="usertype" value="1" th:field="*{userTypeId}" required>
Student</label>
<label><input type="radio" name="usertype" value="3" th:field="*{userTypeId}" required>
Teacher</label>
</div>
<div class="form-group">
<label for="username">Username or Email</label>
<input type="text" id="username" name="username" th:field="*{email}" required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" name="password" th:field="*{password}" required>
</div>
<div class="form-group">
<button type="submit">Login</button>
</div>
<div class="form-group">
<button type="button" onclick="window.location.href='/user/signUp'">Sign Up</button>
</div>
</form>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registration Page</title>
<link rel="stylesheet" th:href="@{/css/login.css}" />
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
.register-container {
width: 100%;
151
max-width: 600px;
margin: auto;
background-color: white;
padding: 20px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
.register-form {
display: flex;
flex-wrap: wrap;
}
.form-group {
flex: 0 0 48%;
margin: 10px 1%;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group select {
width: 100%;
padding: 10px;
margin-top: 5px;
border: 1px solid #ccc;
border-radius: 5px;
}
.form-group label {
display: block;
font-weight: bold;
margin-bottom: 5px;
}
.register-form button {
width: 100%;
padding: 15px;
margin-top: 20px;
background-color: #4CAF50;
border: none;
color: white;
cursor: pointer;
border-radius: 5px;
font-size: 16px;
}
.register-form button:hover {
background-color: #45a049;
}
.full-width {
flex: 0 0 100%;
152
}
h2 {
text-align: center;
width: 100%;
margin-bottom: 20px;
}
.radio-group {
display: flex;
gap: 10px;
padding: 10px 0;
}
.radio-group input {
margin-right: 5px;
}
/* Modal styles */
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 300px;
text-align: center;
}
.modal-content button {
padding: 10px 20px;
border: none;
background-color: #4CAF50;
color: white;
cursor: pointer;
border-radius: 5px;
}
.modal-content button:hover {
153
background-color: #45a049;
}
.error-message {
color: red;
}
/* Responsive Styles */
@media (max-width: 768px) {
.form-group {
flex: 0 0 100%;
margin: 10px 0;
}
.register-form button {
padding: 12px;
font-size: 14px;
}
.radio-group {
flex-direction: column;
align-items: flex-start;
}
}
h2 {
font-size: 24px;
}
.register-form button {
font-size: 14px;
}
.form-group input[type="text"],
.form-group input[type="password"] {
padding: 8px;
}
}
</style>
<script th:inline="javascript">
document.addEventListener("DOMContentLoaded", function() {
// General message (success or info)
var message = [[${message}]] ? [[${message}]] : '';
// Error message
var errorMsg = [[${errorMsg}]] ? [[${errorMsg}]] : '';
154
if (message) {
Swal.fire({
title: 'Message',
text: message,
icon: 'info',
confirmButtonText: 'OK'
});
}
if (errorMsg) {
Swal.fire({
title: 'Error',
text: errorMsg,
icon: 'error',
confirmButtonText: 'OK'
});
}
});
</script>
</head>
<body>
<div class="register-container">
<form class="register-form" th:action="@{/user/signUp}" method="post"
th:object="${userSignUpReq}">
<h2 class="full-width">Sign Up Here</h2>
<div class="form-group">
<label for="surname">Surname:</label>
<input type="text" id="surname" name="surname" required>
</div>
<div class="form-group">
<label for="firstName">First Name:</label>
<input type="text" id="firstName" name="firstName" required>
</div>
<div class="form-group">
<label for="genderId">Gender:</label>
<select id="genderId" name="genderId" required>
<option value="" disabled selected>Select gender</option>
<option value="1">Male</option>
<option value="2">Female</option>
155
<option value="3">Other</option>
</select>
</div>
<div class="form-group">
<label for="mobile">Mobile:</label>
<input type="text" id="mobile" name="mobile" maxlength="10" required>
</div>
<div class="form-group full-width">
<label for="email">Email:</label>
<input type="text" id="email" name="email" required>
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
</div>
<div class="form-group">
<label for="confirmpassword">Confirm Password:</label>
<input type="password" id="confirmpassword" name="confirmpassword" required>
</div>
CSS: Login
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.login-container {
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
156
.login-form {
max-width: 300px;
margin: 0 auto;
}
.login-form h2 {
text-align: center;
margin-bottom: 20px;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
font-weight: bold;
margin-bottom: 5px;
}
.form-group input {
width: 100%;
padding: 8px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 4px;
}
button[type="submit"] {
width: 100%;
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
button[type="submit"]:hover {
background-color: #45a049;
}
button[type="button"] {
width: 100%;
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
157
}
button[type="button"]:hover {
background-color: #45a049;
}
CSS: Styles
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;}
form {
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 800px;
display: flex;
flex-direction: column;
align-items: center;}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
width: 50%;
text-align: left;}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"] {
width: 50%;
padding: 8px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;}
input[type="radio"],
input[type="checkbox"] {
margin-right: 5px;}
.radio-group {
display: flex;
justify-content: space-between;
width: 50%;
margin-bottom: 10px;}
button {
background-color: #4CAF50;
color: white;
158
border: none;
padding: 10px;
border-radius: 5px;
cursor: pointer;
width: 50%;
margin-bottom: 10px;}
button:hover {
background-color: #45a049;}
button[type="button"] {
background-color: #008CBA;}
button[type="button"]:hover {
background-color: #007bb5;}
p{
color: green;
font-weight: bold;}
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.4);}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 300px;
text-align: center;}
.modal-content button {
padding: 10px 20px;
border: none;
background-color: #4CAF50;
color: white;
cursor: pointer;
border-radius: 5px;}
.modal-content button:hover {
background-color: #45a049;}
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;}
.login-container {
width: 100%;
max-width: 400px;
margin: 40px auto;
159
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);}
h2 {
text-align: center;
margin-bottom: 20px;
color: #333;}
.radio-group {
display: flex;
justify-content: space-around;
margin-bottom: 20px;}
.radio-group label {
margin-right: 10px;}
.form-group {
margin-bottom: 15px;}
.form-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;}
.form-group input[type="text"],
.form-group input[type="password"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;}
.form-group button {
width: 100%;
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
font-size: 16px;}
.form-group button:hover {
background-color: #45a049;}
.radio-group label {
margin-bottom: 10px;}
.form-group button {
font-size: 14px;}
h2 {
font-size: 24px;}
.form-group input[type="text"],
.form-group input[type="password"] {
padding: 8px;}
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;}
160
.login-container {
width: 100%;
max-width: 600px;
margin: auto;
background-color: white;
padding: 20px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
border-radius: 8px;}
.register-form {
display: flex;
flex-wrap: wrap;}
.form-group {
flex: 0 0 48%;
margin: 10px 1%;}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group select {
width: 100%;
padding: 10px;
margin-top: 5px;
border: 1px solid #ccc;
border-radius: 5px;}
.form-group label {
display: block;
font-weight: bold;
margin-bottom: 5px;}
.register-form button {
width: 100%;
padding: 15px;
margin-top: 20px;
background-color: #4CAF50;
border: none;
color: white;
cursor: pointer;
border-radius: 5px;
font-size: 16px;}
.register-form button:hover {
background-color: #45a049;}
.full-width {
flex: 0 0 100%;}
h2 {
text-align: center;
width: 100%;
margin-bottom: 20px;}
.radio-group {
display: flex;
gap: 10px;
padding: 10px 0;}
.radio-group input {
margin-right: 5px;}
.modal {
display: none;
161
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.4);}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 300px;
text-align: center;}
.modal-content button {
padding: 10px 20px;
border: none;
background-color: #4CAF50;
color: white;
cursor: pointer;
border-radius: 5px;}
.modal-content button:hover {
background-color: #45a049;}
.error-message {
color: red;}
.register-form button {
padding: 12px;
font-size: 14px;}
.radio-group {
flex-direction: column;
align-items: flex-start;}
.register-form button {
font-size: 14px;}
.login-container {
width: 100%;
max-width: 600px;
margin: 40px auto;
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);}
.home-form {
display: flex;
flex-wrap: wrap;
justify-content: space-between;}
.form-group {
width: 48%;
margin-bottom: 15px;}
.full-width {
162
width: 100%;}
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;}
.container {
width: 100%;
max-width: 1200px;
margin: 20px auto;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);}
h2 {
text-align: center;
margin-bottom: 20px;}
.form-group {
display: flex;
flex-wrap: wrap;
margin-bottom: 15px;}
.form-group label {
flex: 0 0 25%;
padding: 10px;}
.form-group input,
.form-group select {
flex: 1;
padding: 10px;
margin-right: 10px;}
.form-group input[type="submit"] {
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
flex: 0 0 100%;}
.form-group input[type="submit"]:hover {
background-color: #45a049;}
.form-group-back button {
width: 100%;
padding: 12px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
font-size: 16px;}
.form-group-back button:hover {
background-color: #45a049;}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;}
table, th, td {
163
border: 1px solid #ddd;}
th, td {
padding: 12px;
text-align: left;}
th {
background-color: #4CAF50;
color: white;}
.icon-btn {
background-color: #f0f0f0;
border: 1px solid #ccc;
border-radius: 5px;
padding: 8px;
margin: 0 5px;
cursor: pointer;
font-size: 18px;
display: inline-block;
color: #333;
transition: background-color 0.3s ease;}
.icon-btn.edit {
color: #4CAF50;
.icon-btn.delete {
color: #f44336;
.icon-btn:hover {
background-color: #ddd;
.hidden-column {
font-size: 10px;
visibility: hidden;}
.form-group input,
.form-group select {
flex: 1 0 100%;}
.home-container {
width: 100%;
max-width: 600px;
margin: 40px auto;
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);}
.home-form {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 15px; /* Adding gap for consistent spacing */}
.form-group {
flex: 1 1 48%;
margin-bottom: 15px;}
.form-group.full-width {
flex: 1 1 100%;}
.form-group button {
width: 100%;
padding: 12px;
background-color: #4CAF50;
164
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
font-size: 16px;}
.user-name {
text-align: center;
font-size: 20px;
font-weight: bold;
color: #555;
margin-bottom: 20px;}
.form-group button {
font-size: 14px;
padding: 10px;}
.form-group button {
padding: 10px;
background-color: #f44336;
color: white;
border: none;
cursor: pointer;}
.form-group button:hover {
background-color: #d32f2f;}
h1 {
text-align: center;
margin-bottom: 20px;}
.form-group select {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;}
.form-group-back button {
width: 100%;
padding: 12px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
font-size: 16px;
transition: background-color 0.3s;}
.pagination {
display: flex;
justify-content: center;
margin-top: 20px;}
.pagination button {
padding: 10px;
margin: 0 5px;
border: none;
background-color: #4CAF50;
color: white;
cursor: pointer;
border-radius: 5px;
165
transition: background-color 0.3s;}
.pagination button:disabled {
background-color: #ccc;
cursor: not-allowed;}
.pagination span {
align-self: center;
margin: 0 10px;}
.container {
max-width: 1200px;
margin: 20px auto;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);}
th, td {
padding: 12px;
text-align: left;
border: 1px solid #ddd;}
.form-group-back button {
font-size: 14px;
padding: 10px;}
.pagination {
margin-top: 20px;
text-align: center;
display: flex;
justify-content: center;
align-items: center;}
.pagination a, .pagination span {
color: white;
padding: 10px 20px;
text-decoration: none;
margin: 0 5px;
border: 1px solid #4CAF50;
background-color: #4CAF50;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;}
.pagination a.disabled {
background-color: #ddd;
color: #888;
cursor: not-allowed;}
.pagination span {
background-color: #4CAF50;
cursor: default;}
.pagination a:hover:not(.disabled) {
background-color: #45a049;}
.form-group input[type="text"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;}
.container {
166
width: 100%;
max-width: 500px;
margin: 40px auto;
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);}
.form-group select {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;}
.form-group select {
padding: 8px;}
#playButton:disabled {
background-color: #ccc; /* Gray color for disabled state */
color: #666; /* Faded text color */
cursor: not-allowed; /* Change cursor to indicate it's not clickable */}
#playButton {
background-color: #007bff; /* Primary color */
color: white; /* Text color */
border: none;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
border-radius: 5px; /* Rounded corners */
transition: background-color 0.3s; /* Smooth transition */}
#playButton:hover:not(:disabled) {
background-color: #0056b3; /* Darker shade on hover */}
@media screen and (max-width: 768px) {
th, td {
font-size: 14px;
padding: 8px;}
@media (max-width: 480px) {
.home-container {
padding: 15px;}
.form-group button {
font-size: 14px;
padding: 8px;}
@media (max-width: 360px) {
.form-group button {
font-size: 12px;
padding: 6px;}
@media (max-width: 768px) {
.form-group {
width: 100%;
margin-bottom: 10px;}
@media (max-width: 768px) {
.radio-group {
flex-direction: column;
align-items: flex-start;}
167
@media (max-width: 480px) {
.login-container {
padding: 15px;
margin-top: 20px;}
@media (max-width: 768px) {
.form-group {
flex: 0 0 100%;
margin: 10px 0;}
@media (max-width: 480px) {
.login-container {
padding: 15px;}
@media screen and (max-width: 768px) {
.form-group label {
flex: 0 0 100%;}
@media (max-width: 768px) {
.form-group {
flex: 1 1 100%;
margin-bottom: 10px;}
@media (max-width: 768px) {
.form-group button {
font-size: 14px;}
@media (max-width: 480px) {
.container {
padding: 15px;
margin-top: 20px;}
JS: Validation
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("form");
const password = document.querySelector("input[name='password']");
const reenterPassword = document.querySelector("input[name='reenterPassword']");
const errorMessage = document.createElement("p");
errorMessage.style.color = "red";
form.addEventListener("submit", function(event) {
if (password.value !== reenterPassword.value) {
errorMessage.textContent = "Passwords do not match";
form.insertBefore(errorMessage, form.querySelector("button[type='submit']"));
event.preventDefault();
} else if (!/^(?=.*[0-9])(?=.*[!@#$%^&*]).{8,}$/.test(password.value)) {
errorMessage.textContent = "Password must be at least 8 characters long, contain at least one
numeric and one special character";
form.insertBefore(errorMessage, form.querySelector("button[type='submit']"));
event.preventDefault();
} else {
errorMessage.textContent = "";
}
});
});
JS: Common
168
var message = [[${delMsg}]] ? [[${delMsg}]] : '';
if (message) {
Swal.fire({
title: 'Message',
text: message,
icon: 'info',
confirmButtonText: 'OK'
});
}
document.addEventListener("DOMContentLoaded", function() {
var message = [[${delMsg}]] ? [[${delMsg}]] : '';
if (message) {
Swal.fire({
title: 'Message',
text: message,
icon: 'info',
confirmButtonText: 'OK'
});
}
});
$(document).ready(function() {
$('#topicName').change(function() {
var topicId = $(this).val();
if (topicId) {
$.ajax({
url: '/game/quizzes/' + topicId,
method: 'GET',
success: function(data) {
var quizList = $('#quizList');
quizList.empty(); // Clear existing options
quizList.append('<option value="" disabled selected>Select Quiz</option>'); // Add
default option
169
const quizSelect = document.getElementById('quizList');
const playButton = document.getElementById('playButton');
function playGame() {
const quizSelect = document.getElementById('quizList');
const selectedQuizId = quizSelect.value;
USE [FBG]
GO
/****** Object: StoredProcedure [dbo].[ImpQueries] Script Date: 11/30/2024 8:16:49 PM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROC [dbo].[ImpQueries]
AS
BEGIN
SELECT * FROM DifficultyLevel
SELECT * FROM ErrorLog
SELECT * FROM GenderMaster
SELECT * FROM GradeMaster
SELECT * FROM LoginHistory
SELECT * FROM QuestionSet
SELECT QuizId,count(*) FROM QuestionSet GROUP BY QuizId ORDER BY QuizId
SELECT * FROM QuestionSet WHERE QuizID IN (15)--7>>11,9>>9,15>>>8
--UPDATE QuestionSet SET UserId=1
SELECT * FROM Quiz
--UPDATE Quiz SET UserId=1
SELECT * FROM Student
SELECT * FROM StudentPerformanceDetails
SELECT * FROM Teacher
SELECT * FROM TopicDetails
SELECT * FROM UserDetails
SELECT * FROM UserType
170
SELECT * FROM QuestionSet WHERE QuizID IN (15)--7>>11,9>>9,15>>>8
USE [FBG]
GO
/****** Object: StoredProcedure [dbo].[LoginInfo] Script Date: 11/30/2024 8:17:58 PM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROC [dbo].[LoginInfo]
@IMode char (3),
@IUserId INT = NULL,
@IUserTypeId INT = NULL,
@ILoginId VARCHAR(50) = NULL,
@IPwd VARCHAR(50) = NULL,
@IIPAddress VARCHAR(15) = NULL,
@StrResult VARCHAR(150)= 'ERROR' OUTPUT
AS
BEGIN
SET NOCOUNT ON
IF @IMode='LOG'---Login User
BEGIN
IF EXISTS(SELECT LoginId from UserDetails where LoginId= @ILoginId and
Deactive=1 AND UserTypeId=@IUserTypeId)
BEGIN
SET @StrResult= 'User is inactive, please contact your administrator!'
RETURN
END
171
IF NOT EXISTS(SELECT LoginId from UserDetails where LoginId= @ILoginId AND
UserTypeId=@IUserTypeId)
BEGIN
SET @StrResult= 'Invalid Login Id, please try again!'
RETURN
END
BEGIN TRY
BEGIN TRANSACTION
Update UserDetails SET
LoginDate=getDate(),
IPAddress=@IIPAddress,
CNT=0,
Deactive=0,
DACTIVE_TIME=NULL
where LoginId=@ILoginId AND UserTypeId=@IUserTypeId
172
IF @IMode='LUN' --GET login UserName
BEGIN
--SELECT A.FirstName +' ('+B.UserTypeName+')' AS UserName
SELECT A.FirstName AS UserName
from UserDetails A
--INNER JOIN UserType B ON B.UserTypeId=A.UserTypeId
WHERE A.LoginId=@ILoginId AND A.UserTypeId=@IUserTypeId AND
Deactive=0
END
IF @IMode='HIS' --Login History
BEGIN
SELECT TOP 20 B.FirstName,A.LoginId, A.Password, C.UserTypeName,
A.LoginDate, A.LogoutDate, ISNULL(A.totalDuration,0) AS totalDuration --, Success ,
IPAddress
FROM LoginHistory A
INNER JOIN UserDetails B on B.UserTypeId=A.UserTypeId AND
B.UserId =A.UserId
INNER JOIN UserType C on C.UserTypeId=A.UserTypeId
WHERE A.UserId=@IUserId
ORDER BY A.LoginHistoryId DESC
END
IF @IMode='UPD' --Change Password
BEGIN
IF EXISTS(SELECT LoginId from UserDetails where LoginId= @ILoginId and
Deactive=1)
BEGIN
SET @StrResult= 'User is inactive, please contact your administrator!'
RETURN
END
IF @IPwd=@MyPwd
BEGIN
SET @StrResult= 'New Password and Old Password must not be
same'
RETURN
END
IF LEN(@IPwd) < 8
BEGIN
SET @StrResult= 'Password must be at least 8 character long'
173
RETURN
END
UPDATE UserDetails SET Pwd = @IPwd,ChangePasswordDate=GETDATE()
where LoginId=@ILoginId AND Deactive=0
SET @StrResult= 'SUCCESS'
END
IF @IMode='OUT' ---LogOut
BEGIN
UPDATE LoginHistory SET LogoutDate= getDate(),totalDuration =
DATEDIFF(mi,LoginDate,getDate()) WHERE UserId= RTRIM(LTRIM(@IUserId)) AND
UserTypeId =@IUserTypeId and LogoutDate is NULL
and LoginHistoryId=(SELECT MAX(LoginHistoryId) from LoginHistory
where UserId= RTRIM(LTRIM(@IUserId)) AND UserTypeId =@IUserTypeId)
SET @StrResult = 'SUCCESS'
END
END
USE [FBG]
GO
/****** Object: StoredProcedure [dbo].[PlayGame] Script Date: 11/30/2024 8:19:15 PM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[PlayGame]
(
@Mode CHAR(3) = NULL,
@IQuizId INT = NULL,
@ICorrectAnsINT = NULL,
@IUserId INT = NULL,
@IIPAddress VARCHAR(15) = NULL,
@StrResult VARCHAR(150)= 'ERROR' OUTPUT
)
AS BEGIN
DECLARE @MyStudentId AS INT=0
if (@Mode= 'INS') ---Start Game
BEGIN
if exists(select UserId from UserDetails where UserId= @IUserId And UserTypeId=3)
BEGIN
SET @StrResult='Teacher are not allowed to play game'
RETURN
END
174
if exists(select UserId from UserDetails where UserId= @IUserId And UserTypeId=1
AND Deactive=1)
BEGIN
SET @StrResult='User Deactivated not allowed to play game'
RETURN
END
SELECT @MyStudentId=StudentId FROM Student WHERE UserId= @IUserId
175
DECLARE @MyAccuracy AS VARCHAR(10)='N/A'
SET @MyAccuracy= CAST(@ICorrectAns AS
VARCHAR)+'/'+CAST(@MyTotalQuestions AS VARCHAR)
SELECT @MyStudentId=StudentId FROM Student WHERE UserId= @IUserId
BEGIN TRY
BEGIN TRANSACTION
UPDATE StudentPerformanceDetails SET
Accuracy=@MyAccuracy,
Result=@MyResult,
EndTime=GETDATE(),
TotalDuration=DATEDIFF(mi,StartTime,getDate()) ,
isTrophy=CASE WHEN @ICorrectAns>=8
THEN 'Y' ELSE 'N'END,
isCertificate=CASE WHEN
@ICorrectAns=@MyTotalQuestions THEN 'Y' ELSE 'N'END
WHERE StudentId=@MyStudentId AND
QuizId= @IQuizId AND UserId =@IUserId AND EndTime IS NULL
AND PId=(SELECT MAX(PId) FROM
StudentPerformanceDetails WHERE StudentId=@MyStudentId AND QuizId=@IQuizId AND
UserId =@IUserId)
DECLARE @MyTotTrophy AS INT=0
DECLARE @MyTotCertificate AS INT=0
SELECT @MyTotTrophy =
COUNT(Pid) FROM StudentPerformanceDetails WHERE StudentId=@MyStudentId AND
isTrophy='Y'
SELECT @MyTotCertificate =
COUNT(Pid) FROM StudentPerformanceDetails WHERE StudentId=@MyStudentId AND
isCertificate='Y'
UPDATE Student SET
TotalTrophies=@MyTotTrophy,TotalCertificates=@MyTotCertificate WHERE
StudentId=@MyStudentId
SET @StrResult= 'SUCCESS'
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
RETURN ERROR_MESSAGE()
END CATCH
END
END
176
Stored Procedure: QuestionInfo
USE [FBG]
GO
/****** Object: StoredProcedure [dbo].[QuestionInfo] Script Date: 11/30/2024 8:19:38 PM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROC [dbo].[QuestionInfo]
(
@IMode CHAR(3),
@IQuizId INT = NULL,
@IQuestionId INT = NULL,
@IQuestionDescription VARCHAR(MAX) = NULL,
@IQuestionHint VARCHAR(50) = NULL,
@IOptionA VARCHAR(20) = NULL,
@IOptionB VARCHAR(20) = NULL,
@IOptionC VARCHAR(20) = NULL,
@IOptionD VARCHAR(20) = NULL,
@IOptionE VARCHAR(20) = NULL,
@IAnswer CHAR(1) = NULL,
@IisActive BIT = NULL,
@IIPAddress VARCHAR(15) = NULL,
@IUserId INT = NULL,
@StrResult VARCHAR(150)= 'ERROR' OUTPUT
)
AS BEGIN
SET NOCOUNT ON
DECLARE @MyMaxMarks AS INT=0
DECLARE @MyMinMarks AS INT=0
DECLARE @MyDuration AS INT=0
DECLARE @MyCnt AS INT=0
IF @IMode='DD2'
BEGIN
SELECT A.QuizId, A.QuizName+' : Created By '+B.FirstName +' ,Total No
Questions '+CAST(A.TotalQuestions AS VARCHAR) +' ,Max Marks '+CAST(A.MaxMarks AS
VARCHAR)+' ,Duration '+CAST(A.Duration AS VARCHAR)+' Seconds/Question ' AS
QuizName
FROM Quiz A
INNER JOIN Teacher B ON B.TeacherId=A.TeacherId
177
WHERE A.isActive=1 --AND A.UserId=@IUserId
END
IF @IMode='DD3' --List of Difficulty levels
BEGIN
SELECT LevelId, LevelName FROM DifficultyLevel WHERE isActive=1
END
178
IF @MyCnt >=10
BEGIN
SET @StrResult= 'Max 10 Question Allowed in a Quiz!'
RETURN
END
BEGIN TRY
BEGIN TRANSACTION
INSERT INTO QuestionSet(QuizId, questionDescription, questionHint,
optionA, optionB, optionC, optionD, optionE, Answer, isActive, IPAddress, TransDate,
UserId)
VALUES(@IQuizId,@IquestionDescription,
@IquestionHint, @IoptionA,@IoptionB, @IoptionC, @IoptionD, @IoptionE, @IAnswer,
@IisActive,
@IIPaddress, GETDATE(), @IUserId)
SET @StrResult= 'SUCCESS'
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
RETURN ERROR_MESSAGE()
END CATCH
END
IF @IMode= 'UPD'
BEGIN
IF exists(SELECT QuestionId FROM QuestionSet WHERE QuizId=@IQuizId
AND QuestionId<>@IQuestionId AND questionDescription=@IquestionDescription)
BEGIN
SET @StrResult= 'Question already exists in this Quiz, please choose
a different name!'
RETURN
END
179
optionB=@IoptionB,
optionC=@IoptionC,
optionD=@IoptionD,
optionE=@IoptionE,
Answer=@IAnswer,
isActive=@IisActive
WHERE QuizId=@IQuizId AND QuestionId=@IQuestionId
SET @StrResult= 'SUCCESS'
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
RETURN ERROR_MESSAGE()
END CATCH
END
IF @IMode='DAC'
BEGIN
IF EXISTS(SELECT QuizId FROM StudentPerformanceDetails WHERE
QuizId=@IQuizId)
BEGIN
SET @StrResult='You cannot delete the Question because it is
already in process!'
RETURN
END
BEGIN TRY
BEGIN TRANSACTION
UPDATE QuestionSet SET isActive=0 WHERE QuizId=@IQuizId AND
QuestionId=@IQuestionId AND isActive=1
SET @StrResult= 'SUCCESS'
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
RETURN ERROR_MESSAGE()
END CATCH
END
END
USE [FBG]
GO
/****** Object: StoredProcedure [dbo].[QuizInfo] Script Date: 11/30/2024 8:20:11 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
180
GO
ALTER PROC [dbo].[QuizInfo]
(
@Mode CHAR(3),
@IQuizId INT = NULL,
@IQuizName VARCHAR(50) = NULL,
@ITeacherId INT = NULL,
@ITopicId INT = NULL,
@ILevelId INT = NULL,
@ITotalQuestions INT = NULL,
@IisActive BIT = NULL,
@IIPaddress VARCHAR(15) = NULL,
@IUserId INT = NULL,
@StrResult VARCHAR(150)= 'ERROR' OUTPUT
)
AS BEGIN
SET NOCOUNT ON
DECLARE @MyMaxMarks AS INT=0
DECLARE @MyMinMarks AS INT=0
DECLARE @MyDuration AS INT=0
IF @Mode='DD1' --List of topics
BEGIN
SELECT TopicId, TopicName FROM TopicDetails WHERE isActive=1
END
181
--END
IF @Mode='DG1'
BEGIN
SELECT A.QuizId , A.QuizName, B.FirstName + ' '+ B.Surname AS
TeacherName, C.TopicName, D.LevelName, A.TotalQuestions, A.MaxMarks, A.MinMarks,
A.Duration, A.isActive,
A.IPAddress, A.TransDate , A.UserId FROM Quiz A
INNER JOIN Teacher B ON B.TeacherId= A.TeacherId
INNER JOIN TopicDetails C ON C.TopicId= A.TopicId
INNER JOIN DifficultyLevel D ON D.LevelId= A.LevelId
END
IF @Mode= 'INS'
BEGIN
IF exists(SELECT QuizId FROM Quiz WHERE QuizName=@IQuizName)
BEGIN
SET @StrResult= 'Quiz Name already exists, please choose a
different name!'
RETURN
END
IF @ILevelId=1
BEGIN
SET @MyMaxMarks=@ITotalQuestions*1
SET @MyMinMarks=@ITotalQuestions*0.8
SET @MyDuration=@ITotalQuestions*0.5
END
IF @ILevelId=2
BEGIN
SET @MyMaxMarks=@ITotalQuestions*2
SET @MyMinMarks=@ITotalQuestions*0.8
SET @MyDuration=@ITotalQuestions*1.5
END
IF @ILevelId=3
BEGIN
SET @MyMaxMarks=@ITotalQuestions*3
SET @MyMinMarks=@ITotalQuestions*0.8
SET @MyDuration=@ITotalQuestions*3
END
BEGIN TRY
BEGIN TRANSACTION
INSERT INTO Quiz(QuizName, TeacherId, TopicId, LevelId, TotalQuestions,
MaxMarks, MinMarks, Duration, isActive,
IPAddress, TransDate, UserId)
VALUES(@IQuizName, @ITeacherId, @ITopicId,
@ILevelId, @ITotalQuestions, @MyMaxMarks, @MyMinMarks, @MyDuration, @IisActive,
@IIPaddress, GETDATE(), @IUserId)
182
SET @StrResult= 'SUCCESS'
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
RETURN ERROR_MESSAGE()
END CATCH
END
IF @Mode= 'UPD'
BEGIN
IF Exists(SELECT QuizId FROM Quiz WHERE QuizId!=@IQuizId and
QuizName=@IQuizName)
BEGIN
SET @StrResult='Quiz already exists with this name!'
RETURN
END
183
LevelId=@ILevelId,
TotalQuestions=@ITotalQuestions,
MaxMarks=@MyMaxMarks,
MinMarks=@MyMinMarks,
Duration=@MyDuration,
isActive=@IisActive
WHERE QuizId=@IQuizId
SET @StrResult= 'SUCCESS'
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
RETURN ERROR_MESSAGE()
END CATCH
END
IF @Mode='DAC'
BEGIN
IF EXISTS(SELECT QuizId FROM StudentPerformanceDetails WHERE
QuizId=@IQuizId)
BEGIN
SET @StrResult='You cannot delete the quiz because it is already in
process!'
RETURN
END
BEGIN TRY
BEGIN TRANSACTION
UPDATE Quiz SET isActive=0 WHERE QuizId=@IQuizId and
isActive=1
SET @StrResult= 'SUCCESS'
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
RETURN ERROR_MESSAGE()
END CATCH
END
END
USE [FBG]
GO
/****** Object: StoredProcedure [dbo].[SignUpInfo] Script Date: 11/30/2024 8:20:56 PM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
184
GO
ALTER proc [dbo].[SignUpInfo]
(
@IMode CHAR(3) = NULL,
@IUserTypeIdINT = NULL,
@ISurname VARCHAR(50) = NULL,
@IFirstName VARCHAR(50) = NULL,
@IGenderId VARCHAR(10) = NULL,
@IMobileNo VARCHAR(10) = NULL,
@IEmailId VARCHAR(50) = NULL,
@IPwd VARCHAR(50) = NULL,
@IIPAddress VARCHAR(15) = NULL,
@StrResult VARCHAR(150)= 'ERROR' OUTPUT
)
AS BEGIN
DECLARE @MyCnt INT= 0
185
DECLARE @MYUserId AS BIGINT
SET @MYUserId=@@IDENTITY
IF @IUserTypeId=1--Student
BEGIN
INSERT INTO Student(Surname, firstName, Age, GenderId,
GradeId, EmailId, MobileNo, totalTrophies, totalCertificates, isActive, IPAddress, TransDate,
UserId)
values(@ISurname, @IFirstName, 0,
@IGenderId, 0, @IEmailId, @IMobileNo, 0, 0, 1, @IIPAddress, GETDATE(), @MYUserId)
END
IF @IUserTypeId=3--Teacher
BEGIN
INSERT INTO Teacher(Surname, firstName, Age, GenderId,
EmailId, MobileNo, isActive, IPAddress, TransDate, UserId)
values(@ISurname, @IFirstName, 0,
@IGenderId, @IEmailId, @IMobileNo, 1, @IIPAddress, getDate(), @MYUserId)
END
SET @StrResult = 'SUCCESS'
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
RETURN ERROR_MESSAGE()
END CATCH
END
END
USE [FBG]
GO
/****** Object: StoredProcedure [dbo].[StudentInfo] Script Date: 11/30/2024 8:21:18 PM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[StudentInfo]
(
@Mode CHAR(3) = NULL,
@IStudentId INT = NULL,
@ISurname VARCHAR(50) = NULL,
@IfirstName VARCHAR(50) = NULL,
@IPwd VARCHAR(50) = NULL,
@IAge INT = NULL,
186
@IGenderId INT = NULL,
@IGradeId INT = NULL,
@IEmailId VARCHAR(50) = NULL,
@IMobileNo VARCHAR(10) = NULL,
@ITotalTrophies INT = NULL,
@ItotalCertificates INT = NULL,
@IisActive BIT = NULL,
@IIPAddress VARCHAR(15) = NULL,
@IUserId INT = NULL,
@StrResult VARCHAR(150)= 'ERROR' OUTPUT
)
AS BEGIN
DECLARE @MyCnt INT= 0
IF @Mode='DD1'--Grade
BEGIN
SELECT gradeid,grade,isActive FROM GradeMaster WHERE IsActive=1 ORDER
BY GradeId
END
IF @Mode='DD2'--Gender
BEGIN
SELECT GenderId,Gender,isActive FROM GenderMaster WHERE IsActive=1
ORDER BY GenderId
END
IF @Mode='DD3'--Student List
BEGIN
SELECT A.UserId AS studentId,A.FirstName+' '+A.Surname+'
('+B.Gender+')'+' Grade :'+CAST(ISNULL(A.GradeId,-1) AS VARCHAR)+' ,Email
Id:'+A.EmailId+' ,Mobile No:'+A.MobileNo AS studentName
FROM Student A
INNER JOIN GenderMaster B ON B.GenderId = A.GenderId
WHERE A.IsActive=1 ORDER BY StudentId
END
IF (@Mode= 'GET')--BIND Student Details
BEGIN
select surname, firstName,A.GenderId, B.gender, emailID,mobileNo,ISNULL(age,0)
AS age,ISNULL(A.gradeId,0) AS gradeId, C.grade,userId
FROM Student A
INNER JOIN GenderMaster B ON B.GenderId =A.GenderId
LEFT OUTER JOIN GradeMaster C ON C.GradeId =A.GradeId
WHERE UserId=@IUserId
END
IF (@Mode= 'DG1')--BIND Students Details
BEGIN
select studentId, surname, firstName,A.gradeId, B.grade, emailID, age,A.GenderId,
C.gender, mobileNo, totalTrophies, totalCertificates, ipAddress, transDate,A.isActive,userId
from Student A
INNER JOIN GradeMaster B ON B.GradeId =A.GradeId
187
INNER JOIN GenderMaster C ON C.GenderId =A.GenderId
order by StudentId desc
END
IF @Mode='ACH'--Achievements
BEGIN
SELECT TotalTrophies,TotalCertificates from Student WHERE UserId
=@IUserId
END
if (@Mode= 'UPD')
BEGIN
if exists(select StudentId from Student where StudentId!=@IStudentId and MobileNo
= @IMobileNo)
BEGIN
SET @StrResult='Student already exists with this mobile number.'
RETURN
END
BEGIN TRY
BEGIN TRANSACTION
UPDATE Student SET
Surname= @ISurname,
firstName=@IfirstName,
GenderId=@IGenderId,
MobileNo= @IMobileNo,
Age = @IAge
where UserId=@IUserId
SET @StrResult='SUCCESS'
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
RETURN ERROR_MESSAGE()
END CATCH
END
if (@Mode= 'DAC')
BEGIN
BEGIN TRY
BEGIN TRANSACTION
UPDATE Student SET
isActive=0
where StudentId=@IStudentId
SET @StrResult='SUCCESS'
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
188
RETURN ERROR_MESSAGE()
END CATCH
END
END
USE [FBG]
GO
/****** Object: StoredProcedure [dbo].[TeacherInfo] Script Date: 11/30/2024 8:21:29 PM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[TeacherInfo]
(
@Mode CHAR(3) = NULL,
@ITeacherId INT = NULL,
@ISurname VARCHAR(50) = NULL,
@IFirstName VARCHAR(50) = NULL,
@IPwd VARCHAR(50) = NULL,
@IAge INT = NULL,
@IGenderId VARCHAR(10) = NULL,
@IEmailId VARCHAR(50) = NULL,
@IMobileNo VARCHAR(10) = NULL,
@IisActive BIT = NULL,
@IIPAddress VARCHAR(15) = NULL,
@IUserId INT = NULL,
@StrResult VARCHAR(150)= 'ERROR' OUTPUT
)
AS BEGIN
DECLARE @MyCnt INT= 0
IF (@Mode= 'DG1') --Bind Teachers Details
BEGIN
select A.TeacherId, A.Surname, A.firstName,A.GenderId ,B.Gender, A.Age,
A.emailID, A.MobileNo, A.isActive, A.IPAddress, A.TransDate, A.UserId
from Teacher A
INNER JOIN GenderMaster B ON B.GenderId =A.GenderId
order by TeacherId desc
END
IF (@Mode= 'GET')--Bind Teacher Details
BEGIN
select surname, firstName,A.GenderId, B.gender, emailID, mobileNo, age,userId
from Teacher A
INNER JOIN GenderMaster B ON B.GenderId =A.GenderId
where UserId=@IUserId
END
189
if (@Mode= 'UPD')--Update Teacher Details
BEGIN
if exists(select TeacherId from Teacher where TeacherId!=@ITeacherId and
MobileNo= @IMobileNo or emailId= @IEmailId)
BEGIN
SET @StrResult='Teacher already exists with this mobile number or email.'
RETURN
END
BEGIN TRY
BEGIN TRANSACTION
UPDATE Teacher SET
Surname= @ISurname,
firstName=@IfirstName,
GenderId=@IGenderId,
MobileNo= @IMobileNo,
Age = @IAge
where UserId=@IUserId
SET @StrResult= 'SUCCESS'
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
RETURN ERROR_MESSAGE()
END CATCH
END
USE [FBG]
GO
190
/****** Object: StoredProcedure [dbo].[TopicInfo] Script Date: 11/30/2024 8:21:48 PM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[TopicInfo]
(
@Mode CHAR(3) = NULL,
@ITopicId INT = NULL,
@ITopicName VARCHAR(20) = NULL,
@IisActive INT = NULL,
@IUserId INT = NULL,
@StrResult VARCHAR(150)= 'ERROR' OUTPUT
)
AS BEGIN
DECLARE @MyCnt INT= 0
191
INNER JOIN Quiz B
ON B.TopicId = A.TopicId
INNER JOIN Teacher C ON
C.TeacherId = B.TeacherId
WHERE B.QuizId NOT IN (SELECT QuizId FROM StudentPerformanceDetails
WHERE UserID = @IUserId)
END
ELSE
BEGIN
select A.TopicName,B.QuizName,C.FirstName+' '+C.Surname AS
TeacherName,B.TotalQuestions,B.MaxMarks,B.MinMarks,(B.Duration*B.TotalQuestions)/60
AS Duration,CAST('1900-01-01' AS DATE) AS PlayDate,CAST('00:00:00'AS DATE) AS
StartTime,CAST('00:00:00'AS DATE) AS EndTime,NULL AS Score,'Pending' AS Result
from TopicDetails A
INNER JOIN Quiz B
ON B.TopicId = A.TopicId
INNER JOIN Teacher C ON
C.TeacherId = B.TeacherId
--LEFT OUTER JOIN StudentPerformanceDetails D ON D.QuizId
= B.QuizId
order by A.TopicId asc
END
END
IF (@Mode= 'DG1')
BEGIN
select TopicId, TopicName, isActive, UserId from TopicDetails order by TopicId desc
END
192
if (@Mode= 'INS')
BEGIN
if exists(select TopicId from TopicDetails where TopicName= @ITopicName)
BEGIN
SET @StrResult='Topic already exists.'
RETURN
END
BEGIN TRY
BEGIN TRANSACTION
INSERT INTO TopicDetails(TopicName, isActive, TransDate, UserId)
values(@ITopicName, 1, getDate(), @IUserId)
SET @StrResult= 'SUCCESS'
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
RETURN ERROR_MESSAGE()
END CATCH
END
if (@Mode= 'UPD')
BEGIN
if exists(select TopicId from TopicDetails where TopicId!=@ITopicId and TopicName=
@ITopicName)
BEGIN
SET @StrResult='Topic name already exists.'
RETURN
END
BEGIN TRY
BEGIN TRANSACTION
UPDATE TopicDetails SET
TopicName=@ITopicName,
isActive=@IisActive
where TopicId=@ITopicId
SET @StrResult= 'SUCCESS'
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
RETURN ERROR_MESSAGE()
END CATCH
END
if (@Mode= 'DAC')
BEGIN
BEGIN TRY
BEGIN TRANSACTION
UPDATE TopicDetails SET
isActive=0
193
where TopicId=@ITopicId
SET @StrResult= 'SUCCESS'
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
RETURN ERROR_MESSAGE()
END CATCH
END
END
194