[education/rkward] rkward: Add more previews to plugins

Thomas Friedrichsmeier null at kde.org
Wed May 4 17:20:22 BST 2022


Git commit ba8846b91ee1089ffb9770ece027d18bb66f5609 by Thomas Friedrichsmeier.
Committed on 02/05/2022 at 20:41.
Pushed by tfry into branch 'master'.

Add more previews to plugins

M  +1    -1    rkward/pages/rkward_welcome.rkh
M  +10   -3    rkward/plugins/analysis/crosstab_multi.js
M  +1    -1    rkward/plugins/analysis/crosstab_multi.xml
M  +18   -9    rkward/plugins/analysis/t_test.js
M  +1    -0    rkward/plugins/analysis/t_test.xml

https://invent.kde.org/education/rkward/commit/ba8846b91ee1089ffb9770ece027d18bb66f5609

diff --git a/rkward/pages/rkward_welcome.rkh b/rkward/pages/rkward_welcome.rkh
index e05bcd9b..c79fc0a3 100644
--- a/rkward/pages/rkward_welcome.rkh
+++ b/rkward/pages/rkward_welcome.rkh
@@ -29,7 +29,7 @@
 	<li><link href="rkward://page/rkward_for_r_users" /></li>
 	<li><link href="rkward://page/rkward_addons" /></li>
 	<li><link href="rkward://page/rkward_trouble_shooting" /></li>
-	<li>External links: <link href="http://rkward.kde.org/">project homepage</link></li>
+	<li>External links: <link href="https://rkward.kde.org/">project homepage</link></li>
 		</ul>
 	</section>
 </document>
diff --git a/rkward/plugins/analysis/crosstab_multi.js b/rkward/plugins/analysis/crosstab_multi.js
index 84bea8ae..61b05b75 100644
--- a/rkward/plugins/analysis/crosstab_multi.js
+++ b/rkward/plugins/analysis/crosstab_multi.js
@@ -11,9 +11,16 @@ function calculate () {
 	echo (');\n');
 }
 
-function printout () {
-	new Header (i18n ("Crosstabs (n to n)")).add (i18n ("Variables"), noquote ('datadescription')).print ();
-	echo ('\n');
+function printout(is_preview) {
+	if (!is_preview) {
+		new Header (i18n ("Crosstabs (n to n)")).add (i18n ("Variables"), noquote ('datadescription')).print ();
+		echo ('\n');
+	}
 	echo ('rk.print (result)\n');
 }
 
+function preview() {
+	preprocess();
+	calculate();
+	printout(true);
+}
diff --git a/rkward/plugins/analysis/crosstab_multi.xml b/rkward/plugins/analysis/crosstab_multi.xml
index e06db4a0..402c226c 100644
--- a/rkward/plugins/analysis/crosstab_multi.xml
+++ b/rkward/plugins/analysis/crosstab_multi.xml
@@ -11,6 +11,6 @@
 				<checkbox id="exclude_nas" label="Exclude missing values" checked="true"/>
 			</column>
 		</row>
+		<preview id="preview" mode="output"/>
 	</dialog>
-
 </document>
diff --git a/rkward/plugins/analysis/t_test.js b/rkward/plugins/analysis/t_test.js
index 21686a82..b4ec8ef7 100644
--- a/rkward/plugins/analysis/t_test.js
+++ b/rkward/plugins/analysis/t_test.js
@@ -40,16 +40,25 @@ function calculate () {
 	echo (options + ')\n');
 }
 
-function printout () {
-	var header = new Header (noquote ('result$method'));
-	header.add (i18n ('Comparing'), noquote ('names[1]'));
-	header.add (i18nc ("compare against", 'against'), (testForm != "const") ? noquote ('names[2]') : i18n ('constant value: %1', mu));
-	header.add ('H1', noquote ('rk.describe.alternative (result)'));
-	if (testForm == "indep") {
-		header.add (i18n ('Equal variances'), varequal ? i18n ('assumed') : i18n ('not assumed'));
+function preview() {
+	preprocess();
+	calculate();
+	printout(true);
+}
+
+function printout(is_preview) {
+	if (!is_preview) {
+		var header = new Header (noquote ('result$method'));
+		header.add (i18n ('Comparing'), noquote ('names[1]'));
+		header.add (i18nc ("compare against", 'against'), (testForm != "const") ? noquote ('names[2]') : i18n ('constant value: %1', mu));
+		header.add ('H1', noquote ('rk.describe.alternative (result)'));
+		if (testForm == "indep") {
+			header.add (i18n ('Equal variances'), varequal ? i18n ('assumed') : i18n ('not assumed'));
+		}
+		header.print ();
+		echo ('\n');
 	}
-	header.print ();
-	echo ('\n');
+
 	echo ('rk.results (list (\n');
 	echo ('	' + i18n ('Variable Name') + '=names,\n');
 	echo ('	' + i18n ('estimated mean') + '=result$estimate,\n');
diff --git a/rkward/plugins/analysis/t_test.xml b/rkward/plugins/analysis/t_test.xml
index 393c65bd..7b2b6278 100644
--- a/rkward/plugins/analysis/t_test.xml
+++ b/rkward/plugins/analysis/t_test.xml
@@ -38,6 +38,7 @@
 						</radio>
 					</column>
 				</row>
+				<preview id="preview" mode="output"/>
 			</tab>
 			<tab label="Options" id="tab_options">
 				<frame label="Show Confidence Interval" id="confint" checkable="true" checked="true">



More information about the rkward-tracker mailing list