Skip to content

Commit

Permalink
Merge pull request #62 from Learnosity/LRN-44058/feature/api-aide
Browse files Browse the repository at this point in the history
[FEATURE] Add authoraide LRN-44064
  • Loading branch information
markus-liang-lrn authored Jul 11, 2024
2 parents 59580af + b2f9cb3 commit c1a87d9
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [v0.17.0] - 2024-07-04
### Added
* Added support for authoraide API.

## [v0.16.5] - 2023-09-05
### Fixed
* Added support for expiry date in security object.
Expand Down
2 changes: 1 addition & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ Run ```mvn package``` in your root directory (where pom.xml is located). This wi

3.) Install the learnosity SDK with maven into that directory by running the following (modify locations as appropriate):
```bash
mvn deploy:deploy-file -DgroupId=learnositysdk -DartifactId=learnositysdk -Dversion=0.16.5 -Durl=file:./learnosity-sdk-repo/ -DrepositoryId=learnosity-sdk-repo -DupdateReleaseInfo=true -Dfile=/home/temp/learnositysdk-0.16.5.jar -DpomFile=/home/temp/pom.xml
mvn deploy:deploy-file -DgroupId=learnositysdk -DartifactId=learnositysdk -Dversion=0.17.0 -Durl=file:./learnosity-sdk-repo/ -DrepositoryId=learnosity-sdk-repo -DupdateReleaseInfo=true -Dfile=/home/temp/learnositysdk-0.17.0.jar -DpomFile=/home/temp/pom.xml
```

4.) Add the directory as a file based repository in your project pom.xml:
Expand Down
2 changes: 1 addition & 1 deletion docs/quickstart/assessment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<dependency>
<groupId>learnositysdk</groupId>
<artifactId>learnositysdk</artifactId>
<version>0.16.5</version>
<version>0.17.0</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.learnosity.quickstart;

import learnositysdk.request.Init;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONObject;

public class AuthoraideApp 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("authoraide", security, secret, request);
return init.generate();
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}
}

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();

JSONObject user = new JSONObject();
user.put("id", "brianmoser");
user.put("firstname", "Test");
user.put("lastname", "Test");
user.put("email", "[email protected]");
request.put("user", user);

return request;
}
}
33 changes: 33 additions & 0 deletions docs/quickstart/assessment/src/main/webapp/AuthoraideApi.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<%@ page
import="com.learnosity.quickstart.AuthoraideApp"
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 AuthoraideApp app;
public void jspInit() {
app = new AuthoraideApp();
}
public void jspDestroy() {
app = null;
}
%>
<html>
<head><link rel="stylesheet" type="text/css" href="css/style.css"></head>
<body>
<h1>Standalone Assessment Example - Authoraide API</h1>

<!-- Authoraide API will be rendered the app into this div. -->
<div id="aiApp"></div>

<!-- Load the Authoraide API library. -->
<script src="https://authoraide.learnosity.com"></script>

<script>
var authoraideApp = LearnosityAuthorAide.init(
<%= app.initOptions(request.getServerName()) %>,
"#aiApp"
);
</script>
</body>
</html>
1 change: 1 addition & 0 deletions docs/quickstart/assessment/src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<li><a href="QuestionsApi.jsp">Questions API</a></li>
<li><a href="AuthorApi.jsp">Author API</a></li>
<li><a href="ReportsApi.jsp">Reports API</a></li>
<li><a href="AuthoraideApi.jsp">Authoraide API</a></li>
</ul>
</body>
</html>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>learnositysdk</groupId>
<artifactId>learnositysdk</artifactId>
<version>0.16.5</version>
<version>0.17.0</version>

<name>Learnosity SDK</name>
<url>https://github.com/Learnosity/learnosity-sdk-java</url>
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/learnositysdk/request/Init.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public class Init {
/**
* Valid strings for service
*/
private String[] validServices = new String[] {"assess", "author", "data", "items", "questions", "reports", "events"};
private String[] validServices = new String[] {"assess", "author", "data", "items", "questions", "reports", "events", "authoraide"};

/**
* Instantiate this class with all security and request data. It
Expand Down Expand Up @@ -207,7 +207,8 @@ public String generate()
this.service.equals("author") ||
this.service.equals("data") ||
this.service.equals("items") ||
this.service.equals("reports")) {
this.service.equals("reports") ||
this.service.equals("authoraide")) {

// Add the security packet (with signature) to the output
output.put("security", this.securityPacket);
Expand Down

0 comments on commit c1a87d9

Please sign in to comment.