Sharing a random CSV data set across exercises with exams2moodle() - r

I want to create a Moodle quiz with 300 random replications from 6 exercise templates using exams2moodle() from R/exams. The 6 exercise templates depend on a data set that is randomly generated as a CSV file from a larger data base in the first exercise.
The command exams2pdf() does just what I want but I want to reproduce what exams2pdf() does with the exams2moodle() command. However, this just generates a quiz with 300 questions of type 1, 300 of type 2, ..., and 300 of type 6. I don't know how to force Moodle to combine the first type 1 question in the same quiz along with the first type 2 question, the first type 3 question, ..., and the first type 6 question. Then, the exam created would be the same one that the command exams2pdf() generates.

The short answer to this is that this type of sampling is currently not possible in Moodle. You only have the option to inlcude a specific question in a quiz or to select a random question from a certain pool. But there is (to the best of my knowledge) no way of linking the selection of the random questions across pools. Potential workarounds are:
Instead of having 300 versions of the quiz you just have, say, 10 versions. Then you can put together all 10 quizzes, each with a fixed sequence of questions. And then you need to split up your participants into 10 groups and assign them to one of the ten quizzes. This is very tedious but lets you use your questions without modification.
Technical note: When generating the quiz with exams2moodle() with .Rmd (rather than .Rnw) exercises you have to set envir = .GlobalEnv (or some other environment). Only then the randomly-generated data from the first exercise is shared with subsequent exercises when using knitr (while this is the only option when using Sweave()).
Instead of having 6 separate exercises, you combine them into a single cloze exercise. Whether this is feasible, though, depends on the complexity of the 6 tasks. If they are too complex, the cloze exercise would become too long and too convoluted.
For some more discussion regarding these issues, see the following threads from the R/exams forum on R-Forge:
https://R-Forge.R-project.org/forum/forum.php?thread_id=33666&forum_id=4377&group_id=1337
https://R-Forge.R-project.org/forum/forum.php?thread_id=33912&forum_id=4377&group_id=1337

Related

How show points of each question when producing exams' solution? [duplicate]

Consider creating exams using the exams package in R.
When using exams2nops there is a parameter showpoints that, when set to TRUE will show the points of each exercise. However, for exams2pdf this parameter is not available.
How to display the points per exercise when using exams2pdf?
(The answer below is adapted from the R/exams forum at https://R-Forge.R-project.org/forum/forum.php?thread_id=33884&forum_id=4377&group_id=1337.)
There is currently no built-in solution to automatically display the number of points in exams2pdf(). The points= argument only stores the number of points in the R object that exams2pdf() creates (as in other exams2xyz() interfaces) but not in the individual PDF files.
Thus, if you want the points to be displayed you need to do it in some way yourself. A simple solution would be to include it in the individual exercises already, possibly depending on the kind of interface used, e.g., something like this for an .Rmd exercise:
pts <- 17
pts_string <- if(match_exams_call() == "exams2pdf") {
sprintf("_(%s points)_", pts)
} else {
""
}
And then at the beginning of the "Question":
Question
========
`r pts_string` And here starts the question text...
Finally in the meta-information
expoints: `r pts`
This always includes the desired points in the meta-information but only displays them in the question when using exams2pdf(...). This is very flexible and can be easily customized further. The only downside is that it doesn't react to the exams2pdf(..., points = ...) argument.
In .Rnw exercises one would have to use \Sexpr{...} instead of r .... Also the pts_string should be something like sprintf("\\emph{(%s points)}", pts).
Finally, a more elaborate solution would be to create a suitable \newcommand in the .tex template you use. If all exercises have the same number of points, this is not hard to do. But if all the different exercises could have different numbers of points, it would need to be more involved.
The main reason for supporting this in exams2nops() but not exams2pdf() is that the former has a rather restrictive format and vocabulary. In the latter case, however, the point is to give users all freedom regarding layout, language, etc. Hence, I didn't see a solution that is simple enough but also flexible enough to cover all use-cases of exams2pdf().

Randomized order of exercises in Canvas via R/exams

I use the R package exams to create quizzes that are administered through the learning management system Canvas. I would like to randomize the order of exercises. Suppose I have 2 exercises A and B. From each exercise we draw 100 realizations, 1, ..., 100. I would like to create exams consisting of one random A exercise and one random B exercise in random order, i.e., of the following form: {A(2), B(10)}, {B(20), A(60)}, etc.
I am aware that you can use R/exams to generate PDF exams in this form (see: Different orders of questions in exams2pdf() from R/exams). However, I cannot find how to do the same for Canvas using the exams2canvas() function.
At the moment this feature is not available in exams2canvas() and I'm not sure whether it can be implemented. (Should anyone reading this have insights about whether/how this could be achieved, please let me know.)
Conceptually, there is an important difference between those exams2xyz() interfaces that produce a single file per exam (notably, exams2pdf() and exams2nops()) and those that produce a collection for learning management systems (like exams2moodle(), exams2canvas(), exams2blackboard(), and exams2openolat()). The former assure that the 1st replication from A and B are together in one exam - and potentially their order can be randomized. Analogously, for the 2nd and 3rd replication, etc. In the exports for learning management systems this is not easily possible.
Instead, the exports for the different learning management systems produce one "pool" or "section" of 100 exercises for A, and another pool/section of 100 exercises for B. For each exam the learning management system then samples one exercise from the A pool/section and one exercise from the B pool/section. So far, this is what you are looking for.
However, additionally shuffling or randomizing the order of the sections is available in some learning management systems but (to the best of my knowledge) not in all. Notably, OpenOLAT based on the QTI 2.1 format has an option for this. But for systems based on QTI 1.2 (rather than 2.1) like Canvas I did not see any way of including this feature.

How can I generate exams that contain randomly-generated single-choice answers using R/exams package?

I am interested in using R/exams package in order to generate tests composed of 'single-choice' questions. The three most important things that I am looking for are:
-being able to randomly select one (or more) out of a set of exercises for each participant
-being able to randomly shuffle answer alternatives
-being able to randomly select numbers, text blocks, graphics using the R programming language.
I have followed the basic R/exams tutorials and was able to generate their demo exams, but I was not yet able to find a full tutorial on how to achieve these goals. I am a beginner R programmer and I would, therefore, need a step-by-step tutorial.
If there are any suggestions of such tutorials here I would really appreciate any help.
Thank you
All things you are looking for can be accomplished with R/exams. There is not one step-by-step tutorial that illustrates everything, though. But there are quite a few bits and pieces that should get you started.
Do you want to generate written single-choice exams or do you want to conduct your tests in some learning management system like Moodle or so? If you're looking for written exams, then exams2nops() is the most complete solution, see:
http://www.R-exams.org/tutorials/exams2nops/
For setting up single-choice exercises based on numeric questions, a step-by-step tutorial is: http://www.R-exams.org/tutorials/static_num_schoice/
If you prefer an arithmetic illustration rather than one from economics, there is:
http://www.R-exams.org/general/user2019/
For selecting one out of a set of exercises for each participant, you need to define an exam with a list of exercises, e.g.,
exm <- list(
c("a.Rmd", "b.Rmd", "c.Rmd"),
c("d.Rmd", "e.Rmd")
)
When using exams2xyz(exm) then you will get an exam with two exercises. The first one is a random sample of a-c and the second one a random sample of d-e.
I suggest you try to get started with these, keeping it simple in the beginning. I.e., instead of accomplishing all tasks immediately, try to take them one by one.

Text Categorization using R

I am relatively new at using R. I have a dataset of around 5000 datapoints.
My goal is to predict a category using the comments entered.
I have a training dataset of 4500 records and a testing data set of 500 records.
I am looking for 2-3 packages which might help me in doing this.I have to evaluate these packages and prepare a report on that. Can anyone suggest me some good packages which might easier to use and also more efficient.
Again, I have 2 columns
1st one is comments and based on this I have to predict the category.
Right now I have defined around 10 independent categories.
Most of the comments have specific keywords which I have defined as categories
One such example
Comment 1
The website is pretty good --->> category would be WebsiteContent
comment 2 might be like
Excellent article ,very detailed--->> same category as above(WebsiteContent)
But the keywords such as article, website are very limited and can be linked to the category
all of comments are different but the underlying keywords are mostly the same
Thanks,
Ankan
Although all you need is a very long and well written set of if-else statements, try using a Decision tree from the package from the rpart and prp package. I'm saying this only cause you're trying to learn and I'm guessing this is for some assignment which you're supposed to be doing on your own.
tree<-rpart(train$decision~train$comment, method"class")
prp(tree)
The first line builds the model and the second one plots it. This might be a bit overboard actually but since you're learning R this is a fun thing to work with and can be used for a wide variety of things. Although, Decision trees work better with more predictor variables.
Use predict(test,tree) to test out the model on your test dataset.

RadViz & survey/permutation matrix plots in R

I'm currently working on a brief presentation for a graduate class in multivariate data analysis. It's on methods of displaying multivariate data (for human comprehension), and of the six methods we're supposed to present on, I've taken on radial visualization plots (specifically the type referred to as "RadViz") and survey plots (which are a variety of permutation matrix visualization, or so I've been led to understand from my research). While I have been able to find sufficient resources on the uses of these visualization methods, as well as their benefits/drawbacks, I'm coming up with problems finding code to implement them in R.
I have located two user-written functions that will do survey plots and radial visualization in R. These appear to part of the package "dprep", which has since been discontinued from CRAN--and try as I might, I cannot seem to get it to install as a package when I download the older version from the archive. Additionally, all of this code is now six years and several versions out of data, and I am hesitant to recommend it to classmates if it may become completely unusable at some point.
I suppose what I'm asking is if there is any easier or cleaner way--possibly as part of an existing package--to implement these visualizations in R, or if my only option is using the above (very old) code to do it. I'm aware of solutions in other programming languages (Python) as well as other pieces of software (Orange, VisuLab), but since the class is primarily based around using R, I'd like to be able to present in it if I can.
Sounds like we need to teach you to search. The google pathway is always available but for R functionality it sometimes is not sufficiently specific if the topic name is commonly used for other concepts. I often pair the search term with 'rproject'
https://www.google.com/search?q=radviz&ie=utf-8&oe=utf-8#q=radviz+rproject
Brings up:
http://www.cs.uml.edu/~phoffman/Radviz/readme.txt # R interface to C-implementation
... as well as many others but it would take some effort to sort through to find R-specific implementation.
I have many successes using the findFn-function in the sos package:
install.packages("sos")
library(sos)
Originally I thought this was just the ordinary radar chart but seems it might be something different.
> findFn("Radial Coordinate Visualization")
found 12 matches; retrieving 1 page
Downloaded 4 links in 3 packages.
The search on Radviz only brings up a single item, radviz2d, whose help page links to a surveyplot function in the same package 'dprep'. The term 'radial' alone brought up a large number, possibly unmanageable:
> findFn("radial plots")
found 456 matches; retrieving 20 pages, 400 matches.
2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
Those terms deliver a somewhat more manageable number. Radar plots or spider plots are generally being used for discrete variables, but radial coordinate visualization appears to be a method of projecting multivariate associations on a two-dimensional domain. The 'circular' package also deals with display and statistics on continuous variables.
From the CRAN Archive I downloaded and unpackaed version 2.1 of radviz: dprep_2.1.tar.gz:
source('~/Downloads/dprep/R/radviz2d.R', chdir = TRUE)
mmnorm <-
function (data,minval=0,maxval=1)
{
d=dim(data)
c=class(data)
cnames=colnames(data)
classes=data[,d[2]]
data=data[,-d[2]]
minvect=apply(data,2,min)
maxvect=apply(data,2,max)
rangevect=maxvect-minvect
zdata=scale(data,center=minvect,scale=rangevect)
newminvect=rep(minval,d[2]-1)
newmaxvect=rep(maxval,d[2]-1)
newrangevect=newmaxvect-newminvect
zdata2=scale(zdata,center=FALSE,scale=(1/newrangevect))
zdata3=zdata2+newminvect
zdata3=cbind(zdata3,classes)
if (c=="data.frame") zdata3=as.data.frame(zdata3)
colnames(zdata3)=cnames
return(zdata3)
}
load("/Users/davidwinsemius/Downloads/dprep/data/my.iris.rda")
radviz2d(my.iris,"Iris")
The package also has several other functions including survey plot that are available in R, so they do not need to be compile. There is a compiled function in the package which I have not investigated.
I have released a new version of dprep. Edgar Acuna

Resources