diff --git a/app/controllers/oodle/answers_controller.rb b/app/controllers/oodle/answers_controller.rb
index 5378521..77bed69 100644
--- a/app/controllers/oodle/answers_controller.rb
+++ b/app/controllers/oodle/answers_controller.rb
@@ -7,7 +7,7 @@ def index
if Current.user.manager?
@students = Current.user.students.pluck(:id, :email_address)
@answers = Answer.where(user_id: @students[0])
- elsif Current.user.studend? || Current.user.user?
+ elsif Current.user.student? || Current.user.user?
@answers = Current.user.answers
else
@answers = Answer.all
diff --git a/app/views/layouts/oodle/application.html.erb b/app/views/layouts/oodle/application.html.erb
index 6814c6a..e50e734 100644
--- a/app/views/layouts/oodle/application.html.erb
+++ b/app/views/layouts/oodle/application.html.erb
@@ -27,7 +27,7 @@
<%= link_to "Items", oodle.items_path, class: "font-bold #{'nav-link-active' if request.url.include?('items')}" %>
<%= link_to "Answers", oodle.answers_path, class: "font-bold #{'nav-link-active' if request.url.include?('answers')}" %>
<% else %>
- <%= link_to "Questionnaires", oodle.questionnaires_path, class: "font-bold #{'nav-link-active' if request.url.include?('questionnaires')}" %>
+ <%= link_to "My Questionnaires", oodle.questionnaires_path(sorted: 'open'), class: "font-bold #{'nav-link-active' if request.url.include?('questionnaires')}" %>
<%#= link_to "My questionnaires", oodle.user_path(Current.user), class: "font-bold" %>
<% end %>
<% end %>
diff --git a/app/views/oodle/answers/_answer.html.erb b/app/views/oodle/answers/_answer.html.erb
index ae6cada..d11c3ac 100644
--- a/app/views/oodle/answers/_answer.html.erb
+++ b/app/views/oodle/answers/_answer.html.erb
@@ -9,7 +9,7 @@ back_button = link_to("Back", answers_path, class: "w-auto btn btn-back btn-back
actions = []
actions = [show_action] unless action_name == "show"
actions.concat(manager_actions) if Current.user.manager?
-actions.concat([back_button]) if action_name == "show"
+# actions.concat([back_button]) if action_name == "show"
%>
<%= render Oodle::CardComponent.new(
diff --git a/app/views/oodle/answers/_form.html.erb b/app/views/oodle/answers/_form.html.erb
index c4ffba0..6738035 100644
--- a/app/views/oodle/answers/_form.html.erb
+++ b/app/views/oodle/answers/_form.html.erb
@@ -9,11 +9,7 @@
<% end %>
-
-
- <%= question.description %>
-
-
+
<% if question.free_text? %>
<%= form.text_area :result, rows: 10, class: "w-full" %>
@@ -37,6 +33,5 @@
<%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
<%= form.submit 'Next', commit: :next, class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
- <%= link_to "Back to questionnaire", questionnaire_path(@questionnaire.id), class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
<% end %>
diff --git a/app/views/oodle/items/show.html.erb b/app/views/oodle/items/show.html.erb
index c48800c..78cf239 100644
--- a/app/views/oodle/items/show.html.erb
+++ b/app/views/oodle/items/show.html.erb
@@ -1,3 +1 @@
-
<%= notice %>
-
<%= render @item %>
diff --git a/app/views/oodle/questionnaires/show.html.erb b/app/views/oodle/questionnaires/show.html.erb
index e951ca1..3e71147 100644
--- a/app/views/oodle/questionnaires/show.html.erb
+++ b/app/views/oodle/questionnaires/show.html.erb
@@ -1,11 +1,43 @@
-
- <%= render @questionnaire %>
+
+<% if Current.user.manager? %>
+
+ <%= render @questionnaire %>
-
-
Questions: <%= @questionnaire.questions.count %>
+
+
Questions: <%= @questionnaire.questions.count %>
-
- <%= render partial: "oodle/questions/question", collection: @questionnaire.questions, as: :question %>
+
+ <%= render partial: "oodle/questions/question", collection: @questionnaire.questions, as: :question %>
+
-
\ No newline at end of file
+<% else %>
+
+
+ <%= render @questionnaire %>
+
+
+ <% @questionnaire.questions.each do |q| %>
+ <% @answer = Current.user
+ .answers
+ .find_by(questionnaire_id: params[:id],question_id: q.id) %>
+ <% if @answer.present? %>
+ <%= render @answer %>
+ <% else %>
+ <%= render Oodle::CardComponent.new(
+ title: q.description,
+ id: dom_id(q),
+ actions: []
+ ) do %>
+ <%= render "oodle/answers/form",
+ answer: Oodle::Answer.new,
+ questionnaire: @questionnaire,
+ question: q %>
+ <% end %>
+
+ <% end %>
+ <% end %>
+
+
+<% end %>
+
diff --git a/app/views/oodle/questions/_question.html.erb b/app/views/oodle/questions/_question.html.erb
index 2f15b80..e39951b 100644
--- a/app/views/oodle/questions/_question.html.erb
+++ b/app/views/oodle/questions/_question.html.erb
@@ -4,11 +4,12 @@ manager_actions = [
link_to("Edit", edit_question_path(question), data: { turbo_frame: "_top" }, class: "btn btn-edit btn-edit-hover btn-edit-focus transition-base", aria: { label: "Edit question" }),
button_to("Destroy", question, method: :delete, data: { turbo_confirm: "Are you sure?", turbo_frame: "_top" }, class: "btn btn-delete btn-delete-hover btn-delete-focus transition-base", aria: { label: "Delete question" })
]
+student_actions = [link_to("Answered", new_answer_path(questionnaire_id: params[:id], question_id: question.id), data: { turbo_frame: "_top" }, class: "btn btn-show btn-show-hover btn-show-focus transition-base")]
back_button = link_to("Back", questions_path, class: "w-auto btn btn-back btn-back-hover btn-back-focus transition-base")
actions = []
actions = [show_action] unless action_name == "show"
-actions.concat(manager_actions) if Current.user.manager?
+Current.user.manager? ? actions.concat(manager_actions) : actions.concat(student_actions)
actions.concat([back_button]) if action_name == "show"
%>
@@ -18,7 +19,7 @@ actions.concat([back_button]) if action_name == "show"
actions: actions
) do %>
-
+ ">
Description:
<%= question.description %>