Unable to include an Image in mirtCAT

95 views
Skip to first unread message

Atmajitsinh Gohil

unread,
Sep 30, 2020, 3:18:02 AM9/30/20
to mirt-package
Hi Phil,

Thank you for the mirtCAT package, it has been very helpful to me.

I apologize if this has been answered before. I am trying to include image as a part of the questions. I was able to include html tags but the tags do not work if i use <img>. 

In the attached csv file the row 2 works fine. I used rmarkdown to create a html file and it does the job. But, when i use the following in row 7 the image does not show up.

<p>
<img alt="" src="/www/areaofcircle.png" style="width: 400px; height: 434px;" />
</p>

I have also seen your example of using video and audio files in questions. That too works great but somehow it fails for img tag. 

Any thoughts or workaround? i have a lot of questions with images so creating a markdown file for each is not very efficient solution.

Thank you for your help.

Regards,
Atmajit

items_pro.csv

Phil Chalmers

unread,
Sep 30, 2020, 3:54:19 PM9/30/20
to Atmajitsinh Gohil, mirt-package
Can you provide a simple reproducible example of this behaviour? That would be the easiest way to determine what the issue is on our end. Thanks.

Phil


--
You received this message because you are subscribed to the Google Groups "mirt-package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mirt-package...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mirt-package/8cf692f2-d407-4503-a9bb-3382f80a262bn%40googlegroups.com.
Message has been deleted

Phil Chalmers

unread,
Oct 26, 2020, 1:55:43 PM10/26/20
to John Manacup, mirt-package
Hi John,

I believe that all extra content material must be placed into the subfolder www/ in order for shiny to render the html content correctly. To fix this in your example:

1) Create a directory www/ below your current working directory that stores the script and html file
2) Move the png. file into www/, and edit the original html file that pointed to this image (e.g., using a text editor replace 'sample.png' in the HTML code with `www/sample.png`)
3) Execute your mirtCAT() call from the same working directory as the R source file.

The above is a little clunky, as one would expect shiny to export all file information in the current working directory. I haven't been able to figure out how to do this yet (tried multiple approaches), however the above approach at least solves the problem for now. Alternatively, you could just make a self-contained HTML file and point to that instead, which should avoid this particular headache. HTH.

Phil


On Tue, Oct 20, 2020 at 12:59 PM John Manacup <john.m...@gmail.com> wrote:
Hello, it's been a while since this thread got a response and I am also wondering the same thing Atmajit mentioned and would like to give a simple reprex for the problem. Here attached is a modified "Math-stem.html" (http://philchalmers.github.io/mirtCAT/html/customizeGUI.html) which I inserted an <img> tag that sources out a sample picture called "sample.png" After running this code,

library(mirtCAT)
type <- c("radio")
questions <- c("")
options <- rbind(c("1236", "1238", "1240", "1242", "1244"))
answers <- c("1236")

#stem paths can be relative or absolute (relative here, in the save working directory)
stem_locations <- c("Math-stem.html")
oneitem <- data.frame(Question = questions, Option = options, Answer = answers,
                       Stem = stem_locations, Type = type, stringsAsFactors = FALSE)

results <- mirtCAT(df = oneitem, design = list(max_items = 2))



The result shows:



Hope this would help out in determining the problem for img sourcing inside the html stem file and would greatly appreciate an update for this fix. Thanks!

John
Reply all
Reply to author
Forward
0 new messages