Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quests improvements #5433

Merged
merged 5 commits into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions app/assets/v2/js/pages/quests.new.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@

$(document).ready(function() {
const QUESTIONS_LIMIT = 6;
const ANSWERS_LIMIT = 10;
const question_template = $('.form-group.question:last').clone();
const answer_template = question_template.children('span:last').clone();

$(document).on('form#newkudos', 'submit', function(e) {
// e.preventDefault();
// console.log($(this).formdata);
// alert('hi');

});

$(document).on('click', '.add_answer', function(e) {
e.preventDefault();
var dupe_me = $(this).parents('.form-group').find('span:last');
var clone = dupe_me.clone();

dupe_me.after(clone);
if ($(this).parents('.question').children('span').length >= ANSWERS_LIMIT) {
alert(gettext('The number of answers for each question are limited to ') + ANSWERS_LIMIT);
return;
}

var last_answer = $(this).parents('.form-group.question').children('span:last');

last_answer.after(answer_template.clone());
});
$(document).on('click', '.new_quest_background', function(e) {
e.preventDefault();
Expand All @@ -26,17 +36,22 @@ $(document).ready(function() {

$(document).on('click', '.add_question', function(e) {
e.preventDefault();
var dupe_me = $('.form-group.question:last');
var clone = dupe_me.clone();

dupe_me.after(clone);
if ($('.form-group.question').length > QUESTIONS_LIMIT) {
alert(gettext('The number of questions are limited to ') + QUESTIONS_LIMIT);
return;
}

var last_question = $('.form-group.question:last');

last_question.after(question_template.clone());
});


$(document).on('click', '.close_answer', function(e) {
e.preventDefault();
if ($(this).parents('.question').find('span').length <= 1) {
alert('you cannot have 0 answers per question');
alert(gettext('You cannot have 0 answers per question'));
return;
}
var ele = $(this).parents('span');
Expand All @@ -57,7 +72,7 @@ $(document).ready(function() {
$(document).on('click', '.close_question', function(e) {
e.preventDefault();
if ($('div.question').length <= 1) {
alert('you cannot have 0 questsions');
alert(gettext('you cannot have 0 questsions'));
return;
}
var ele = $(this).parents('div.question');
Expand Down
16 changes: 8 additions & 8 deletions app/quests/templates/quests/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h4>
Gitcoin Quests was designed to educate, inspired, and entertain web2 and web3 developers alike. It was designed to guide users to their 'a-ha' moments about cryptocurrency, decentralization, and the potential of a free and open source financial system.
</p>
<p>
We look forward to guiding your community through an engaging decentralization learning experience, and working with you to do so!
We look forward to guiding your community through an engaging decentralization learning experience, and working with you to do so!
</p>
<p>
&lt;3 <a href="/about#team">Team Gitcoin</a>
Expand Down Expand Up @@ -111,13 +111,13 @@ <h4>
<input type="text" name="reading_material_name" class="form__input" placeholder='Ethereum Whitepaper' value="{{package.reading_material_name}}" required>
</div>
<label class="form__label" for="enemy">{% trans "Reading Material Time Commitment (minutes)" %}</label>
<input type="number" name="est_read_time_mins" class="form__input" placeholder='10' value="{{package.est_read_time_mins}}" required>
<input type="number" name="est_read_time_mins" class="form__input" placeholder='10' min="0" value="{{package.est_read_time_mins}}" required>
<div class="form-group">
<label class="form__label" for="enemy">{% trans "Enemy Kudos" %}</label>
<label class="form__label" for="enemy">{% trans "Enemy Kudos" %}</label>
<i class='fa fa-info-circle' data-placement="bottom" data-toggle="tooltip" data-html="true" title="The enemy to be battled during the quest"></i>
{% if package.enemy %}
<BR>
<span class=default_kudos>Kudos ID {{package.enemy}}</span>
<span class=default_kudos>Kudos ID {{package.enemy}}</span>
<input name=enemy type="hidden" value={{package.enemy}}>
<a class="remove" href=#>Remove</a>
<div class=hidden>
Expand All @@ -132,7 +132,7 @@ <h4>
<i class='fa fa-info-circle' data-placement="bottom" data-toggle="tooltip" data-html="true" title="The reward kudos to be minted if the hero wins the quest"></i>
{% if package.reward %}
<BR>
<span class=default_kudos>Kudos ID {{package.reward}}</span>
<span class=default_kudos>Kudos ID {{package.reward}}</span>
<input name=reward type="hidden" value={{package.reward}}>
<a class="remove" href=#>Remove</a>
<div class=hidden>
Expand All @@ -145,12 +145,12 @@ <h4>
<div class="form-group">
<label class="form__label" for="points">{% trans "Reward Points Value" %}</label>
<i class='fa fa-info-circle' data-placement="bottom" data-toggle="tooltip" data-html="true" title="The number of Gitcoin Quest Points rewarded to winner. Should scale with difficulty (Subject to final approval by Gitcoin team)"></i>
<input type="number" name="points" class="form__input" placeholder='1' value="{{package.points}}" required>
<input type="number" name="points" class="form__input" placeholder='1' value="{{package.points}}" min="0" required>
</div>
<div class="form-group">
<label class="form__label" for="minutes">{% trans "Cooldown Minutes" %}</label>
<i class='fa fa-info-circle' data-placement="bottom" data-toggle="tooltip" data-html="true" title="If someone fails the quest, how many minutes until they can try again?"></i>
<input type="number" name="minutes" class="form__input" placeholder='3' value="{{package.minutes}}" required>
<input type="number" name="minutes" class="form__input" placeholder='3' value="{{package.minutes}}" min="0" required>
</div>
{% for question in questions %}
<div class="form-group question pl-3">
Expand All @@ -166,7 +166,7 @@ <h4>
<br>
<label class="form__label" for="seconds_to_respond[]">{% trans "Seconds to Respond" %}</label>
<i class='fa fa-info-circle' data-placement="bottom" data-toggle="tooltip" data-html="true" title="How many seconds will the user have to respond to this question? Recommending starting point: 30"></i>
<input type="number" name="seconds_to_respond[]" class="form__input" placeholder='Seconds To Respond' value="{{question.seconds_to_respond}}" required>
<input type="number" name="seconds_to_respond[]" class="form__input" placeholder='Seconds To Respond' value="{{question.seconds_to_respond}}" min="0" required>
<label class="form__label" for="question[]">{% trans "Question Text" %}</label>
<input type="text" name="question[]" class="form__input" placeholder='Does Ethereum foo the bar?' value="{{question.question}}" required>
{% for response in question.responses %}
Expand Down