Amazon Mechanical Turk: How to use react/redux to implement HIT? - javascript

I have implemented a complex interactive HTML form using React and Redux. I want to show this form to mturk workers and retrieve the results as a json string (basically containing the redux state after completion of the form).
After some googling, I see three options how to do this:
1) Use a ExternalQuestion and host it on my own server. However, I can't find an option how to create an ExternalQuestion using the Mechanical Turk web-interface. I only found tutorials that explain how to create such a question using the mturk API. Is there no other way to do this? I want to avoid writing scripts for publishing, retrieving the results and approving the workers myself.
2) Use a pre-defined question type such as "Survey". In this question type I can embed an iframe pointing to my own server where the react app is hosted. Using additional javascript I could retrieve the results from the iframe, store it in a hidden field in the survey and submit that as my final result.
3) Compile my react app, upload the JS and CSS files to my own server, copy the HTML to mturk and reference the JS/CSS from there.
None of these options feels right to me. How can this be done correctly?
I think an ExternalQuestion would be my best bet, but I want to avoid writing my own API calls as bugs could result in money loss.

Option 3 is the typical pattern for this kind of use case.
You can reference your assets and then in your javascript put your submit value in a hidden input within the .
This blog post shows how to achieve a use case like this using Crowd HTML Elements with Amazon SageMaker Ground Truth. It should be a helpful starting point for how to do this using MTurk directly.
Please feel free to reach out to me at samhenry#amazon.com if you get stuck.
Thank you,
Amazon Mechanical Turk

Related

Automatically create a CSV file with Javascript data on Github

I'm working on a Quizz with Html/JS on Github and which will be dedicated to my comrades.
I would like to be able to read everyone’s answers so I thought about creating a text or csv file with their answers that would be saved in a specific directory of the github project.
But I’m a beginner and I don’t know if that’s possible, i’ve seen tracks that use PHP or NodeJs with FileSaver.js, but I haven’t managed any of them because i would like it to be automatic, not to ask the user to download his answers.
If some people knwo how to do it or explain me why it’s impossible and how to do it otherwise it’ll be cool.
Thanks ! ;)
Unless you want to make every person using the quiz a contributor to your Github project (which will require that they sign up for Github accounts and tell you their account name so you can manually grant them permission) and then use the API to read the CSV file, modify it, then commit the change (and resolve any merge conflicts caused by race conditions): This is not possible (and if you are willing to do that, then it is among the most complex approach that you could take).
If you want to store and aggregate data submitted by visitors to a website then write some server-side code (using whatever language and frameworks you like, PHP and Node.js are both options) and use a web hosting service designed to support them. Github Pages is designed only for static pages and doesn't support any form of server-side programming.
Once you store the data in a file, just use git commands to commit and push it.

What is the simplest way of receiving and then processing a csv on a website?

Essentially I built an application using Python (specifically Pandas) that reads a csv then performs some actions on it then ultimately produces an output graph.
I wanted to make this application into a website and I have learnt a bit of HTML, CSS and JavaScript to do this. I want the website to mainly do these 2 things
Receive a file
Process the file using Python then output the image back to the website
What is the best course of action for this problem? Learn Flask? Learn Django? Would I need to learn anything else?
I've already learnt how to create a file uploader for the website using Vue but can't seem to wrap my head around connecting it to a database.
The simplest, leanest solution to just receive data and reply would be to start a http.server, see: https://docs.python.org/3/library/http.server.html. Anything else will be extra overhead, both in terms of learning and running. On the other hand, if this application will grow, learning Flask or Django will have added benefits.
Here I found a quick introductory tutorial on http.server: https://www.afternerd.com/blog/python-http-server/
For uploading, take a look at do_POST (e.g. here https://pymotw.com/3/http.server/) and look how to handle multipart form uploads (e.g. full example here https://gist.github.com/rctay/25bed284cd4bcc1477f4)

Accessing html form fields with an external application

I created a command line tool to help expedite HTML form filling. It uses a brute force approach in that it sends TAB keys to a window and writes info from a config file. This is unstable so I want to refactor it to set form fields using javascript.
I've looked into writing a Firefox addon to do this. I was able to hard-code each field id and write to it from a config file. My issue is I need this functionality in IE.
Is there a way an external application (ie cmd line tool) can write to HTML fields using javascript? I've tried recreating the entire html page with form fields filled in Java. I then try to send this to the normal destination using an HTTP POST. I ran into authentication issues because the forms require a log in.
My other idea is looking into web service tricks. It may be unrelated, I have no idea.
Why not try something like Selenium?
It will stop your reliance on hard coding everything as you have pretty much free reign over the DOM.
Correct me if I'm wrong, though.
You can open an CwebBrowser2 in your C++/C# application and use it as an HTML browser and get all the HTML programatically. You can then parse the HTML with a XML parses and call certain Javascript hooks.
The HTTP Post idea still seems best, if you have trouble with authenticating you just need to mimic that part as well or get the session ID (if a given session is enough for you).

MVC3 - How to dynamically set facebook app Id in javascript?

I have an MVC3 web app that uses a number of the facebook api calls. When I am testing I am using one facebook app Id but will use another in prod (this will be swapped in during the build).
Ideally I'd like to put the app Id in the web.config file to make swapping it during the build easy and so that the id is only in one place. However, I can't see an elegant way to get the id from the app.config into the multiple javascript functions that need it. I looked at reading it into a variable in the _AppStart.cshtml file but not sure that this is right as it means reading the value into a c# object and then passing that as a string to a javascript function that is called before each page loads and that smells a bit wrong.
I'm still learning javascipt so I'm not sure how this thing "should" be done. Any pointers would be great.
Matt
So, I've just come across this which deals with my question. I thought I'd exhausted google before asking this question but obviously not ;-)
integrating-facebook-login-button-in-aspnet-mvc-4-application

blogengine without php or asp.net etc

Is there a way to have a blog directly integrated into my HTML/javascript-only website, without having to have something like a SQL-database and a dynamic engine like PHP or MySQL?
Maybe there is some service in the web that offers this (hopefully without ads :) ). Or maybe I can have a blog engine entirely written in javasript?
Entirely written in JavaScript? Surely that defeats the entire point of having a "blog-engine" in the first place? The point being that the data is stored somewhere and dynamically retrieved. To avoid using anything server-side (which seems to be your intent), and only use HTML/JavaScript, you'd have to store all the data for the blog in files that are served up to each visitor, and then retrieve the data from the particular, local, locations using JavaScript.
Sorry if I'm misunderstanding the point here... but this seems to be an utterly useless way of trying to go about things. Blogs are, in general, either written statically (in HTML [even though this is rare]), or are dynamically generated from a database by a server-side scripting language (most common).
Edit: As an additional point, I suppose you could include some third-party blog feed, or service, in your page, via use of JavaScript... but I'm unsure as to which (if any) blogging services would directly support this method of working. Additionally, this is quite an unreliable way of including third-party data in a page...
Here's a thought. It's not really a blog engine - but a wiki.
Entirely javascript/html/css. All lives in a single html file:
http://www.tiddlywiki.com/
not sure how it would work on a real live site, but their site is using it:
* A personal notebook
* A GTD ("Getting Things Done") productivity tool
* A collaboration tool
* For building websites (this site is a TiddlyWiki file!)
* For rapid prototyping
* ...and much more!
You could use github pages. You will get a generated blog with version control.
Other option is to use a Desktop blog tool and then update your site.
You can user iWeb if you have a Mac or CityDesk on Windows or you may try this open source tool
Edit Today I came across this tool: Zeta producer that may help.
http://code.google.com/p/showdown-blog/
Blog engine written in just JS and XML [v0.6] {JavaScript, XML}
So, what you want is to have a blog where you're website provider doesn't provide a way to serve dynamic content?
The only way I see that you can do it in that case is writing html-files (or text-files if you prefer) and adding them to the site. After that you can have some JavaScript to add them to your "blog-page".
You of course need to upload them to the website in the same way as you do for the other files, and then have a way for the JavaScript to know which pages it should fetch.
I am not aware of any JavaScript blog-engines, but you can have a look at the templating functions in for instance Prototype
Of course, that means that you will have to fetch both the template and the content through Ajax and let the client do all the processing (could be slow and possibly insecure), and you still need to have a place to upload the content and update it.
Your best bet is going to be using a generator to create the HTML/CSS/JS to upload to your server, take a look at Webby: http://webby.rubyforge.org/
IF you really need to you can use a public api for a service that lets you post small bits of info and retrieve it using javascript.
for example if you only need small posts you can make a blog in html.javascript that utilizes twitter as the engine. of course you will be limited to 140 chars. I am sure there are other services that will allow a similar idea but with less restrictions.
And of course the best option - Get a blog software or host your blog with a service provider and link to it from you site.
Good luck
One solution would be to use some application that generates the static web pages of your blog, and uploads them to your web server. This way you'd have a blog with static content that could all be managed in javascript alongside your existing site, without needing to install database, daemon software, or additional dynamic web programming languages on your server. The static content generation could happen directly on your server if possible, or you could run the html generation tool locally and upload the output.
MoveableType has a tool like this. You still need somewhere to store the content of your blog, and for this MoveableType uses MySQL by default, so you'd still need to install a database somewhere, but the database could simply be one your local desktop.
MoveableType also has support via plugins or older versions that can retrieve data from a sqlite or other database. The advantage of sqlite is that it doesn't require installing daemons like MySQL does, you can just put a sqlite file on disk somewhere, give MoveableType the path to the file, and run the script to generate your static content.
There are likely other tools like MoveableType, and I have in the past generated blog-like web pages simply by writing small scripts to generate HTML. The main issue is just that you need somewhere for these scripts to fetch data from.
Another option might be to develop your blog using XSLT, ... with XSLT, you'd put the content of your pages in XML files, and then write a template in XSL that converts your XML to HTML.
If you google for 'static blog site generation' you might find other ideas/options, including Jekyll/github mentioned in one of the other responses.

Categories