Ejemplo n.º 1
0
 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));
     }
   }
 }
Ejemplo n.º 2
0
 private List<PrasyaratDisplay> checkPrasyarat() throws IOException {
   Scraper scrap = new Scraper();
   Mahasiswa mhs = new Mahasiswa(session("npm"));
   scrap.requestNilai(session("phpsessid"), mhs);
   List<PrasyaratDisplay> table = new ArrayList<PrasyaratDisplay>();
   List<MataKuliah> mkList = scrap.requestAvailableKuliah(session("phpsessid"));
   for (MataKuliah mk : mkList) {
     if (mhs.hasLulusKuliah(mk.getKode())) {
       table.add(new PrasyaratDisplay(mk, new String[] {"sudah lulus"}));
     } else {
       if ((Object) mk instanceof HasPrasyarat) {
         List<String> reasons = new ArrayList<String>();
         ((HasPrasyarat) mk).checkPrasyarat(mhs, reasons);
         if (!reasons.isEmpty()) {
           table.add(new PrasyaratDisplay(mk, reasons.toArray(new String[reasons.size()])));
         } else {
           if (mhs.hasLulusKuliah(mk.getKode())) {
             table.add(new PrasyaratDisplay(mk, new String[] {"sudah lulus"}));
           } else {
             table.add(new PrasyaratDisplay(mk, new String[] {"memenuhi syarat"}));
           }
         }
       } else {
         table.add(new PrasyaratDisplay(mk, new String[] {"tidak memiliki prasyarat"}));
       }
     }
   }
   return table;
 }
Ejemplo n.º 3
0
  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));
      }
    }
  }