Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Openstud: Add support for attending modes in exam reservations #26

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package lithium.openstud.driver.core.models;

import org.json.JSONArray;
import org.threeten.bp.LocalDate;

import java.util.Objects;
Expand All @@ -24,6 +25,10 @@ public class ExamReservation {
private String ssd;
private String module;

private JSONArray attendingModesList;

private String attendingModeType = "0";

public LocalDate getExamDate() {
return examDate;
}
Expand Down Expand Up @@ -168,6 +173,22 @@ public void setModule(String module) {
this.module = module;
}

public JSONArray getAttendingModesList() {
return attendingModesList;
}

public void setAttendingModesList(JSONArray attendingModesList) {
this.attendingModesList = attendingModesList;
}

public String getAttendingModeType() {
return attendingModeType;
}

public void setAttendingModeType(String attendingModeType) {
this.attendingModeType = attendingModeType;
}

@Override
public String toString() {
return "ExamReservation{" +
Expand All @@ -189,6 +210,8 @@ public String toString() {
", note='" + note + '\'' +
", ssd='" + ssd + '\'' +
", module='" + module + '\'' +
", attendingModesList='" + attendingModesList + '\'' +
", attendingModeType='" + attendingModeType + '\'' +
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to update the equals and hashcode method too as the openstud client relies on them quite a bit for handling the app cache

'}';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,18 @@ public Pair<Integer, String> insertReservation(ExamReservation res) throws Opens

private ImmutablePair<Integer, String> _insertReservation(ExamReservation res) throws OpenstudInvalidResponseException, OpenstudConnectionException {
try {
String requrl =
String.format("%s/prenotazione/%s/%s/%s/%s/?ingresso=%s",
os.getEndpointAPI(),
res.getReportID(),
res.getSessionID(),
res.getCourseCode(),
res.getAttendingModeType(),
os.getToken()
);
RequestBody reqbody = RequestBody.create(new byte[]{}, null);
Request req = new Request.Builder().url(String.format("%s/prenotazione/%s/%s/%s/0/?ingresso=%s", os.getEndpointAPI(), res.getReportID(), res.getSessionID(), res.getCourseCode(), os.getToken())).post(reqbody).build();
Request req = new Request.Builder().url(requrl).post(reqbody).build();

JSONObject response = handleRequest(req);
String url = null;
int flag = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ static List<ExamReservation> extractReservations(Openstud os, JSONArray array) {
case "SiglaModuloDidattico":
if (!obj.isNull("SiglaModuloDidattico")) res.setModule(obj.getString("SiglaModuloDidattico"));
break;
case "modalitaSvolgimentoList":
if (!obj.isNull("modalitaSvolgimentoList")) res.setAttendingModesList(obj.getJSONArray("modalitaSvolgimentoList"));
break;
default:
break;
}
Expand Down