Add CommunitySolution
* Also slightly refactor some JS files
This commit is contained in:
66
app/views/community_solutions/_form.html.slim
Normal file
66
app/views/community_solutions/_form.html.slim
Normal file
@ -0,0 +1,66 @@
|
||||
.exercise.clearfix
|
||||
div
|
||||
span.badge.badge-pill.badge-primary.float-right.score
|
||||
|
||||
h1 id="exercise-headline"
|
||||
i id="description-symbol" class=(@embed_options[:collapse_exercise_description] ? 'fa fa-chevron-right' : 'fa fa-chevron-down')
|
||||
=> @community_solution.model_name.human(count: 1)
|
||||
= @community_solution.exercise.title
|
||||
|
||||
#description-card.lead class=(@embed_options[:collapse_exercise_description] ? 'description-card-collapsed' : 'description-card')
|
||||
.card.border-success.mb-3
|
||||
.card-header
|
||||
i.fa.fa-info-circle.text-success
|
||||
strong.text-success
|
||||
=> t('community_solutions.help_us_out')
|
||||
= t('community_solutions.explanation')
|
||||
br
|
||||
i.fa.fa-flask.text-success
|
||||
strong.text-success
|
||||
=> t('community_solutions.research_status')
|
||||
== t('community_solutions.research_explanation')
|
||||
hr
|
||||
= render_markdown(@community_solution.exercise.description)
|
||||
|
||||
a#toggle href="#" data-show=t('shared.show') data-hide=t('shared.hide')
|
||||
- if @embed_options[:collapse_exercise_description]
|
||||
= t('shared.show')
|
||||
- else
|
||||
= t('shared.hide')
|
||||
.row.mt-4
|
||||
.col-xl-6
|
||||
h4
|
||||
= t('community_solutions.current_community_solution')
|
||||
#community-solution-editor.row
|
||||
.pr-0 class=(@community_solution.exercise.hide_file_tree ? 'd-none col-sm-3' : 'col-sm-3')
|
||||
.card.border-secondary
|
||||
.card-header.d-flex.justify-content-between.align-items-center.px-0.py-2
|
||||
.px-2 = I18n.t('exercises.editor_file_tree.file_root')
|
||||
.card-body.pt-0.pr-0.pl-1.pb-1
|
||||
#files data-entries=FileTree.new(@files).to_js_tree
|
||||
div class=(@community_solution.exercise.hide_file_tree ? 'col-sm-12' : 'col-sm-9')
|
||||
div.editor-col.col.p-0 id='frames'
|
||||
- @files.each do |file|
|
||||
= render('exercises/editor_frame', exercise: @community_solution.exercise, file: file)
|
||||
|
||||
.col-xl-6.container-fluid
|
||||
div.bg-dark.h-100.float-left.row style="width: 1px"
|
||||
div
|
||||
h4
|
||||
= t('community_solutions.your_submission')
|
||||
#own-solution-editor.row
|
||||
.pr-0 class=(@community_solution.exercise.hide_file_tree ? 'd-none col-sm-3' : 'col-sm-3')
|
||||
.card.border-secondary
|
||||
.card-header.d-flex.justify-content-between.align-items-center.px-0.py-2
|
||||
.px-2 = I18n.t('exercises.editor_file_tree.file_root')
|
||||
.card-body.pt-0.pr-0.pl-1.pb-1
|
||||
#own-files data-entries=FileTree.new(@own_files).to_js_tree
|
||||
div class=(@community_solution.exercise.hide_file_tree ? 'col-sm-12' : 'col-sm-9')
|
||||
div.editor-col.col.p-0 id='own-frames'
|
||||
- @own_files.each do |file|
|
||||
= render('exercises/editor_frame', exercise: @community_solution.exercise, file: file, own_solution: true)
|
||||
#statusbar.visible.mt-2 style="height: 5em"
|
||||
p.text-center
|
||||
= render('exercises/editor_button', classes: 'btn-lg btn-success ml-5 mr-3', data: {'data-url': community_solution_path(@community_solution), 'data-http-method': 'PUT', 'data-cause': 'change-community-solution', 'data-exercise-id': @community_solution.exercise.id}, icon: 'fa fa-send', id: 'submit', label: t('community_solutions.change_community_solution'))
|
||||
= render('exercises/editor_button', classes: 'btn-lg btn-secondary ml-5', data: {'data-url': community_solution_path(@community_solution), 'data-http-method': 'PUT', 'data-cause': 'accept-community-solution', 'data-exercise-id': @community_solution.exercise.id}, icon: 'fa fa-check', id: 'accept', label: t('community_solutions.accept_community_solution'))
|
||||
button style="display:none" id="autosave" data-url=community_solution_path(@community_solution) data-http-method='PUT' data-cause='autosave-community-solution' data-exercise-id=@community_solution.exercise.id
|
6
app/views/community_solutions/edit.html.slim
Normal file
6
app/views/community_solutions/edit.html.slim
Normal file
@ -0,0 +1,6 @@
|
||||
- content_for :head do
|
||||
// Force a full page reload, see https://github.com/turbolinks/turbolinks/issues/326.
|
||||
Otherwise, code might not be highlighted correctly (race condition)
|
||||
meta name='turbolinks-visit-control' content='reload'
|
||||
|
||||
== render 'form'
|
19
app/views/community_solutions/index.html.slim
Normal file
19
app/views/community_solutions/index.html.slim
Normal file
@ -0,0 +1,19 @@
|
||||
h1 Listing community_solutions
|
||||
|
||||
table
|
||||
thead
|
||||
tr
|
||||
th
|
||||
th
|
||||
th
|
||||
|
||||
tbody
|
||||
- @community_solutions.each do |community_solution|
|
||||
tr
|
||||
td = link_to 'Show', community_solution
|
||||
td = link_to 'Edit', edit_community_solution_path(community_solution)
|
||||
td = link_to 'Destroy', community_solution, data: { confirm: 'Are you sure?' }, method: :delete
|
||||
|
||||
br
|
||||
|
||||
= link_to 'New Community solution', new_community_solution_path
|
@ -1,4 +1,4 @@
|
||||
.frame data-executable=file.file_type.executable? data-filename=file.name_with_extension data-renderable=file.file_type.renderable? data-role=file.role data-binary=file.file_type.binary? data-context-type=file.context_type data-read-only=file.read_only
|
||||
div class=(defined?(own_solution) ? "own-frame" : "frame") data-executable=file.file_type.executable? data-filename=file.name_with_extension data-renderable=file.file_type.renderable? data-role=file.role data-binary=file.file_type.binary? data-context-type=file.context_type data-read-only=file.read_only
|
||||
- if file.file_type.binary?
|
||||
.binary-file data-file-id=file.ancestor_id
|
||||
- if file.file_type.renderable?
|
||||
@ -12,4 +12,4 @@
|
||||
= link_to(file.native_file.file.filename, file.native_file.url)
|
||||
- else
|
||||
.editor-content.d-none 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-allow-auto-completion=exercise.allow_auto_completion.to_s data-id=file.id
|
||||
div class=(defined?(own_solution) ? "own-editor" : "editor") data-file-id=file.ancestor_id data-indent-size=file.file_type.indent_size data-mode=file.file_type.editor_mode data-allow-auto-completion=exercise.allow_auto_completion.to_s data-id=file.id
|
@ -55,7 +55,7 @@ html lang="#{I18n.locale || I18n.default_locale}"
|
||||
= render('flash')
|
||||
- if current_user.try(:admin?) or current_user.try(:teacher?) && !@embed_options[:hide_navbar]
|
||||
= yield(:breadcrumbs)
|
||||
- if (controller_name == "exercises" && action_name == "implement")
|
||||
- if (controller_name == "exercises" && action_name == "implement") || (controller_name == 'community_solutions' && action_name == 'edit')
|
||||
.container-fluid
|
||||
= yield
|
||||
- else
|
||||
|
Reference in New Issue
Block a user