-
Notifications
You must be signed in to change notification settings - Fork 38
/
exercise-format.txt
178 lines (134 loc) · 3.05 KB
/
exercise-format.txt
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
Title: teenSum
Language: Java
Tags: if, condition, plus, integer
Stem:
Given two `int`s, _a_ and _b_, return their sum. However, "teen" values in the
range 13..19, inclusive, are extra lucky. So if either value is a teen,
just return 19.
Code:
public class Answer
{
\show[
public int teenSum(int a, int b)
{
\[
if (a >= 13 && a <= 19
|| b >= 13 && b <= 19)
{
return 19;
}
else
{
return a + b;
}
]\
}
]\
}
Explanation:
This description shows as the feedback/explanation after completing a
question. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed
diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
sed diam voluptua.
Tests:
tests {
subject { new Answer() }
example tests {
teenSum( 3, 4) is 7
teenSum(10, 13) is 19
teenSum(13, 2) is 19
}
teenSum( 3, 19) is 19
teenSum(10, 10) is 20
teenSum( 6, 14) is 19
teenSum(15, 2) is 19
teenSum(12, 4) is 16
teenSum( 2, 20) is 22
teenSum( 2, 17) is 19
teenSum( 2, 16) is 19
hidden tests {
teenSum(13, 13) is 19
teenSum(19, 19) is 19
teenSum( 6, 7) is 13
teenSum(19, 20) is 19
teenSum( 2, 18) is 19
}
}
===========================================================================
Exercise:
Title:
Tags:
Owner:
Owners:
License:
Source:
Difficulty:
Explanation:
Stem:
Main text areas are in Markdown format (supports embedded HTML)
Prompt:
(choices as detected by Respondus? correct answer as detected by Respondus?)
Text formatting: Markdown and/or HTML?
Recognize Markdown H1 as title?
How to embed images? Use Markdown links and provide guidelines for how
relative links work.
Stem is implicit if omitted--all text up to prompt or choices or code
How to include read-only code in stem/prompt?
Use markdown format
How to indicate language for syntax highlighting?
answer code/scaffold?
Code:
\source_code[
\source_code_file[filename.java][ ]\
\[ blank ]\
\hide[ ]\
\show[ ]\
\fake[ ]\
]\
Tests:
xtest { assert 1 == 1 }
xtest "test case" { }
val num = 1 + 1
xtest ("test " + num) {}
xtest "ArrayList" {
xtest "Starts Empty" {
assert list.empty
}
for (i : 1..5) xtest ("Add " + i) {
list.add(i)
assert list.contains(i)
}
}
test "name" {
test "deeper" {
subject { new Tip() }
tip(20.99, 15) is 3.14
tip(47.32, 20) is 9.46
tip(50, 100) is 50.0
tip(50, 100) // matches reference
test "description" tip(50, 100) is 50.0
head is a method call (or chain) with a receiver (or, implicitly, the
subject; the subject can be a class; the subject can be given a name,
which defaults to "subject" if not specified)
is
is not
is instanceof
is (operator)
==
!=
<
>
<=
>=
between(max, min).inclusive
between(max, min).exclusive
throws
matches
given (lazy)
before
after
subject
assert
options(exact_match, anything else?)
}
}