Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
@@ -0,0 +1,28 @@
package org.wise.vle.domain.webservice.crater;

import org.json.JSONException;
import org.json.JSONObject;

import lombok.Getter;
import lombok.Setter;

@Setter
public abstract class AbstractCRaterRequest implements CRaterRequest {
String itemId;
String cRaterClientId;

@Getter
String cRaterUrl;

public String generateBodyData() throws JSONException {
JSONObject body = new JSONObject();
body.put("client_id", cRaterClientId);
body.put("service", "ScoringService");
body.put("item_id", itemId);
return body.toString();
}

public boolean forBerkeleyEndpoint() {
return itemId.substring(0, 9).equals("berkeley_");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,15 @@
import org.json.JSONObject;
import org.wise.portal.presentation.util.http.Base64;

import lombok.Getter;
import lombok.Setter;

@Setter
public class CRaterScoringRequest implements CRaterRequest {
String itemId;
public class CRaterScoringRequest extends AbstractCRaterRequest {
String responseId;
String responseText;
String cRaterClientId;

@Getter
String cRaterUrl;

public String generateBodyData() throws JSONException {
JSONObject body = new JSONObject();
body.put("client_id", cRaterClientId);
body.put("service", "ScoringService");
body.put("item_id", itemId);
JSONObject body = new JSONObject(super.generateBodyData());
JSONArray responses = new JSONArray();
JSONObject response = new JSONObject();
response.put("response_id", responseId);
Expand All @@ -31,9 +22,4 @@ public String generateBodyData() throws JSONException {
body.put("responses", responses);
return body.toString();
}

// Duplicate method implementation would be abstracted in issue 285
public boolean forBerkeleyEndpoint() {
return itemId.substring(0, 9).equals("berkeley_");
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,3 @@
package org.wise.vle.domain.webservice.crater;

import org.json.JSONException;
import org.json.JSONObject;

import lombok.Getter;
import lombok.Setter;

@Setter
public class CRaterVerificationRequest implements CRaterRequest {
String itemId;
String cRaterClientId;

@Getter
String cRaterUrl;

public String generateBodyData() throws JSONException {
JSONObject body = new JSONObject();
body.put("client_id", cRaterClientId);
body.put("service", "VerificationService");
body.put("item_id", itemId);
return body.toString();
}

// Duplicate method implementation would be abstracted in issue 285
public boolean forBerkeleyEndpoint() {
return itemId.substring(0, 9).equals("berkeley_");
}
}
public class CRaterVerificationRequest extends AbstractCRaterRequest {}