I need a cloze question with a general statement and some results (random data and tables of statistical analysis) that includes several schoice questions each of them with its own statement. But I don't know how I should include that subquestions statements. A simple example cloze0.Rmd is shown below. I need export 30 different versios of this cloze question to moodle using the command exams2moodle("cloze0.Rmd", n = 30, name = "Simple_Cloze0", rule = 'none', schoice = list(shuffle = T), verbose = T) but this command includes the fist subquestion statement as a response option and misplace the correct answer in all subquestions. Any ideas much appreciated!
cloze0.Rmd ==> (moodle-result) ==> (needed-moodle-result)
```{r data generation, echo = FALSE, results = "hide"}
# sample
dt <- rnorm(30, 100, 5)
# Statistics
ndt <- length(dt)
mdt <- mean(dt)
sdt <- sd(dt)
vdt <- var(dt)
cvdt <- sdt/abs(mdt)
```
Question
========
A sample of **`r ndt`** individuals is draw and a variable $X$ is measured.
```{r, echo = F, comment = NA}
dt
```
Answerlist
----------
Choose the mean of $X$.
* `r mdt`.
* `r sdt`.
* `r vdt`.
* `r cvdt`.
Choose the standard deviation of $X$.
* `r mdt`.
* `r sdt`.
* `r vdt`.
* `r cvdt`.
Choose the variance of $X$.
* `r mdt`.
* `r sdt`.
* `r vdt`.
* `r cvdt`.
Choose the coefficient of variation of $X$.
* `r mdt`.
* `r sdt`.
* `r vdt`.
* `r cvdt`.
Meta-information
================
exname: simple_cloze
extype: cloze
exsolution: 1000|0100|0010|0001
exclozetype: schoice|schoice|schoice|schoice
extol: 0|0|0|0
exshuffle: TRUE
If you want this kind of control over the formatting of a cloze exercise then it is better to use ##ANSWERi## syntax or placing the answer interaction fields where you need them. See the boxhist2 exercise for a worked example.
In your case I would put the following questions before the Answerlist:
a. Choose the mean of $X$: ##ANSWER1##
b. Choose the standard deviation of $X$: ##ANSWER2##
c. Choose the variance of $X$: ##ANSWER3##
d. Choose the coefficient of variation of $X$: ##ANSWER4##
And then the Answerlist would just look like this:
Answerlist
----------
* `r mdt`.
* `r sdt`.
* `r vdt`.
* `r cvdt`.
* `r mdt`.
* `r sdt`.
...
Note that rather than manually listing all four statistics four times you could also do the following to create the entire Answerlist:
```{r, echo=FALSE, results="asis"}
answerlist(rep(c(mdt, sdt, vdt, cvdt), 4), markup = "markdown")
```
I would also add some rounding to, say, three digits for the answers. (Well, personally, I would create a cloze with four "num" items rather than "schoice" items.)
By default
exams2moodle("cloze0.Rmw")
will create dropdown menus for each of the four choice list (display "MULTICHOICE" in Moodle). If you really want radio buttons in a vertical layout instead (display "MULTICHOICE_V") you can switch to:
exams2moodle("cloze0.Rmd",
cloze = list(cloze_schoice_display = "MULTICHOICE_V"))
Note that in versions up to 2.3-6 of the package, the argument was called cloze_mchoice_display rather than cloze_schoice_display.
Related
I have a series of data, for example:
0.767838478
0.702426493
0.733858228
0.703275979
0.651456058
0.62427187
0.742353261
0.646359026
0.695630431
0.659101665
0.598786652
0.592840135
0.59199059
which I know fits best to an equation of the form:
y=ae^(b*x)+c
How can I fit the custom function to this data?
Similar question had been already asked on LibreOffice forum without a proper answer. I would appreciate if you could help me know how to do this. Preferably answers applying to any custom function rather than workarounds to this specific case.
There are multiple possible solutions for this. But one approach would be the following:
For determining the aand b in the trend line function y = a*e^(b*x) there are solutions using native Calc functions (LINEST, EXP, LN).
So we could the y = a*e^(b*x)+c taking as y-c= a*e^(b*x) and so if we are knowing c, the solution for y = a*e^(b*x) could be taken too. How to know c? One approach is described in Exponential Curve Fitting. There approximation of b, a and then c are made.
I have the main part of the delphi code from Exponential Curve Fitting : source listing translated to StarBasic for Calc. The part of the fine tuning of c is not translated until now. To-Do for you as professional and enthusiast programmers.
Example:
Data:
x y
0 0.767838478
1 0.702426493
2 0.733858228
3 0.703275979
4 0.651456058
5 0.62427187
6 0.742353261
7 0.646359026
8 0.695630431
9 0.659101665
10 0.598786652
11 0.592840135
12 0.59199059
Formulas:
B17: =EXP(INDEX(LINEST(LN($B$2:$B$14),$A$2:$A$14),1,2))
C17: =INDEX(LINEST(LN($B$2:$B$14),$A$2:$A$14),1,1)
y = a*e^(b*x) is also the function used for the chart's trend line calculation.
B19: =INDEX(TRENDEXPPLUSC($B$2:$B$14,$A$2:$A$14),1,1)
C19: =INDEX(TRENDEXPPLUSC($B$2:$B$14,$A$2:$A$14),1,2)
D19: =INDEX(TRENDEXPPLUSC($B$2:$B$14,$A$2:$A$14),1,3)
Code:
function trendExpPlusC(rangey as variant, rangex as variant) as variant
'get values from ranges
redim x(ubound(rangex)-1) as double
redim y(ubound(rangex)-1) as double
for i = lbound(x) to ubound(x)
x(i) = rangex(i+1,1)
y(i) = rangey(i+1,1)
next
'make helper arrays
redim dx(ubound(x)-1) as double
redim dy(ubound(x)-1) as double
redim dxyx(ubound(x)-1) as double
redim dxyy(ubound(x)-1) as double
for i = lbound(x) to ubound(x)-1
dx(i) = x(i+1) - x(i)
dy(i) = y(i+1) - y(i)
dxyx(i) = (x(i+1) + x(i))/2
dxyy(i) = dy(i) / dx(i)
next
'approximate b
s = 0
errcnt = 0
for i = lbound(dxyx) to ubound(dxyx)-1
on error goto errorhandler
s = s + log(abs(dxyy(i+1) / dxyy(i))) / (dxyx(i+1) - dxyx(i))
on error goto 0
next
b = s / (ubound(dxyx) - errcnt)
'approximate a
s = 0
errcnt = 0
for i = lbound(dx) to ubound(dx)
on error goto errorhandler
s = s + dy(i) / (exp(b * x(i+1)) - exp(b * x(i)))
on error goto 0
next
a = s / (ubound(dx) + 1 - errcnt)
'approximate c
s = 0
errcnt = 0
for i = lbound(x) to ubound(x)
on error goto errorhandler
s = s + y(i) - a * exp(b * x(i))
on error goto 0
next
c = s / (ubound(x) + 1 - errcnt)
'make y for (y - c) = a*e^(b*x)
for i = lbound(x) to ubound(x)
y(i) = log(abs(y(i) - c))
next
'get a and b from LINEST for (y - c) = a*e^(b*x)
oFunctionAccess = createUnoService( "com.sun.star.sheet.FunctionAccess" )
args = array(array(y), array(x))
ab = oFunctionAccess.CallFunction("LINEST", args)
if a < 0 then a = -exp(ab(0)(1)) else a = exp(ab(0)(1))
b = ab(0)(0)
trendExpPlusC = array(a, b, c)
exit function
errorhandler:
errcnt = errcnt + 1
resume next
end function
The formula y = beax is the exponential regression equation for LibreOffice chart trend lines.
LibreOffice exports all settings
All the settings of LibreOffice, all in the LibreOffice folder.
C:\Users\a←When installing the operating system, the name
entered.\AppData←File Manager ~ "Hidden project" to open, the AppData
folder will be displayed.\Roaming\LibreOffice
Back up the LibreOffice folder, when reinstalling, put the LibreOffice folder in its original place.
Note:
1. If the installation is preview edition, because the name of preview edition is LibreOfficeDev, so the LibreOfficeDev folder will be
displayed.
2. Formal edition can be installed together with preview edition, if both formal edition and preview edition are installed, LibreOffice
folder and LibreOfficeDev folder will be displayed.
3. To clear all settings, just delete the LibreOffice folder, then open the program, a new LibreOffice folder will be created.
LibreOffice exports a single toolbar I made
Common path
C:\Users\a←When installing the operating system, the name
entered.\AppData←File Manager ~ "Hidden project" to open, the AppData
folder will be
displayed.\Roaming\LibreOffice\4\user\config\soffice.cfg\modules\Please
connect the branch path of the individual software below.
Branch path
\modules\StartModule\toolbar\The "Start" toolbar I made is placed here.
\modules\swriter\toolbar\The "writer" toolbar I made is placed here.
\modules\scalc\toolbar\The "calc" toolbar I made is placed here.
\modules\simpress\toolbar\The "impress" toolbar I made is placed here.
\modules\sdraw\toolbar\The "draw" toolbar I made is placed here.
\modules\smath\toolbar\The "math" toolbar I made is placed here.
\modules\dbapp\toolbar\The "base" toolbar I made is placed here.
Backup file, when reinstalling, put the file in the original place.
Note:
Because of the toolbar that I made myself, default file name, will automatically use Numbering, so to open the file, can know the name of
the toolbar.
The front file name "custom_toolbar_" cannot be changed, change will cause error, behind's file name can be changed. For example:
custom_toolbar_c01611ed.xml→custom_toolbar_AAA.xml.
Do well of toolbar, can be copied to other places to use. For example: In the "writer" Do well of toolbar, can be copied to "calc"
places to use.
LibreOffice self-made symbol toolbar
Step 1 Start "Recording Macros function" Tools\Options\Advanced\Enable macro recording(Tick), in the
"Tools\Macros", the "Record Macro" option will appear.
Step 2 Recording Macros Tools\Macros\Record Macro→Recording action (click "Ω" to enter symbol→select symbol→Insert)→Stop
Recording→The name Macros stored in "Module1" is Main→Modify Main
name→Save.
Step 3 Add item new toolbar Tools\Customize\Toolbar→Add→Enter a name (example: symbol)→OK, the new toolbar will appear in the top
left.
Step 4 Will Macros Add item new toolbar Tools\Customize\Toolbar\Category\Macros\My
Macros\Standard\Module1\Main→Click "Main"→Add item→Modify→Rename (can
be named with symbol)→OK→OK.
I am trying to use &let in the beginning of my script to define a new macro variable... it should consist of equation from variables from dataset. The equation looks something like this, but SAS always gives me error like this (Runtime error was encountered, please see the log...).
The equation:
%let var_bad = (receivable_actual * 0.5) -
(EM_EVENTPROBABILITY * 0.02 * receivable_actual) +
((1 - EM_EVENTPROBABILITY) * 0.5 * (receivable_actual - amt_instalment));
Can you guys help me fix it?
Thanks,
Adam
#Jetzler: These are the errors it shows me in log.
ERROR 214-322: Variable name ( is not valid.
ERROR 22-7: Invalid option name -.
ERROR 23-7: Invalid value for the KEEP option.
---
23
1 ! (receivable_actual * 0.5) - (EM_EVENTPROBABILITY * 0.02 * receivable_actual) + ((1 - EM_EVENTPROBABILITY) * 0.5 * (receivable_actual - amt_instalment))
- -
214 22
ERROR 214-322: Variable name * is not valid.
ERROR 22-7: Invalid option name +.
1 ! (receivable_actual * 0.5) - (EM_EVENTPROBABILITY * 0.02 * receivable_actual) + ((1 - EM_EVENTPROBABILITY) * 0.5 * (receivable_actual - amt_instalment))
--- -
214 22
14338 + rename=(em_eventprobability = score_no_call));
-------
22 22
201 76
ERROR 214-322: Variable name 0.5 is not valid.
ERROR 22-7: Invalid option name *.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, -, :, ;, END, INDSNAME, KEY, KEYS, NOBS, OPEN, POINT, DATA, LAST, NULL.
ERROR 201-322: The option is not recognized and will be ignored.
ERROR 76-322: Syntax error, statement will be ignored.
Why don't you just calculate the variable in the dataset and then select it into a macro variable?
I am writing a rmarkdown document knitting to pdf with tables taken from portions of lists from the ezANOVA package. The tables are made using the pander package. Toy Rmarkdown file with toy dataset below.
---
title: "Table Doc"
output: pdf_document
---
```{r global_options, include=FALSE}
#set global knit options parameters.
knitr::opts_chunk$set(fig.width=12, fig.height=8, fig.path='Figs/',
echo=FALSE, warning=FALSE, message=FALSE, dev = 'pdf')
```
```{r, echo=FALSE}
# toy data
id <- rep(c(1,2,3,4), 5)
group1 <- factor(rep(c("A", "B"), 10))
group2 <- factor(rep(c("A", "B"), each = 10))
dv <- runif(20, min = 0, max = 10)
df <- data.frame(id, group1, group2, dv)
```
``` {r anova, echo = FALSE}
library(ez)
library(plyr)
library(pander)
# create anova object
anOb <- ezANOVA(df,
dv = dv,
wid = id,
between = c(group1, group2),
type = 3,
detailed = TRUE)
# extract the output table from the anova object, reduce it down to only desired columns
anOb <- data.frame(anOb[[1]][, c("Effect", "F", "p", "p<.05")])
# format entries in columns
anOb[,2] <- format( round (anOb[,2], digits = 1), nsmall = 1)
anOb[,3] <- format( round (anOb[,3], digits = 4), nsmall = 1)
pander(anOb, justify = c("left", "center", "center", "right"))
```
Now I have a few problems
a) For the last three columns I would like to have the column heading in the table aligned in the center, but the actual column entries underneath those headings aligned to the right.
b) I would like to have the column headings 'F' and 'p' in italics and the 'p' in the 'p<.05' column in italics also but the rest in normal font. So they read F, p and p<.05
I tried renaming the column headings using plyr::rename like so
anOb <- rename(anOb, c("F" = "italic(F)", "p" = "italic(p)", "p<.05" = ""))
But it didn't work
In markdown, you have to use the markdown syntax for italics, which is wrapping text between a star or underscore:
> names(anOb) <- c('Effect', '*F*', '*p*', '*p<.05*')
> pander(anOb)
-----------------------------------------
Effect *F* *p* *p<.05*
--------------- ------ -------- ---------
(Intercept) 52.3 0.0019 *
group1 1.3 0.3180
group2 2.0 0.2261
group1:group2 3.7 0.1273
-----------------------------------------
If you want to do that in a programmatic way, you can also use the pandoc.emphasis helper function to add the starts to a string.
But your other problem is due to a bug in the package, for which I've just proposed a fix on GH. Please feel free to give a try to that branch and report back on GH -- I will try to get some time later this week to clean up the related unit tests and merge the branch if everything seem to be OK.
I've been doing an OS-COMMAND that execute the -p "procedure.p" with -param that are inside a loop.
My question is how can I handle the number of prowin32.exe that will not spawn too much so it won't consume all my processor and also not less to make it fast?
Note: Version 8.3c
Sample Code
DEFINE VARIABLE Filter AS CHARACTER NO-UNDO.
For Each Item No-lock:
Assign Filter = "Item.Item = " + Item.Item NO-ERROR.
OS-COMMAND NO-WAIT
VALUE("C:\dlcs\83c\bin\prowin32 " +
"-p C:\nanox\syte_server5\ATMS-CONFIGURED-ICONS\LIVE\Nanox_utility\procedure.p " +
"-pf C:\nanox\syte_server5\ATMS-CONFIGURED-ICONS\LIVE\Nanox_utility\Conf\pilot.pf " +
"-param " + Filter).
END.
QUIT.
I would do it a bit differently. Decide ahead of time how many threads and then divvy up the work like so:
/* worker.p
*
* i.e.:
* mbpro dbName -p worker.p -param "0,5"
* mbpro dbName -p worker.p -param "1,5"
* mbpro dbName -p worker.p -param "2,5"
* mbpro dbName -p worker.p -param "3,5"
* mbpro dbName -p worker.p -param "4,5"
*
* in this sample the threadNum starts at 0 -- so end it at numThreads - 1
*
*/
define variable threadNum as integer no-undo.
define variable numThreads as integer no-undo.
assign
threadNum = integer( entry( 1, session:parameter ))
numThreads = integer( entry( 2, session:parameter ))
.
for each item no-lock where (( item.item modulo numThreads ) = threadnum ):
/* whatever */
end.
return.
For starters I suggest that numThreads be roughly the number of cores available in the server.
Also, headless batch processes shouldn't be using prowin32.exe. They should use _progres.exe.
8.3 is unspeakably ancient, obsolete and unsupported. Is this system running on a single core Pentium with Windows 3.11? That's relevant because the 8.3 "workgroup edition" will not behave very well if this is a multi-core system. If it is "enterprise" it won't be so bad. But even so you'd be very well advised to upgrade to a current release (11.3 as of this writing) if performance is at all important to you.
I do not work with version8.3, but it must pass (possibly replace the temp-table by a work-table).
Here I what I certainly do but it must improve:
DEFINE TEMP-TABLE ttpid NO-UNDO
FIELD pid AS CHARACTER
FIELD SIZE AS CHARACTER
INDEX i1 IS UNIQUE PRIMARY pid.
DEFINE VARIABLE wline AS CHARACTER NO-UNDO.
DEFINE VARIABLE wfile AS CHARACTER NO-UNDO.
wfile = "c:/tmp/list_tasklis.txt".
OS-COMMAND SILENT VALUE("tasklist > " + wfile).
INPUT FROM VALUE(wfile).
REPEAT:
IMPORT UNFORMATTED wline.
IF wline BEGINS "prowin32.exe"
THEN DO:
DO WHILE wline MATCHES "* *":
wline = REPLACE(wline, " ", " ").
END.
FIND FIRST ttpid
WHERE ttpid.pid = ENTRY(2, wline, " ")
NO-LOCK NO-ERROR.
IF NOT AVAILABLE ttpid
THEN DO:
CREATE ttpid.
ASSIGN ttpid.pid = ENTRY(2, wline, " ")
ttpid.SIZE = ENTRY(5, wline, " ").
END.
END.
END.
INPUT CLOSE.
FOR EACH ttpid
NO-LOCK:
MESSAGE "PID =" ttpid.pid SKIP
"SIZE =" ttpid.SIZE
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
OS-DELETE VALUE (wfile) NO-ERROR.
I m working on SSRS 2008.
i want to display date as 1st January 2011..
but "st" should be in superscipt ..
not like "1st".
is there any way to display "st", "nd","rd" and "th" in superscipt without installing any custom font type(other Font Type).
just copy and paste from the following list:
ABC⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ⁺ ⁻ ⁼ ⁽ ⁾
ABC₀ ₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ₊ ₋ ₌ ₍ ₎
ABCᵃ ᵇ ᶜ ᵈ ᵉ ᶠ ᵍ ʰ ⁱ ʲ ᵏ ˡ ᵐ ⁿ ᵒ ᵖ ʳ ˢ ᵗ ᵘ ᵛ ʷ ˣ ʸ ᶻ
ABCᴬ ᴮ ᴰ ᴱ ᴳ ᴴ ᴵ ᴶ ᴷ ᴸ ᴹ ᴺ ᴼ ᴾ ᴿ ᵀ ᵁ ᵂ
ABCₐ ₑ ᵢ ₒ ᵣ ᵤ ᵥ ₓ
ABC½ ¼ ¾ ⅓ ⅔ ⅕ ⅖ ⅗ ⅘ ⅙ ⅚ ⅛ ⅜ ⅝ ⅞ № ℠ ™ © ®
ABC^ ± ¶
Maybe...
You are limited to what can be done with String.Format. Font size and spacing also refer to the whole text box. So it isn't "native"
However, superscript is unicode so you may be able to to do it with some fancy expression that concatenate characters. I'd suggest custom code.
I haven't tried this, but these articles mention it
http://beyondrelational.com/blogs/jason/archive/2010/12/06/subscripts-and-superscripts-in-ssrs-reports.aspx
http://www.codeproject.com/KB/reporting-services/SSRSSuperscript.aspx
I am not looking for credit here as above solution has answered it for you but for beginners sake, I use a code function within my report.
So in my SQL say I have Number field, then I add a new field OrdinalNumber:
SELECT ..., Number,
CASE WHEN (Number % 100) BETWEEN 10 AND 20 THEN 4
WHEN (Number % 10) = 1 THEN 1
WHEN (Number % 10) = 2 THEN 2
WHEN (Number % 10) = 3 THEN 3
ELSE 4 END AS OrdinalNumber,
...
Then my code function:
Function OrdinalText(ByVal OrdinalNumber As Integer) As String
Dim result As String
Select Case OrdinalNumber
Case 1
result = "ˢᵗ"
Case 2
result = "ⁿᵈ"
Case 3
result = "ʳᵈ"
Case Else
result = "ᵗʰ"
End Select
Return result
End Function
Then in the report textbox I use the expression:
=CStr(Fields!Number.Value) & Code.OrdinalText(Fields!OrdinalNumber.Value)