Merge branch 'master' of github.com:flxw/codeocean

This commit is contained in:
Felix Wolff
2015-04-09 16:58:00 +02:00
4 changed files with 43 additions and 42 deletions

View File

@ -231,7 +231,7 @@ $(function() {
showTab(3);
};
var stderrOutput = ''
var stderrOutput = '';
var handleStderrOutputForFlowr = function(event) {
var json = JSON.parse(event.data);
@ -239,35 +239,35 @@ $(function() {
stderrOutput += json.stderr;
} else if (json.code) {
if (stderrOutput == '') {
return
return;
}
var flowrUrl = $('#flowrHint').data('url')
var flowrHintBody = $('#flowrHint .panel-body')
var flowrUrl = $('#flowrHint').data('url');
var flowrHintBody = $('#flowrHint .panel-body');
var queryParameters = {
query: stderrOutput
}
flowrHintBody.empty()
flowrHintBody.empty();
jQuery.getJSON(flowrUrl, queryParameters, function(data) {
for (var question in data.queryResults) {
var collapsibleTileHtml = flowrResultHtml.replace(/{{collapseId}}/g, 'collapse-' + question).replace(/{{headingId}}/g, 'heading-' + question)
var resultTile = $(collapsibleTileHtml)
var collapsibleTileHtml = flowrResultHtml.replace(/{{collapseId}}/g, 'collapse-' + question).replace(/{{headingId}}/g, 'heading-' + question);
var resultTile = $(collapsibleTileHtml);
resultTile.find('h4 > a').text(data.queryResults[question].title + ' | Found via ' + data.queryResults[question].source)
resultTile.find('.panel-body').html(data.queryResults[question].body)
resultTile.find('.panel-body').append('<a href="' + data.queryResults[question].url + '" class="btn btn-primary btn-block">Open this question</a>')
resultTile.find('h4 > a').text(data.queryResults[question].title + ' | Found via ' + data.queryResults[question].source);
resultTile.find('.panel-body').html(data.queryResults[question].body);
resultTile.find('.panel-body').append('<a href="' + data.queryResults[question].url + '" class="btn btn-primary btn-block">Open this question</a>');
flowrHintBody.append(resultTile)
flowrHintBody.append(resultTile);
}
if (data.queryResults.length !== 0) {
$('#flowrHint').fadeIn()
$('#flowrHint').fadeIn();
}
})
stderrOutput = ''
stderrOutput = '';
}
};
@ -315,8 +315,8 @@ $(function() {
var file_id = $(element).data('file-id');
setAnnotations(editor, file_id);
session.on('annotationRemoval', handleAnnotationRemoval)
session.on('annotationChange', handleAnnotationChange)
session.on('annotationRemoval', handleAnnotationRemoval);
session.on('annotationChange', handleAnnotationChange);
// TODO refactor here
// Code for clicks on gutter / sidepanel
@ -330,54 +330,54 @@ $(function() {
var row = e.getDocumentPosition().row;
e.stop();
var commentModal = $('#comment-modal')
var commentModal = $('#comment-modal');
if (hasCommentsInRow(editor, row)) {
var rowComments = getCommentsForRow(editor, row)
var comments = _.pluck(rowComments, 'text').join('\n')
commentModal.find('#other-comments').text(comments)
var rowComments = getCommentsForRow(editor, row);
var comments = _.pluck(rowComments, 'text').join('\n');
commentModal.find('#other-comments').text(comments);
} else {
commentModal.find('#other-comments').text('none')
commentModal.find('#other-comments').text('none');
}
commentModal.find('#addCommentButton').off('click')
commentModal.find('#removeAllButton').off('click')
commentModal.find('#addCommentButton').off('click');
commentModal.find('#removeAllButton').off('click');
commentModal.find('#addCommentButton').on('click', function(e){
var user_id = $(element).data('user-id')
var commenttext = commentModal.find('textarea').val()
var user_id = $(element).data('user-id');
var commenttext = commentModal.find('textarea').val();
if (commenttext !== "") {
createComment(user_id, file_id, row, editor, commenttext)
commentModal.modal('hide')
createComment(user_id, file_id, row, editor, commenttext);
commentModal.modal('hide');
}
})
commentModal.find('#removeAllButton').on('click', function(e){
var user_id = $(element).data('user-id')
var user_id = $(element).data('user-id');
deleteComment(user_id,file_id,row,editor);
commentModal.modal('hide')
commentModal.modal('hide');
})
commentModal.modal('show')
commentModal.modal('show');
});
});
};
var hasCommentsInRow = function (editor, row){
return editor.getSession().getAnnotations().some(function(element) {
return element.row === row
return element.row === row;
})
}
var getCommentsForRow = function (editor, row){
return editor.getSession().getAnnotations().filter(function(element) {
return element.row === row
return element.row === row;
})
}
var setAnnotations = function (editor, file_id){
var session = editor.getSession()
var session = editor.getSession();
var url = "/comments";
var jqrequest = $.ajax({
@ -498,7 +498,7 @@ $(function() {
$('#create-file').on('click', showFileDialog);
$('#destroy-file').on('click', confirmDestroy);
$('#download').on('click', downloadCode);
$('#request-for-comments').on('click', requestComments)
$('#request-for-comments').on('click', requestComments);
};
var initializeTooltips = function() {

View File

@ -90,7 +90,7 @@ class ExercisesController < ApplicationController
if current_user.respond_to? :external_id
@user_id = current_user.external_id
else
@user_id = '00000001-3100-4444-9999-000000000001'
@user_id = current_user.id
end
end

View File

@ -23,15 +23,15 @@
<script type="text/javascript">
//(function() {
var commentitor = $('#commentitor')
var userid = commentitor.data('user-id')
var fileid = commentitor.data('file-id')
var lineInput = $('#lineInput')
var commentInput = $('#commentInput')
commentitor = ace.edit(commentitor[0])
var commentitor = $('#commentitor');
var userid = commentitor.data('user-id');
var fileid = commentitor.data('file-id');
var lineInput = $('#lineInput');
var commentInput = $('#commentInput');
commentitor = ace.edit(commentitor[0]);
$('#submitComment').click(addComment)
setAnnotations()
$('#submitComment').click(addComment);
setAnnotations();
function setAnnotations() {
var session = commentitor.getSession()

View File

@ -6,6 +6,7 @@ describe 'exercises/implement.html.slim' do
let(:non_binary_files) { files.reject { |file| file.file_type.binary? } }
before(:each) do
assign(:current_user, FactoryGirl.create(:admin))
assign(:exercise, exercise)
assign(:files, files)
assign(:paths, [])