public Result jadwalKuliah() throws IOException {

    if (session("npm") == null || session("phpsessid") == null) {
      session().clear();
      return index();
    } else {
      Scraper scrap = new Scraper();
      Mahasiswa mhs = new Mahasiswa(session("npm"));
      List<JadwalKuliah> jadwalList = scrap.requestJadwal(session("phpsessid"));
      mhs.setJadwalKuliahList(jadwalList);
      TahunSemester currTahunSemester =
          scrap.requestNamePhotoTahunSemester(session("phpsessid"), mhs);
      JadwalDisplay table = new JadwalDisplay(mhs.getJadwalKuliahList());
      String semester =
          currTahunSemester.getSemester()
              + " "
              + currTahunSemester.getTahun()
              + "/"
              + (currTahunSemester.getTahun() + 1);
      Logger.info(
          "User "
              + session("email")
              + " mengakses halaman jadwal kuliah dari "
              + request().remoteAddress());
      return ok(views.html.jadwalKuliah.render(table, semester));
    }
  }
  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));
      }
    }
  }