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

[WIP] Fixing and Adding Tutorials to Pages #766

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6353501
initial test course making framework
abagel21 Mar 23, 2023
b3fb501
generate sessions
abagel21 Mar 25, 2023
1919f63
tags and firebase function for making questions
abagel21 Apr 16, 2023
85672be
basic tutorial code
abagel21 Apr 17, 2023
e907c6c
reflecting comment
abagel21 Apr 17, 2023
2642bd3
comments missed
abagel21 Apr 17, 2023
fe034e2
lint fixes
abagel21 Apr 17, 2023
d0372f9
tutorial ongoing work
abagel21 Apr 30, 2023
d82c636
styling tutorial box
abagel21 May 3, 2023
303133d
Changed file structure and separated tutorial into professor, student…
jewang25 Oct 11, 2023
bf384aa
Merge branch 'alex/tutorial' into jessica-sophie/tutorials
jewang25 Oct 12, 2023
6205f5c
fixed file paths
jewang25 Oct 12, 2023
0fcd8f4
Assigned tutorials to specific pages
jewang25 Oct 12, 2023
f189b8c
Added placeholders for professor tutorial
jewang25 Oct 12, 2023
0837ed2
updated driver.js
jewang25 Oct 23, 2023
bbafa02
add documentation for start tutorial
jewang25 Oct 23, 2023
78ecad9
added driver.js updated library to package.json and yarn.lock
jewang25 Oct 26, 2023
8821064
instructions and ids for student + ta tutorials
swang235 Oct 26, 2023
4d59f16
studenttutorial documentation
swang235 Oct 29, 2023
55c6354
fixed button styling for tutorials
jewang25 Nov 1, 2023
1eab12c
added tutorial icon in top bar and done button in tutorial popover
jewang25 Nov 7, 2023
d081879
added fields in firebase to only show tutorial for first time users
jewang25 Nov 8, 2023
fc79567
Add documentation for showing tutorials and storing tutorial values i…
jewang25 Nov 13, 2023
2f14f21
create placeholder course for tutorial [in progress]
swang235 Nov 23, 2023
e1e9e09
WIP course placeholder
swang235 Nov 29, 2023
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
87 changes: 81 additions & 6 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
/**
* Function that handles data and sends a text message to a requested phone number
*/
async function sendSMS (user: FireUser, message: string) {
if(process.env.DATABASE === "staging") {
async function sendSMS(user: FireUser, message: string) {
if (process.env.DATABASE === "staging") {
return;
}
const userPhone = user.phoneNumber;
Expand Down Expand Up @@ -69,22 +69,32 @@
const newRoles = (doc.data() as FirePendingUser).roles;
const taCourseIds: string[] = [];
const profCourseIds: string[] = [];

var profTutorial = false

Check failure on line 72 in functions/src/index.ts

View workflow job for this annotation

GitHub Actions / build

All 'var' declarations must be at the top of the function scope

Check failure on line 72 in functions/src/index.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected var, use let or const instead
var taTutorial = false

Check failure on line 73 in functions/src/index.ts

View workflow job for this annotation

GitHub Actions / build

All 'var' declarations must be at the top of the function scope

Check failure on line 73 in functions/src/index.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected var, use let or const instead
var studentTutorial = true

Check failure on line 74 in functions/src/index.ts

View workflow job for this annotation

GitHub Actions / build

All 'var' declarations must be at the top of the function scope

Check failure on line 74 in functions/src/index.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected var, use let or const instead
for (const [courseId, role] of Object.entries(newRoles)) {

if (role === 'ta') {
taCourseIds.push(courseId);
taTutorial = true
} else if (role === 'professor') {
profCourseIds.push(courseId);
profTutorial = true
}
}

const batch = db.batch();

const profAndTaCourses = [...taCourseIds, ...profCourseIds]
if (user.courses.length > profAndTaCourses.length) {
studentTutorial = true
}
// and update the newly-created user with their new roles
userRef.update({
courses: [...taCourseIds, ...profCourseIds],
roles: { ...currentRoles, ...newRoles }
courses: profAndTaCourses,
roles: { ...currentRoles, ...newRoles },
studentTutorial: studentTutorial,

Check failure on line 95 in functions/src/index.ts

View workflow job for this annotation

GitHub Actions / build

Expected property shorthand
taTutorial: taTutorial,

Check failure on line 96 in functions/src/index.ts

View workflow job for this annotation

GitHub Actions / build

Expected property shorthand
profTutorial: profTutorial

Check failure on line 97 in functions/src/index.ts

View workflow job for this annotation

GitHub Actions / build

Expected property shorthand
})

const taCourseDocs = await Promise.all(
Expand Down Expand Up @@ -323,8 +333,8 @@
// Derive changes in counts
const newStatus = newQuestion.status;
const prevStatus = prevQuestion.status;
const newNumbers = questionStatusNumbers.get(newStatus)!;

Check warning on line 336 in functions/src/index.ts

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion
const prevNumbers = questionStatusNumbers.get(prevStatus)!;

Check warning on line 337 in functions/src/index.ts

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion

// Grab number of changes
const numQuestionChange = newNumbers[0] - prevNumbers[0];
Expand All @@ -350,7 +360,7 @@

// Derive timing changes (changes from assigned to resolved)
if (numResolvedChange === 1 && newQuestion.timeAssigned !== undefined) {
resolveTimeChange = newQuestion.timeAddressed!.seconds - newQuestion.timeAssigned.seconds;

Check warning on line 363 in functions/src/index.ts

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion
}
else if (numResolvedChange === -1
&& prevQuestion.timeAssigned !== undefined
Expand Down Expand Up @@ -484,4 +494,69 @@
totalWaitTime: admin.firestore.FieldValue.increment(waitTimeChange),
totalResolveTime: admin.firestore.FieldValue.increment(resolveTimeChange),
});
});

exports.addQuestionsTutorial = functions.pubsub.schedule('30 23 * * *')
.timeZone('America/New_York')
.onRun(async () => {
const year = admin.firestore.Timestamp.now().toDate().getFullYear() % 100;
const term = admin.firestore.Timestamp.now().toDate().getMonth() > 6 ? 'FA': 'SP';

const day = new Date();
day.setDate(admin.firestore.Timestamp.now().toDate().getDate() + 1);
day.setHours(0);
day.setMinutes(0);
const endDate = new Date(day);
endDate.setDate(day.getDate() + 1);
// get session for questions
const sessionsQuery = db.collection('sessions')
.where('startTime', '>=', day)
.where('startTime', '<=', endDate)
.where('courseId', '==', `TC00${1}-${term}-${year}`);
const virtualSession = (await sessionsQuery.where('modality', '==', 'virtual').get())
.docs[0].data() as FireSession;
const inPersonSession = (await sessionsQuery.where('modality', '==', 'in-person').get())
.docs[0].data() as FireSession;
const reviewSession = (await sessionsQuery.where('modality', '==', 'review').get())
.docs[0].data() as FireSession;
const sessions = [virtualSession, inPersonSession, reviewSession];


// get tags for questions
const hwtag = (await db.collection('tags').where('courseId', '==', `TC00${1}-${term}-${year}`)
.where('level', '==', 1).get()).docs[0].data() as FireTag;
const subtag = (await db.collection('tags').where('courseId', '==', `TC00${1}-${term}-${year}`)
.where('level', '==', 2).get()).docs[0].data() as FireTag;

// generate questions
sessions.forEach(session => {
const batch = db.batch();
const questionId = db.collection('questions').doc().id;
const finalLocation = session.modality == 'in-person' ? {} : { location: 'Back of room' };

Check warning on line 535 in functions/src/index.ts

View workflow job for this annotation

GitHub Actions / build

Expected '===' and instead saw '=='
const upvotedUsers = session.modality === "review" ? { upvotedUsers: ['cvLM2pAFFJMYlzZU7FEF9qYADap1'] } : {}
const newQuestionSlot: Omit<FireQuestionSlot, 'questionId'> = {
askerId: "cvLM2pAFFJMYlzZU7FEF9qYADap1",
sessionId: session.sessionId,
status: 'unresolved',
timeEntered: admin.firestore.Timestamp.now()
};

const newQuestion: Omit<FireOHQuestion, 'questionId'> = {
...newQuestionSlot,
...finalLocation,
...upvotedUsers,
answererId: '',
content: "I'm having some trouble with problem 3 on the homework.",
primaryTag: hwtag.tagId,
secondaryTag: subtag.tagId,
wasNotified: true,
position: session.totalQuestions - session.assignedQuestions + 1,

};
batch.set(db.collection('questionSlots').doc(questionId), newQuestionSlot);
batch.set(db.collection('questions').doc(questionId), newQuestion);
batch.commit();
})

return true;
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@types/node": "^12.12.15",
"@types/react-linkify": "^1.0.1",
"chai": "^4.2.0",
"driver.js": "^1.3.0",
"firebase": "^8.0.1",
"firebase-admin": "^9.3.0",
"firebase-functions": "^3.11.0",
Expand Down
130 changes: 65 additions & 65 deletions src/components/includes/AddQuestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
return (
<div className='QuestionView' onKeyDown={(e) => handleKeyPressDown(e)}>
{(stage < CLOSE_TO_END_OF_OH || width < mobileBreakpoint) && (
<div className='AddQuestion'>
<div className='AddQuestion' id="AddQuestion">
<div className='queueHeader'>
<p className='title'>Join The Queue</p>
</div>
Expand Down Expand Up @@ -306,7 +306,7 @@
))
) : (
<p className='placeHolder'>
{activeTags.length > 0 ? 'First select a category' :''}
{activeTags.length > 0 ? 'First select a category' : ''}
</p>
)}
</div>
Expand All @@ -319,49 +319,49 @@
<div className='tagsMiniContainer'>
{
<p className='header'>
{session.modality === 'hybrid' ?
{session.modality === 'hybrid' ?
'Location or Zoom Link' : 'Location'} &nbsp;
{session.modality ===
'in-person' && (
<span
className={
'characterCount ' +
(location.length >=
LOCATION_CHAR_LIMIT
? 'warn'
: '')
}
>
(
{LOCATION_CHAR_LIMIT -
location.length}{' '}
character
{LOCATION_CHAR_LIMIT -
location.length !==
1 && 's'}{' '}
left)
</span>
)}
<span

Check failure on line 326 in src/components/includes/AddQuestion.tsx

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 48 spaces but found 52
className={
'characterCount ' +
(location.length >=
LOCATION_CHAR_LIMIT
? 'warn'
: '')
}
>
(
{LOCATION_CHAR_LIMIT -
location.length}{' '}
character
{LOCATION_CHAR_LIMIT -
location.length !==
1 && 's'}{' '}
left)
</span>
)}
</p>
}
{stage >= SECONDARY_SELECTED || activeTags.length === 0 ? (
<div className='locationInput'>
{session.modality === 'hybrid' &&
<Checkbox
className="hybridCheckbox"
label="Are you virtual?"
checked={isVirtual}
onClick={() => setIsVirtual(!isVirtual)}
/>}
{!(session.modality === 'hybrid' &&
typeof session.useTALink !== 'undefined' && session.useTALink) &&
{session.modality === 'hybrid' &&
<Checkbox
className="hybridCheckbox"
label="Are you virtual?"
checked={isVirtual}
onClick={() => setIsVirtual(!isVirtual)}
/>}
{!(session.modality === 'hybrid' &&
typeof session.useTALink !== 'undefined' && session.useTALink) &&
<textarea
className='TextInput location'
value={location}
onChange={handleUpdateLocation}
placeholder={(session.modality === 'in-person' || !isVirtual) ?
placeholder={(session.modality === 'in-person' || !isVirtual) ?
'What is your location?' : 'What is your zoom link?'}
/>
/>
}
</div>
) : (
Expand All @@ -376,42 +376,42 @@
<div className='tagsMiniContainer'>
<p className='header'>{'Question '}</p>
{stage >= LOCATION_INPUTTED ||
primaryTags.length === 0 ||
secondaryTags.length === 0 ||
activeTags.length === 0 ? (
<textarea
className='TextInput question'
value={question}
onChange={handleUpdateQuestion}
placeholder="What's your question about?"
/>
) : (
<textarea
disabled
className='TextInput question'
value={question}
onChange={handleUpdateQuestion}
placeholder={
!('building' in session)
? 'First select a category and a tag'
: 'Enter your location...'
}
/>
)}
primaryTags.length === 0 ||
secondaryTags.length === 0 ||
activeTags.length === 0 ? (
<textarea
className='TextInput question'
value={question}
onChange={handleUpdateQuestion}
placeholder="What's your question about?"
/>
) : (
<textarea
disabled
className='TextInput question'
value={question}
onChange={handleUpdateQuestion}
placeholder={
!('building' in session)
? 'First select a category and a tag'
: 'Enter your location...'
}
/>
)}
</div>
<div className='addButtonWrapper'>
{stage > LOCATION_INPUTTED ||
primaryTags.length === 0 ||
secondaryTags.length === 0 ? (
<p
className='AddButton active'
onClick={() => handleJoinClick()}
>
primaryTags.length === 0 ||
secondaryTags.length === 0 ? (
<p
className='AddButton active'
onClick={() => handleJoinClick()}
>
Add My Question
</p>
) : (
<p className='AddButton'> Add My Question </p>
)}
</p>
) : (
<p className='AddButton'> Add My Question </p>
)}
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/includes/CalendarDaySelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const CalendarDaySelect: React.FC<Props> = (props) => {
}

return (
<div className="CalendarDaySelect">
<div className="CalendarDaySelect" id="CalendarDaySelect">
<p className="month">{monthNames[now.getMonth()]}</p>
<div className="selector">
<button
Expand Down
2 changes: 1 addition & 1 deletion src/components/includes/CalendarSessions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const CalendarSessions = ({
}

return (
<div className='CalendarSessions'>
<div className='CalendarSessions' id='CalendarSessions'>
{sessions.length === 0 && (
<>
<p className='noHoursHeading'>No Office Hours</p>
Expand Down
4 changes: 2 additions & 2 deletions src/components/includes/ProfessorAddNew.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const ProfessorAddNew = (props: { courseId: string; taOptions?: DropdownItemProp
const [editVisible, setEditVisible] = useState(false);
const [discussVisible, setDiscussVisible] = useState(false);

const text = props.taOptions ? 'Add New Office Hour' : 'Add New Assignment';
const text = props.taOptions ? 'Add New Office Hour' : 'Add New Category';
return (
<div className="ProfessorAddNew">
<div className={'Add ' + (!editVisible && !discussVisible)}>
<button type="button" className="NewOHButton" onClick={() => setEditVisible(true)}>
<button id="AddOHButton" type="button" className="NewOHButton" onClick={() => setEditVisible(true)}>
<Icon name="plus" />
{text}
</button>
Expand Down
Loading
Loading