Skip to content

Commit aba1143

Browse files
committed
form and badges
Date: Fri May 20 08:22:27 2022 +0100
1 parent ea553a7 commit aba1143

File tree

5 files changed

+96
-40
lines changed

5 files changed

+96
-40
lines changed

functions/views/badges.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
extends _layout
22

33
block content
4-
h1 Badges
4+
include ../build/badges.html
55

66
.toggle
77
for l in user.sidebarLevels

functions/views/signup.pug

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,65 +4,95 @@ block content
44

55
h1 Create New Account
66

7-
form(v-on:submit="user.signup" v-bind:class="{loading: user.signupForm.loading}")
7+
form(v-on:submit="user.signup" v-bind:class="{loading: user.signupForm.loading}" class="signup-form")
88

99
.toggle
10-
a(v-on:click="user.signupForm.isTeacher = false" v-bind:class="{active: !user.signupForm.isTeacher}") Student
11-
a(v-on:click="user.signupForm.isTeacher = true" v-bind:class="{active: user.signupForm.isTeacher}") Teacher
10+
a(v-on:click="user.signupForm.type = 'student'" v-bind:class="{active: user.signupForm.type === 'student'}") Student
11+
a(v-on:click="user.signupForm.type = 'teacher'" v-bind:class="{active: user.signupForm.type === 'teacher'}") Teacher
12+
a(v-on:click="user.signupForm.type = 'parent'" v-bind:class="{active: user.signupForm.type === 'parent'}") Parent
1213

1314
.error(v-show="user.signupForm.error" style="margin-top: .5em") {{user.signupForm.error}}
1415

1516
label
16-
| First Name
17+
span(v-if="user.signupForm.type !== 'parent'") First Name
18+
span(v-if="user.signupForm.type === 'parent'") Your child's first name
1719
input(type="text" required v-model="user.signupForm.first" autocomplete="given-name")
1820

1921
label
20-
| Surname
22+
span(v-if="user.signupForm.type !== 'parent'") Surname
23+
span(v-if="user.signupForm.type === 'parent'") Your child's surname
2124
input(type="text" required v-model="user.signupForm.last" autocomplete="family-name")
2225

2326
label
24-
| Email
27+
span Email
28+
br
29+
div(class="info" v-if="user.signupForm.type === 'student'") (We sometimes find that our emails are blocked by school firewalls and therefore suggest that you do not use a school email address if possible.)
30+
div(class="info" v-if="user.signupForm.type === 'parent'") (Used to log in)
2531
input(type="email" required v-model="user.signupForm.email" autocomplete="email")
2632

33+
label(v-if="user.signupForm.type !== 'teacher'")
34+
span(v-if="user.signupForm.type === 'student'") Is your own email or a parent's email?
35+
span(v-if="user.signupForm.type === 'parent'") Is this your child's own email or a parent's email?
36+
div(style="text-align: center")
37+
input(type='radio' v-model="user.signupForm.primaryEmailType" value='student')#is-student-email-student
38+
label(class="radio-label" for="is-student-email-student") Child's
39+
input(type='radio' v-model="user.signupForm.primaryEmailType" value='parent')#is-student-email-parent
40+
label(class="radio-label" for="is-student-email-parent") Parent's
41+
42+
//- label(v-if="user.signupForm.type !== 'teacher' && user.signupForm.primaryEmailType === 'student' && user.signupForm.birthYear < 2009")
43+
//- span Parent's Email
44+
//- br
45+
//- div(class="info" v-if="user.signupForm.type === 'student'") (NEED STUDENT TEXT)
46+
//- div(class="info" v-if="user.signupForm.type === 'parent'") (NEED PARENT TEXT)
47+
//- input(type="email" required v-model="user.signupForm.guardianEmail" autocomplete="email")
48+
2749
label
28-
| Password (min 6 characters)
50+
span Password
51+
div(class="info") (min 6 characters)
2952
input(type="password" required pattern=".{6,}" v-model="user.signupForm.password" autocomplete="password")
3053

31-
label(v-if="!user.signupForm.isTeacher")
32-
| Teacher code (if you are participating as part of a school)
54+
label(v-if="user.signupForm.type !== 'teacher'")
55+
span Teacher code
56+
div(class="info") (if you are participating as part of a school)
3357
input(type="text" v-model="user.signupForm.teacherCode")
3458

35-
label(v-if="!user.signupForm.isTeacher")
36-
| Year
59+
label(v-if="user.signupForm.type !== 'teacher'")
60+
span(v-if="user.signupForm.type === 'student'") Year
61+
span(v-if="user.signupForm.type === 'parent'") Your child's year group
3762
select(v-model="user.signupForm.level")
3863
option(value="year7") Year 7 (age 12 or below)
3964
option(value="year8") Year 8 (age 12–13)
4065
option(value="year9") Year 9 (age 13–14)
4166
option(value="year10") Year 10 (age 14–15)
4267
option(value="year11") Year 11 (age 15 or above)
4368

44-
label(v-if="!user.signupForm.isTeacher && !user.signupForm.teacherCode")
45-
| Year of Birth
69+
label(v-if="user.signupForm.type !== 'teacher' && !user.signupForm.teacherCode")
70+
span(v-if="user.signupForm.type === 'student'") Year of Birth
71+
span(v-if="user.signupForm.type === 'parent'") Your child's year of birth
4672
select(v-model="user.signupForm.birthYear")
4773
- var year = 1920;
4874
while year < 2016
4975
option= year++
5076

51-
label(v-if="user.signupForm.isTeacher")
52-
| School Name
77+
label(v-if="user.signupForm.type === 'teacher'")
78+
span School Name
5379
input(type="text" v-model="user.signupForm.schoolName" required)
5480

55-
label(v-if="user.signupForm.isTeacher")
56-
| School Post Code
81+
label(v-if="user.signupForm.type === 'teacher'")
82+
span School Post Code
5783
input(type="text" v-model="user.signupForm.postCode" required)
5884

59-
label(v-if="user.signupForm.isTeacher")
60-
| School Phone Number
85+
label(v-if="user.signupForm.type === 'teacher'")
86+
span School Phone Number
6187
input(type="text" v-model="user.signupForm.phoneNumber" required)
6288

6389
//- TODO Calculate the age dynamically
64-
label(v-if="!user.signupForm.isTeacher && !user.signupForm.teacherCode && user.signupForm.birthYear >= 2009")
65-
| Email of a parent or guardian#[br]#[em This is required because you are not yet 13 years old.]
90+
label(v-if="user.signupForm.type !== 'teacher' && !user.signupForm.teacherCode && user.signupForm.birthYear >= 2009 && user.signupForm.primaryEmailType !== 'parent'")
91+
span Email of a parent or guardian
92+
div(class="info" v-if="user.signupForm.type === 'student'") This is required because you are not yet 13 years old.
93+
div(class="info" v-if="user.signupForm.type === 'parent'") This is required because your child is not yet 13 years old.
94+
95+
6696
input(type="email" v-model="user.signupForm.guardianEmail" required)
6797

6898
p.checkbox

pages/badges.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Badges
2+
3+
In the Parallel Universe, you can earn awards by collecting points.
4+
5+
This page shows the points you have earned by completing Parallelograms. You earn 1 point for every percentage point you score in every Parallelogram. Points turn into badges.
6+
7+
At the end of the academic year, you will be awarded a certificate based on the points you have scored.
8+
9+
You can also earn points and awards by attending our live Parallel Circles.

static/scripts/user.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export default function() {
8888
const editForm = {loading: false, error: '', teacherCodes: []};
8989
const passwordForm = {loading: false, error: ''};
9090
const signupForm = {error: null, loading: false, level: 'year7',
91-
birthYear: 2000, isTeacher: location.hash === '#teacher'};
91+
birthYear: 2000, type: location.hash === '#teacher' ? 'teacher' : location.hash === '#parent' ? 'parent' : 'student', primaryEmailType: null};
9292

9393
if (window.USER_DATA) {
9494
for (let key of ['first', 'last', 'schoolName', 'postCode', 'phoneNumber', 'level']) {
@@ -209,7 +209,7 @@ export default function() {
209209
signupForm.loading = true;
210210
signupForm.error = null;
211211

212-
if (signupForm.isTeacher) {
212+
if (signupForm.type === 'teacher') {
213213
if (!signupForm.schoolName) {
214214
signupForm.loading = false;
215215
return signupForm.error = 'Please provide a valid school name.';
@@ -236,7 +236,7 @@ export default function() {
236236
}
237237

238238
// Redirect after login
239-
nextUrl = signupForm.isTeacher ? '/dashboard' : '/introduction';
239+
nextUrl = signupForm.type === 'teacher' ? '/dashboard' : '/introduction';
240240

241241
// user has come from parallel live, send them back
242242
if(window.location.href.includes('#live') || window.location.href.includes('?live') || window.location.href.includes('#circles') || window.location.href.includes('?circles')) {
@@ -246,22 +246,25 @@ export default function() {
246246
// Ensure that there are no existing cookies
247247
document.cookie = '__session=;max-age=-999';
248248

249+
const signupData = {
250+
first: signupForm.first || null,
251+
last: signupForm.last || null,
252+
teacherCode: signupForm.teacherCode ? [signupForm.teacherCode] : null,
253+
code: signupForm.code || null,
254+
level: signupForm.level || null,
255+
birthYear: signupForm.birthYear || null,
256+
schoolName: signupForm.schoolName || null,
257+
phoneNumber: signupForm.phoneNumber || null,
258+
postCode: signupForm.postCode || null,
259+
guardianEmail: signupForm.guardianEmail || null,
260+
acceptedTerms: true,
261+
userReference: generateUserReference(),
262+
primaryEmailType: signupForm.type === 'teacher' ? 'teacher' : signupForm.primaryEmailType
263+
}
264+
249265
userPromise = fbAuth.createUserWithEmailAndPassword(signupForm.email, signupForm.password)
250266
.then(({user}) => {
251-
return fbDatabase.collection('users').doc(user.uid).set({
252-
first: signupForm.first || null,
253-
last: signupForm.last || null,
254-
teacherCode: signupForm.teacherCode ? [signupForm.teacherCode] : null,
255-
code: signupForm.code || null,
256-
level: signupForm.level || null,
257-
birthYear: signupForm.birthYear || null,
258-
schoolName: signupForm.schoolName || null,
259-
phoneNumber: signupForm.phoneNumber || null,
260-
postCode: signupForm.postCode || null,
261-
guardianEmail: signupForm.guardianEmail || null,
262-
acceptedTerms: true,
263-
userReference: generateUserReference()
264-
});
267+
return fbDatabase.collection('users').doc(user.uid).set(signupData);
265268
})
266269
.catch(error => {
267270
console.error(error);

static/styles/forms.less

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,21 @@
22
// Parallel Forms
33
// =============================================================================
44

5-
5+
.signup-form {
6+
span {
7+
font-size: 16px;
8+
margin-right: 4px;
9+
}
10+
.info {
11+
display: inline-block;
12+
}
13+
.radio-label {
14+
display: inline-block;
15+
font-size: 16px;
16+
padding: 6px;
17+
margin: 0;
18+
}
19+
}
620

721
form {
822
line-height: 1.5;

0 commit comments

Comments
 (0)