2
function preprocess () {
3
// we'll need the ltm package, so in case it's not loaded...
8
function calculate () {
11
function printout () {
21
function doPrintout ($final) {
22
// this function takes care of generating the code for the printout() section. If $final is set to true,
23
// it generates the full code, including headers. If $final is set to false, only the essentials will
26
// let's read all values into php variables for the sake of readable code
27
$plot_type = getRK_val("plot_type");
28
$plot_type_item = getRK_val("plot_type_item");
29
$inp_items = getRK_val("inp_items");
30
$spin_from = getRK_val("spin_from");
31
$spin_to = getRK_val("spin_to");
32
$annotation = getRK_val("annotation");
33
$spin_categ = getRK_val("spin_categ");
35
// in case there are generic plot options defined:
36
$plot_options = getRK_val("plotoptions.code.printout");
37
$plot_ops_main = getRK_val("plotoptions.main");
38
$plot_ops_type = getRK_val("plotoptions.pointtype");
39
$plot_ops_xlab = getRK_val("plotoptions.xlab");
40
$plot_ops_ylab = getRK_val("plotoptions.ylab");
42
///////////////////////////////////
43
// check for selected options
45
if($plot_type == "items" && $plot_type_item == "ICC")
46
$options[] = "type=\"ICC\"" ;
47
if($plot_type == "items" && $plot_type_item == "IIC")
48
$options[] = "type=\"IIC\"" ;
49
if($plot_type == "items" && $plot_type_item == "OCCu")
50
$options[] = "type=\"OCCu\"" ;
51
if($plot_type == "items" && $plot_type_item == "OCCl")
52
$options[] = "type=\"OCCl\"" ;
54
if($plot_type == "items" && $inp_items) {
55
// for user convenience, we replace "-", ";" and space, split all input into an array
56
// and join it again, separated by commas:
57
$inp_items = str_replace("-",":",$inp_items);
58
$arr_items = split('[ ;]', $inp_items);
59
$options[] = "items=c(".join(",", $arr_items).")"; }
60
// plot all categories?
61
if($plot_type == "items" && $spin_categ != "0")
62
$options[] = "category=$spin_categ" ;
64
// for the test information curve, items must be set to "0":
65
if($plot_type == "TIC")
66
$options[] = "type=\"IIC\", items=0" ;
67
// there is no option for standard error curves yet, so we need some extra magic
68
// (see the "SEC" section in the plotting function below as well!)
69
if($plot_type == "SEC")
70
$options[] = "type=\"IIC\", items=0, plot=FALSE" ;
72
// more advanced options
73
// user defined zrange? we'll round it to two digits
74
if($spin_from != "-3.8" || $spin_to != "3.8")
75
$options[] = "zrange=c(".round($spin_from,2).",".round($spin_to,2).")" ;
76
// annotate lines and show legend?
77
if($annotation == "legend")
78
$options[] = "legend=TRUE" ;
79
if($annotation == "plain")
80
$options[] = "annot=FALSE" ;
83
rk.header("Graded response model plot")
87
// only the following section will be generated for $final==false
89
// first we'll check wheter standard error curves should be plotted,
90
// because it takes two steps to draw them:
91
if ($plot_type == "SEC") { ?>
92
# two steps are needed to plot standard error curves
93
# first some values are generated...
94
res <- try(plot(<? getRK("x");
95
if($options) echo(", ".join(", ", $options));
98
# ... and then they're used to plot the curves:
99
try(plot(res[,"z"], 1/sqrt(res[,"test.info"]), lwd=2<?
100
// we give come defaults, but they can be changed via the embedded plot options:
101
if(!$plot_ops_type) echo(", type=\"l\"");
102
if(!$plot_ops_xlab) echo(", xlab=\"Ability\"");
103
if(!$plot_ops_ylab) echo(", ylab=\"Standard Error\"");
104
if(!$plot_ops_main) echo(", main=\"Stadard Error of Measurement\"");
105
if($plot_options) echo($plot_options);
108
// and this will be plotted if anything else than stadard error curves are chosen:
110
try(plot(<? getRK("x");
111
if($options) echo(", ".join(", ", $options));
112
if($plot_options) echo($plot_options);
b'\\ No newline at end of file'