Moved codepilot into dedicated file.
Renamed prompt.js Moved requestComments out of flowr.js
This commit is contained in:
24
app/assets/javascripts/editor/codepilot.js.erb
Normal file
24
app/assets/javascripts/editor/codepilot.js.erb
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
CodeOceanEditorCodePilot = {
|
||||||
|
qa_api: undefined,
|
||||||
|
QaApiOutputBuffer: {'stdout': '', 'stderr': ''},
|
||||||
|
|
||||||
|
initializeCodePilot: function () {
|
||||||
|
if ($('#questions-column').isPresent() && (typeof QaApi != 'undefined') && QaApi.isBrowserSupported()) {
|
||||||
|
$('#editor-column').addClass('col-md-10').removeClass('col-md-12');
|
||||||
|
$('#questions-column').addClass('col-md-2');
|
||||||
|
|
||||||
|
var node = document.getElementById('questions-holder');
|
||||||
|
var url = $('#questions-holder').data('url');
|
||||||
|
|
||||||
|
this.qa_api = new QaApi(node, url);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
handleQaApiOutput: function () {
|
||||||
|
if (this.qa_api) {
|
||||||
|
this.qa_api.executeCommand('syncOutput', [[this.QaApiOutputBuffer]]);
|
||||||
|
// reset the object
|
||||||
|
}
|
||||||
|
this.QaApiOutputBuffer = {'stdout': '', 'stderr': ''};
|
||||||
|
}
|
||||||
|
};
|
@ -24,7 +24,6 @@ var CodeOceanEditor = {
|
|||||||
active_file: undefined,
|
active_file: undefined,
|
||||||
active_frame: undefined,
|
active_frame: undefined,
|
||||||
running: false,
|
running: false,
|
||||||
qa_api: undefined,
|
|
||||||
output_mode_is_streaming: true,
|
output_mode_is_streaming: true,
|
||||||
|
|
||||||
numMessages: 0,
|
numMessages: 0,
|
||||||
@ -35,7 +34,6 @@ var CodeOceanEditor = {
|
|||||||
|
|
||||||
ENTER_KEY_CODE: 13,
|
ENTER_KEY_CODE: 13,
|
||||||
|
|
||||||
QaApiOutputBuffer: {'stdout': '', 'stderr': ''},
|
|
||||||
flowrResultHtml: '<div class="panel panel-default"><div id="{{headingId}}" role="tab" class="panel-heading"><h4 class="panel-title"><a data-toggle="collapse" data-parent="#flowrHint" href="#{{collapseId}}" aria-expanded="true" aria-controls="{{collapseId}}"></a></h4></div><div id="{{collapseId}}" role="tabpanel" aria-labelledby="{{headingId}}" class="panel-collapse collapse"><div class="panel-body"></div></div></div>',
|
flowrResultHtml: '<div class="panel panel-default"><div id="{{headingId}}" role="tab" class="panel-heading"><h4 class="panel-title"><a data-toggle="collapse" data-parent="#flowrHint" href="#{{collapseId}}" aria-expanded="true" aria-controls="{{collapseId}}"></a></h4></div><div id="{{collapseId}}" role="tabpanel" aria-labelledby="{{headingId}}" class="panel-collapse collapse"><div class="panel-body"></div></div></div>',
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ CodeOceanEditorFlowr = {
|
|||||||
var flowrHintBody = $('#flowrHint .panel-body');
|
var flowrHintBody = $('#flowrHint .panel-body');
|
||||||
var queryParameters = {
|
var queryParameters = {
|
||||||
query: this.flowrOutputBuffer
|
query: this.flowrOutputBuffer
|
||||||
}
|
};
|
||||||
|
|
||||||
flowrHintBody.empty();
|
flowrHintBody.empty();
|
||||||
|
|
||||||
@ -30,57 +30,5 @@ CodeOceanEditorFlowr = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.flowrOutputBuffer = '';
|
this.flowrOutputBuffer = '';
|
||||||
},
|
|
||||||
|
|
||||||
requestComments: function () {
|
|
||||||
var user_id = $('#editor').data('user-id');
|
|
||||||
var exercise_id = $('#editor').data('exercise-id');
|
|
||||||
var file_id = $('.editor').data('id');
|
|
||||||
var question = $('#question').val();
|
|
||||||
|
|
||||||
var createRequestForComments = function (submission) {
|
|
||||||
$.ajax({
|
|
||||||
method: 'POST',
|
|
||||||
url: '/request_for_comments',
|
|
||||||
data: {
|
|
||||||
request_for_comment: {
|
|
||||||
exercise_id: exercise_id,
|
|
||||||
file_id: file_id,
|
|
||||||
submission_id: submission.id,
|
|
||||||
question: question
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}).done(function () {
|
|
||||||
this.hideSpinner();
|
|
||||||
$.flash.success({text: $('#askForCommentsButton').data('message-success')});
|
|
||||||
}.bind(this)).error(this.ajaxError.bind(this));
|
|
||||||
};
|
|
||||||
|
|
||||||
this.createSubmission($('.requestCommentsButton'), null, createRequestForComments.bind(this));
|
|
||||||
|
|
||||||
$('#comment-modal').modal('hide');
|
|
||||||
var button = $('#requestComments');
|
|
||||||
button.prop('disabled', true);
|
|
||||||
},
|
|
||||||
|
|
||||||
//tODO move codepilot out of here.
|
|
||||||
initializeCodePilot: function () {
|
|
||||||
if ($('#questions-column').isPresent() && (typeof QaApi != 'undefined') && QaApi.isBrowserSupported()) {
|
|
||||||
$('#editor-column').addClass('col-md-10').removeClass('col-md-12');
|
|
||||||
$('#questions-column').addClass('col-md-2');
|
|
||||||
|
|
||||||
var node = document.getElementById('questions-holder');
|
|
||||||
var url = $('#questions-holder').data('url');
|
|
||||||
|
|
||||||
this.qa_api = new QaApi(node, url);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
handleQaApiOutput: function () {
|
|
||||||
if (this.qa_api) {
|
|
||||||
this.qa_api.executeCommand('syncOutput', [[this.QaApiOutputBuffer]]);
|
|
||||||
// reset the object
|
|
||||||
}
|
|
||||||
this.QaApiOutputBuffer = {'stdout': '', 'stderr': ''};
|
|
||||||
},
|
|
||||||
};
|
};
|
@ -170,5 +170,36 @@ CodeOceanEditorSubmissions = {
|
|||||||
window.location = response.redirect;
|
window.location = response.redirect;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
requestComments: function () {
|
||||||
|
var user_id = $('#editor').data('user-id');
|
||||||
|
var exercise_id = $('#editor').data('exercise-id');
|
||||||
|
var file_id = $('.editor').data('id');
|
||||||
|
var question = $('#question').val();
|
||||||
|
|
||||||
|
var createRequestForComments = function (submission) {
|
||||||
|
$.ajax({
|
||||||
|
method: 'POST',
|
||||||
|
url: '/request_for_comments',
|
||||||
|
data: {
|
||||||
|
request_for_comment: {
|
||||||
|
exercise_id: exercise_id,
|
||||||
|
file_id: file_id,
|
||||||
|
submission_id: submission.id,
|
||||||
|
question: question
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).done(function () {
|
||||||
|
this.hideSpinner();
|
||||||
|
$.flash.success({text: $('#askForCommentsButton').data('message-success')});
|
||||||
|
}.bind(this)).error(this.ajaxError.bind(this));
|
||||||
|
};
|
||||||
|
|
||||||
|
this.createSubmission($('.requestCommentsButton'), null, createRequestForComments.bind(this));
|
||||||
|
|
||||||
|
$('#comment-modal').modal('hide');
|
||||||
|
var button = $('#requestComments');
|
||||||
|
button.prop('disabled', true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user