Resume in articulate with tin-can api - tin-can-api

I am trying to implement this endpoint activities/state/?method=GET in my LRS - but I can not seem to get the resume functionality working. I have all the data, but not sure what does Articulate expect the LRS to return in order to resume where the user left off. I also tried looking at Articulate support page, but nothing useful so far. Any help would be appreciated.

It's looking for the state string to be returned. Which is just a long string that is sent out when the state ( bookmark ) is saved.

I recommend testing with the Golf Prototype at http://tincanapi.com/prototypes/ first so that you know the issue is with the LRS. Try the prototypes in both Internet Explorer and another browser such as Chrome; any difference in behaviour could be a clue.
Please also look at your network tab in Chrome's developer tools and let us know if any requests are failing and what is being stored and retrieved from the State.
Full details of how the State API is supposed to work are found in the spec. Here's the relevant section in version 1.0.2: https://github.com/adlnet/xAPI-Spec/blob/a752217060b83a2e15dfab69f8c257cd86a888e6/xAPI.md#stateapi
It's also worth noting that building an LRS is hard. There are a number of commercial and open source LRS that will likely be cheaper than building one yourself.

I managed to get this working. I was using .NET Web API.
I had to explicitly set the content-type header to octet-stream - It was defaulting to text/html.
The following code did the trick:
HttpResponseMessage httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK);
httpResponseMessage.Content = new StringContent(studentModuleName.SuspendData);
httpResponseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");

Related

Generating Dynamic SSML from "HTTP Request" to be used on a "Get Input"

I'm wondering if anyone can be of assistance.
I am trying to generate some dynamic Amazon Polly SSML to be used on the Plivo PHLO platform. When someone dials into a particular number, they should be greeted with a custom message (in a particular language) and prompted to enter a number.
I have an HTTP request that hits my API, which receives the request and generates the SSML using Plivo's PHP Server SDK.
$response = new Response();
$speak_elem = $response->addSpeak($result['text'], ['language'=> 'en-US, 'voice'=>"Polly.Joanna"]);
Header('Content-type: text/xml');
die( $response->toXML() );
It seems to me that this HTTP Request is working perfectly and returning perfect SSML. When I copy and hard-code-paste the SSML into the Get Input node, it works OK.
<?xml version="1.0" encoding="utf-8"?>
<Response><Speak language="en-US" voice="Polly.Joanna">Welcome To 101 Broadway. For English, press 1.</Speak></Response>
However, when I try to add a Get Input component and link it's "prompt" audio to the resulting SSML, I am getting an error that says Invalid SSML (See Screenshots at the bottom).
WHAT I'VE TRIED
I've tried returning the SSML in plain XML and using {{HTTP_Welcome.response}}
I've tried returning the SSML as text in a JSON object called SSML and using {{HTTP_Welcome.response.SSML}}
I've tried returning the SSML both with and without the xml tag.
I've tried returning the SSML both with and without the Result tag.
I've tried taking a break and coming back to it. Hey, you never know.
No matter how I return the SSML, and how I try to link it to the Get Input prompt, I am unsuccessful. I'm starting to wonder if this is even possible?
Any help would be immensely appreciated. Thanks!
SCREENSHOT 1
SCREENSHOT 2
My name is Mohammed Huzaif, and I work for Plivo as a Developer Evangelist.
Unfortunately, the "GetInput node" in PHLO does not yet implement the feature you are searching for. The best option is to use a standard speak which is customisable in your way, which may have a less natural feel than SSML.
Currently, I've narrow information about your use case as of now but If you still want to use a custom SSML, I'd recommend utilising a framework instead of PHLO to design your call flow. Here's a tutorial that covers a few use cases by Plivo in several frameworks to help you develop one.
If you experience any problems, please feel free to contact our support team.

How to read a Google People api response object [updated]

I'm new to Google's API and I'm having trouble reading the content of a People contact.
To get the details of a particular contact, references show this code should work [Edit: I updated the personfields]:
profile = service.people().get(resourceName='people/c63810788897573286', personFields='names')
The resourceName is the ID of a particular contact (that ID will only work for someone with access to my account). The server grabs it correctly and returns this:
<googleapiclient.discovery.Resource object at 0x10fd183c8>
How do I read the content of this object? I can't figure out from the documentation
I want to print out the Name. I'm pretty new to APIs, so maybe there is a standard way to read an HTTP object or maybe it's something unique to Google's API. Thanks for any advice
I found an answer in another somewhat related StackOverflow. I needed to the add .execute() to the call
profile = service.people().get(resourceName='people/c63810788897573286', personFields='names').execute()

HtmlUnit. How can I get site content updated by ajax and websockets?

I need to fetch comments from this site https://russian.rt.com/, for example, for this news: https://russian.rt.com/sport/article/486467-rossiya-hokkei-zoloto-olimpiady
So I try this:
String url = "https://russian.rt.com/sport/article/486467-rossiya-hokkei-zoloto-olimpiady";
try (WebClient client = new WebClient(BrowserVersion.FIREFOX_52)) {
client.getOptions().setJavaScriptEnabled(true);
client.getOptions().setThrowExceptionOnScriptError(false);
client.getOptions().setThrowExceptionOnFailingStatusCode(false);
client.setAjaxController(new NicelyResynchronizingAjaxController());
HtmlPage rtPage = client.getPage(agencyURL);
HtmlElement comBlock = rtPage.getFirstByXPath("//ul[#class='sppre_messages-list']");
} ...
But HtmlElement comBlock is always null.
I've tried waiting for javascript to complete by
client.waitForBackgroundJavaScript(10*1000);
- scrolling page:
client.getCurrentWindow().setInnerHeight(60000);
or
rtPage.executeJavaScript("window.scrollBy(0,600)");
- getting elements at the bottom of the page and clicking them.
But neither of that helped and HtmlElement comBlock after all these operations is always null.
Maybe comments module uses some kind of websockets and this is not even possible?
Can anyone help me, please?
Have done some short tests with this site. At first i have seen a NPE when calling the site. This is fixed now in HtmlUnit. Usually i will inform via Twitter (www.twitter.com/HtmlUnit) if a new snapshot build is available. After that fix i faced many more javascript problems. Looks like the page does a lot of javascript including some uggly things. If you like to get this fixed it will be a great help if you can isolate simple cases that show the problems to give us a chance to fix HtmlUnit (there is more info about this on the HtmlUnit home page).
Sorry for not having a direct solution but as for many open source projects we need help from the community to do all the work.

How to obtain firefox user agent string?

I'm building an add-on for FireFox that simulates a website, but running from a local library. (If you want to know more, look here)
I'm looking for a way to get a hold of the user-agent string that FireFox would send if it were doing plain http. I'm doing the nsIProtocolHandler myself and serve my own implementation of nsIHttpChannel, so if I have a peek at the source, it looks like I'll have to do all the work myself.
Unless there's a contract/object-id on nsHttpHandler I could use to create an instance just for a brief moment to get the UserAgent? (Though I notice I'll need to call Init() because it does InitUserAgentComponents() and hope it'll get to there... And I guess the http protocol handler does the channels and handlers so there won't be a contract to nsHttpHandler directly.)
If I have a little peek over the wall I notice this globally available call ObtainUserAgentString which does just this in that parallel dimension...
Apparently Firefox changed how this was done in version 4. Have you tried:
alert(window.navigator.userAgent);
You can get it via XPCOM like this:
var httpHandler = Cc["#mozilla.org/network/protocol;1?name=http"].
getService(Ci.nsIHttpProtocolHandler);
var userAgent = httpHandler.userAgent;
If for some reason you actaully do need to use NPAPI like you suggest in your tags, you can use NPN_UserAgent to get it; however, I would be shocked if you actually needed to do that just for an extension. Most likely Anthony's answer is more what you're looking for.

Cross domain content usage from client script (security issues)

I'm trying to load some external content using jQuery load function to div on my page. load method works ok, with local content, but if you want something out of your domain, it won't work.
$("#result").load("http://extrnal.com/page.htm #data);
(it actually works in IE with security warning, but refuses to work in Chrome at all). jQuery documentation says that it is right, because cross-domain content is restricted because of security reasons. Same warning I get if use .getJSON method.
OK, after a googling a bit I found very interesting approach of using YQL for loading content, I've tried some examples, like this:
var request = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Ffinance.yahoo.com%2Fq%3Fs%3Dyhoo%22&format=json&diagnostics=true&callback=?";
$.getJSON(request, function (json) {
alert(json);
}
);
And it really works!
What I dont understand now is that http://query.yahooapis.com is also cross-domain resouce but browser (both IE and Chrome) works OK with that?
Whats the difference? What am I missing?
Thank you
The results you are getting back from YQL are in JSON format which is permitted for cross site AJAX calls like this. Its the same mechanism that allows you to communicate with web services for external sites via JSON (Ie. the twitter API).
Details here - http://www.wait-till-i.com/2010/01/10/loading-external-content-with-ajax-using-jquery-and-yql/
you can make on external site JSON like this:
callback({key:value,etc:1})
and define
function callback(json) {
..here is processing..
}
Thanks for your answers, but unfortunately both of them do not answer my orginal question..
I've checked out related questions on stackoverflow (i know i need to do that first) and found the reason of such behavior.
First code snipset uses AJAX/JSON to retrive the data and it is permitted because of Same Origin Policy. But request to YQL uses JSONP instead, that is OK.
The JSONP was something that I don't know about, that's why I didn't undrestand the behaviour.
Introduction info on JSONP could be found here:
http://ajaxian.com/archives/jsonp-json-with-padding

Resources