Skip to content

Commit

Permalink
Merge in recent commits from master to new-ui (#554)
Browse files Browse the repository at this point in the history
* Change order of deploy workflow?

* Fix index + signup on mobile (new UI) (#548)

* Migrate to Azure CDN

* Change default font to Inter

* Initialize tailwind

* Implement new navbar

* Fine-tune new homepage

* Finish bare-bones landing page

* Finish redesign of signup page

* Work on flashes, get semi-working dismiss thing

* Fix a few bugs on sign up page

* Tidy up flashes, work on sign up page

* Make express-ejslayouts not default, for now

* Adjust default x-padding

* Fix flashes for sign in page

* Do more stuff with sign in page errors?

* Fix signin issue

* Tidy up some stuff on main page

* New about page

* Fixed about page emails

* Add Ved picture, restyle about page

* Deploy new board

* Fix contact form

* Prettify about page

* Fix a bunch of UI issues on mobile

---------

Co-authored-by: William Y. Feng <[email protected]>
Co-authored-by: Samuel Stankiewicz <[email protected]>

* Make stats on index page dynamic

* Add password recovery to signin page

* Remove Inter font from Latex equations

* ess enabling and icon centering (#549)

* inclusion of usabo questions in the homepage stats

* hour refactoring during reviewing transfer fix

* reviewer role created

* contributor stats fix

* admin optimization and search direct to question feature

* references update

* contributor stats fix

* moved grace up on about page

* usabo frontend reroutes and fixes

* prelim questions equations/constants

* comment

* Fix equations + constants in question page

* references fix

* equations and constants on display question

* fix no reviewers problem

* add usabo to nav bar

* icon centering and ess enabling

---------

Co-authored-by: Patrick Feng <[email protected]>
Co-authored-by: William Y. Feng <[email protected]>

* add ess to nav bar (#550)

* inclusion of usabo questions in the homepage stats

* hour refactoring during reviewing transfer fix

* reviewer role created

* contributor stats fix

* admin optimization and search direct to question feature

* references update

* contributor stats fix

* moved grace up on about page

* usabo frontend reroutes and fixes

* prelim questions equations/constants

* comment

* Fix equations + constants in question page

* references fix

* equations and constants on display question

* fix no reviewers problem

* add usabo to nav bar

* icon centering and ess enabling

* add ess to navbar

---------

Co-authored-by: Patrick Feng <[email protected]>
Co-authored-by: William Y. Feng <[email protected]>

* return to homepage redirect fix

* add debugging tools

* fix and add debugging tools (#551)

* inclusion of usabo questions in the homepage stats

* hour refactoring during reviewing transfer fix

* reviewer role created

* contributor stats fix

* admin optimization and search direct to question feature

* references update

* contributor stats fix

* moved grace up on about page

* usabo frontend reroutes and fixes

* prelim questions equations/constants

* comment

* Fix equations + constants in question page

* references fix

* equations and constants on display question

* fix no reviewers problem

* add usabo to nav bar

* icon centering and ess enabling

* add ess to navbar

* fix

---------

Co-authored-by: Patrick Feng <[email protected]>
Co-authored-by: William Y. Feng <[email protected]>

* ess fix and initialization (#552)

* inclusion of usabo questions in the homepage stats

* hour refactoring during reviewing transfer fix

* reviewer role created

* contributor stats fix

* admin optimization and search direct to question feature

* references update

* contributor stats fix

* moved grace up on about page

* usabo frontend reroutes and fixes

* prelim questions equations/constants

* comment

* Fix equations + constants in question page

* references fix

* equations and constants on display question

* fix no reviewers problem

* add usabo to nav bar

* icon centering and ess enabling

* add ess to navbar

* fix

* add question model fix

* ess fix and initialization

---------

Co-authored-by: Patrick Feng <[email protected]>
Co-authored-by: William Y. Feng <[email protected]>

* fixed leaderboard background colors

issue #343

* fixes issues

yob must be greater than 1900, dark mode on by default for new users, join the team on index now redirects to discord

* instagram hex change to e4008a

* create stat initailization

* Change USABO description on homepage

---------

Co-authored-by: William Y. Feng <[email protected]>
Co-authored-by: Samuel Stankiewicz <[email protected]>
Co-authored-by: Patrick Feng <[email protected]>
Co-authored-by: Patrick Feng <[email protected]>
Co-authored-by: Arya Gummadi <[email protected]>
  • Loading branch information
6 people authored Nov 20, 2023
1 parent c7d6b92 commit 858ea56
Show file tree
Hide file tree
Showing 18 changed files with 194 additions and 146 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/master_test-instance-0(master).yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ jobs:
with:
node-version: '18.x'

- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm run test --if-present
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
Expand All @@ -46,6 +40,12 @@ jobs:
with:
name: node-app

- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm run test --if-present
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
Expand Down
4 changes: 2 additions & 2 deletions public/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

p a,
label a {
@apply text-blue-500
opacity-100 hover:opacity-70
@apply text-blue-600 underline-offset-2
opacity-100 hover:underline
transition-opacity;
}
}
49 changes: 24 additions & 25 deletions routes/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ module.exports = (app, mongo) => {
source_statement: req.body.sourceStatement,
subject: req.body.subject,
units: req.body.units,
hourRefactor: 1,
stats: {
pass: 0,
fail: 0,
Expand Down Expand Up @@ -287,31 +288,29 @@ module.exports = (app, mongo) => {

// Master list of questions
app.get('/admin/allQuestions', async (req, res) => {
let questionArray = await mongo.db.collection('questions').find().toArray();
/*for (question of questionArray){
if (!question.hourRefactor) {
let newQ = new mongo.Ques({
question: question.question,
choices: question.choices,
tags: question.tags,
rating: question.rating,
answer: question.answer,
answer_ex: question.answer_ex,
author: question.author,
type: question.type,
ext_source: question.ext_source,
source_statement: question.source_statement,
subject: question.subject,
units: question.units,
reviewers: question.reviewers,
stats: question.stats,
writtenDate: question.writtenDate,
hourRefactor: 1
});
newQ.save();
mongo.db.collection("questions").deleteOne({ _id: question._id });
}
}*/
/*let questionArray = await mongo.db.collection('questions').find().toArray();
for (question of questionArray){
let newQ = new mongo.Ques({
question: question.question,
choices: question.choices,
tags: question.tags,
rating: question.rating,
answer: question.answer,
answer_ex: question.answer_ex,
author: question.author,
type: question.type,
ext_source: question.ext_source,
source_statement: question.source_statement,
subject: question.subject,
units: question.units,
reviewers: question.reviewers,
stats: question.stats,
writtenDate: question.writtenDate,
hourRefactor: 1
});
newQ.save();
mongo.db.collection("questions").deleteOne({ _id: mongoose.Types.ObjectId(question._id) });
}*/
const allQuestions = await mongo.db
.collection('questions')
.find()
Expand Down
22 changes: 18 additions & 4 deletions routes/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,27 @@ const {
} = require('../utils/functions/database');
const { calculateLevel } = require('../utils/functions/siteAlgorithms');
const { sendDiscordWebhook } = require('../utils/functions/webhook.js');
const { User, Ques, SiteData } = require('../utils/functions/mongo');

const VIEWS = '../views/';

module.exports = (app, mongo) => {
// PUBLIC GET
// `username` is email
// `ign` is username
app.get('/', expressLayouts, (req, res) => {
res.render(VIEWS + 'public/indexV2.ejs', { layout: 'layouts/base.ejs' });
app.get('/', expressLayouts, async (req, res) => {
const { questionCount, tagCount, usaboQuestionCount, totalSolves } =
await getSiteData(User, Ques, SiteData);

res.render(VIEWS + 'public/indexV2.ejs', {
layout: 'layouts/base.ejs',
questionCount: questionCount + usaboQuestionCount,
tagCount,
totalSolves: Array.from(Object.values(totalSolves)).reduce(
(a, b) => (a + b ? b : 0), // Catch if b is NaN
0
),
});
});

app.get('/signin', expressLayouts, (req, res) => {
Expand Down Expand Up @@ -59,13 +71,13 @@ module.exports = (app, mongo) => {
res.render(VIEWS + 'public/teamV2', {
pageName: 'About Mutorials',
authenticated: true,
layout: 'layouts/base.ejs'
layout: 'layouts/base.ejs',
});
} else {
res.render(VIEWS + 'public/teamV2', {
pageName: 'About Mutorials',
authenticated: false,
layout: 'layouts/base.ejs'
layout: 'layouts/base.ejs',
});
}
});
Expand Down Expand Up @@ -145,6 +157,7 @@ module.exports = (app, mongo) => {
if (
!/^(19|20)\d{2}$/.test(req.body.yob) ||
req.body.yob.length != 4 ||
req.body.yob < 1900 ||
req.body.yob > new Date().getFullYear()
) {
req.flash('errorFlash', 'Please enter a valid year of birth!');
Expand Down Expand Up @@ -190,6 +203,7 @@ module.exports = (app, mongo) => {
},
preferences: {
hideProfile: new Date().getFullYear() - thisYob < 13 ? true : false,
dark_mode: true,
},
achievements: {
join_mutorials: true,
Expand Down
38 changes: 14 additions & 24 deletions routes/reviewers.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ module.exports = (app, mongo) => {
if (err) {
console.log(err);
} else {
mongo.db.collection('questions').insertOne(
{
const newQ = new mongo.Ques({
question: req.body.question,
choices: parseDelimiter(req.body.choices),
tags: parseDelimiter(req.body.tags),
Expand All @@ -143,17 +142,13 @@ module.exports = (app, mongo) => {
units: req.body.units,
hourRefactor: question.hourRefactor,
writtenDate: question.writtenDate,
reviewers: question.reviewers
},
(err, _) => {
if (err) {
console.log(err);
reviewers: question.reviewers,
stats: {
pass: 0,
fail: 0
}
res.json({
success: true,
});
}
);
});
newQ.save();
}
});
} else {
Expand Down Expand Up @@ -227,8 +222,7 @@ module.exports = (app, mongo) => {
if (err) {
console.log(err);
} else {
mongo.db.collection('usaboQuestions').insertOne(
{
const newQ = new mongo.USABOQues({
question: req.body.question,
choices: parseDelimiter(req.body.choices),
year: req.body.year,
Expand All @@ -242,17 +236,13 @@ module.exports = (app, mongo) => {
categories: req.body.categories,
hourRefactor: question.hourRefactor,
writtenDate: question.writtenDate,
reviewers: question.reviewers
},
(err, _) => {
if (err) {
console.log(err);
reviewers: question.reviewers,
stats: {
pass: 0,
fail: 0
}
res.json({
success: true,
});
}
);
});
newQ.save();
}
});
} else {
Expand Down
23 changes: 18 additions & 5 deletions routes/train.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module.exports = (app, mongo) => {
{ username: req.user.username },
{ $set: { rating: req.user.rating } }
);
res.redirect('/' /* + req.body.subject + '/chooseUnits'*/);
res.redirect('/homepage' /* + req.body.subject + '/chooseUnits'*/);
});

app.post('/selQ', (req, res, next) => {
Expand Down Expand Up @@ -491,16 +491,21 @@ module.exports = (app, mongo) => {
// define units and attempt to get queued question
const units = req.query.units.split(',');
let q = '';

if (req.user.stats.toAnswer[req.params.subject.toLowerCase()]) {
q = await getQuestion(
mongo.Ques,
req.user.stats.toAnswer[req.params.subject.toLowerCase()]
);
}

// get experience stats
let experienceStats = await calculateLevel(req.user.stats.experience);
// Test if they have a question pending to answer which is valid for their units selected
if (q && units.some((r) => q.units.includes(r))) {

console.log("in the if statement");

res.render(VIEWS + 'private/train/displayQuestion.ejs', {
units: units,
newQues: q,
Expand All @@ -511,6 +516,9 @@ module.exports = (app, mongo) => {
referenceSheet
});
} else {

console.log("in the else statement");

// deduct 8 rating if previously queued question was skipped
if (q) {
skipQuestionUpdates(
Expand All @@ -521,11 +529,8 @@ module.exports = (app, mongo) => {
);
}
// get parameters set up
if (req.user.rating['usabo'] === undefined) {
setRating('USABO', -1, req);
}

if (req.user.rating['ess'] === undefined) {
console.log('setting ess rating from undefined to -1');
setRating('ESS', -1, req);
}

Expand All @@ -534,9 +539,17 @@ module.exports = (app, mongo) => {
);
const floor = ceilingFloor.floor;
const ceiling = ceilingFloor.ceiling;

//debugging usage
console.log(floor);
console.log(ceiling);

// get question
getQuestions(mongo.Ques, floor, ceiling, req.params.subject, units).then(
(qs) => {

//console.log(qs);

// select random question
curQ = qs[Math.floor(Math.random() * qs.length)];
console.log(curQ);
Expand Down
4 changes: 4 additions & 0 deletions utils/functions/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ async function getQuestions(Ques, ratingFloor, ratingCeiling, subject, units) {
subject: [subject],
rating: { $gte: ratingFloor, $lte: ratingCeiling },
});

let tempQ = await gotQ.exec();

console.log(tempQ.length);

for (i = 0; i < tempQ.length; i++) {
const found = units.some((r) => tempQ[i].units.includes(r));
if (!found) {
Expand Down
2 changes: 1 addition & 1 deletion views/partials/flashes.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
success: ['bg-green-100', 'border-green-100']
} %>

<div class="flex justify-center w-full mb-4">
<div id="flash-container" class="flex justify-center w-full">
<div class="flex flex-col w-full max-w-md gap-2">
<% for (let pair of flashMessages) { %>
<% if (!pair || !pair[0]) continue; %>
Expand Down
6 changes: 3 additions & 3 deletions views/partials/header.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@
<!-- <link href="css/style.css" rel="stylesheet"> -->
<style>
* {
font-family: 'Inter', Arial, Helvetica, sans-serif;
body {
font-family: 'Inter', Arial, Helvetica, sans-serif;
}
.center {
Expand Down Expand Up @@ -179,7 +179,7 @@
/* Facebook to linkedin aren't used as of rn*/
.instagram {
background: #bc2a8d;
background: #e4008a;
color: white;
}
Expand Down
1 change: 1 addition & 0 deletions views/partials/navigationPrivate.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<a class="dropdown-item" href="/train/Physics/chooseUnits">Physics</a>
<a class="dropdown-item" href="/train/Chemistry/chooseUnits">Chemistry</a>
<a class="dropdown-item" href="/train/Biology/chooseUnits">Biology</a>
<a class="dropdown-item" href="/train/ESS/chooseUnits">ESS</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="/train/rush">Problem Rush</a>
<a class="dropdown-item" href="/train/daily">Daily Question</a>
Expand Down
2 changes: 1 addition & 1 deletion views/partials/navigationV2.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%# Left group: logo, about %>
<ul class="flex items-center gap-4 mr-auto">
<li>
<a class="flex items-center" href="/v2">
<a class="flex items-center" href="/">
<img class="mr-2" src="https://cdn.mutorials.org/images/icons/Icon_Main.svg" width="30">
<b class="hidden sm:block sm:visible">Mutorials</b>
</a>
Expand Down
Loading

0 comments on commit 858ea56

Please sign in to comment.