Implement support for some basic embed options for work sheets via LTI

This commit also fixes an issue with the flash messages being positioned too high and displayed for too long
This commit is contained in:
Sebastian Serth
2018-12-10 16:53:43 +01:00
parent 4fd128b31b
commit a0d8b30ef2
25 changed files with 178 additions and 90 deletions

View File

@@ -110,6 +110,10 @@ configureEditors: function () {
// The event ready.jstree is fired too early and thus doesn't work.
selectFileInJsTree: function(filetree, file_id) {
if (!filetree.is(':visible'))
// The left sidebar is not shown and thus the filetree is not rendered.
return;
if (!filetree.hasClass('jstree-loading')) {
filetree.jstree("deselect_all");
filetree.jstree().select_node(file_id);
@@ -224,6 +228,11 @@ configureEditors: function () {
// remove last (empty) that is there by default line
document.removeLines(document.getLength() - 1, document.getLength() - 1);
editor.setReadOnly($(element).data('read-only') !== undefined);
if (editor.getReadOnly()) {
editor.setHighlightActiveLine(false);
editor.setHighlightGutterLine(false);
editor.renderer.$cursorLayer.element.style.opacity = 0;
}
editor.setShowPrintMargin(false);
editor.setTheme(this.THEME);
@@ -458,7 +467,7 @@ configureEditors: function () {
var editor = this.editor_for_file.get(file);
editor.gotoLine(line, 0);
event.preventDefault();
},
augmentStacktraceInOutput: function () {
@@ -722,6 +731,7 @@ configureEditors: function () {
this.initPrompt();
this.renderScore();
this.showFirstFile();
this.resizeAceEditors();
$(window).on("beforeunload", this.unloadAutoSave.bind(this));
// create autosave when the editor is opened the first time

View File

@@ -27,8 +27,11 @@ CodeOceanEditorEvaluation = {
printScoringResult: function (result, index) {
$('#results').show();
var card = $('#dummies').children().first().clone();
this.populateCard(card, result, index);
$('#results ul').first().append(card);
if (card.isPresent()) {
// the card won't be present if @embed_options[::hide_test_results] == true
this.populateCard(card, result, index);
$('#results ul').first().append(card);
}
},
printScoringResults: function (response) {
@@ -141,14 +144,19 @@ CodeOceanEditorEvaluation = {
},
printOutput: function (output, colorize, index) {
if (output.stderr === undefined && output.stdout === undefined) {
// Prevent empty element with no text at all
return;
}
var element = this.findOrCreateOutputElement(index);
if (!colorize) {
if (output.stdout != undefined && output.stdout != '') {
if (output.stdout !== undefined && output.stdout !== '') {
//element.append(output.stdout)
element.text(element.text() + output.stdout)
}
if (output.stderr != undefined && output.stderr != '') {
if (output.stderr !== undefined && output.stderr !== '') {
//element.append('StdErr: ' + output.stderr);
element.text('StdErr: ' + element.text() + output.stderr);
}

View File

@@ -172,8 +172,9 @@ CodeOceanEditorRequestForComments = {
this.createSubmission($('#requestComments'), null, createRequestForComments.bind(this));
$('#comment-modal').modal('hide');
$('#question').val('');
// we disabled the button to prevent that the user spams RFCs, but decided against this now.
//var button = $('#requestComments');
//button.prop('disabled', true);
},
}
};

View File

@@ -10,6 +10,7 @@ CodeOceanEditorSubmissions = {
*/
createSubmission: function (initiator, filter, callback) {
this.showSpinner(initiator);
var url = $(initiator).data('url') || $('#editor').data('submissions-url');
var jqxhr = this.ajax({
data: {
submission: {
@@ -21,7 +22,7 @@ CodeOceanEditorSubmissions = {
},
dataType: 'json',
method: 'POST',
url: $(initiator).data('url') || $('#editor').data('submissions-url')
url: url + '.json'
});
jqxhr.always(this.hideSpinner.bind(this));
jqxhr.done(this.createSubmissionCallback.bind(this));