File tree Expand file tree Collapse file tree 3 files changed +35
-38
lines changed
src/main/java/org/wise/vle/domain/webservice/crater Expand file tree Collapse file tree 3 files changed +35
-38
lines changed Original file line number Diff line number Diff line change 1+ package org .wise .vle .domain .webservice .crater ;
2+
3+ import org .json .JSONException ;
4+ import org .json .JSONObject ;
5+
6+ import lombok .Getter ;
7+ import lombok .Setter ;
8+
9+ @ Setter
10+ public abstract class AbstractCRaterRequest implements CRaterRequest {
11+ String itemId ;
12+ String cRaterClientId ;
13+
14+ @ Getter
15+ String cRaterUrl ;
16+
17+ public String generateBodyData () throws JSONException {
18+ JSONObject body = new JSONObject ();
19+ body .put ("client_id" , cRaterClientId );
20+ body .put ("item_id" , itemId );
21+ return body .toString ();
22+ }
23+
24+ public boolean forBerkeleyEndpoint () {
25+ return itemId .length () > 9 && itemId .substring (0 , 9 ).equals ("berkeley_" );
26+ }
27+ }
Original file line number Diff line number Diff line change 55import org .json .JSONObject ;
66import org .wise .portal .presentation .util .http .Base64 ;
77
8- import lombok .Getter ;
98import lombok .Setter ;
109
1110@ Setter
12- public class CRaterScoringRequest implements CRaterRequest {
13- String itemId ;
11+ public class CRaterScoringRequest extends AbstractCRaterRequest {
1412 String responseId ;
1513 String responseText ;
16- String cRaterClientId ;
17-
18- @ Getter
19- String cRaterUrl ;
2014
2115 public String generateBodyData () throws JSONException {
22- JSONObject body = new JSONObject ();
23- body .put ("client_id" , cRaterClientId );
16+ JSONObject body = new JSONObject (super .generateBodyData ());
2417 body .put ("service" , "ScoringService" );
25- body .put ("item_id" , itemId );
2618 JSONArray responses = new JSONArray ();
2719 JSONObject response = new JSONObject ();
2820 response .put ("response_id" , responseId );
@@ -31,9 +23,4 @@ public String generateBodyData() throws JSONException {
3123 body .put ("responses" , responses );
3224 return body .toString ();
3325 }
34-
35- // Duplicate method implementation would be abstracted in issue 285
36- public boolean forBerkeleyEndpoint () {
37- return itemId .substring (0 , 9 ).equals ("berkeley_" );
38- }
3926}
Original file line number Diff line number Diff line change 33import org .json .JSONException ;
44import org .json .JSONObject ;
55
6- import lombok .Getter ;
7- import lombok .Setter ;
8-
9- @ Setter
10- public class CRaterVerificationRequest implements CRaterRequest {
11- String itemId ;
12- String cRaterClientId ;
13-
14- @ Getter
15- String cRaterUrl ;
16-
17- public String generateBodyData () throws JSONException {
18- JSONObject body = new JSONObject ();
19- body .put ("client_id" , cRaterClientId );
20- body .put ("service" , "VerificationService" );
21- body .put ("item_id" , itemId );
22- return body .toString ();
23- }
24-
25- // Duplicate method implementation would be abstracted in issue 285
26- public boolean forBerkeleyEndpoint () {
27- return itemId .substring (0 , 9 ).equals ("berkeley_" );
28- }
6+ public class CRaterVerificationRequest extends AbstractCRaterRequest {
7+ public String generateBodyData () throws JSONException {
8+ JSONObject body = new JSONObject (super .generateBodyData ());
9+ body .put ("service" , "VerificationService" );
10+ return body .toString ();
11+ }
2912}
You can’t perform that action at this time.
0 commit comments