How to show multiple images at once with a jspsych plugin? - gorilla

I am coding in Gorilla and try to show multiple images at once using a JsPsych plugin.
Currently I am using the plugin jsPsychImageButtonResponse as follows:
var trial = {
type: jsPsychImageButtonResponse,
stimulus: [aURL, bURL, cURL],
choices: [aURL, bURL, cURL],
};
I would like to show three cards (named aURL, bURL, cURL) and make the participants click on one of them.
I uploaded the images in the resources tab on Gorilla and referred to them like this:
// URL's for images
var aURL = gorilla.stimuliURL('a.png');
var bURL = gorilla.stimuliURL('b.png');
var cURL = gorilla.stimuliURL('c.png');
// Create an array containing all the URL's for our required stimuli
var images = [];
images.push(aURL);
images.push(bURL);
images.push(cURL);
Any help is welcome.
Thank you in advance!

Related

Is there any way to get google classroom form question insert title image URL

I want to get the image url which is inserted when create a question into the classroom form.
Below is the code through we get the title , choices if available but i am not able to get the image url which is insert under the question title.
function getCourse() {
var form = FormApp.openById(id);
var formResponses = form.getItems();
var type=formResponses[0].getType();
var title = formResponses[0].getTitle();
var image =formResponses[0].getImage();//no such method Logger.log(image);
}
That image is not available through the Forms Service, it's added through the /viewresponse source code which is generated some way by Google. You could get it by using the URL Fetch Service (UrlFetchApp).
Related
How can I scrape text and images from a random web page?
(javascript / google scripts) How to get the title of a page encoded with iso-8859-1 so that the title will display correctly in my utf-8 website?
var blob = questionType.getImage();
var b64 = blob.getContentType() + ';base64,'+ Utilities.base64Encode(blob.getBytes());
var html = "data:" + b64 ;

Oracle Apex PDF Viewer

i am new in Oracle-Apex. I need Help to show a PDF in Oracle APEX. I have a question: I have uploaded the PDF in to the Database. I save the PDF as a blob in database. After that i showed the name of the PDF in Classic Report.When i click on the name, i want to see the preview of the PDF that i had uploaded.
Now i am searching a way to show the PDF with a Code. Can somebody help?
I need previous and next button.
How can i show this PDF in the Region?here is my Page
Here's an example I quickly whipped up using APEX_APPLICATION_TEMP_FILES. Hopefully it's what you're trying to achieve.
https://apex.oracle.com/pls/apex/f?p=34781
Username: demo
Password: demo
This uses the PDF.js project by Mozilla. Here's a quick recipe of what you may need.
Create a File Browse page item and set the Storage Type to Table APEX_APPLICATION_TEMP_FILES.
Create a page button to submit the page.
Create a Classic Report region and enter the following query:
select
id
, filename
from apex_application_temp_files
where application_id = :APP_ID
Add a virtual column and set the HTML Expression:
<button type="button" class="btn-preview-pdf" data-id="#ID#">Preview</button>
Create a region and enter the following in the Source:
<canvas id="preview-pane"></canvas>
Create a Click dynamic action.
a. Set the selection Type to jQuery Selector.
b. Enter the jQuery Selector .btn-preview-pdf.
Add a Execute JavaScript Code action with the following JS code (check out the examples from the PDF.js website for more details on what the code does):
var fileId = $(this.triggeringElement).data('id');
var docUrl = 'f?p=&APP_ID.:0:&APP_SESSION.:APPLICATION_PROCESS=DOWNLOADPDF:::FILE_ID:' + fileId;
var previewPane = this.affectedElements[0];
// from PDF.js examples
pdfjsLib.getDocument(docUrl).then(function(pdf) {
var pageNumber = 1;
pdf.getPage(pageNumber).then(function(page) {
console.log('Page loaded');
var scale = 1.5;
var viewport = page.getViewport(scale);
// Prepare canvas using PDF page dimensions
var canvas = previewPane;
var context = canvas.getContext('2d');
canvas.height = viewport.height;
canvas.width = viewport.width;
// Render PDF page into canvas context
var renderContext = {
canvasContext: context,
viewport: viewport
};
var renderTask = page.render(renderContext);
renderTask.then(function () {
console.log('Page rendered');
});
})
}, function(reason) {
console.error(reason);
});
For the action, also set the Affected Elements:
a. Selection Type: jQuery Selector
b. jQuery Selector: #preview-pane
Follow Joel Kallman's post on creating a link to download a file. You will need an Application Process (DOWNLOADPDF) and an Application Item (FILE_ID) The modified code for the Application Process DOWNLOADPDF looks like this:
begin
for file in (select *
from apex_application_temp_files
where id = :FILE_ID) loop
--
sys.htp.init;
sys.owa_util.mime_header( file.mime_type, FALSE );
sys.htp.p('Content-length: ' || sys.dbms_lob.getlength( file.blob_content));
sys.htp.p('Content-Disposition: attachment; filename="' || file.filename || '"' );
sys.htp.p('Cache-Control: max-age=3600'); -- tell the browser to cache for one hour, adjust as necessary
sys.owa_util.http_header_close;
sys.wpg_docload.download_file( file.blob_content );
apex_application.stop_apex_engine;
end loop;
end;
Almost missed this out. On the Page Attributes, set the JavaScript File URLs to any of the CDNs listed. For example:
//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.0.550/pdf.min.js
Note that this is a very basic prototype. The preview only allows you to view the first page. You will need to figure out the API and then do the necessary to allow multipage viewing. I'll leave you to figure that out.
That should be it. Let me know if it doesn't work for you.

fabricjs cloned object affect old(default) object

I am trying to get shadow Image of Text object without affecting the output of fabric.
Code
var clonedText = jQuery.extend({}, obj);
clonedText.fill = "rgba(50,50,50,0.5)";
imageURL = clonedText.toDataURL({format:'png'});
Result
Default:
AfterRun:
How can it be fixed?
I mean how can I copy object so that cant affect default image?
UPDATE:
I also tried this and this.
canvas._objects.forEach(function(obj, index){
var clonedText = fabric.util.object.clone(obj);
clonedText.fill = "rgba(50,50,50,0.5)";
imageURL = clonedText.toDataURL({format:'png'});
});
This has same result.
So you should not really clone instances like you would clone javascript objects.
Fabric objects can have references to canvas elements, image elements, deep structures, and every clone logic works on its own.
on fabricjs docs is specified that fabric.util.object.extende/clone does not clones fabricJS objects:
http://fabricjs.com/docs/fabric.util.object.html
Also in the docs is specified the clone method:
So you have to run
myText.clone(function(cloned) {
// do something with cloned....
});
If you are in need of a full syncronous process, and you are not using patterns or image sources for text you can also do:
var objectForm = myText.toObject();
var clonedText = new fabric.Text(objectForm.text, objectForm);

Firefox addon: how to grab data from webpage?

Purpose
I am trying to make a common answer database for a website form. The form is a description of computer hardware specifications, and I am trying to make it so that based on a model field, other fields are filled in automatically. The extension with have two buttons, "populate" which will based on the model field, check the database for a matching entry, and then populate data into the forms based on that. The second button being "save", which will take data in the fields and marry it to the model field and place it into the database.
Question
So, my main question is on interacting with the webpage itself, how do I grab data from the webpage, and then how do I make changes to fields?
So, my main question is on interacting with the webpage itself, how do I grab data from the webpage, and then how do I make changes to fields?
You can do this with a Firefox Add-on SDK Page-mod, click here for the documentation
Here is an example for getting data:
Example Page-Mod
/lib/main.js:
var tag = "p";
var data = require("sdk/self").data;
var pageMod = require("sdk/page-mod");
pageMod.PageMod({
include: "*.mozilla.org",
contentScriptFile: data.url("element-getter.js"),
onAttach: function(worker) {
worker.port.emit("getElements", tag);
worker.port.on("gotElement", function(elementContent) {
console.log(elementContent);
});
}
});
/data/element-getter.js:
self.port.on("getElements", function(tag) {
var elements = document.getElementsByTagName(tag);
for (var i = 0; i < elements.length; i++) {
self.port.emit("gotElement", elements[i].innerHTML);
}
});

Titanium ImageView wont display images?

I created an image directory in my projects in the UI folder to place my images.
So the full path is currently Resources/UI/Images.
When i create an image view it wont display the images.
I tried different options, even a web image but nothing works?
var self = Ti.UI.createView({
backgroundColor:'white'
});
var imgv = Titanium.UI.createImageView({url:"http://upload.wikimedia.org/wikipedia/commons/thumb/1/1a/Volkswagen_Logo.png/600px-Volkswagen_Logo.png"});
self.add(imgv);
var imgv = Titanium.UI.createImageView({url:"../images/sb02.jpg"});
self.add(imgv);
var imgv = Titanium.UI.createImageView({url:"Resources/ui/images/sb03.jpg"});
self.add(imgv);
There is an error in your code. There is no url property for ImageView control. You should use image property. Try the following code
var imgv = Titanium.UI.createImageView({
image:"../images/sb02.jpg"
});
self.add(imgv);
To answer my question thanks to Anand for the tips:
Images should be placed in the Resources dir
Afterwards reference them just by /folder/image.jpg in my case /images/sb1.jpg

Resources