summary page rebuild

This commit is contained in:
Mark Moser 2016-08-09 23:17:35 -05:00
parent 084a1a2326
commit 76bb21a150
17 changed files with 141 additions and 258 deletions

View File

@ -87,17 +87,6 @@
} }
/* Set the width */
// var sidebarWidth = linesDiv.outerWidth();
// var paddingHorizontal = parseInt( linedWrapDiv.css("border-left-width") ) + parseInt( linedWrapDiv.css("border-right-width") ) + parseInt( linedWrapDiv.css("padding-left") ) + parseInt( linedWrapDiv.css("padding-right") );
// var linedWrapDivNewWidth = originalTextAreaWidth - paddingHorizontal;
// var textareaNewWidth = originalTextAreaWidth - sidebarWidth - paddingHorizontal - 20;
//
// textarea.width( textareaNewWidth );
// linedWrapDiv.width( linedWrapDivNewWidth );
/* React to the scroll event */ /* React to the scroll event */
textarea.scroll( function(){ textarea.scroll( function(){
var domTextArea = $(this)[0]; var domTextArea = $(this)[0];

View File

@ -1,4 +1,6 @@
function updateResults(elem) { function updateResults(elem) {
if ($(elem).length ===0){return false;};
var resultsContainer = $(elem).find('[data-id="results"]')[0]; var resultsContainer = $(elem).find('[data-id="results"]')[0];
var codeHtml = $(elem).find('.code-html')[0].value.trim(); var codeHtml = $(elem).find('.code-html')[0].value.trim();
var codeCss = $(elem).find('.code-css')[0].value.trim(); var codeCss = $(elem).find('.code-css')[0].value.trim();
@ -100,7 +102,7 @@ $(function(){
// wait a half second before updating results // wait a half second before updating results
// restart the timer if they resume typing // restart the timer if they resume typing
$('html').on('keyup', '.code-input textarea', function(){ $('html').on('keyup', '.code-input textarea', function(){
var elem = $(this).closest('.answer-sec.live_code-type, .answer-sec.live_code_text-type'); var elem = $(this).closest("[data-id=live-coder-answer]");
if (timer) { clearTimeout(timer); } if (timer) { clearTimeout(timer); }
timer = setTimeout(updateResults(elem), 500); timer = setTimeout(updateResults(elem), 500);
}); });

View File

@ -1,181 +1,83 @@
/* global updateResults */
/* TODO: remove global ^ once live-coder is properly name spaced */
/** /**
* Summary Page Answer Editor * Summary Page Answer Editor
*/ */
function disableForm($form){
$form.find('fieldset').prop('disabled', true);
$form.find('textarea').prop('disabled', true);
$form.find('.button-save, .button-cancel').hide();
$form.find('.button-edit').show();
$form.find('.editable').removeClass('editable');
$('.button-edit, .submit-button').removeClass('disabled-button');
}
(function($){ function restoreValues($form){
$.fn.setTextAreaHeight = function(input) { $form.find('[type=radio][data-last], [type=checkbox][data-last]').each(function(){
return this.each(function(){ $(this).prop('checked', $(this).attr('data-last'));
var lineHeight = parseInt($(this).css('line-height'));
var rows = Math.ceil(input / lineHeight);
rows = rows === 0 ? 1 : rows;
$(this).attr('rows', rows);
}); });
};
$('input[type="radio"]').on('change', function() { $form.find('textarea[data-last]').each(function(){
var inputName = $(this).attr('name'); $(this).val($(this).attr('data-last'));
//$('input[name="'+inputName+'"]').attr('checked', false); });
var value = $(this).attr('value'); }
$('input[name="'+inputName+'"][value="'+value+'"]').attr("checked",true);
$('input[name="'+inputName+'"]').each(function() { function updateLocalValues($form){
if($(this).val() != value) { $form.find('[type=radio][data-last], [type=checkbox][data-last]').each(function(){
$(this).attr('checked', false); $(this).attr('data-last', $(this).prop('checked') ? 'checked' : '');
});
$form.find('textarea[data-last]').each(function(){
$(this).attr('data-last', $(this).val());
});
}
function prepareAjax($form) {
$form.on("ajax:success", function(e, data){
$form.prepend('<div class="success">' + data.message + '</div>');
disableForm($form);
updateLocalValues($form);
}).on("ajax:error", function(e, xhr) {
if (xhr.status === 400){
$form.prepend('<div class="error">' + xhr.responseJSON.join('<br>') + '</div>');
} else {
$form.prepend('<div class="error">Oops! There was an error processing your request. Please try again.</div>');
} }
}); });
}); }
// $('.run-js').hide().delay(); function editClickHandler(e) {
}(jQuery));
var existingValue = [];
var editClickHandler = function(e) {
e.preventDefault(); e.preventDefault();
var thisEd = $(e.delegateTarget);
var height = thisEd.find('p').height();
thisEd.data('answer', thisEd.find('p').text());
if(thisEd.find('input').attr('type') == 'radio') {
existingValue = thisEd.find('input:checked').val();
}
else if(thisEd.find('input').attr('type') == 'checkbox') {
$(thisEd.find('input')).each(function() {
if($(this).prop('checked') === true) {
existingValue.push($(this).val());
}
});
}
else if (thisEd.find('textarea:not(.code-answer)')) {
existingValue = thisEd.find('textarea:not(.code-answer)').val();
thisEd.find('.chars.hidden').removeClass('hidden');
}
$('.button-edit, .submit-button').addClass('disabled-button'); $('.button-edit, .submit-button').addClass('disabled-button');
thisEd.addClass('editable'); var $form = $(e.delegateTarget).closest('form');
// thisEd.find('.text-answer:not(.code-answer)').replaceWith('<textarea class="answer-block">' + $.trim(thisEd.data('answer')) + '</textarea>'); $(e.delegateTarget).addClass('editable');
thisEd.find('.answer-block, .code-answer').prop('disabled', false); $form.find('fieldset').prop('disabled', false);
thisEd.find('textarea').setTextAreaHeight(height); $form.find('textarea').prop('disabled', false);
thisEd.find('textarea.answer-block').focus(); $form.find('textarea').focus();
thisEd.find('.button-edit').hide().delay(); $form.find('.button-edit').hide().delay();
thisEd.find('.button-save, .button-cancel').show().delay(); $form.find('.button-save, .button-cancel').show().delay();
// thisEd.find('button.run-js').show().delay(); }
};
var cancelClickHandler = function(e) { function cancelClickHandler(e) {
e.preventDefault(); e.preventDefault();
var thisEd = $(e.delegateTarget); var $form = $(e.delegateTarget).closest('form');
if(thisEd.find('input').attr('type') == 'radio') { $form.find('.error, .success').remove();
$(thisEd.find('input')).each(function() { disableForm($form);
if($(this).val()!=existingValue) { restoreValues($form);
$(this).attr('checked', false).prop('checked', false); updateResults($form.find("[data-id=live-coder-answer]"));
} }
else {
$(this).prop('checked', true);
}
});
}
else if(thisEd.find('input').attr('type') == 'checkbox') {
$(existingValue).each(function(index, value) {
thisEd.find('input[value="'+value+'"]').prop('checked', true);
});
}
else if (thisEd.find('textarea:not(.code-answer)')) {
thisEd.find('textarea:not(.code-answer)').val(existingValue);
thisEd.find('.chars').addClass('hidden');
}
$('.success, .error').remove();
$('.button-edit, .submit-button').removeClass('disabled-button');
thisEd.removeClass('editable');
// thisEd.find('textarea:not(.code-answer)').replaceWith('<p class="text-answer answer-container">' + $.trim(thisEd.data('answer')) + '</p>');
thisEd.find('.answer-block, .code-answer').prop('disabled', true);
thisEd.find('.button-edit').show();
thisEd.find('.button-save, .button-cancel').hide();
// thisEd.find('button.run-js').hide();
existingValue = [];
};
var saveClickHandler = function(e) { function saveClickHandler(e) {
e.preventDefault(); e.preventDefault();
var thisEd = $(e.delegateTarget); var $form = $(e.delegateTarget).closest('form');
var data =[]; $form.find('.error, .success').remove();
var executeQuery; $form.submit();
var questionId = thisEd.find('.button-edit').attr('data-questionId');
var answerId = thisEd.find('.button-edit').attr('data-answerId');
if (thisEd.hasClass('live_code-type')) {
var htmlAnswer = $(thisEd.find('textarea.code-html')[0]).val();
var cssAnswer = $(thisEd.find('textarea.code-css')[0]).val();
var jsAnswer = $(thisEd.find('textarea.code-js')[0]).val();
data = {
'live_code': {
'html': htmlAnswer,
'css': cssAnswer,
'js': jsAnswer
}
};
} else if(thisEd.hasClass('radio-type')) {
$(thisEd.find('input')).each(function() {
if($(this).prop('checked') === true) {
data = ({
'radio': $(this).val()
});
}
});
} else if(thisEd.hasClass('checkbox-type')) {
data = {'checkbox': []};
$(thisEd.find('input')).each(function() {
if($(this).prop('checked') === true) {
data.checkbox.push($(this).val());
}
});
} else {
data = {'text': thisEd.find('textarea').val()};
} }
if(data === '') { $('.summary_tpl fieldset').prop('disabled', true);
$(thisEd).before('<div class="error">Please select or enter a value.</div>'); $('.summary_tpl textarea').prop('disabled', true);
} else { $('.summary_tpl form').each(function(){ prepareAjax($(this)); });
thisEd.find('textarea:not(.code-answer)').replaceWith('<p class="text-answer answer-container">' + $.trim(thisEd.find('textarea').val()) + '</p>'); $('.summary_tpl .answer-sec')
var postUrl = thisEd.closest('form').attr('action');
$.ajax({
type: "POST",
url: postUrl,
data: ({
'answer': $.extend(data, {'question_id': questionId, 'answer_id': answerId}),
'submit': true
}),
success: function(){ //unused data
executeQuery = true;
},
error: function(){ //unused data
executeQuery = false;
}
}).done(function() {
if(executeQuery === true) {
$('.success, .error').remove();
$(thisEd).before('<div class="success">Your answer has been updated successfully!</div>');
$(thisEd).find('.code-answer').attr('disabled', true);
}
if(executeQuery === false) {
$('.error, .success').remove();
$(thisEd).before('<div class="error">Oops! There was an error processing your request. Please try again.</div>');
}
});
$('.button-edit, .submit-button').removeClass('disabled-button');
thisEd.removeClass('editable');
thisEd.find('.answer-block').prop('disabled', true);
thisEd.find('.button-edit').show();
thisEd.find('.button-save, .button-cancel').hide();
}
};
$('.answer-block').prop('disabled', true);
// Question events
$('.answer-sec')
.find('.button-cancel, .button-save').hide().end() .find('.button-cancel, .button-save').hide().end()
.on('click', '.button-edit', editClickHandler) .on('click', '.button-edit', editClickHandler)
.on('click', '.button-cancel', cancelClickHandler) .on('click', '.button-cancel', cancelClickHandler)

View File

@ -78,6 +78,10 @@ textarea {
padding: 0 0 3rem; padding: 0 0 3rem;
} }
.summary_tpl textarea {
padding: 1rem 1rem 3rem;
}
[type="search"] { [type="search"] {
appearance: none; appearance: none;
} }

View File

@ -2,18 +2,12 @@
margin: 10px 0; margin: 10px 0;
textarea { textarea {
background-color: #fff;
border: 1px solid black;
font-family: "Lucida Console", Monaco, monospace; font-family: "Lucida Console", Monaco, monospace;
font-size: 10px; font-size: 10px;
// line-height: 1.6em; // line-height: 1.6em;
margin-bottom: 0; margin-bottom: 0;
min-height: 205px; min-height: 205px;
width: 100%; width: 100%;
&[disabled] {
background-color: #ddd;
}
} }
} }
@ -44,12 +38,6 @@ iframe {
width: 100%; width: 100%;
} }
.live-coder-summary{
button.update-button{
display: none;
}
}
@media only screen and (min-width: $desktop) { @media only screen and (min-width: $desktop) {
.code-input { .code-input {
float: left; float: left;
@ -107,7 +95,7 @@ iframe {
.linedtextarea textarea { .linedtextarea textarea {
padding-right: 0.3em; padding-right: 0.3em;
padding-top: 0.3em; padding-top: 0.3em;
border: 0; border: 0 !important;
} }
.linedwrap .lines { .linedwrap .lines {

View File

@ -10,9 +10,10 @@ class QuizController < ApplicationController
end end
def update_answer def update_answer
qid = answer_params[:question_id] || prep_status.current_question_id @answer = prep_answer answer_params[:question_id]
@answer = prep_answer qid send "process_#{prep_question(answer_params[:question_id]).input_type}"
send "process_#{prep_question(qid).input_type}" route_remote and return if request.xhr?
route_answer
end end
def summary def summary
@ -65,49 +66,50 @@ class QuizController < ApplicationController
if @answer.errors.present? if @answer.errors.present?
prep_status prep_status
prep_question answer_params[:question_id] prep_question answer_params[:question_id]
flash[:answer_error] = answer_params[:question_id].to_i flash[:error] = answer_params[:question_id].to_i
render :question render :question
else else
flash.delete(:answer_error)
# TODO: change params.key? to submit = save/next/summary # TODO: change params.key? to submit = save/next/summary
# redirect_to :summary and return if params.key?(:update)
redirect_to :saved and return if params.key?(:save) redirect_to :saved and return if params.key?(:save)
redirect_to :question redirect_to :question
end end
end end
def route_remote
if @answer.errors.present?
render json: @answer.errors["answer"].to_json, status: 400
else
render json: { message: "Your answer has been updated successfully!" }.to_json
end
end
def process_text def process_text
@answer.update(answer: answer_params[:text], @answer.update(answer: answer_params[:text],
saved: params.key?(:save), saved: params.key?(:save),
submitted: params.key?(:submit)) submitted: params.key?(:submit))
route_answer
end end
def process_radio def process_radio
@answer.update(answer: answer_params[:radio], @answer.update(answer: answer_params[:radio],
saved: params.key?(:save), saved: params.key?(:save),
submitted: params.key?(:submit)) submitted: params.key?(:submit))
route_answer
end end
def process_checkbox def process_checkbox
@answer.update(answer: answer_params[:checkbox], @answer.update(answer: answer_params[:checkbox],
saved: params.key?(:save), saved: params.key?(:save),
submitted: params.key?(:submit)) submitted: params.key?(:submit))
route_answer
end end
def process_live_code def process_live_code
@answer.update(answer: answer_params[:live_code].to_h, @answer.update(answer: answer_params[:live_code].to_h,
saved: params.key?(:save), saved: params.key?(:save),
submitted: params.key?(:submit)) submitted: params.key?(:submit))
route_answer
end end
def process_live_code_text def process_live_code_text
@answer.update(answer: answer_params[:live_code_text].to_h, @answer.update(answer: answer_params[:live_code_text].to_h,
saved: params.key?(:save), saved: params.key?(:save),
submitted: params.key?(:submit)) submitted: params.key?(:submit))
route_answer
end end
end end

View File

@ -1,4 +1,4 @@
<% if flash[:answer_error] == question.question_id && answer.present? %> <% if flash[:error] == question.question_id && answer.try(:errors) %>
<% answer.errors.messages[:answer].each do |message| %> <% answer.errors.messages[:answer].each do |message| %>
<div class="error"><%= message %></div> <div class="error"><%= message %></div>
<% end %> <% end %>

View File

@ -1,11 +1,11 @@
<% <% question.input_options.each_with_index do | option, i |
question.input_options.each_with_index do | option, i |
option_id = "#{question.question_id}_#{i}" option_id = "#{question.question_id}_#{i}"
checkbox_html = {class: 'checkbox', checkbox_html = {class: 'checkbox',
id: "answer_#{option_id}", id: "answer_#{option_id}",
name: "answer[checkbox][]", name: "answer[checkbox][]",
checked: Array(question.answer).include?(option) checked: Array(question.answer).include?(option),
data: { last: Array(question.answer).include?(option) ? 'checked' : '' }
} }
answers = answer.try(:answer) || answer answers = answer.try(:answer) || answer
%> %>

View File

@ -5,7 +5,6 @@
name: "answer[#{question.input_type}][later]", name: "answer[#{question.input_type}][later]",
checked: Array(question.answer).include?('finish-later') checked: Array(question.answer).include?('finish-later')
} }
disabled = local_assigns.fetch :disable_input, false
answers = answer.try(:answer) || answer answers = answer.try(:answer) || answer
%> %>
@ -31,17 +30,17 @@
<div id="answer<%= question.question_id %>" data-id="live-coder-answer" style="display: none;"> <div id="answer<%= question.question_id %>" data-id="live-coder-answer" style="display: none;">
<div class="code-input"> <div class="code-input">
<label for="answer_live_code_html">HTML</label> <label for="answer_live_code_html">HTML</label>
<%= text_area_tag 'answer[live_code][html]', (answers['html']), { disabled: disabled, 'data-id' => 'code-html', class: 'code-answer code-html' } %> <%= text_area_tag 'answer[live_code][html]', (answers['html']), { data: {id: 'code-html', last: answers['html'] }, class: 'code-answer code-html' } %>
</div> </div>
<div class="code-input"> <div class="code-input">
<label for="answer_live_code_css">CSS</label> <label for="answer_live_code_css">CSS</label>
<%= text_area_tag 'answer[live_code][css]', (answers['css']), { disabled: disabled, 'data-id' => 'code-css', class: 'code-answer code-css' } %> <%= text_area_tag 'answer[live_code][css]', (answers['css']), { data: {id: 'code-css', last: answers['css']}, class: 'code-answer code-css' } %>
</div> </div>
<div class="code-input"> <div class="code-input">
<label for="answer_live_code_js">JS</label> <label for="answer_live_code_js">JS</label>
<%= text_area_tag 'answer[live_code][js]', (answers['js']), { disabled: disabled, 'data-id' => 'code-js', class: 'code-answer code-js' } %> <%= text_area_tag 'answer[live_code][js]', (answers['js']), { data: {id: 'code-js', last: answers['js']}, class: 'code-answer code-js' } %>
</div> </div>
<div class="results" data-id="results"></div> <div class="results" data-id="results"></div>

View File

@ -5,7 +5,6 @@
name: "answer[#{question.input_type}][later]", name: "answer[#{question.input_type}][later]",
checked: Array(question.answer).include?('finish-later') checked: Array(question.answer).include?('finish-later')
} }
disabled = local_assigns.fetch :disable_input, false
answers = answer.try(:answer) || answer answers = answer.try(:answer) || answer
%> %>
@ -30,21 +29,21 @@
<div id="answer<%= question.question_id %>" data-id="live-coder-answer" style="display: none;"> <div id="answer<%= question.question_id %>" data-id="live-coder-answer" style="display: none;">
<label for="answer_live_code_text">Reasoning</label> <label for="answer_live_code_text">Reasoning</label>
<%= text_area_tag 'answer[live_code_text][text]', (answers['text']) %> <%= text_area_tag 'answer[live_code_text][text]', (answers['text']), {data: {last: answers['text']}} %>
<div class="code-input"> <div class="code-input">
<label for="answer_live_code_html">HTML</label> <label for="answer_live_code_html">HTML</label>
<%= text_area_tag 'answer[live_code_text][html]', (answers['html']), { disabled: disabled, 'data-id' => 'code-html', class: 'code-answer code-html' } %> <%= text_area_tag 'answer[live_code_text][html]', (answers['html']), { data: {id: 'code-html', last: answers['html']}, class: 'code-answer code-html' } %>
</div> </div>
<div class="code-input"> <div class="code-input">
<label for="answer_live_code_css">CSS</label> <label for="answer_live_code_css">CSS</label>
<%= text_area_tag 'answer[live_code_text][css]', (answers['css']), { disabled: disabled, 'data-id' => 'code-css', class: 'code-answer code-css' } %> <%= text_area_tag 'answer[live_code_text][css]', (answers['css']), { data: {id: 'code-css', last: answers['css']}, class: 'code-answer code-css' } %>
</div> </div>
<div class="code-input"> <div class="code-input">
<label for="answer_live_code_js">JS</label> <label for="answer_live_code_js">JS</label>
<%= text_area_tag 'answer[live_code_text][js]', (answers['js']), { disabled: disabled, 'data-id' => 'code-js', class: 'code-answer code-js' } %> <%= text_area_tag 'answer[live_code_text][js]', (answers['js']), { data: {id: 'code-js', last: answers['js']}, class: 'code-answer code-js' } %>
</div> </div>
<div class="results" data-id="results"></div> <div class="results" data-id="results"></div>

View File

@ -1,7 +1,6 @@
<% <% question.input_options.each do | option |
question.input_options.each do | option |
option_id = "#{option.parameterize}_#{question.to_i}" option_id = "#{option.parameterize}_#{question.to_i}"
radio_html = {class: 'radio', id: option_id} radio_html = {class: 'radio', id: option_id, data: {last: (question.answer == option) ? 'checked' : '' }}
answers = answer.try(:answer) || answer answers = answer.try(:answer) || answer
%> %>
<div class="form-group-multiples"> <div class="form-group-multiples">

View File

@ -1,11 +1,10 @@
<% <%
hidden = params[:action] == 'summary' ? 'hidden' : ''
answers = answer.try(:answer) || answer answers = answer.try(:answer) || answer
%> %>
<label for="answer_text">Enter answer here</label> <label for="answer_text">Enter answer here</label>
<textarea id="answer_text" name="answer[text]" rows="10"><%= answers %></textarea> <%= text_area_tag 'answer[text]', answers, {rows: 10, data: { last: answers } } %>
<div class="chars <%= hidden %>">Characters remaining: <span></span></div> <div class="chars <%= params[:action] == 'summary' ? 'hidden' : '' %>">Characters remaining: <span></span></div>
<%= render partial: "quiz/answer_errors", locals: {question: question, answer: answer} %> <%= render partial: "quiz/answer_errors", locals: {question: question, answer: answer} %>

View File

@ -14,14 +14,14 @@
<hr> <hr>
<% @quiz.each do |question| %> <% @quiz.each do |question| %>
<%= form_for(:answer, url: post_answer_path(answer_id: question.answer_id), html:{class: 'summary-form'}) do |form| %> <%= form_for(:answer, remote: true, url: post_answer_path(answer_id: question.answer_id), html:{class: 'summary-form'}) do |form| %>
<article class="answer-sec <%= question.input_type %>-type" data-qid="<%= question.question_id %>"> <article class="answer-sec">
<div class="question-heading"> <div class="question-heading">
<div class="question-title"> <div class="question-title">
<h3><%= question.question %></h3> <h3><%= question.question %></h3>
</div> </div>
<div class="answer-buttons"> <div class="answer-buttons">
<a href="<%= question_path(question.question_id) %>" class="tertiary-btn button-edit" data-answerId="<%= question.answer_id %>" data-questionId="<%= question.question_id %>">Edit</a> <a href="<%= question_path(question.question_id) %>" class="tertiary-btn button-edit">Edit</a>
<button class="tertiary-btn button-save">Save</button> <button class="tertiary-btn button-save">Save</button>
<button class="tertiary-btn button-cancel">Cancel</button> <button class="tertiary-btn button-cancel">Cancel</button>
</div> </div>
@ -35,7 +35,8 @@
<fieldset disabled class="answer-block"> <fieldset disabled class="answer-block">
<%= hidden_field_tag 'answer[question_id]', question.question_id %> <%= hidden_field_tag 'answer[question_id]', question.question_id %>
<%= hidden_field_tag 'answer[answer_id]', question.answer_id %> <%= hidden_field_tag 'answer[answer_id]', question.answer_id %>
<%= render partial: question.input_type, locals: {question: question, form: form, answer: question.answer, disable_input: true} %> <%= hidden_field_tag 'submit', true %>
<%= render partial: question.input_type, locals: {question: question, form: form, answer: question.answer} %>
</fieldset> </fieldset>
</div> </div>
</article> </article>

View File

@ -7,7 +7,7 @@
</p> </p>
<% @quiz.each do |question| %> <% @quiz.each do |question| %>
<%= form_for(:answer, url: post_summary_path, html:{id: 'summary-form'}) do |form| %> <%= form_for(:answer, url: '#never-post', html:{id: 'summary-form'}) do |form| %>
<article class="answer-sec <%= question.input_type %>-type" data-qid="<%= question.question_id %>"> <article class="answer-sec <%= question.input_type %>-type" data-qid="<%= question.question_id %>">
<div class="question-heading"> <div class="question-heading">
<div class="question-title"> <div class="question-title">
@ -20,7 +20,6 @@
<%= image_tag question.attachment %> <%= image_tag question.attachment %>
<% end %> <% end %>
<fieldset disabled class="answer-block"> <fieldset disabled class="answer-block">
<%= hidden_field_tag 'answer[question_id]', question.question_id %>
<%= render partial: "quiz/#{question.input_type}", locals: {question: question, answer: question.answer, form: form} %> <%= render partial: "quiz/#{question.input_type}", locals: {question: question, answer: question.answer, form: form} %>
</fieldset> </fieldset>
</div> </div>

View File

@ -23,6 +23,6 @@ class QuizControllerTest < ActionDispatch::IntegrationTest
assert_response :success assert_response :success
assert session[:test_id].present? assert session[:test_id].present?
assert_equal qid, flash[:answer_error] assert_equal qid, flash[:error]
end end
end end

View File

@ -3,7 +3,7 @@
roy1: roy1:
candidate: roy candidate: roy
question: fed1 question: fed1
answer: option2 answer: Nullam id dolor id nibh ultricies vehicula ut id elit. Sed posuere consectetur est at lobortis. Nullam id dolor id nibh ultricies vehicula ut id elit. Sed posuere consectetur est at lobortis.
saved: 0 saved: 0
submitted: true submitted: true
created_at: <%= DateTime.now() - 90.minutes - 36.hours %> created_at: <%= DateTime.now() - 90.minutes - 36.hours %>
@ -12,7 +12,7 @@ roy1:
roy2: roy2:
candidate: roy candidate: roy
question: fed2 question: fed2
answer: ["option-1", "option-4", "option5"] answer: ['indexOf()', 'inArray()']
saved: 1 saved: 1
submitted: true submitted: true
created_at: <%= DateTime.now() - 85.minutes - 36.hours %> created_at: <%= DateTime.now() - 85.minutes - 36.hours %>
@ -21,7 +21,7 @@ roy2:
dawn1: dawn1:
candidate: dawn candidate: dawn
question: fed1 question: fed1
answer: option-1 answer: Sed posuere consectetur est at lobortis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
saved: 0 saved: 0
submitted: true submitted: true
created_at: <%= DateTime.now() - 38.hours - 50.minutes %> created_at: <%= DateTime.now() - 38.hours - 50.minutes %>
@ -30,7 +30,7 @@ dawn1:
dawn2: dawn2:
candidate: dawn candidate: dawn
question: fed2 question: fed2
answer: ["option2", "option-4"] answer: ["indexOf()"]
saved: 0 saved: 0
submitted: true submitted: true
created_at: <%= DateTime.now() - 38.hours - 50.minutes %> created_at: <%= DateTime.now() - 38.hours - 50.minutes %>
@ -57,7 +57,7 @@ dawn4:
dawn5: dawn5:
candidate: dawn candidate: dawn
question: fed5 question: fed5
answer: "option 3" answer: 'Dynamic listeners'
saved: 0 saved: 0
submitted: true submitted: true
created_at: <%= DateTime.now() - 38.hours - 50.minutes %> created_at: <%= DateTime.now() - 38.hours - 50.minutes %>
@ -111,7 +111,7 @@ dawn10:
peggy1: peggy1:
candidate: peggy candidate: peggy
question: fed1 question: fed1
answer: option-1 answer: Donec sed odio dui. Etiam porta sem malesuada magna mollis euismod. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
saved: 0 saved: 0
submitted: true submitted: true
created_at: <%= DateTime.now() - 38.hours - 50.minutes %> created_at: <%= DateTime.now() - 38.hours - 50.minutes %>
@ -120,7 +120,7 @@ peggy1:
peggy2: peggy2:
candidate: peggy candidate: peggy
question: fed2 question: fed2
answer: ["option2", "option-4"] answer: ['indexOf()']
saved: 0 saved: 0
submitted: true submitted: true
created_at: <%= DateTime.now() - 38.hours - 50.minutes %> created_at: <%= DateTime.now() - 38.hours - 50.minutes %>
@ -147,7 +147,7 @@ peggy4:
peggy5: peggy5:
candidate: peggy candidate: peggy
question: fed5 question: fed5
answer: "option 3" answer: 'Dynamic listeners'
saved: 0 saved: 0
submitted: true submitted: true
created_at: <%= DateTime.now() - 38.hours - 50.minutes %> created_at: <%= DateTime.now() - 38.hours - 50.minutes %>
@ -201,7 +201,7 @@ peggy10:
richard1: richard1:
candidate: richard candidate: richard
question: fed1 question: Cras justo odio, dapibus ac facilisis in, egestas eget quam. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit.
answer: option 3 answer: option 3
saved: 0 saved: 0
submitted: true submitted: true
@ -211,7 +211,7 @@ richard1:
richard2: richard2:
candidate: richard candidate: richard
question: fed2 question: fed2
answer: [option-1, option2, option5] answer: 'indexOf()'
saved: 0 saved: 0
submitted: true submitted: true
created_at: <%= DateTime.now() - 36.hours - 24.minutes %> created_at: <%= DateTime.now() - 36.hours - 24.minutes %>
@ -238,7 +238,7 @@ richard4:
richard5: richard5:
candidate: richard candidate: richard
question: fed5 question: fed5
answer: option-1 answer: 'Dynamic listeners'
saved: 0 saved: 0
submitted: true submitted: true
created_at: <%= DateTime.now() - 36.hours - 30.minutes %> created_at: <%= DateTime.now() - 36.hours - 30.minutes %>
@ -265,7 +265,7 @@ richard7:
richard8: richard8:
candidate: richard candidate: richard
question: fed8 question: fed8
answer: option2 answer: option-4
saved: 0 saved: 0
submitted: true submitted: true
created_at: <%= DateTime.now() - 36.hours - 36.minutes %> created_at: <%= DateTime.now() - 36.hours - 36.minutes %>

View File

@ -92,9 +92,9 @@ class QuizStatusTest < ActiveSupport::TestCase
assert_equal questions(:fed1).id, status.current_question_id assert_equal questions(:fed1).id, status.current_question_id
end end
test "richard is summary" do test "dawn is on summary" do
richard = candidates :richard dawn = candidates :dawn
status = QuizStatus.new richard status = QuizStatus.new dawn
assert_equal nil, status.current_question_id assert_equal nil, status.current_question_id
end end