Merge branch 'pr/14'

Conflicts:
	app/views/exercises/_editor_file_tree.html.slim
This commit is contained in:
Jan Renz
2015-04-10 20:39:53 +02:00
47 changed files with 19493 additions and 111 deletions

View File

@@ -0,0 +1,37 @@
<%= form_for(@comment) do |f| %>
<% if @comment.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:</h2>
<ul>
<% @comment.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :user_id %><br>
<%= f.text_field :user_id %>
</div>
<div class="field">
<%= f.label :file_id %><br>
<%= f.text_field :file_id %>
</div>
<div class="field">
<%= f.label :row %><br>
<%= f.number_field :row %>
</div>
<div class="field">
<%= f.label :column %><br>
<%= f.number_field :column %>
</div>
<div class="field">
<%= f.label :text %><br>
<%= f.text_field :text %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>

View File

@@ -0,0 +1,6 @@
<h1>Editing comment</h1>
<%= render 'form' %>
<%= link_to 'Show', @comment %> |
<%= link_to 'Back', comments_path %>

View File

@@ -0,0 +1,33 @@
<h1>Listing comments</h1>
<table>
<thead>
<tr>
<th>User</th>
<th>File</th>
<th>Row</th>
<th>Column</th>
<th>Text</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @comments.each do |comment| %>
<tr>
<td><%= comment.user %></td>
<td><%= comment.file %></td>
<td><%= comment.row %></td>
<td><%= comment.column %></td>
<td><%= comment.text %></td>
<td><%= link_to 'Show', comment %></td>
<td><%= link_to 'Edit', edit_comment_path(comment) %></td>
<td><%= link_to 'Destroy', comment, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New Comment', new_comment_path %>

View File

@@ -0,0 +1,4 @@
json.array!(@comments) do |comment|
json.extract! comment, :id, :user_id, :file_id, :row, :column, :text, :username
json.url comment_url(comment, format: :json)
end

View File

@@ -0,0 +1,5 @@
<h1>New comment</h1>
<%= render 'form' %>
<%= link_to 'Back', comments_path %>

View File

@@ -0,0 +1,29 @@
<p id="notice"><%= notice %></p>
<p>
<strong>User:</strong>
<%= @comment.user %>
</p>
<p>
<strong>File:</strong>
<%= @comment.file %>
</p>
<p>
<strong>Row:</strong>
<%= @comment.row %>
</p>
<p>
<strong>Column:</strong>
<%= @comment.column %>
</p>
<p>
<strong>Text:</strong>
<%= @comment.text %>
</p>
<%= link_to 'Edit', edit_comment_path(@comment) %> |
<%= link_to 'Back', comments_path %>

View File

@@ -0,0 +1 @@
json.extract! @comment, :id, :user_id, :file_id, :row, :column, :text, :created_at, :updated_at

View File

@@ -0,0 +1,9 @@
h5 =t('exercises.implement.comment.others')
pre#other-comments
h5 =t('exercises.implement.comment.addyours')
textarea.form-control(style='resize:none;')
p = ''
button#addCommentButton.btn.btn-block.btn-primary(type='button') =t('exercises.implement.comment.addComment')
button#removeAllButton.btn.btn-block.btn-warning(type='button') =t('exercises.implement.comment.removeAllOnLine')

View File

@@ -1,4 +1,4 @@
#editor.row data-exercise-id=exercise.id data-message-timeout=t('exercises.editor.timeout', permitted_execution_time: @exercise.execution_environment.permitted_execution_time) data-errors-url=execution_environment_errors_path(exercise.execution_environment) data-submissions-url=submissions_path
#editor.row data-exercise-id=exercise.id data-message-timeout=t('exercises.editor.timeout', permitted_execution_time: @exercise.execution_environment.permitted_execution_time) data-errors-url=execution_environment_errors_path(exercise.execution_environment) data-submissions-url=submissions_path data-user-id=@current_user.id
.col-sm-3 = render('editor_file_tree', files: @files)
#frames.col-sm-9
- @files.each do |file|
@@ -33,3 +33,5 @@
i.fa.fa-rocket
= t('exercises.editor.test')
= render('editor_button', data: {:'data-placement' => 'top', :'data-tooltip' => true}, icon: 'fa fa-trophy', id: 'assess', label: t('exercises.editor.score'), title: t('shared.tooltips.shortcut', shortcut: 'ALT + s'))
= render('shared/modal', id: 'comment-modal', title: t('exercises.implement.comment.dialogtitle'), template: 'exercises/_comment_dialogcontent')

View File

@@ -5,5 +5,6 @@ hr
= render('editor_button', classes: 'btn-block btn-primary btn-xs', data: {:'data-cause' => 'file'}, icon: 'fa fa-plus', id: 'create-file', label: t('exercises.editor.create_file'))
= render('editor_button', classes: 'btn-block btn-warning btn-xs', data: {:'data-cause' => 'file', :'data-message-confirm' => t('shared.confirm_destroy')}, icon: 'fa fa-times', id: 'destroy-file', label: t('exercises.editor.destroy_file'))
= render('editor_button', classes: 'btn-block btn-primary btn-xs', icon: 'fa fa-download', id: 'download', label: t('exercises.editor.download'))
= render('editor_button', classes: 'btn-block btn-primary btn-xs', icon: 'fa fa-bullhorn', id: 'request-for-comments', label: 'Request comments')
= render('shared/modal', id: 'modal-file', template: 'code_ocean/files/_form', title: t('exercises.editor.create_file'))

View File

@@ -11,4 +11,5 @@
- else
= link_to(file.native_file.file.name_with_extension, file.native_file.url)
- else
.editor data-file-id=file.ancestor_id data-indent-size=file.file_type.indent_size data-mode=file.file_type.editor_mode data-read-only=file.read_only = file.content
.editor-content.hidden data-file-id=file.ancestor_id = file.content
.editor data-file-id=file.ancestor_id data-indent-size=file.file_type.indent_size data-mode=file.file_type.editor_mode data-read-only=file.read_only data-id=file.id

View File

@@ -1,73 +1,79 @@
h1 = @exercise
.row
#editor-column.col-md-10.col-md-offset-1
h1 = @exercise
span.badge.pull-right.score
span.badge.pull-right.score
p.lead = @exercise.description
p.lead = @exercise.description
#alert.alert.alert-danger role='alert'
h4 = t('.alert.title')
p = t('.alert.text', application_name: application_name)
#alert.alert.alert-danger role='alert'
h4 = t('.alert.title')
p = t('.alert.text', application_name: application_name)
#development-environment
ul.nav.nav-justified.nav-tabs role='tablist'
li.active
a data-placement='top' data-toggle='tab' data-tooltip=true href='#instructions' role='tab' title=t('shared.tooltips.shortcut', shortcut: 'ALT + 1')
i.fa.fa-question
= t('activerecord.attributes.exercise.instructions')
li
a data-placement='top' data-toggle='tab' data-tooltip=true href='#workspace' role='tab' title=t('shared.tooltips.shortcut', shortcut: 'ALT + 2')
i.fa.fa-code
= t('.workspace')
li
a data-placement='top' data-toggle='tab' data-tooltip=true href='#outputInformation' role='tab' title=t('shared.tooltips.shortcut', shortcut: 'ALT + 3')
i.fa.fa-terminal
= t('.output')
li
a data-placement='top' data-toggle='tab' data-tooltip=true href='#progress' role='tab' title=t('shared.tooltips.shortcut', shortcut: 'ALT + 4')
i.fa.fa-line-chart
= t('.progress')
#development-environment
ul.nav.nav-justified.nav-tabs role='tablist'
li.active
a data-placement='top' data-toggle='tab' data-tooltip=true href='#instructions' role='tab' title=t('shared.tooltips.shortcut', shortcut: 'ALT + 1')
i.fa.fa-question
= t('activerecord.attributes.exercise.instructions')
li
a data-placement='top' data-toggle='tab' data-tooltip=true href='#workspace' role='tab' title=t('shared.tooltips.shortcut', shortcut: 'ALT + 2')
i.fa.fa-code
= t('.workspace')
li
a data-placement='top' data-toggle='tab' data-tooltip=true href='#outputInformation' role='tab' title=t('shared.tooltips.shortcut', shortcut: 'ALT + 3')
i.fa.fa-terminal
= t('.output')
li
a data-placement='top' data-toggle='tab' data-tooltip=true href='#progress' role='tab' title=t('shared.tooltips.shortcut', shortcut: 'ALT + 4')
i.fa.fa-line-chart
= t('.progress')
hr
hr
.tab-content
#instructions.tab-pane.active
p = render_markdown(@exercise.instructions)
br
p.text-center
a#start.btn.btn-lg.btn-success
i.fa.fa-code
= t('.start')
#workspace.tab-pane = render('editor', exercise: @exercise, files: @files, submission: @submission)
#outputInformation.tab-pane data-message-no-output=t('.no_output')
#hint
.panel.panel-warning
.panel-heading = t('.hint')
.panel-body
#output
pre = t('.no_output_yet')
- if CodeOcean::Config.new(:code_ocean).read[:flowr][:enabled]
#flowrHint.panel.panel-info data-url=CodeOcean::Config.new(:code_ocean).read[:flowr][:url] role='tab'
.panel-heading = 'Gain more insights here'
.panel-body
#progress.tab-pane
#results
h2 = t('.results')
p.test-count == t('.test_count', count: 0)
ul.list-unstyled
ul#dummies.hidden.list-unstyled
li.panel.panel-default
.panel-heading
h3.panel-title == t('.file', filename: '', number: 0)
.panel-body
= row(label: '.passed_tests', value: t('shared.out_of', maximum_value: 0, value: 0).html_safe)
= row(label: 'activerecord.attributes.submission.score', value: t('shared.out_of', maximum_value: 0, value: 0).html_safe)
= row(label: '.feedback')
= row(label: '.output', value: link_to(t('shared.show'), '#'))
#score data-maximum-score=@exercise.maximum_score data-score=@submission.try(:score)
h4
span == "#{t('activerecord.attributes.submission.score')}:&nbsp;"
span.score
.progress
.progress-bar role='progressbar'
br
p.text-center = render('editor_button', classes: 'btn-lg btn-success', data: {:'data-message-confirm' => t('exercises.editor.confirm_submit'), :'data-url' => submit_exercise_path(@exercise)}, icon: 'fa fa-send', id: 'submit', label: t('exercises.editor.submit'))
.tab-content
#instructions.tab-pane.active
p = render_markdown(@exercise.instructions)
br
p.text-center
a#start.btn.btn-lg.btn-success
i.fa.fa-code
= t('.start')
#workspace.tab-pane = render('editor', exercise: @exercise, files: @files, submission: @submission)
#outputInformation.tab-pane data-message-no-output=t('.no_output')
#hint
.panel.panel-warning
.panel-heading = t('.hint')
.panel-body
#output
pre = t('.no_output_yet')
- if CodeOcean::Config.new(:code_ocean).read[:flowr][:enabled]
#flowrHint.panel.panel-info data-url=CodeOcean::Config.new(:code_ocean).read[:flowr][:url] role='tab'
.panel-heading = 'Gain more insights here'
.panel-body
#progress.tab-pane
#results
h2 = t('.results')
p.test-count == t('.test_count', count: 0)
ul.list-unstyled
ul#dummies.hidden.list-unstyled
li.panel.panel-default
.panel-heading
h3.panel-title == t('.file', filename: '', number: 0)
.panel-body
= row(label: '.passed_tests', value: t('shared.out_of', maximum_value: 0, value: 0).html_safe)
= row(label: 'activerecord.attributes.submission.score', value: t('shared.out_of', maximum_value: 0, value: 0).html_safe)
= row(label: '.feedback')
= row(label: '.output', value: link_to(t('shared.show'), '#'))
#score data-maximum-score=@exercise.maximum_score data-score=@submission.try(:score)
h4
span == "#{t('activerecord.attributes.submission.score')}:&nbsp;"
span.score
.progress
.progress-bar role='progressbar'
br
p.text-center = render('editor_button', classes: 'btn-lg btn-success', data: {:'data-message-confirm' => t('exercises.editor.confirm_submit'), :'data-url' => submit_exercise_path(@exercise)}, icon: 'fa fa-send', id: 'submit', label: t('exercises.editor.submit'))
- if qa_url
#questions-column
#questions-holder data-url="#{qa_url}/qa/index/#{@exercise.id}/#{@user_id}"
= qa_js_tag

View File

@@ -40,4 +40,4 @@ h1 = Exercise.model_name.human(count: 2)
td = link_to(t('shared.statistics'), statistics_exercise_path(exercise))
= render('shared/pagination', collection: @exercises)
p = render('shared/new_button', model: Exercise)
p = render('shared/new_button', model: Exercise)

View File

@@ -34,6 +34,12 @@ html lang='en'
.container data-controller=controller_name
= render('breadcrumbs')
= render('flash')
= yield
- if (controller_name == "exercises" && action_name == "implement")
.container-fluid
= yield
- else
.container
= yield
- template_variables = {execution_environment: @exercise.execution_environment} if action_name == 'implement'
= render('shared/modal', classes: 'modal-lg', id: 'modal-help', template: 'application/help', template_variables: template_variables, title: t('shared.help.headline'))

View File

@@ -0,0 +1,33 @@
<%= form_for(@request_for_comment) do |f| %>
<% if @request_for_comment.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@request_for_comment.errors.count, "error") %> prohibited this request_for_comment from being saved:</h2>
<ul>
<% @request_for_comment.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :requestorid %><br>
<%= f.number_field :requestorid %>
</div>
<div class="field">
<%= f.label :exerciseid %><br>
<%= f.number_field :exerciseid %>
</div>
<div class="field">
<%= f.label :fileid %><br>
<%= f.number_field :fileid %>
</div>
<div class="field">
<%= f.label :requested_at %><br>
<%= f.datetime_select :requested_at %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>

View File

@@ -0,0 +1,12 @@
<h1><%= t('exercises.implement.comment.listing') %></h1>
<div class="list-group">
<% @request_for_comments.each do |request_for_comment| %>
<a href="<%= request_for_comment_path(request_for_comment) %>" class="list-group-item">
<h4 class="list-group-item-heading"><%= Exercise.find(request_for_comment.exerciseid) %></h4>
<p class="list-group-item-text">
<%= InternalUser.find(request_for_comment.requestorid) %> | <%= request_for_comment.requested_at %>
</p>
</a>
<% end %>
</div>

View File

@@ -0,0 +1,4 @@
json.array!(@request_for_comments) do |request_for_comment|
json.extract! request_for_comment, :id, :requestorid, :exerciseid, :fileid, :requested_at
json.url request_for_comment_url(request_for_comment, format: :json)
end

View File

@@ -0,0 +1,89 @@
<div class="list-group">
<h4 class="list-group-item-heading"><%= Exercise.find(@request_for_comment.exerciseid) %></h4>
<p class="list-group-item-text">
<%= InternalUser.find(@request_for_comment.requestorid) %> | <%= @request_for_comment.requested_at %>
</p>
</div>
<form class="form-inline">
<div class="form-group">
<p style='display:inline-block'><%= t('exercises.implement.comment.line') %></p>
<input type="number" class="form-control" id="lineInput" placeholder="1" required>
</div>
<div class="form-group">
<p style='display:inline-block'><%= t('exercises.implement.comment.a_comment') %></p>
<input type="text" class="form-control" id="commentInput" placeholder="I'd suggest a variable here" required>
</div>
<button id='submitComment' type="submit" class="btn btn-default"><%= t('exercises.implement.comment.addComment') %>!</button>
</form>
<div id='commentitor' class='editor' data-read-only='true' data-file-id='<%=@request_for_comment.fileid%>'>
<%= CodeOcean::File.find(@request_for_comment.fileid).content %>
</div>
<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]);
commentitor.setReadOnly(true);
$('#submitComment').click(addComment);
setAnnotations();
function setAnnotations() {
var session = commentitor.getSession()
var jqrequest = $.ajax({
dataType: 'json',
method: 'GET',
url: '/comments',
data: {
file_id: fileid
}
});
jqrequest.done(function(response){
$.each(response, function(index, comment) {
comment.className = "code-ocean_comment"
comment.text = comment.username + ": " + comment.text
})
commentitor.getSession().setAnnotations(response)
})
}
function addComment() {
var line = lineInput.val()
var comment = commentInput.val()
if (line == '' || comment == '') {
return
} else {
line = parseInt(line) - 1
}
var jqxhr = $.ajax({
data: {
comment: {
user_id: userid,
file_id: fileid,
row: line,
column: 0,
text: comment
}
},
dataType: 'json',
method: 'POST',
url: "/comments"
})
jqxhr.done(setAnnotations)
lineInput.val(''); commentInput.val('');
}
//})()
</script>

View File

@@ -0,0 +1 @@
json.extract! @request_for_comment, :id, :requestorid, :exerciseid, :fileid, :requested_at, :created_at, :updated_at