-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathREADME.html
More file actions
206 lines (180 loc) · 18.3 KB
/
README.html
File metadata and controls
206 lines (180 loc) · 18.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="George Moroz" />
<meta name="date" content="2017-03-16" />
<title>AssignmentCheck: automatic check of your students’ assignments</title>
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
div.sourceCode { overflow-x: auto; }
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
margin: 0; padding: 0; vertical-align: baseline; border: none; }
table.sourceCode { width: 100%; line-height: 100%; }
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
td.sourceCode { padding-left: 5px; }
code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
code > span.dt { color: #902000; } /* DataType */
code > span.dv { color: #40a070; } /* DecVal */
code > span.bn { color: #40a070; } /* BaseN */
code > span.fl { color: #40a070; } /* Float */
code > span.ch { color: #4070a0; } /* Char */
code > span.st { color: #4070a0; } /* String */
code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
code > span.ot { color: #007020; } /* Other */
code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
code > span.fu { color: #06287e; } /* Function */
code > span.er { color: #ff0000; font-weight: bold; } /* Error */
code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
code > span.cn { color: #880000; } /* Constant */
code > span.sc { color: #4070a0; } /* SpecialChar */
code > span.vs { color: #4070a0; } /* VerbatimString */
code > span.ss { color: #bb6688; } /* SpecialString */
code > span.im { } /* Import */
code > span.va { color: #19177c; } /* Variable */
code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code > span.op { color: #666666; } /* Operator */
code > span.bu { } /* BuiltIn */
code > span.ex { } /* Extension */
code > span.pp { color: #bc7a00; } /* Preprocessor */
code > span.at { color: #7d9029; } /* Attribute */
code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
</style>
<link href="data:text/css;charset=utf-8,body%20%7B%0Abackground%2Dcolor%3A%20%23fff%3B%0Amargin%3A%201em%20auto%3B%0Amax%2Dwidth%3A%20700px%3B%0Aoverflow%3A%20visible%3B%0Apadding%2Dleft%3A%202em%3B%0Apadding%2Dright%3A%202em%3B%0Afont%2Dfamily%3A%20%22Open%20Sans%22%2C%20%22Helvetica%20Neue%22%2C%20Helvetica%2C%20Arial%2C%20sans%2Dserif%3B%0Afont%2Dsize%3A%2014px%3B%0Aline%2Dheight%3A%201%2E35%3B%0A%7D%0A%23header%20%7B%0Atext%2Dalign%3A%20center%3B%0A%7D%0A%23TOC%20%7B%0Aclear%3A%20both%3B%0Amargin%3A%200%200%2010px%2010px%3B%0Apadding%3A%204px%3B%0Awidth%3A%20400px%3B%0Aborder%3A%201px%20solid%20%23CCCCCC%3B%0Aborder%2Dradius%3A%205px%3B%0Abackground%2Dcolor%3A%20%23f6f6f6%3B%0Afont%2Dsize%3A%2013px%3B%0Aline%2Dheight%3A%201%2E3%3B%0A%7D%0A%23TOC%20%2Etoctitle%20%7B%0Afont%2Dweight%3A%20bold%3B%0Afont%2Dsize%3A%2015px%3B%0Amargin%2Dleft%3A%205px%3B%0A%7D%0A%23TOC%20ul%20%7B%0Apadding%2Dleft%3A%2040px%3B%0Amargin%2Dleft%3A%20%2D1%2E5em%3B%0Amargin%2Dtop%3A%205px%3B%0Amargin%2Dbottom%3A%205px%3B%0A%7D%0A%23TOC%20ul%20ul%20%7B%0Amargin%2Dleft%3A%20%2D2em%3B%0A%7D%0A%23TOC%20li%20%7B%0Aline%2Dheight%3A%2016px%3B%0A%7D%0Atable%20%7B%0Amargin%3A%201em%20auto%3B%0Aborder%2Dwidth%3A%201px%3B%0Aborder%2Dcolor%3A%20%23DDDDDD%3B%0Aborder%2Dstyle%3A%20outset%3B%0Aborder%2Dcollapse%3A%20collapse%3B%0A%7D%0Atable%20th%20%7B%0Aborder%2Dwidth%3A%202px%3B%0Apadding%3A%205px%3B%0Aborder%2Dstyle%3A%20inset%3B%0A%7D%0Atable%20td%20%7B%0Aborder%2Dwidth%3A%201px%3B%0Aborder%2Dstyle%3A%20inset%3B%0Aline%2Dheight%3A%2018px%3B%0Apadding%3A%205px%205px%3B%0A%7D%0Atable%2C%20table%20th%2C%20table%20td%20%7B%0Aborder%2Dleft%2Dstyle%3A%20none%3B%0Aborder%2Dright%2Dstyle%3A%20none%3B%0A%7D%0Atable%20thead%2C%20table%20tr%2Eeven%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0A%7D%0Ap%20%7B%0Amargin%3A%200%2E5em%200%3B%0A%7D%0Ablockquote%20%7B%0Abackground%2Dcolor%3A%20%23f6f6f6%3B%0Apadding%3A%200%2E25em%200%2E75em%3B%0A%7D%0Ahr%20%7B%0Aborder%2Dstyle%3A%20solid%3B%0Aborder%3A%20none%3B%0Aborder%2Dtop%3A%201px%20solid%20%23777%3B%0Amargin%3A%2028px%200%3B%0A%7D%0Adl%20%7B%0Amargin%2Dleft%3A%200%3B%0A%7D%0Adl%20dd%20%7B%0Amargin%2Dbottom%3A%2013px%3B%0Amargin%2Dleft%3A%2013px%3B%0A%7D%0Adl%20dt%20%7B%0Afont%2Dweight%3A%20bold%3B%0A%7D%0Aul%20%7B%0Amargin%2Dtop%3A%200%3B%0A%7D%0Aul%20li%20%7B%0Alist%2Dstyle%3A%20circle%20outside%3B%0A%7D%0Aul%20ul%20%7B%0Amargin%2Dbottom%3A%200%3B%0A%7D%0Apre%2C%20code%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0Aborder%2Dradius%3A%203px%3B%0Acolor%3A%20%23333%3B%0Awhite%2Dspace%3A%20pre%2Dwrap%3B%20%0A%7D%0Apre%20%7B%0Aborder%2Dradius%3A%203px%3B%0Amargin%3A%205px%200px%2010px%200px%3B%0Apadding%3A%2010px%3B%0A%7D%0Apre%3Anot%28%5Bclass%5D%29%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0A%7D%0Acode%20%7B%0Afont%2Dfamily%3A%20Consolas%2C%20Monaco%2C%20%27Courier%20New%27%2C%20monospace%3B%0Afont%2Dsize%3A%2085%25%3B%0A%7D%0Ap%20%3E%20code%2C%20li%20%3E%20code%20%7B%0Apadding%3A%202px%200px%3B%0A%7D%0Adiv%2Efigure%20%7B%0Atext%2Dalign%3A%20center%3B%0A%7D%0Aimg%20%7B%0Abackground%2Dcolor%3A%20%23FFFFFF%3B%0Apadding%3A%202px%3B%0Aborder%3A%201px%20solid%20%23DDDDDD%3B%0Aborder%2Dradius%3A%203px%3B%0Aborder%3A%201px%20solid%20%23CCCCCC%3B%0Amargin%3A%200%205px%3B%0A%7D%0Ah1%20%7B%0Amargin%2Dtop%3A%200%3B%0Afont%2Dsize%3A%2035px%3B%0Aline%2Dheight%3A%2040px%3B%0A%7D%0Ah2%20%7B%0Aborder%2Dbottom%3A%204px%20solid%20%23f7f7f7%3B%0Apadding%2Dtop%3A%2010px%3B%0Apadding%2Dbottom%3A%202px%3B%0Afont%2Dsize%3A%20145%25%3B%0A%7D%0Ah3%20%7B%0Aborder%2Dbottom%3A%202px%20solid%20%23f7f7f7%3B%0Apadding%2Dtop%3A%2010px%3B%0Afont%2Dsize%3A%20120%25%3B%0A%7D%0Ah4%20%7B%0Aborder%2Dbottom%3A%201px%20solid%20%23f7f7f7%3B%0Amargin%2Dleft%3A%208px%3B%0Afont%2Dsize%3A%20105%25%3B%0A%7D%0Ah5%2C%20h6%20%7B%0Aborder%2Dbottom%3A%201px%20solid%20%23ccc%3B%0Afont%2Dsize%3A%20105%25%3B%0A%7D%0Aa%20%7B%0Acolor%3A%20%230033dd%3B%0Atext%2Ddecoration%3A%20none%3B%0A%7D%0Aa%3Ahover%20%7B%0Acolor%3A%20%236666ff%3B%20%7D%0Aa%3Avisited%20%7B%0Acolor%3A%20%23800080%3B%20%7D%0Aa%3Avisited%3Ahover%20%7B%0Acolor%3A%20%23BB00BB%3B%20%7D%0Aa%5Bhref%5E%3D%22http%3A%22%5D%20%7B%0Atext%2Ddecoration%3A%20underline%3B%20%7D%0Aa%5Bhref%5E%3D%22https%3A%22%5D%20%7B%0Atext%2Ddecoration%3A%20underline%3B%20%7D%0A%0Acode%20%3E%20span%2Ekw%20%7B%20color%3A%20%23555%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%0Acode%20%3E%20span%2Edt%20%7B%20color%3A%20%23902000%3B%20%7D%20%0Acode%20%3E%20span%2Edv%20%7B%20color%3A%20%2340a070%3B%20%7D%20%0Acode%20%3E%20span%2Ebn%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Efl%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Ech%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Est%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Eco%20%7B%20color%3A%20%23888888%3B%20font%2Dstyle%3A%20italic%3B%20%7D%20%0Acode%20%3E%20span%2Eot%20%7B%20color%3A%20%23007020%3B%20%7D%20%0Acode%20%3E%20span%2Eal%20%7B%20color%3A%20%23ff0000%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%0Acode%20%3E%20span%2Efu%20%7B%20color%3A%20%23900%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%20code%20%3E%20span%2Eer%20%7B%20color%3A%20%23a61717%3B%20background%2Dcolor%3A%20%23e3d2d2%3B%20%7D%20%0A" rel="stylesheet" type="text/css" />
</head>
<body>
<h1 class="title toc-ignore"><code>AssignmentCheck</code>: automatic check of your students’ assignments</h1>
<h4 class="author"><em>George Moroz</em></h4>
<h4 class="date"><em>2017-03-16</em></h4>
<div id="installation" class="section level3">
<h3>1. Installation</h3>
<p>Since <code>AssignmentCheck</code> is an R package, you should install <a href="https://www.r-project.org/">R</a> on your PC if you haven’t already done so. To install the <code>AssignmentCheck</code> package, run the following command at your R IDE, so you can also get the development version from GitHub:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">install.packages</span>(<span class="st">"devtools"</span>)
devtools::<span class="kw">install_github</span>(<span class="st">"agricolamz/AssignmentCheck"</span>)</code></pre></div>
<p>Load package:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">library</span>(AssignmentCheck)</code></pre></div>
</div>
<div id="checks" class="section level3">
<h3>2. Checks</h3>
<p>Imagine that we have a directory with some files from our students</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">list.files</span>()</code></pre></div>
<pre><code>## [1] "test_1.Rmd" "test_2.Rmd" "test_3.Rmd" "test_4.Rmd" "test.txt"</code></pre>
<p>As you can see, there are <code>.Rmd</code> files and one <code>.txt</code> file. These files have awfull names, but believe me: even if you ask your student to name files in line with some pattern, you will recieve a couple files with nasty names. Lets look inside of one of them:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">readLines</span>(<span class="st">"test_1.Rmd"</span>)</code></pre></div>
<pre><code>## [1] "---"
## [2] "title: \"test\""
## [3] "author: \"Tom Sawyer\""
## [4] "group: \"1 group\""
## [5] "date: '14-03-2017'"
## [6] "output: html_document"
## [7] "---"
## [8] ""
## [9] "```{r setup, include=FALSE}"
## [10] "knitr::opts_chunk$set(echo = TRUE)"
## [11] "```"
## [12] ""
## [13] "### 1.1"
## [14] "Tro-lo-lo"
## [15] "```{r}"
## [16] "2+2"
## [17] "```"
## [18] ""
## [19] "### 1.2"
## [20] "Tro-lo-lo"
## [21] "```{r}"
## [22] "fit <- lm(mpg~cyl, mtcars)"
## [23] "fit$coefficients"
## [24] "```"</code></pre>
<p>As a teacher you can make your own correct file and create an expectations object using <code>make_expectations</code> function. Lets make <code>test_1.Rmd</code> the base correct file:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">make_expectations</span>(<span class="st">"test_1.Rmd"</span>)</code></pre></div>
<pre><code>## [[1]]
## [1] 4
##
## [[2]]
## (Intercept) cyl
## 37.88458 -2.87579</code></pre>
<p>So that correct answers you can provide to the <code>test_files</code> function. This function takes all <code>.Rmd</code> files and check, whether <code>R</code> code in <code>R</code> chunks produces the same result that we expected. Our expectations should be provided via <code>list()</code> object.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">fit <-<span class="st"> </span><span class="kw">lm</span>(mpg~cyl, mtcars)
<span class="kw">test_files</span>(<span class="dt">expectations =</span> <span class="kw">list</span>(<span class="dv">4</span>, fit$coefficients))</code></pre></div>
<pre><code>## author ### 1.1 ### 1.2 results file_name
## 1 Tom Sawyer TRUE TRUE 2 test_1.Rmd
## 2 Huckleberry Finn TRUE TRUE 2 test_2.Rmd
## 3 Joe Harper FALSE TRUE 1 test_3.Rmd
## 4 Amy Lawrence FALSE FALSE 0 test_4.Rmd</code></pre>
<p>As you can see, there are students’ name from <code>name:</code> field and summary for each student.</p>
<p>There is a variable <code>keyword_prefix</code> that defines the common part of the keywords, so you can ask your students to put their answer code chunks after some keywords. By default <code>keyword_prefix</code> is <code>"### "</code>, so your students can write “### 1.1”, “### 1.2” and so on. But you can specify your own prefixes.</p>
<p>If we combine both <code>test_files</code> and <code>make_expectations</code> functions we can get the same summary for all students:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">test_files</span>(<span class="dt">expectations =</span> <span class="kw">make_expectations</span>(<span class="st">"test_1.Rmd"</span>))</code></pre></div>
<pre><code>## author ### 1.1 ### 1.2 results file_name
## 1 Tom Sawyer TRUE TRUE 2 test_1.Rmd
## 2 Huckleberry Finn TRUE TRUE 2 test_2.Rmd
## 3 Joe Harper FALSE TRUE 1 test_3.Rmd
## 4 Amy Lawrence FALSE FALSE 0 test_4.Rmd</code></pre>
<p>Sometimes it is nice to know the students’ group, so just ask them to write “group: …” (see <code>readLines("test_1.Rmd")</code> example below) in the rmarkdown header and use <code>group</code> argument.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">test_files</span>(<span class="dt">expectations =</span> <span class="kw">make_expectations</span>(<span class="st">"test_1.Rmd"</span>, <span class="dt">group =</span> <span class="ot">TRUE</span>))</code></pre></div>
<pre><code>## author group_name ### 1.1 ### 1.2 results file_name
## 1 Tom Sawyer 1 group TRUE TRUE 2 test_1.Rmd
## 2 Huckleberry Finn 1 group TRUE TRUE 2 test_2.Rmd
## 3 Joe Harper 2 group FALSE TRUE 1 test_3.Rmd
## 4 Amy Lawrence 2 group FALSE FALSE 0 test_4.Rmd</code></pre>
<p>It is important to note, that all checks don’t create any variables in your working environment, so all students are checked independently. But you should know libraries that your students used and turn them on in advance.</p>
<p>If your students (and you) have some plots in your markdowns, they will be created in your Viewer, so it is nice practice to ask your students to write their names on the plots. There is no good way to check plot correctness, so I propose not to use automatic check here.</p>
<p>When you get the result metrix from the <code>test_files()</code> function you can use the <code>mistaken_tasks()</code> function for generating a new rmarkdown file with fragments of students’ works.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">result <-<span class="st"> </span><span class="kw">test_files</span>(<span class="dt">expectations =</span> <span class="kw">make_expectations</span>(<span class="st">"test_1.Rmd"</span>))
<span class="kw">mistaken_tasks</span>(result, <span class="dt">write_file =</span> <span class="ot">FALSE</span>)</code></pre></div>
<pre><code>## [1] "---" "date: \"`r Sys.Date()`\""
## [3] "output: html_document" "---"
## [5] "" "### 1.1 Joe Harper"
## [7] "Tro-lo-lo" "```{r}"
## [9] "2+3" "```"
## [11] "" "### 1.1 Amy Lawrence"
## [13] "Tro-lo-lo" "```{r}"
## [15] "2+6" "```"
## [17] "" "### 1.2 Amy Lawrence"
## [19] "Tro-lo-lo" "```{r}"
## [21] "fit <- lm(mpg~cyl, mtcars)" "fit$coefficients+1"
## [23] "```"</code></pre>
<p>As you see, It is the new rmarkdown file, where all fragments with unexpected values are named after a student that produced this part of rmarkdown. If you use <code>write_file = TRUE</code> it will creat a file <code>"mistaken_tasks.Rmd"</code> in your working directory. You can open it using <code>file.edit("mistaken_tasks.Rmd")</code> command.</p>
</div>
<div id="citing-assignmentcheck" class="section level3">
<h3>3. Citing <code>AssignmentCheck</code></h3>
<p>It is important to cite R and R packages when you use them. For this purpose use the <code>citation</code> function in R:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">citation</span>(<span class="st">"AssignmentCheck"</span>)</code></pre></div>
<pre><code>##
## To cite package 'AssignmentCheck' in publications use:
##
## George Moroz (2017). AssignmentCheck: Check r cjunks in
## rmarkdown files. R package version 0.1.0.
## https://github.com/agricolamz/AssignmentCheck/
##
## A BibTeX entry for LaTeX users is
##
## @Manual{,
## title = {AssignmentCheck: Check r cjunks in rmarkdown files},
## author = {George Moroz},
## year = {2017},
## note = {R package version 0.1.0},
## url = {https://github.com/agricolamz/AssignmentCheck/},
## }
##
## ATTENTION: This citation information has been auto-generated from
## the package DESCRIPTION file and may need manual editing, see
## 'help("citation")'.</code></pre>
</div>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>