fixes #40 - summary noJS messages
This commit is contained in:
parent
5d906c6ff4
commit
8640effbfc
@ -7,11 +7,11 @@
|
|||||||
return this.each(function(){
|
return this.each(function(){
|
||||||
var lineHeight = parseInt($(this).css('line-height'));
|
var lineHeight = parseInt($(this).css('line-height'));
|
||||||
var rows = Math.ceil(input / lineHeight);
|
var rows = Math.ceil(input / lineHeight);
|
||||||
rows = rows == 0 ? 1 : rows;
|
rows = rows === 0 ? 1 : rows;
|
||||||
|
|
||||||
$(this).attr('rows', rows);
|
$(this).attr('rows', rows);
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
$('input[type="radio"]').on('change', function() {
|
$('input[type="radio"]').on('change', function() {
|
||||||
var inputName = $(this).attr('name');
|
var inputName = $(this).attr('name');
|
||||||
@ -40,7 +40,7 @@ var editClickHandler = function(e) {
|
|||||||
}
|
}
|
||||||
else if(thisEd.find('input').attr('type') == 'checkbox') {
|
else if(thisEd.find('input').attr('type') == 'checkbox') {
|
||||||
$(thisEd.find('input')).each(function() {
|
$(thisEd.find('input')).each(function() {
|
||||||
if($(this).prop('checked')==true) {
|
if($(this).prop('checked') === true) {
|
||||||
existingValue.push($(this).val());
|
existingValue.push($(this).val());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -91,7 +91,8 @@ var saveClickHandler = function(e) {
|
|||||||
var thisEd = $(e.delegateTarget);
|
var thisEd = $(e.delegateTarget);
|
||||||
var data =[];
|
var data =[];
|
||||||
var executeQuery;
|
var executeQuery;
|
||||||
var questionId = thisEd.find('.button-edit').attr('data-questionid');
|
var questionId = thisEd.find('.button-edit').attr('data-questionId');
|
||||||
|
var answerId = thisEd.find('.button-edit').attr('data-answerId');
|
||||||
|
|
||||||
if (thisEd.hasClass('live_code-type')) {
|
if (thisEd.hasClass('live_code-type')) {
|
||||||
var htmlAnswer = $(thisEd.find('textarea.code-html')[0]).val();
|
var htmlAnswer = $(thisEd.find('textarea.code-html')[0]).val();
|
||||||
@ -103,27 +104,28 @@ var saveClickHandler = function(e) {
|
|||||||
'css': cssAnswer,
|
'css': cssAnswer,
|
||||||
'js': jsAnswer
|
'js': jsAnswer
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
} else if(thisEd.hasClass('radio-type')) {
|
} else if(thisEd.hasClass('radio-type')) {
|
||||||
$(thisEd.find('input')).each(function() {
|
$(thisEd.find('input')).each(function() {
|
||||||
if($(this).prop('checked')==true) {
|
if($(this).prop('checked') === true) {
|
||||||
data = ({
|
data = ({
|
||||||
'radio': $(this).val()
|
'radio': $(this).val()
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if(thisEd.hasClass('checkbox-type')) {
|
} else if(thisEd.hasClass('checkbox-type')) {
|
||||||
data = {'checkbox': []};
|
data = {'checkbox': []};
|
||||||
|
|
||||||
$(thisEd.find('input')).each(function() {
|
$(thisEd.find('input')).each(function() {
|
||||||
if($(this).prop('checked')==true) {
|
if($(this).prop('checked') === true) {
|
||||||
data.checkbox.push($(this).val());
|
data.checkbox.push($(this).val());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
data = {'text': thisEd.find('textarea').val()};
|
data = {'text': thisEd.find('textarea').val()};
|
||||||
}
|
}
|
||||||
if(data == '') {
|
|
||||||
|
if(data === '') {
|
||||||
$(thisEd).before('<div class="error">Please select or enter a value.</div>');
|
$(thisEd).before('<div class="error">Please select or enter a value.</div>');
|
||||||
} else {
|
} else {
|
||||||
thisEd.find('textarea:not(.code-answer)').replaceWith('<p class="text-answer answer-container">' + $.trim(thisEd.find('textarea').val()) + '</p>');
|
thisEd.find('textarea:not(.code-answer)').replaceWith('<p class="text-answer answer-container">' + $.trim(thisEd.find('textarea').val()) + '</p>');
|
||||||
@ -133,7 +135,7 @@ var saveClickHandler = function(e) {
|
|||||||
type: "POST",
|
type: "POST",
|
||||||
url: url,
|
url: url,
|
||||||
data: ({
|
data: ({
|
||||||
'answer': data,
|
'answer': $.extend(data, {'question_id': questionId, 'answer_id': answerId}),
|
||||||
'submit': true
|
'submit': true
|
||||||
}),
|
}),
|
||||||
success: function(data){
|
success: function(data){
|
||||||
@ -143,12 +145,12 @@ var saveClickHandler = function(e) {
|
|||||||
executeQuery = false;
|
executeQuery = false;
|
||||||
}
|
}
|
||||||
}).done(function() {
|
}).done(function() {
|
||||||
if(executeQuery == true) {
|
if(executeQuery === true) {
|
||||||
$('.success, .error').remove();
|
$('.success, .error').remove();
|
||||||
$(thisEd).before('<div class="success">Your answer has been updated successfully!</div>');
|
$(thisEd).before('<div class="success">Your answer has been updated successfully!</div>');
|
||||||
$(thisEd).find('.code-answer').attr('disabled', true);
|
$(thisEd).find('.code-answer').attr('disabled', true);
|
||||||
}
|
}
|
||||||
if(executeQuery == false) {
|
if(executeQuery === false) {
|
||||||
$('.error, .success').remove();
|
$('.error, .success').remove();
|
||||||
$(thisEd).before('<div class="error">Oops! There was an error processing your request. Please try again.</div>');
|
$(thisEd).before('<div class="error">Oops! There was an error processing your request. Please try again.</div>');
|
||||||
}
|
}
|
||||||
@ -167,7 +169,7 @@ $('.answer-block').prop('disabled', true);
|
|||||||
// Question events
|
// Question events
|
||||||
$('.answer-sec')
|
$('.answer-sec')
|
||||||
.find('.button-cancel, .button-save').hide().end()
|
.find('.button-cancel, .button-save').hide().end()
|
||||||
// // delegating events
|
// delegating events
|
||||||
.on('click', '.button-edit', editClickHandler)
|
.on('click', '.button-edit', editClickHandler)
|
||||||
.on('click', '.button-cancel', cancelClickHandler)
|
.on('click', '.button-cancel', cancelClickHandler)
|
||||||
.on('click', '.button-save', saveClickHandler);
|
.on('click', '.button-save', saveClickHandler);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<% if flash[:answer_error] == question.question_id %>
|
<% if flash[:answer_error] == question.question_id && answer.present? %>
|
||||||
<% 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 %>
|
||||||
|
@ -11,18 +11,22 @@
|
|||||||
Please revisit this page with JavaScript enabled to modify your answer.
|
Please revisit this page with JavaScript enabled to modify your answer.
|
||||||
</div> -->
|
</div> -->
|
||||||
|
|
||||||
<% unless params[:action] == 'summary' %>
|
|
||||||
<div data-id="live-coder-finish-later">
|
<div data-id="live-coder-finish-later">
|
||||||
<p class="warning">
|
<p class="warning">
|
||||||
This is a question where you will be asked to write code, and it utilizes a JavaScript-enabled
|
This is a question where you will be asked to write code, and it utilizes a JavaScript-enabled
|
||||||
environment. It looks like JavaScript is not loaded. Please check the box below
|
environment. It looks like JavaScript is not loaded.
|
||||||
to acknowledge that you agree to come back at a later time to finish answering this question
|
<% unless params[:action] == 'summary' %>
|
||||||
before you can submit the test.
|
Please check the box below to acknowledge that you agree to come back at a later time to finish
|
||||||
|
answering this question before you can submit the test.
|
||||||
|
<% else %>
|
||||||
|
You will need to enable JavaScript and answer this question before you can submit the test.
|
||||||
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
|
<% unless params[:action] == 'summary' %>
|
||||||
<%= form.check_box(:answer, checkbox_html, true, '') %>
|
<%= form.check_box(:answer, checkbox_html, true, '') %>
|
||||||
<%= form.label(option_id, 'I will come back later to finish this code question') %>
|
<%= form.label(option_id, 'I will come back later to finish this code question') %>
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div data-id="live-coder-answer">
|
<div data-id="live-coder-answer">
|
||||||
<% # answers inserted dynamically via jQuery .load()
|
<% # answers inserted dynamically via jQuery .load()
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<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-questionId="<%= question.question_id %>">Edit</a>
|
<a href="<%= question_path(question.question_id) %>" class="tertiary-btn button-edit" data-answerId="<%= question.answer_id %>" data-questionId="<%= question.question_id %>">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>
|
||||||
|
Loading…
Reference in New Issue
Block a user