Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight differences in expected and student result #44

Open
sravanareddy opened this issue Nov 12, 2016 · 1 comment
Open

Highlight differences in expected and student result #44

sravanareddy opened this issue Nov 12, 2016 · 1 comment

Comments

@sravanareddy
Copy link
Contributor

Identify and highlight differences between outputs.

@bpw
Copy link
Member

bpw commented Mar 27, 2017

Some potentially helpful code, used for output diffing on cs111 ps01 code feedback before @fturbak added raw_input support to otter inspect. This will work until dealing with unordered output where structural checks (and highlighting) are needed.

https://docs.python.org/2/library/difflib.html

difflib.HtmlDiff().make_table(student_output, expected_output, fromdesc="Your output", todesc="Expected output")

Add a little CSS to do highlighting for:

.diff_add
.diff_sub
.diff_chg

e.g.:

.diff {
background: #eee;
border: 1px solid #ccc;
}
/* Output diff checking */
.diff td {
background: #f8f8f8;
font-family: monospace;
padding: 0em 0.2em;
border-color: #ccc;
}
.diff th {
padding: 0.25em;
}

.diff_sub {
color: #d70;
background: #fed;
border: 1px solid;
margin: 0px -1px;
padding: -1px 0px;
font-weight: bold;
font-family: monospace;
/* text-decoration: line-through; */
}
.diff_add {
color: #428;
background: #edf;
border: 1px solid;
margin: 0px -1px;
padding: -1px 0px;
font-weight: bold;
font-family: monospace;
/* text-decoration: overline; */
}
.diff_chg {
color: #833;
background: #fdd;
border: 1px solid;
margin: 0px -1px;
padding: -1px 0px;
font-weight: bold;
font-family: monospace;
/* text-decoration: underline; */
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants