grievances redressal system
This commit is contained in:
@@ -68,30 +68,7 @@ public class StudentMenuHandler {
|
||||
break;
|
||||
|
||||
case "student_timetable":
|
||||
String rawTimetable = imsApiService.getTimetable(token);
|
||||
String todaySchedule = MessageFormatter.formatTimetable(rawTimetable);
|
||||
|
||||
// Truncate to stay safely within WhatsApp 1024 character limit for button bodies
|
||||
if (todaySchedule.length() > 1020) {
|
||||
todaySchedule = todaySchedule.substring(0, 1017) + "...";
|
||||
}
|
||||
|
||||
List<Map<String, String>> buttons = new ArrayList<>();
|
||||
Map<String, String> weeklyBtn = new HashMap<>();
|
||||
weeklyBtn.put("id", "student_weekly_timetable");
|
||||
weeklyBtn.put("title", "Weekly Timetable");
|
||||
buttons.add(weeklyBtn);
|
||||
|
||||
Map<String, String> menuBtn = new HashMap<>();
|
||||
menuBtn.put("id", "student_show_menu");
|
||||
menuBtn.put("title", "Student Menu");
|
||||
buttons.add(menuBtn);
|
||||
|
||||
System.out.println("FINAL TODAY TIMETABLE MESSAGE:\n" + todaySchedule);
|
||||
|
||||
Map<String, Object> buttonMessage = WhatsAppMessageBuilder.buildButtonMessage(todaySchedule, buttons);
|
||||
messageService.sendInteractiveMessage(phoneNumber, buttonMessage);
|
||||
sendStudentMenuDirectly(phoneNumber);
|
||||
sendTimetableMenu(phoneNumber, token);
|
||||
break;
|
||||
|
||||
case "student_internal_marks":
|
||||
@@ -113,35 +90,14 @@ public class StudentMenuHandler {
|
||||
case "student_assignment_marks":
|
||||
handleAssignmentMarks(phoneNumber);
|
||||
break;
|
||||
|
||||
|
||||
case "student_semester_results":
|
||||
sendSemesterSelection(phoneNumber, token);
|
||||
break;
|
||||
|
||||
case "student_fee_details": {
|
||||
String rawFees = imsApiService.getFees(token);
|
||||
String bodyText = MessageFormatter.formatAcademicFeesOnly(rawFees);
|
||||
|
||||
List<Map<String, String>> feeButtons = new ArrayList<>();
|
||||
Map<String, String> examBtn = new HashMap<>();
|
||||
examBtn.put("id", "student_exam_fees");
|
||||
examBtn.put("title", "Exam Fees");
|
||||
feeButtons.add(examBtn);
|
||||
|
||||
Map<String, String> historyBtn = new HashMap<>();
|
||||
historyBtn.put("id", "student_payment_history");
|
||||
historyBtn.put("title", "Payment History");
|
||||
feeButtons.add(historyBtn);
|
||||
|
||||
if (bodyText.length() > 1020) {
|
||||
bodyText = bodyText.substring(0, 1017) + "...";
|
||||
}
|
||||
|
||||
Map<String, Object> feeButtonMessage = WhatsAppMessageBuilder.buildButtonMessage(bodyText, feeButtons);
|
||||
messageService.sendInteractiveMessage(phoneNumber, feeButtonMessage);
|
||||
sendStudentMenuDirectly(phoneNumber);
|
||||
|
||||
case "student_fee_details":
|
||||
sendFeeDetailsMenu(phoneNumber, token);
|
||||
break;
|
||||
}
|
||||
|
||||
case "student_raise_grievance":
|
||||
grievanceHandler.startGrievanceFlow(phoneNumber);
|
||||
@@ -208,16 +164,18 @@ public class StudentMenuHandler {
|
||||
|
||||
if (mediaId != null) {
|
||||
messageService.sendDocumentMessage(phoneNumber, mediaId, "Here are your Semester " + semester + " results!", fileName);
|
||||
// Send menu afterwards
|
||||
sendResponseWithMenu(phoneNumber, "Select an option from the menu below.");
|
||||
sendSemesterSelection(phoneNumber, token);
|
||||
} else {
|
||||
sendResponseWithMenu(phoneNumber, "Failed to upload the results document to WhatsApp.");
|
||||
messageService.sendMessage(phoneNumber, "Failed to upload the results document to WhatsApp.");
|
||||
sendSemesterSelection(phoneNumber, token);
|
||||
}
|
||||
} else {
|
||||
sendResponseWithMenu(phoneNumber, "Failed to download your results. They may not be published yet.");
|
||||
messageService.sendMessage(phoneNumber, "Failed to download your results. They may not be published yet.");
|
||||
sendSemesterSelection(phoneNumber, token);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
sendResponseWithMenu(phoneNumber, "Invalid semester selected.");
|
||||
messageService.sendMessage(phoneNumber, "Invalid semester selected.");
|
||||
sendSemesterSelection(phoneNumber, token);
|
||||
}
|
||||
|
||||
sessionService.resetState(phoneNumber); // Reset state after fetching results
|
||||
@@ -256,15 +214,18 @@ public class StudentMenuHandler {
|
||||
String mediaId = messageService.uploadMedia(pdfBytes, fileName, "application/pdf");
|
||||
if (mediaId != null) {
|
||||
messageService.sendDocumentMessage(phoneNumber, mediaId, docMessage, fileName);
|
||||
sendResponseWithMenu(phoneNumber, "Select an option from the menu below.");
|
||||
sendPaymentHistoryMenu(phoneNumber, token);
|
||||
} else {
|
||||
sendResponseWithMenu(phoneNumber, "Failed to upload the receipt document to WhatsApp.");
|
||||
messageService.sendMessage(phoneNumber, "Failed to upload the receipt document to WhatsApp.");
|
||||
sendPaymentHistoryMenu(phoneNumber, token);
|
||||
}
|
||||
} else {
|
||||
sendResponseWithMenu(phoneNumber, "Failed to download your receipt. It may not be available.");
|
||||
messageService.sendMessage(phoneNumber, "Failed to download your receipt. It may not be available.");
|
||||
sendPaymentHistoryMenu(phoneNumber, token);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
sendResponseWithMenu(phoneNumber, "Invalid receipt selected.");
|
||||
messageService.sendMessage(phoneNumber, "Invalid receipt selected.");
|
||||
sendPaymentHistoryMenu(phoneNumber, token);
|
||||
}
|
||||
|
||||
sessionService.resetState(phoneNumber); // Reset state after fetching receipt
|
||||
@@ -283,8 +244,8 @@ public class StudentMenuHandler {
|
||||
// Send weekly timetable as standard message (up to 4096 characters limit)
|
||||
messageService.sendMessage(phoneNumber, weeklyTimetable);
|
||||
|
||||
// Follow up with Student Menu list message
|
||||
sendResponseWithMenu(phoneNumber, "Select an option from the menu below.");
|
||||
// Follow up with Timetable sub-menu again
|
||||
sendTimetableMenu(phoneNumber, token);
|
||||
}
|
||||
|
||||
public void handleExamFees(String phoneNumber) {
|
||||
@@ -296,7 +257,8 @@ public class StudentMenuHandler {
|
||||
|
||||
String rawExamFees = imsApiService.getExamFees(token);
|
||||
String formattedExamFees = MessageFormatter.formatExamFees(rawExamFees);
|
||||
sendResponseWithMenu(phoneNumber, formattedExamFees);
|
||||
messageService.sendMessage(phoneNumber, formattedExamFees);
|
||||
sendFeeDetailsMenu(phoneNumber, token);
|
||||
}
|
||||
|
||||
public void handlePaymentHistory(String phoneNumber) {
|
||||
@@ -305,7 +267,61 @@ public class StudentMenuHandler {
|
||||
messageService.sendMessage(phoneNumber, "Your session has expired. Please type 'Reset' to login again.");
|
||||
return;
|
||||
}
|
||||
sendPaymentHistoryMenu(phoneNumber, token);
|
||||
}
|
||||
|
||||
public void sendTimetableMenu(String phoneNumber, String token) {
|
||||
String rawTimetable = imsApiService.getTimetable(token);
|
||||
String todaySchedule = MessageFormatter.formatTimetable(rawTimetable);
|
||||
|
||||
// Truncate to stay safely within WhatsApp 1024 character limit for button bodies
|
||||
if (todaySchedule.length() > 1020) {
|
||||
todaySchedule = todaySchedule.substring(0, 1017) + "...";
|
||||
}
|
||||
|
||||
List<Map<String, String>> buttons = new ArrayList<>();
|
||||
Map<String, String> weeklyBtn = new HashMap<>();
|
||||
weeklyBtn.put("id", "student_weekly_timetable");
|
||||
weeklyBtn.put("title", "Weekly Timetable");
|
||||
buttons.add(weeklyBtn);
|
||||
|
||||
Map<String, String> menuBtn = new HashMap<>();
|
||||
menuBtn.put("id", "student_show_menu");
|
||||
menuBtn.put("title", "Student Menu");
|
||||
buttons.add(menuBtn);
|
||||
|
||||
System.out.println("FINAL TODAY TIMETABLE MESSAGE:\n" + todaySchedule);
|
||||
|
||||
Map<String, Object> buttonMessage = WhatsAppMessageBuilder.buildButtonMessage(todaySchedule, buttons);
|
||||
messageService.sendInteractiveMessage(phoneNumber, buttonMessage);
|
||||
sendStudentMenuDirectly(phoneNumber);
|
||||
}
|
||||
|
||||
public void sendFeeDetailsMenu(String phoneNumber, String token) {
|
||||
String rawFees = imsApiService.getFees(token);
|
||||
String bodyText = MessageFormatter.formatAcademicFeesOnly(rawFees);
|
||||
|
||||
List<Map<String, String>> feeButtons = new ArrayList<>();
|
||||
Map<String, String> examBtn = new HashMap<>();
|
||||
examBtn.put("id", "student_exam_fees");
|
||||
examBtn.put("title", "Exam Fees");
|
||||
feeButtons.add(examBtn);
|
||||
|
||||
Map<String, String> historyBtn = new HashMap<>();
|
||||
historyBtn.put("id", "student_payment_history");
|
||||
historyBtn.put("title", "Payment History");
|
||||
feeButtons.add(historyBtn);
|
||||
|
||||
if (bodyText.length() > 1020) {
|
||||
bodyText = bodyText.substring(0, 1017) + "...";
|
||||
}
|
||||
|
||||
Map<String, Object> feeButtonMessage = WhatsAppMessageBuilder.buildButtonMessage(bodyText, feeButtons);
|
||||
messageService.sendInteractiveMessage(phoneNumber, feeButtonMessage);
|
||||
sendStudentMenuDirectly(phoneNumber);
|
||||
}
|
||||
|
||||
public void sendPaymentHistoryMenu(String phoneNumber, String token) {
|
||||
String rawExamFees = imsApiService.getExamFees(token);
|
||||
String rawFeesHistory = imsApiService.getAcademicFeesHistory(token);
|
||||
|
||||
@@ -408,7 +424,8 @@ public class StudentMenuHandler {
|
||||
}
|
||||
String rawCatMarks = imsApiService.getCatMarks(token);
|
||||
String formatted = com.rit.whatsapp.util.MessageFormatter.formatCat1Marks(rawCatMarks);
|
||||
sendResponseWithMenu(phoneNumber, formatted);
|
||||
messageService.sendMessage(phoneNumber, formatted);
|
||||
sendInternalMarksMenu(phoneNumber);
|
||||
}
|
||||
|
||||
public void handleCat2Marks(String phoneNumber) {
|
||||
@@ -419,7 +436,8 @@ public class StudentMenuHandler {
|
||||
}
|
||||
String rawCatMarks = imsApiService.getCatMarks(token);
|
||||
String formatted = com.rit.whatsapp.util.MessageFormatter.formatCat2Marks(rawCatMarks);
|
||||
sendResponseWithMenu(phoneNumber, formatted);
|
||||
messageService.sendMessage(phoneNumber, formatted);
|
||||
sendInternalMarksMenu(phoneNumber);
|
||||
}
|
||||
|
||||
public void handleCat3Marks(String phoneNumber) {
|
||||
@@ -430,7 +448,8 @@ public class StudentMenuHandler {
|
||||
}
|
||||
String rawCatMarks = imsApiService.getCatMarks(token);
|
||||
String formatted = com.rit.whatsapp.util.MessageFormatter.formatCat3Marks(rawCatMarks);
|
||||
sendResponseWithMenu(phoneNumber, formatted);
|
||||
messageService.sendMessage(phoneNumber, formatted);
|
||||
sendInternalMarksMenu(phoneNumber);
|
||||
}
|
||||
|
||||
public void handleAssignmentMarks(String phoneNumber) {
|
||||
@@ -441,7 +460,8 @@ public class StudentMenuHandler {
|
||||
}
|
||||
String rawAssignmentMarks = imsApiService.getAssignmentMarks(token);
|
||||
String formatted = com.rit.whatsapp.util.MessageFormatter.formatAssignmentMarks(rawAssignmentMarks);
|
||||
sendResponseWithMenu(phoneNumber, formatted);
|
||||
messageService.sendMessage(phoneNumber, formatted);
|
||||
sendInternalMarksMenu(phoneNumber);
|
||||
}
|
||||
|
||||
private List<Map<String, String>> getStudentMenuRows() {
|
||||
|
||||
Reference in New Issue
Block a user