Skip to content

Commit

Permalink
Merge pull request #22 from juliet-tech/questions-migration
Browse files Browse the repository at this point in the history
ran migration so that each number will have a number column for optim…
  • Loading branch information
juliettech13 committed Sep 2, 2019
2 parents ea93a33 + c6671a2 commit b7f5076
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 28 deletions.
9 changes: 9 additions & 0 deletions app/assets/stylesheets/pages/_legislation.scss
Expand Up @@ -264,6 +264,15 @@ button{
margin-right: 10px
}

.medium-font{
font-weight: bold;
font-size: 15px
}

.small-font{
font-size: 13px;
}

@media only screen and (max-width: 600px) {

.title .jumbotron {
Expand Down
8 changes: 4 additions & 4 deletions app/views/consultations/new.html.erb
Expand Up @@ -35,7 +35,7 @@
</li>
<hr>
<li style='list-style: none; text-align: justify;' class='align-left'>
<p>Toma en cuenta que para leer los <strong>artículos modificados</strong> sólo debes pasar el cursor sobre el botón <span class="badge badge-danger">MODIFICADO</span>. Al hacerlo, se abrirá una ventana con el contenido propuesto por la <strong>Concertación Nacional para el Desarrollo</strong>.</p>
<p>Toma en cuenta que para leer los <strong>artículos modificados</strong> sólo debes pasar el cursor sobre el botón <span class="badge badge-danger">VER MODIFICADO</span>. Al hacerlo, se abrirá una ventana con el contenido propuesto por la <strong>Concertación Nacional para el Desarrollo</strong>.</p>
</li>
</ol>
<p style="font-size: 14px;"><strong>Nota:</strong> Si lo deseas, puedes bajar el PDF del texto <a href="../download_pdf" style='font-weight: bold'target="_blank">aquí</a>.</p>
Expand All @@ -44,18 +44,18 @@

<!-- instruciton 3 -->
<div data-target="slideshow.slide" class="slide introductory-section">
<div id="scale" style="">
<div id="scale">
<h4>Cuando veas esta escala, toma en cuenta que:</h4>
<p>1 = <strong>no me gusta en absoluto</strong> 👎🏽</p>
<p>5 = <strong>estoy absolutamente de acuerdo</strong> 👍🏽</p>
</div>
</div>

<div data-target="slideshow.slide" class="slide introductory-section" id="third">
<div id="own-pace" style="">
<div id="own-pace">
<h4>Lee el documento a tu propio ritmo</h4>
<p>No hay ningun requerimiento de participación. Todos están invitados a colaborar y a leer y comentar todas las veces que quieran. Cualquier idea es aceptada para mejorar el país.</p>
<p>Has "click" en <button class="btn btn-primary">terminar la Consulta</button> cuando termines de leer el texto.</p>
<p>Has "click" en <button class="btn btn-primary">terminar la consulta</button> cuando termines de leer el texto.</p>
</div>
</div>

Expand Down
39 changes: 20 additions & 19 deletions app/views/legislations/show.html.erb
Expand Up @@ -62,7 +62,7 @@
<%# @metadata = Metadatum.find_by(article: article) %>
<div class="flex flex-row success-badges">
<h6 class="align-left p-2">Artículo <%= article.number %></h6>
<p class="p-2"><button data-html="true" data-toggle="popover" data-trigger="hover" title="Artículo Modificado" class='badge badge-danger text-white popover-body font-12' data-content="<%= render 'metadata_show', metadata: Metadatum.find_by(article: article) %>" data-boundary='scrollParent'>MODIFICADO</button></p>
<p class="p-2"><button data-html="true" data-toggle="popover" data-trigger="hover" title="Artículo Modificado" class='badge badge-danger text-white popover-body font-12' data-content="<%= render 'metadata_show', metadata: Metadatum.find_by(article: article) %>" data-boundary='scrollParent'>VER MODIFICADO</button></p>
</div>
<% else %>
<% if article.new == true %>
Expand Down Expand Up @@ -103,75 +103,76 @@

<div id="collapse_<%= article.id %>" class="collapse hide" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body" data-controller="slideshow">
<% unless article.questions[0].answers.exists?(consultation: current_user.consultations.last) %>
<% unless article.questions.find_by(number: 1).answers.exists?(consultation: current_user.consultations.last) %>
<div data-target="slideshow.slide" class="slide">
<%= article.questions[0].content %><p>(1 = no me gusta en absoluto, 5 = estoy absolutamente de acuerdo)</p>
<p class='medium-font'><%= article.questions.find_by(number: 1).content %></p>
<p style="font-size: 12px">(1 = no me gusta en absoluto, 5 = estoy absolutamente de acuerdo)</p>
<%= form_for @answer, html: { id: "reportform" }, remote: true, update: { success: "response", failure: "error"}, method: :post do |f| %>
<%= f.hidden_field :user_id, :value => current_user.id %>
<%= f.hidden_field :question_id, :value => article.questions[0].id %>
<%= f.hidden_field :question_id, :value => article.questions.find_by(number: 1).id %>
<%= f.hidden_field :consultation_id, :value => @consultation.id %>
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
<div class="buttonspacing">
<a data-action="slideshow#next">
<%= f.submit '1', :name => "content", :class => 'btn-primary' %>
<%= f.submit '1', name: "content", class: 'btn-primary' %>
</a>
<a data-action="slideshow#next">
<%= f.submit '2', :name => "content", :class => 'btn-primary' %>
<%= f.submit '2', name: "content", class: 'btn-primary' %>
</a>
<a data-action="slideshow#next">
<%= f.submit '3', :name => "content", :class => 'btn-primary' %>
<%= f.submit '3', name: "content", class: 'btn-primary' %>
</a>
<a data-action="slideshow#next">
<%= f.submit '4', :name => "content", :class => 'btn-primary' %>
<%= f.submit '4', name: "content", class: 'btn-primary' %>
</a>
<a data-action="slideshow#next">
<%= f.submit '5', :name => "content", :class => 'btn-primary' %>
<%= f.submit '5', name: "content", class: 'btn-primary' %>
</a>
</div>
<% end %>
</div>
<% end %>
<% unless article.questions[1].answers.exists?(consultation: current_user.consultations.last) %>
<% unless article.questions.find_by(number: 2).answers.exists?(consultation: current_user.consultations.last) %>
<div data-target="slideshow.slide" class="slide">
<%= article.questions[1].content %><p>(1 = not at all, 5 = very much)</p>
<p class='medium-font'><%= article.questions.find_by(number: 2).content %></p>
<%= form_for @answer, html: { id: "reportform" }, remote: true, update: { success: "response", failure: "error"} do |f| %>
<%= f.hidden_field :user_id, :value => current_user.id %>
<%= f.hidden_field :question_id, :value => article.questions[1].id %>
<%= f.hidden_field :question_id, :value => article.questions.find_by(number: 2).id %>
<%= f.hidden_field :consultation_id, :value => @consultation.id %>
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
<div class="buttonspacing">
<a data-action="slideshow#next slideshow#answered">
<%= f.submit 'SÍ', name: "content", :class => 'btn-primary' %>
<%= f.submit 'SÍ', name: "content", class: 'btn-primary' %>
</a>
<a data-action="slideshow#next slideshow#answered">
<%= f.submit 'NO', name: "content", :class => 'btn-primary' %>
<%= f.submit 'NO', name: "content", class: 'btn-primary' %>
</a>
</div>
<% end %>
</div>
<% end %>
<% unless article.questions[2].answers.exists?(consultation: current_user.consultations.last) %>
<% unless article.questions.find_by(number: 3).answers.exists?(consultation: current_user.consultations.last) %>
<div data-target="slideshow.slide" class="slide">
<p>¿Quisieras sugerir algún comentario sobre el artículo?</p>
<p class='medium-font'>¿Quisieras sugerir algún comentario sobre el artículo?</p>
<div class=" form-group buttonspacing">
<button data-action="slideshow#next" class="btn-primary"></button>
<button data-action="slideshow#close" class="btn-primary">No</button>
</div>
</div>

<div data-target="slideshow.slide" class="slide">
<%= article.questions[2].content %>
<p class="medium-font"><%= article.questions.find_by(number: 3).content %></p>
<%= form_for Answer.new, html: { id: "reportform" }, remote: true, update: { success: "response", failure: "error"} do |f| %>
<div class="form-group">
<%= f.hidden_field :user_id, :value => current_user.id %>
<%= f.hidden_field :question_id, :value => article.questions[2].id %>
<%= f.hidden_field :question_id, :value => article.questions.find_by(number: 3).id %>
<%= f.hidden_field :consultation_id, :value => @consultation.id %>
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
<%= f.text_area :content, :name => "content", required: true, :class => 'form-control', placeholder: "Me parece que este artículo es bueno/malo porque .... Esto se podría arreglar agregando/quitando ...." %>
<a data-action="slideshow#close slideshow#revised slideshow#next">
<%= f.submit 'Sugiere tu revisión', :class => 'btn-primary' %>
<%= f.submit 'sugiere tu revisión', :class => 'btn-primary' %>
</a>
</div>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/active_admin.rb
Expand Up @@ -112,7 +112,7 @@
# roots for each namespace.
#
# Default:
config.root_to = 'general_feedbacks#index'
config.root_to = 'answers#index'

# == Admin Comments
#
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20190825001535_add_number_to_questions.rb
@@ -0,0 +1,5 @@
class AddNumberToQuestions < ActiveRecord::Migration[5.2]
def change
add_column :questions, :number, :integer
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2019_08_16_135412) do
ActiveRecord::Schema.define(version: 2019_08_25_001535) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -132,6 +132,7 @@
t.bigint "article_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "number"
t.index ["article_id"], name: "index_questions_on_article_id"
end

Expand Down
6 changes: 3 additions & 3 deletions db/seeds.rb
Expand Up @@ -4811,7 +4811,7 @@
# La ultima pregunta referirá a un Si/No sobre si el ciudadano quiere escribir alguna sugerencia.
puts 'Creating questions for each article'
Article.all.each do |article|
Question.create!(content: "¿Tienes alguna sugerencia?", article: article)
Question.create!(content: "¿Piensas que este artículo beneficia a Panamá a largo plazo?", article: article)
Question.create!(content: "¿Sientes que este artículo representa tu opinión sobre este tema?", article: article)
Question.create!(content: "¿Tienes alguna sugerencia?", article: article, number: 3)
Question.create!(content: "¿Piensas que este artículo beneficia a Panamá a largo plazo?", article: article, number: 2)
Question.create!(content: "¿Sientes que este artículo representa tu opinión sobre este tema?", article: article, number: 1)
end

0 comments on commit b7f5076

Please sign in to comment.