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");
34
// in case there are generic plot options defined:
35
$plot_options = getRK_val("plotoptions.code.printout");
36
$plot_ops_main = getRK_val("plotoptions.main");
37
$plot_ops_type = getRK_val("plotoptions.pointtype");
38
$plot_ops_xlab = getRK_val("plotoptions.xlab");
39
$plot_ops_ylab = getRK_val("plotoptions.ylab");
41
///////////////////////////////////
42
// check for selected options
44
if($plot_type == "items" && $plot_type_item == "ICC")
45
$options[] = "type=\"ICC\"" ;
46
if($plot_type == "items" && $plot_type_item == "IIC")
47
$options[] = "type=\"IIC\"" ;
49
if($plot_type == "items" && $inp_items) {
50
// for user convenience, we replace "-", ";" and space, split all input into an array
51
// and join it again, separated by commas:
52
$inp_items = str_replace("-",":",$inp_items);
53
$arr_items = split('[ ;]', $inp_items);
54
$options[] = "items=c(".join(",", $arr_items).")"; }
56
// for the test information curve, items must be set to "0":
57
if($plot_type == "TIC")
58
$options[] = "type=\"IIC\", items=0" ;
59
// there is no option for standard error curves yet, so we need some extra magic
60
// (see the "SEC" section in the plotting function below as well!)
61
if($plot_type == "SEC")
62
$options[] = "type=\"IIC\", items=0, plot=FALSE" ;
64
// more advanced options
65
// user defined zrange? we'll round it to two digits
66
if($spin_from != "-3.8" || $spin_to != "3.8")
67
$options[] = "zrange=c(".round($spin_from,2).",".round($spin_to,2).")" ;
68
// annotate lines and show legend?
69
if($annotation == "legend")
70
$options[] = "legend=TRUE" ;
71
if($annotation == "plain")
72
$options[] = "annot=FALSE" ;
75
rk.header("Rasch model plot")
79
// only the following section will be generated for $final==false
81
// first we'll check wheter standard error curves should be plotted,
82
// because it takes two steps to draw them:
83
if ($plot_type == "SEC") { ?>
84
# two steps are needed to plot standard error curves
85
# first some values are generated...
86
res <- try(plot(<? getRK("x");
87
if($options) echo(", ".join(", ", $options));
90
# ... and then they're used to plot the curves:
91
try(plot(res[,"z"], 1/sqrt(res[,"info"]), lwd=2<?
92
// we give come defaults, but they can be changed via the embedded plot options:
93
if(!$plot_ops_type) echo(", type=\"l\"");
94
if(!$plot_ops_xlab) echo(", xlab=\"Ability\"");
95
if(!$plot_ops_ylab) echo(", ylab=\"Standard Error\"");
96
if(!$plot_ops_main) echo(", main=\"Stadard Error of Measurement\"");
97
if($plot_options) echo($plot_options);
100
// and this will be plotted if anything else than stadard error curves are chosen:
102
try(plot(<? getRK("x");
103
if($options) echo(", ".join(", ", $options));
104
if($plot_options) echo($plot_options);
b'\\ No newline at end of file'