-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Add Signature V2 LRN-39610
- Loading branch information
1 parent
738394b
commit 39fef5d
Showing
14 changed files
with
400 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ target | |
Dist | ||
.idea | ||
learnositysdk.iml | ||
.DS_Store | ||
*/.DS_Store | ||
docs/quickstart/assessment/webapps/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
docs/quickstart/assessment/src/main/java/com/learnosity/quickstart/AuthorApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.learnosity.quickstart; | ||
|
||
import learnositysdk.request.Init; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.json.JSONObject; | ||
|
||
public class AuthorApp extends App | ||
{ | ||
public String initOptions(String domain) { | ||
Map<String, String> security = createSecurityObject(domain); | ||
JSONObject request = createRequestObject(); | ||
String secret = config.getProperty("consumerSecret"); | ||
|
||
try { | ||
Init init = new Init("author", security, secret, request); | ||
return init.generate(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return ""; | ||
} | ||
} | ||
|
||
Map<String, String> createSecurityObject(String domain) { | ||
var security = new HashMap(); | ||
security.put("domain", domain); | ||
security.put("consumer_key", config.getProperty("consumer")); | ||
return security; | ||
} | ||
|
||
JSONObject createRequestObject() { | ||
JSONObject request = new JSONObject(); | ||
request.put("mode", "item_list"); | ||
request.put("reference", "my-item-reference"); | ||
|
||
JSONObject config = new JSONObject(); | ||
JSONObject config_item_edit = new JSONObject(); | ||
JSONObject config_item_edit_item = new JSONObject(); | ||
JSONObject config_item_edit_item_reference = new JSONObject(); | ||
config_item_edit_item_reference.put("show", true); | ||
config_item_edit_item_reference.put("edit", true); | ||
config_item_edit_item.put("reference", config_item_edit_item_reference); | ||
config_item_edit_item.put("dynamic_content", true); | ||
config_item_edit_item.put("shared_passage", true); | ||
config_item_edit_item.put("enable_audio_recording", true); | ||
config_item_edit.put("item", config_item_edit_item); | ||
config.put("item_edit", config_item_edit); | ||
request.put("config", config); | ||
|
||
JSONObject user = new JSONObject(); | ||
user.put("id", "brianmoser"); | ||
user.put("firstname", "Test"); | ||
user.put("lastname", "Test"); | ||
user.put("email", "test@test.com"); | ||
request.put("user", user); | ||
|
||
return request; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
docs/quickstart/assessment/src/main/java/com/learnosity/quickstart/ItemsApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.learnosity.quickstart; | ||
|
||
import learnositysdk.request.Init; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.json.JSONObject; | ||
|
||
public class ItemsApp extends App | ||
{ | ||
public String initOptions(String domain) { | ||
Map<String, String> security = createSecurityObject(domain); | ||
JSONObject request = createRequestObject(); | ||
String secret = config.getProperty("consumerSecret"); | ||
try { | ||
Init init = new Init("items", security, secret, request); | ||
return init.generate(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return ""; | ||
} | ||
} | ||
|
||
Map<String, String> createSecurityObject(String domain) { | ||
var security = new HashMap(); | ||
security.put("domain", domain); | ||
security.put("consumer_key", config.getProperty("consumer")); | ||
return security; | ||
} | ||
|
||
JSONObject createRequestObject() { | ||
JSONObject request = new JSONObject(); | ||
request.put("user_id", this.user_id); | ||
request.put("activity_template_id", "quickstart_examples_activity_template_001"); | ||
request.put("session_id", this.session_id); | ||
request.put("activity_id", "quickstart_examples_activity_001"); | ||
request.put("rendering_type", "assess"); | ||
request.put("type", "submit_practice"); | ||
request.put("name", "Items API Quickstart"); | ||
request.put("state", "initial"); | ||
return request; | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
docs/quickstart/assessment/src/main/java/com/learnosity/quickstart/QuestionsApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.learnosity.quickstart; | ||
|
||
import learnositysdk.request.Init; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.json.JSONObject; | ||
import org.json.JSONArray; | ||
|
||
public class QuestionsApp extends App | ||
{ | ||
public String initOptions(String domain) { | ||
Map<String, String> security = createSecurityObject(domain); | ||
JSONObject request = createRequestObject(); | ||
String secret = config.getProperty("consumerSecret"); | ||
|
||
try { | ||
Init init = new Init("questions", security, secret, request); | ||
return init.generate(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return ""; | ||
} | ||
} | ||
|
||
Map<String, String> createSecurityObject(String domain) { | ||
var security = new HashMap(); | ||
security.put("domain", domain); | ||
security.put("consumer_key", config.getProperty("consumer")); | ||
security.put("user_id", this.user_id); | ||
return security; | ||
} | ||
|
||
JSONObject createRequestObject() { | ||
JSONObject request = new JSONObject(); | ||
request.put("type", "local_practice"); | ||
request.put("state", "initial"); | ||
request.put("id", "questionsapi-demo"); | ||
request.put("name", "Questions API Demo"); | ||
request.put("course", "mycourse"); | ||
|
||
JSONArray arr_questions = new JSONArray(); | ||
JSONObject question = new JSONObject(); | ||
question.put("type", "association"); | ||
question.put("response_id", "60001"); | ||
question.put("stimulus", "Match the cities to the parent nation."); | ||
question.put("instant_feedback", true); | ||
|
||
JSONArray stimulust_list = new JSONArray(); | ||
stimulust_list.put("London"); | ||
stimulust_list.put("Dublin"); | ||
stimulust_list.put("Paris"); | ||
stimulust_list.put("Sydney"); | ||
question.put("stimulus_list", stimulust_list); | ||
|
||
JSONArray possible_responses = new JSONArray(); | ||
possible_responses.put("Australia"); | ||
possible_responses.put("France"); | ||
possible_responses.put("Ireland"); | ||
possible_responses.put("England"); | ||
question.put("possible_responses", possible_responses); | ||
|
||
JSONObject validation = new JSONObject(); | ||
JSONArray valid_responses = new JSONArray(); | ||
valid_responses.put(new JSONArray().put("England")); | ||
valid_responses.put(new JSONArray().put("Ireland")); | ||
valid_responses.put(new JSONArray().put("France")); | ||
valid_responses.put(new JSONArray().put("Australia")); | ||
validation.put("valid_responses", valid_responses); | ||
question.put("validation", validation); | ||
|
||
arr_questions.put(question); | ||
request.put("questions", arr_questions); | ||
|
||
return request; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
docs/quickstart/assessment/src/main/java/com/learnosity/quickstart/ReportsApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.learnosity.quickstart; | ||
|
||
import learnositysdk.request.Init; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.json.JSONObject; | ||
import org.json.JSONArray; | ||
|
||
public class ReportsApp extends App | ||
{ | ||
public String initOptions(String domain) { | ||
Map<String, String> security = createSecurityObject(domain); | ||
JSONObject request = createRequestObject(); | ||
String secret = config.getProperty("consumerSecret"); | ||
|
||
try { | ||
Init init = new Init("reports", security, secret, request); | ||
return init.generate(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return ""; | ||
} | ||
} | ||
|
||
Map<String, String> createSecurityObject(String domain) { | ||
var security = new HashMap(); | ||
security.put("domain", domain); | ||
security.put("consumer_key", config.getProperty("consumer")); | ||
return security; | ||
} | ||
|
||
JSONObject createRequestObject() { | ||
JSONObject report = new JSONObject(); | ||
report.put("id", "session-detail"); | ||
report.put("type", "session-detail-by-item"); | ||
report.put("user_id", this.user_id); | ||
report.put("session_id", this.session_id); | ||
|
||
JSONArray reports = new JSONArray(); | ||
reports.put(report); | ||
|
||
JSONObject request = new JSONObject(); | ||
request.put("reports", reports); | ||
|
||
return request; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<%@ page | ||
import="com.learnosity.quickstart.AuthorApp" | ||
language="java" contentType="text/html; charset=ISO-8859-1" | ||
pageEncoding="ISO-8859-1"%> | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | ||
<%! | ||
private AuthorApp app; | ||
public void jspInit() { | ||
app = new AuthorApp(); | ||
} | ||
public void jspDestroy() { | ||
app = null; | ||
} | ||
%> | ||
<html> | ||
<head><link rel="stylesheet" type="text/css" href="css/style.css"></head> | ||
<body> | ||
<h1>Standalone Assessment Example - Author API</h1> | ||
|
||
<!-- Items API will render the assessment app into this div. --> | ||
<div id="learnosity-author"></div> | ||
|
||
<!-- Load the Author API library. --> | ||
<script src="https://authorapi.learnosity.com/?latest"></script> | ||
|
||
<!-- Initiate Author API assessment rendering, using the JSON blob of signed params. --> | ||
<script> | ||
var authorApp = LearnosityAuthor.init( | ||
<%= app.initOptions(request.getServerName()) %> | ||
); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<%@ page | ||
import="com.learnosity.quickstart.ItemsApp" | ||
language="java" contentType="text/html; charset=ISO-8859-1" | ||
pageEncoding="ISO-8859-1"%> | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | ||
<%! | ||
private ItemsApp app; | ||
public void jspInit() { | ||
app = new ItemsApp(); | ||
} | ||
public void jspDestroy() { | ||
app = null; | ||
} | ||
%> | ||
<html> | ||
<head><link rel="stylesheet" type="text/css" href="css/style.css"></head> | ||
<body> | ||
<h1>Standalone Assessment Example - Items API</h1> | ||
|
||
<!-- Items API will render the assessment app into this div. --> | ||
<div id="learnosity_assess"></div> | ||
|
||
<!-- Load the Items API library. --> | ||
<script src="https://items.learnosity.com/?latest"></script> | ||
|
||
<!-- Initiate Items API assessment rendering, using the JSON blob of signed params. --> | ||
<script> | ||
var itemsApp = LearnosityItems.init( | ||
<%= app.initOptions(request.getServerName()) %> | ||
); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.