From 6c2363735c3ca2feb72fe487fd703e96bb0aadfe Mon Sep 17 00:00:00 2001 From: net8floz Date: Tue, 25 Feb 2020 22:53:53 -0800 Subject: [PATCH 1/5] adds email validation --- src/views/Accounts/Register/index.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/views/Accounts/Register/index.vue b/src/views/Accounts/Register/index.vue index 6d5b442..3c868d7 100644 --- a/src/views/Accounts/Register/index.vue +++ b/src/views/Accounts/Register/index.vue @@ -74,6 +74,10 @@ import Step4 from "./Step4"; import * as api from "@/api"; +function validateEmail(mail) { + return /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(mail); +} + export default { components: { Step1, @@ -102,7 +106,7 @@ export default { await api.auth.createAccount({ foundUs: this.fields.heardAboutUs.value === "Other" - ? this.fields.heardAboutUsText.value + ? "Other - " + this.fields.heardAboutUsText.value : this.fields.heardAboutUs.value, studentFirstName: this.fields.firstName.value, studentLastName: this.fields.lastName.value, @@ -153,7 +157,7 @@ export default { label: "Parent's E-mail Address", type: "email", value: "", - rules: [v => !!v || "Please provide a email"] + rules: [v => validateEmail(v) || "Please provide a valid e-mail"] }, studentEmail: { label: "Student's E-mail Address (optional)", From 312315c369177ffd62c8f41f7d9029d7cb7f3f17 Mon Sep 17 00:00:00 2001 From: net8floz Date: Tue, 25 Feb 2020 22:54:12 -0800 Subject: [PATCH 2/5] fixes rank display on countdown --- src/views/Quiz/QuizCountdown.vue | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/views/Quiz/QuizCountdown.vue b/src/views/Quiz/QuizCountdown.vue index a929a12..fe9f063 100644 --- a/src/views/Quiz/QuizCountdown.vue +++ b/src/views/Quiz/QuizCountdown.vue @@ -7,7 +7,7 @@
Congratulations, {{ User.displayName }}!
- You've conquered Level {{ User.rank }}. + You've conquered Level {{ User.rank - 1 }}.

That's all the questions available for now.
@@ -16,7 +16,7 @@
Congratulations, {{ User.displayName }}!
- You've conquered Level {{ User.rank }}. + You've conquered Level {{ User.rank - 1 }}.

@@ -37,7 +37,15 @@ icon >mdi-facebook - mdi-twitter + mdi-twitter From cf5b511b492dd3cdcec00ec2fb2f466d70747fc9 Mon Sep 17 00:00:00 2001 From: net8floz Date: Tue, 25 Feb 2020 22:54:33 -0800 Subject: [PATCH 3/5] adds reminders for myself about how the submission works --- src/views/Quiz/QuizFinalQuestion.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/views/Quiz/QuizFinalQuestion.vue b/src/views/Quiz/QuizFinalQuestion.vue index 0c84ce1..ba0f511 100644 --- a/src/views/Quiz/QuizFinalQuestion.vue +++ b/src/views/Quiz/QuizFinalQuestion.vue @@ -90,11 +90,12 @@ export default { const jsCode = `function calculateAnswer(){ return 100; } +// we check your answer by looking at the output var var output = calculateAnswer();`; const pyCode = `def calculateAnswer(): return 100 - -output = calculateAnswer()`; +# we check your answer by what you print +print(calculateAnswer())`; return { isLoading: false, isSubmitting: false, From 2dc31c0527588dba09a1d6cc2164dfc89ea52283 Mon Sep 17 00:00:00 2001 From: net8floz Date: Tue, 25 Feb 2020 22:54:51 -0800 Subject: [PATCH 4/5] adds pagination and additional styles --- src/api/voting.js | 6 +- src/views/Voting/Ballot.vue | 71 ++++++++++++++---------- src/views/Voting/CodeModal.vue | 27 +++------ src/views/Voting/SuccessModal.vue | 91 +++++++++++++++++++++++++++++++ 4 files changed, 146 insertions(+), 49 deletions(-) create mode 100644 src/views/Voting/SuccessModal.vue diff --git a/src/api/voting.js b/src/api/voting.js index 5b07932..b2b0cfd 100644 --- a/src/api/voting.js +++ b/src/api/voting.js @@ -1,8 +1,10 @@ import routes from "./routes"; import request from "./request"; -async function getBallot() { - return request(routes.voting_ballot); +async function getBallot(page, per) { + return request(routes.voting_ballot, { + params: { page, per } + }); } async function cast(answerId, email) { diff --git a/src/views/Voting/Ballot.vue b/src/views/Voting/Ballot.vue index f016711..4b69f6a 100644 --- a/src/views/Voting/Ballot.vue +++ b/src/views/Voting/Ballot.vue @@ -3,21 +3,34 @@

- Lorem Ipsum is simply dummy text of the printing and typesetting - industry. Lorem Ipsum has been the industry's standard dummy text ever - since the 1500s, when an unknown printer took a galley of type and - scrambled it to make a type specimen book. + Cast your vote below!

- + + + +

+ Loading Results
Please Wait
+

+
+
+ - + /> + + + @@ -36,12 +49,14 @@ export default { }, data() { return { + isLoading: true, + per: 16, item: null, showModal: false, hasNext: false, hasPrev: false, nextNum: false, - page: 0, + page: 1, prevNum: null, totalItems: 0, totalPages: 0, @@ -53,30 +68,28 @@ export default { showCode(item) { this.item = item; this.showModal = true; + }, + async loadPage() { + this.isLoading = true; + try { + const results = await voting.getBallot(this.page, this.per); + for (const [key, value] of Object.entries(results)) { + Vue.set(this, key, value); + } + // console.log(results); + } catch (err) { + this.$router.push({ name: "redirect" }); + } + this.isLoading = false; } }, - async mounted() { - // for (let i = 0; i < 100; i++) { - // this.items.push({ - // display: "Kyle A.", - // firstName: "Kyle", - // id: 45, - // lastName: "Askew", - // numVotes: 0, - // text: - // "function calculateAnswer(){\n return 100;\n}\nvar output = calculateAnswer();;output", - // username: "net8floz2" - // }); - // } - try { - const results = await voting.getBallot(); - for (const [key, value] of Object.entries(results)) { - Vue.set(this, key, value); - } - // console.log(results); - } catch (err) { - this.$router.push({ name: "redirect" }); + watch: { + page(val) { + this.loadPage(val); } + }, + async mounted() { + this.loadPage(); } }; diff --git a/src/views/Voting/CodeModal.vue b/src/views/Voting/CodeModal.vue index 70b3092..cdafb2b 100644 --- a/src/views/Voting/CodeModal.vue +++ b/src/views/Voting/CodeModal.vue @@ -51,22 +51,9 @@
- - - - We have sent a voting confirmation e-mail. - - - Please check your inbox to confirm your vote. - - - - Okay - - - + + + @@ -77,7 +64,7 @@ - Okay @@ -88,11 +75,15 @@ + + From 7d53a15c2477153ae2fa56bfb7f573a57fe5f8a0 Mon Sep 17 00:00:00 2001 From: net8floz Date: Tue, 25 Feb 2020 22:59:34 -0800 Subject: [PATCH 5/5] fixes modal logic --- src/views/Voting/CodeModal.vue | 3 +-- src/views/Voting/SuccessModal.vue | 12 ++++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/views/Voting/CodeModal.vue b/src/views/Voting/CodeModal.vue index cdafb2b..c074c0b 100644 --- a/src/views/Voting/CodeModal.vue +++ b/src/views/Voting/CodeModal.vue @@ -83,7 +83,7 @@ export default { }, data() { return { - showSuccess: true, + showSuccess: false, showError: false, errorMessage: "", isOpen: this.value, @@ -140,7 +140,6 @@ export default { this.errorMessage = err.message; this.showError = true; } - this.isSubmitting = false; } } diff --git a/src/views/Voting/SuccessModal.vue b/src/views/Voting/SuccessModal.vue index 509b62b..f96f08d 100644 --- a/src/views/Voting/SuccessModal.vue +++ b/src/views/Voting/SuccessModal.vue @@ -36,6 +36,18 @@