Skip to content
This repository was archived by the owner on Oct 25, 2025. It is now read-only.

Commit 4e81d69

Browse files
committed
fix style grading
1 parent 86a7329 commit 4e81d69

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

src/graders/style.arr

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,17 @@ fun check-fun-names(ast :: A.Program) block:
102102
end
103103
}
104104
ast.visit(visitor)
105-
violation.reverse()
105+
violations.reverse()
106106
end
107107

108108
fun check-binds(ast :: A.Program) block:
109109
var violations = [list:]
110110

111111
visitor = A.default-iter-visitor.{
112112
method s-bind(self, l, _, name, _):
113-
if not(is-valid-name(true, name)) block:
113+
if not(is-valid-name(true, name.s)) block:
114114
line = l.start-line
115-
violations := link(violation(line, other-name(name)), violations)
115+
violations := link(violation(line, other-name(name.s)), violations)
116116
true
117117
else:
118118
true
@@ -134,7 +134,10 @@ fun check-tl-fun-spacing(ast :: A.Program):
134134
| s-fun(l, _, _, _, _, _, _, _, _, _) =>
135135
start = l.start-line
136136
_end = l.end-line
137-
if (prev-end + 2) <= start:
137+
if (start - prev-end) < 2:
138+
print("pre-fun: " + torepr(prev-fun) + "\n")
139+
print("prev: " + torepr(prev-end) + "\n")
140+
print("start: " + torepr(start) + "\n")
138141
new-violations = link(
139142
violation(start, function-spacing), violations
140143
)
@@ -153,7 +156,7 @@ fun check-tl-fun-spacing(ast :: A.Program):
153156
end
154157

155158
fun score-style(
156-
path :: String
159+
path :: String, base-filename :: String
157160
):
158161
cases (Either) CA.parse-path(path):
159162
| left(err) =>
@@ -163,7 +166,7 @@ fun score-style(
163166
check-fun-names(prog) +
164167
check-binds(prog) +
165168
check-tl-fun-spacing(prog)
166-
info = style-info(path, violations)
169+
info = style-info(base-filename, violations)
167170
num = L.length(violations)
168171
score = 1 - if num > 10: 0 else: 0.1 * num end
169172
right({score; info})
@@ -185,12 +188,12 @@ fun fmt-style(score, info :: StyleInfo) -> AG.ComboAggregate:
185188
end
186189

187190
fun mk-style(
188-
id :: AG.Id, deps :: List<AG.Id>, path :: String,
191+
id :: AG.Id, deps :: List<AG.Id>, path :: String, base-filename :: String,
189192
max-score :: Number
190193
):
191194
name = "Automated Style Grading"
192195
scorer = lam():
193-
score-style(path)
196+
score-style(path, base-filename)
194197
end
195198
fmter = fmt-style
196199
part = none

src/input.arr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ fun convert-grader(
166166
mk-program-inspector(id, deps, entry)
167167
| typ == "style" then:
168168
points = grader.get("points").and-then(expect-num).or-else(0)
169-
mk-style(id, deps, entry, points)
169+
mk-style(id, deps, entry, entry-opt.value, points)
170170
| typ == "image-artifact" then:
171171
out = grader.get-value("out") ^ expect-str
172172
config = grader.get-value("config") ^ expect-obj

src/output.arr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ data PawtograderAnnotations:
196196
rubric-check-id :: Option<Number>,
197197
released :: Boolean) with:
198198
method to-json(self) block:
199-
sd = self.common-sd(self)
199+
sd = self.common-sd()
200200
J.j-obj(sd.freeze())
201201
end
202202
| feedback-line-comment(
@@ -208,7 +208,7 @@ data PawtograderAnnotations:
208208
line :: Number,
209209
file-name :: String) with:
210210
method to-json(self) block:
211-
sd = self.common-sd(self)
211+
sd = self.common-sd()
212212
add(sd, "line", self.line, J.to-json)
213213
add(sd, "file_name", self.file-name, J.to-json)
214214
J.j-obj(sd.freeze())
@@ -221,14 +221,14 @@ data PawtograderAnnotations:
221221
released :: Boolean,
222222
artifact-name :: String) with:
223223
method to-json(self) block:
224-
sd = self.common-sd(self)
224+
sd = self.common-sd()
225225
add(sd, "artifact_name", self.artifact-name, J.to-json)
226226
J.j-obj(sd.freeze())
227227
end
228228
sharing:
229229
method common-sd(self) block:
230230
sd = [SD.mutable-string-dict:]
231-
add(sd, "author", self.author, _.to-json)
231+
add(sd, "author", self.author, _.to-json())
232232
add(sd, "message", self.message, J.to-json)
233233
add(sd, "points", self.points, num-to-json)
234234
add(sd, "rubric_check_id", self.rubric-check-id, num-to-json)

tests/scripts/from-yaml.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ program
3030
.option("-s, --solution <dir>", "Directory containing pawtograder.yml", ".")
3131
.action(async (submission, { solution }) => {
3232
const rawConfig = await readFile(join(solution, "pawtograder.yml"), "utf8");
33-
const config = yaml.parse(rawConfig);
33+
const config = yaml.parse(rawConfig, { merge: true });
3434
const spec = Spec.parse({
3535
solution_dir: solution,
3636
submission_dir: submission,

0 commit comments

Comments
 (0)