Reduce file attributes in JSON for submission#show
This commit is contained in:

committed by
Sebastian Serth

parent
8c41aa5a73
commit
65212c4b4b
@ -54,7 +54,7 @@ CodeOceanEditorSubmissions = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
createSubmissionCallback: function(data){
|
createSubmissionCallback: function(submission){
|
||||||
// set all frames context types to submission
|
// set all frames context types to submission
|
||||||
$('.frame').each(function(index, element) {
|
$('.frame').each(function(index, element) {
|
||||||
$(element).data('context-type', 'Submission');
|
$(element).data('context-type', 'Submission');
|
||||||
@ -63,10 +63,7 @@ CodeOceanEditorSubmissions = {
|
|||||||
// update the ids of the editors and reload the annotations
|
// update the ids of the editors and reload the annotations
|
||||||
for (var i = 0; i < this.editors.length; i++) {
|
for (var i = 0; i < this.editors.length; i++) {
|
||||||
|
|
||||||
// set the data attribute to submission
|
const file_id_old = $(editor.container).data('file-id');
|
||||||
//$(editors[i].container).data('context-type', 'Submission');
|
|
||||||
|
|
||||||
var file_id_old = $(this.editors[i].container).data('file-id');
|
|
||||||
|
|
||||||
// file_id_old is always set. Either it is a reference to a teacher supplied given file, or it is the actual id of a new user created file.
|
// file_id_old is always set. Either it is a reference to a teacher supplied given file, or it is the actual id of a new user created file.
|
||||||
// This is the case, since it is set via a call to ancestor_id on the model, which returns either file_id if set, or id if it is not set.
|
// This is the case, since it is set via a call to ancestor_id on the model, which returns either file_id if set, or id if it is not set.
|
||||||
@ -142,11 +139,11 @@ CodeOceanEditorSubmissions = {
|
|||||||
const cause = $('#render');
|
const cause = $('#render');
|
||||||
this.startSentryTransaction(cause);
|
this.startSentryTransaction(cause);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if ($('#render').is(':visible')) {
|
if (cause.is(':visible')) {
|
||||||
this.createSubmission(cause, null, function (response) {
|
this.createSubmission(cause, null, function (response) {
|
||||||
if (response.render_url === undefined) return;
|
if (response.render_url === undefined) return;
|
||||||
|
|
||||||
const active_file = CodeOceanEditor.active_file.filename.replace(/#$/,''); // remove # if it is the last character, this is not part of the filename and just an anchor
|
const active_file = CodeOceanEditor.active_file.filename;
|
||||||
const desired_file = response.render_url.filter(hash => hash.filepath === active_file);
|
const desired_file = response.render_url.filter(hash => hash.filepath === active_file);
|
||||||
const url = desired_file[0].url;
|
const url = desired_file[0].url;
|
||||||
// Allow to open the new tab even in Safari.
|
// Allow to open the new tab even in Safari.
|
||||||
@ -195,7 +192,7 @@ CodeOceanEditorSubmissions = {
|
|||||||
const cause = $('#test');
|
const cause = $('#test');
|
||||||
this.startSentryTransaction(cause);
|
this.startSentryTransaction(cause);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if ($('#test').is(':visible')) {
|
if (cause.is(':visible')) {
|
||||||
this.createSubmission(cause, null, function(response) {
|
this.createSubmission(cause, null, function(response) {
|
||||||
this.showSpinner($('#test'));
|
this.showSpinner($('#test'));
|
||||||
$('#score_div').addClass('d-none');
|
$('#score_div').addClass('d-none');
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.extract! @submission, :id, :files
|
json.id @submission.id
|
||||||
|
json.files @submission.files do |file|
|
||||||
|
json.extract! file, :id, :file_id
|
||||||
|
end
|
||||||
json.download_url download_submission_path(@submission, format: :json)
|
json.download_url download_submission_path(@submission, format: :json)
|
||||||
json.score_url score_submission_path(@submission, format: :json)
|
json.score_url score_submission_path(@submission, format: :json)
|
||||||
json.download_file_url download_file_submission_path(@submission, 'a.', format: :json).gsub(/a\.\.json$/,
|
json.download_file_url download_file_submission_path(@submission, 'a.', format: :json).gsub(/a\.\.json$/,
|
||||||
|
Reference in New Issue
Block a user