Skip to content

Commit

Permalink
min-width on the feedback column in part marking testing
Browse files Browse the repository at this point in the history
This also changes the display of `dict` values to "Dictionary with <N>
entries", instead of a JSON encoding.
  • Loading branch information
christianp committed Jan 11, 2018
1 parent 52ef3c5 commit 74a0871
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
9 changes: 9 additions & 0 deletions editor/static/css/question/edit.css
Expand Up @@ -118,6 +118,7 @@
.jme-value[data-jme-value-type="error"], .jme-value[data-jme-value-type="error"],
.jme-value[data-jme-value-type="string"], .jme-value[data-jme-value-type="string"],
.jme-value[data-jme-value-type="list"], .jme-value[data-jme-value-type="list"],
.jme-value[data-jme-value-type="dict"],
.jme-value[data-jme-value-type="html"] { .jme-value[data-jme-value-type="html"] {
font-family: inherit; font-family: inherit;
} }
Expand Down Expand Up @@ -155,6 +156,14 @@
.table.notes col.name { .table.notes col.name {
width: 13em; width: 13em;
} }
.table.notes col.feedback {
min-width: 13em;
}
.table.notes .note .value {
max-height: 5em;
overflow-y: auto;
overflow-x: hidden;
}


/* /*
#question-name { #question-name {
Expand Down
9 changes: 8 additions & 1 deletion editor/static/js/editor.js
Expand Up @@ -1366,7 +1366,7 @@ $(document).ready(function() {
} }
}; };


function displayJMEValue(v) { var displayJMEValue = Editor.displayJMEValue = function(v) {
switch(v.type) { switch(v.type) {
case 'string': case 'string':
return Numbas.util.escapeHTML(v.value); return Numbas.util.escapeHTML(v.value);
Expand All @@ -1377,6 +1377,13 @@ $(document).ready(function() {
} else { } else {
return 'List of '+v.value.length+' '+Numbas.util.pluralise(v.value.length,'item','items'); return 'List of '+v.value.length+' '+Numbas.util.pluralise(v.value.length,'item','items');
} }
case 'dict':
var s = Numbas.jme.display.treeToJME({tok:v});
if(s.length<30) {
return s;
} else {
return 'Dictionary with '+Object.keys(v.value).length+" entries";
}
case 'html': case 'html':
if(v.value.length==1 && v.value[0].tagName=='IMG') { if(v.value.length==1 && v.value[0].tagName=='IMG') {
var src = v.value[0].getAttribute('src'); var src = v.value[0].getAttribute('src');
Expand Down
22 changes: 1 addition & 21 deletions editor/static/js/question/edit.js
Expand Up @@ -1364,30 +1364,10 @@ $(document).ready(function() {


this.display = ko.computed(function() { this.display = ko.computed(function() {
var v; var v;

if(this.anyError()) { if(this.anyError()) {
return this.anyError(); return this.anyError();
} else if(v = this.value()) { } else if(v = this.value()) {
switch(v.type) return Editor.displayJMEValue(v);
{
case 'string':
return Numbas.util.escapeHTML(v.value);
case 'list':
var s = Numbas.jme.display.treeToJME({tok:v});
if(s.length<30) {
return s;
} else {
return 'List of '+v.value.length+' '+Numbas.util.pluralise(v.value.length,'item','items');
}
case 'html':
if(v.value.length==1 && v.value[0].tagName=='IMG') {
var src = v.value[0].getAttribute('src');
return '<img src="'+src+'" title="'+src+'">';
}
return 'HTML node';
default:
return Numbas.jme.display.treeToJME({tok:v});
}
} else { } else {
return ''; return '';
} }
Expand Down
4 changes: 3 additions & 1 deletion editor/templates/question/edit.html
Expand Up @@ -551,6 +551,8 @@ <h4>Test that the marking algorithm works</h4>
<table class="notes table"> <table class="notes table">
<colgroup> <colgroup>
<col class="name"></col> <col class="name"></col>
<col class="value"></col>
<col class="feedback"></col>
</colgroup> </colgroup>
<thead> <thead>
<tr> <tr>
Expand All @@ -572,7 +574,7 @@ <h4>Test that the marking algorithm works</h4>
<span class="name monospace" data-bind="text: name, attr: {title: description}"></span> <span class="name monospace" data-bind="text: name, attr: {title: description}"></span>
</td> </td>
<td class="only-when-shown"> <td class="only-when-shown">
<span class="value jme-value" data-bind="jmevalue: value, error: error"></span> <div class="value jme-value" data-bind="jmevalue: value, error: error"></div>
</td> </td>
<td class="only-when-shown"> <td class="only-when-shown">
<ul class="list-unstyled" data-bind="foreach: messages"> <ul class="list-unstyled" data-bind="foreach: messages">
Expand Down

0 comments on commit 74a0871

Please sign in to comment.