Skip to content

Commit

Permalink
Merge pull request #109 from DigiKlausur/collapsible_cells
Browse files Browse the repository at this point in the history
Add button to hide the code of test cells
  • Loading branch information
tmetzl authored Jun 27, 2022
2 parents 42a360d + 1fb3f11 commit da0d682
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 23 additions & 0 deletions e2xgrader/server_extensions/formgrader/static/js/formgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ FormGrader.prototype.init = function () {
this.loadGrades();
this.loadComments();
this.loadAnnotations();
this.collapsibleCells();

// disable link selection on tabs
$('a:not(.tabbable)').attr('tabindex', '-1');
Expand Down Expand Up @@ -68,6 +69,28 @@ FormGrader.prototype.init = function () {
this.loaded = true;
};

FormGrader.prototype.collapsibleCells = function () {
console.log('hello');
$('.collapsible').each(function(idx, elem) {
let button = $(elem);
console.log(button);
let body = button.parent().parent().find('.panel-body');

button.click(function () {
$(body).toggle();
if ($(body).is(":hidden")) {
button.text("Show Test Code");
} else {
button.text("Hide Test Code");

}

});

console.log(body);
});
};

FormGrader.prototype.loadGrades = function () {
var that = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ div.prompt {
{%- elif cell.metadata.nbgrader.grade -%}
<span class="nbgrader-label"><code>{{ cell.metadata.nbgrader.grade_id }}</code></span>
{{ score(cell) }}
<button class="collapsible" style="color: black;">Hide Test Code</button>
{%- endif -%}
</div>
{%- endmacro %}
Expand Down Expand Up @@ -437,4 +438,4 @@ div.prompt {
</div>
{%- endif -%}

{% endblock input %}
{% endblock input %}

0 comments on commit da0d682

Please sign in to comment.