public Result kelulusan() throws IOException { if (session("npm") == null || session("phpsessid") == null) { session().clear(); return index(); } else { String phpsessid = session("phpsessid"); Logger.info( "User " + session("email") + " mengakses halaman Data akademik dari " + request().remoteAddress()); Scraper scrap = new Scraper(); Mahasiswa mhs = new Mahasiswa(session("npm")); scrap.requestNilai(phpsessid, mhs); scrap.requestNilaiTOEFL(phpsessid, mhs); if (mhs.getRiwayatNilai().size() == 0) { KelulusanDisplay display = null; return ok(views.html.kelulusan.render(display)); } else { Mahasiswa currMahasiswa = mhs; KelulusanDisplay display = new KelulusanDisplay(); Kelulusan str = new Kelulusan(); ArrayList<String> arrString = new ArrayList<>(); str.checkPrasyarat(currMahasiswa, arrString); display.alasanBelumLulus = arrString; return ok(views.html.kelulusan.render(display)); } } }
public Result perwalian() throws IOException { if (session("npm") == null || session("phpsessid") == null) { session().clear(); return index(); } else { String phpsessid = session("phpsessid"); Logger.info( "User " + session("email") + " mengakses halaman prasyarat dari " + request().remoteAddress()); Mahasiswa mhs = new Mahasiswa(session("npm")); Scraper scrap = new Scraper(); TahunSemester currTahunSemester = scrap.requestNamePhotoTahunSemester(session("phpsessid"), mhs); scrap.requestAvailableKuliah(phpsessid); scrap.requestNilaiTOEFL(phpsessid, mhs); List<JadwalKuliah> jadwalList = scrap.requestJadwal(phpsessid); mhs.setJadwalKuliahList(jadwalList); scrap.requestNilai(phpsessid, mhs); DataAkademikDisplay dataAkademik = new DataAkademikDisplay(); dataAkademik.ips = String.format("%.2f", mhs.calculateIPS()); dataAkademik.ipKumulatif = String.format("%.2f", mhs.calculateIPKumulatif()); dataAkademik.ipLulus = String.format("%.2f", mhs.calculateIPLulus()); dataAkademik.ipNTerbaik = String.format("%.2f", mhs.calculateIPTempuh(false)); dataAkademik.sksLulusTotal = mhs.calculateSKSLulus(); dataAkademik.nilaiTOEFL = "" + mhs.getNilaiTOEFL().values(); List<Nilai> riwayatNilai = mhs.getRiwayatNilai(); int lastIndex = riwayatNilai.size() - 1; Semester semester = riwayatNilai.get(lastIndex).getSemester(); int tahunAjaran = riwayatNilai.get(lastIndex).getTahunAjaran(); int totalSKS = 0; for (int i = lastIndex; i >= 0; i--) { Nilai nilai = riwayatNilai.get(i); if (nilai.getSemester() == semester && nilai.getTahunAjaran() == tahunAjaran) { if (nilai.getAngkaAkhir() != null) { totalSKS += nilai.getMataKuliah().getSks(); } } else { break; } } String semTerakhir = semester + " " + tahunAjaran + "/" + (tahunAjaran + 1); dataAkademik.semesterTerakhir = semTerakhir; dataAkademik.sksLulusSemTerakhir = totalSKS; if (riwayatNilai.size() == 0) { List<PrasyaratDisplay> table = null; String currentSemester = currTahunSemester.getSemester() + " " + currTahunSemester.getTahun() + "/" + (currTahunSemester.getTahun() + 1); return ok(views.html.perwalian.render(table, currentSemester, dataAkademik)); } else { List<PrasyaratDisplay> table = checkPrasyarat(); String currentSemester = currTahunSemester.getSemester() + " " + currTahunSemester.getTahun() + "/" + (currTahunSemester.getTahun() + 1); return ok(views.html.perwalian.render(table, currentSemester, dataAkademik)); } } }