Skip to content

Commit 3f09542

Browse files
committed
Rename display type & add markdown display
1 parent 1c88926 commit 3f09542

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

app/helpers/problems_helper.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,12 @@ def visible_state_desc_map
112112
"invisible" => "invisible",
113113
}
114114
end
115+
116+
def sample_display_type_desc_map
117+
{
118+
"plaintext" => "Plaintext",
119+
"raw_html" => "Raw HTML",
120+
"markdown" => "Markdown",
121+
}
122+
end
115123
end

app/models/sample_testdatum.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ class SampleTestdatum < ActiveRecord::Base
1919
default_scope { order('id ASC') }
2020

2121
belongs_to :problem
22-
enum :display_type, {plaintext: 0, markdown: 1}, prefix: :display
22+
enum :display_type, {plaintext: 0, raw_html: 1, markdown: 2}, prefix: :display
2323
end

app/views/problems/_form.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
<%= t.link_to_remove "Remove this sample testdatum", class: "btn btn-danger pull-right", name: "testdatum_remove" %>
8888
<%= t.text_area :output, class: 'form-control flat code-input', rows: '7' %>
8989
<%= t.label :display_type, "Sample Display Type" %>
90-
<%= t.select :display_type, SampleTestdatum.display_types.keys.map{|key| [key, key]}, {}, {class: 'form-control flat'} %>
90+
<%= t.select :display_type, SampleTestdatum.display_types.keys.map{|key| [sample_display_type_desc_map[key], key]}, {}, {class: 'form-control flat'} %>
9191
</div>
9292
</div>
9393
</div>

app/views/problems/show.html.erb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,10 @@
158158
<% end %>
159159
</div>
160160
<div class="panel-body">
161-
<% if sample.display_markdown? %>
161+
<% if sample.display_raw_html? %>
162162
<div class="mathjax_ignore sample-testdata"><%= raw sample.input.gsub(/\n/, '<br/>') %></div>
163+
<% elsif sample.display_markdown? %>
164+
<%= markdown(sample.input) %>
163165
<% else %>
164166
<pre class="copy-group-code sample-testdata"><%= sample.input %></pre>
165167
<% end %>
@@ -175,8 +177,10 @@
175177
<% end %>
176178
</div>
177179
<div class="panel-body">
178-
<% if sample.display_markdown? %>
180+
<% if sample.display_raw_html? %>
179181
<div class="mathjax_ignore sample-testdata"><%= raw sample.output.gsub(/\n/, '<br/>') %></div>
182+
<% elsif sample.display_markdown? %>
183+
<%= markdown(sample.output) %>
180184
<% else %>
181185
<pre class="copy-group-code sample-testdata"><%= sample.output %></pre>
182186
<% end %>

0 commit comments

Comments
 (0)