Skip to content
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
2 changes: 1 addition & 1 deletion src/blog-posts
Submodule blog-posts updated 60 files
+9 −0 README.md
+7 −0 blogs/computational-thinking/meta.json
+129 −0 blogs/computational-thinking/post.md
+7 −0 blogs/is-comp-sci-for-you/meta.json
+96 −0 blogs/is-comp-sci-for-you/post.md
+7 −0 blogs/studying-cs-vs-studying-everything-else/meta.json
+82 −0 blogs/studying-cs-vs-studying-everything-else/post.md
+7 −0 blogs/the-importance-of-taking-breaks/meta.json
+138 −0 blogs/the-importance-of-taking-breaks/post.md
+7 −0 blogs/the-role-of-empathy-in technical-fields/meta.json
+105 −0 blogs/the-role-of-empathy-in technical-fields/post.md
+7 −0 blogs/what-is-computer-science/meta.json
+168 −0 blogs/what-is-computer-science/post.md
+20 −3 build-blog
+2 −1 technical/boolean_operations/meta.json
+9 −2 technical/boolean_operations/post.md
+35 −0 technical/boolean_operations/questions.json
+2 −1 technical/dictionaries/meta.json
+1 −0 technical/dictionaries/post.md
+40 −0 technical/dictionaries/questions.json
+2 −1 technical/for_loops/meta.json
+2 −2 technical/for_loops/post.md
+37 −0 technical/for_loops/questions.json
+2 −1 technical/functions/meta.json
+1 −0 technical/functions/post.md
+45 −0 technical/functions/questions.json
+2 −1 technical/if_statements/meta.json
+2 −1 technical/if_statements/post.md
+34 −0 technical/if_statements/questions.json
+2 −1 technical/lists/meta.json
+1 −0 technical/lists/post.md
+50 −0 technical/lists/questions.json
+2 −1 technical/math_operations/meta.json
+3 −2 technical/math_operations/post.md
+39 −0 technical/math_operations/questions.json
+2 −1 technical/more_on_for_loops/meta.json
+1 −0 technical/more_on_for_loops/post.md
+39 −0 technical/more_on_for_loops/questions.json
+2 −1 technical/more_on_strings_lists/meta.json
+2 −0 technical/more_on_strings_lists/post.md
+37 −0 technical/more_on_strings_lists/questions.json
+2 −1 technical/range/meta.json
+6 −1 technical/range/post.md
+41 −0 technical/range/questions.json
+2 −1 technical/statements_expressions/meta.json
+1 −0 technical/statements_expressions/post.md
+35 −0 technical/statements_expressions/questions.json
+2 −1 technical/string_operations/meta.json
+42 −0 technical/string_operations/questions.json
+2 −1 technical/tuples/meta.json
+1 −0 technical/tuples/post.md
+35 −0 technical/tuples/question.json
+2 −1 technical/types/meta.json
+1 −0 technical/types/post.md
+34 −0 technical/types/questions.json
+2 −1 technical/variables/meta.json
+1 −0 technical/variables/post.md
+36 −0 technical/variables/questions.json
+2 −1 technical/while_loops/meta.json
+37 −0 technical/while_loops/questions.json
9 changes: 6 additions & 3 deletions src/components/layout/UpperNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface Props {
userData: { name: string; pfp_id: number } | null;
isAdmin: boolean;
signOut: () => void;
setActiveSession: (param: boolean) => void;
}

export default function UpperNavBar({
Expand All @@ -34,6 +35,7 @@ export default function UpperNavBar({
userData,
isAdmin,
signOut,
setActiveSession,
}: Props) {
const navigate = useNavigate();

Expand All @@ -51,13 +53,14 @@ export default function UpperNavBar({
endSession();
navigate('/post-session', { state: { sessionId } });
} else if (activeSession && !sessionTimerRunning) {
setActiveSession(false)
navigate('/post-session', { state: { sessionId } });
} else {
navigate('/session');
}
}}
sx={{
backgroundColor: activeSession ? '#d4ff99' : '#d4ff99',
backgroundColor: activeSession && !sessionTimerRunning ? '#ff8b78' : '#d4ff99',
color: '#1a3e00',
borderRadius: '999px',
px: 2,
Expand All @@ -71,8 +74,8 @@ export default function UpperNavBar({
{sessionTimerRunning
? `Ongoing session — ${formatTime(sessionRemainingSeconds)} left`
: activeSession
? 'Complete Session Reflection'
: 'Start Session'}
? 'Complete Session Reflection'
: 'Start Session'}
</Button>

<Link to="/profile">
Expand Down
21 changes: 12 additions & 9 deletions src/hooks/useSessionManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface UseSessionManagementReturn {
startSession: (sessionIdFromState: string, durationMinutes: number, exerciseCount: number) => void;
endSession: () => void;
formatTime: (seconds: number) => string;
setActiveSession: (param: boolean) => void;
}

export default function useSessionManagement(session: Session | null): UseSessionManagementReturn {
Expand Down Expand Up @@ -51,8 +52,10 @@ export default function useSessionManagement(session: Session | null): UseSessio

const formatTime = (seconds: number): string => {
const minutes = Math.floor(seconds / 60);
const remainingSeconds = seconds % 60;
return `${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`;
//Below is the antiquated return statement, kept just in case
//const remainingSeconds = seconds % 60;
//return `${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`;
return `${minutes} min`
};
// Handle session start when coming back from PreSessionForm
useEffect(() => {
Expand Down Expand Up @@ -93,16 +96,15 @@ export default function useSessionManagement(session: Session | null): UseSessio

if (remaining <= 0) {
clearInterval(sessionTimerRef.current!);
setActiveSession(false);
setSessionStartTime(null);
setSessionRemainingSeconds(0);
setSessionTimerRunning(false);
navigate('/post-session', {
state: {
sessionId,
timerExpired: true,
},
});
// navigate('/post-session', {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question why removing this part?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eric wanted us to have a non-intrusive ending to the sessions. Before this change, when a session would end, a user would be redirected to the post-session form even if they were in the middle of working on a problem. Now, users have to go there manually so their workflow isn't interrupted.

// state: {
// sessionId,
// timerExpired: true,
// },
// });
}
}, 1000);

Expand All @@ -123,5 +125,6 @@ export default function useSessionManagement(session: Session | null): UseSessio
startSession,
endSession,
formatTime,
setActiveSession
};
}
2 changes: 1 addition & 1 deletion src/public-problems
Submodule public-problems updated 69 files
+4 −0 fundamentals/calculate-absolute/description.md
+2 −2 fundamentals/calculate-absolute/io.json
+1 −1 fundamentals/calculate-absolute/meta.json
+3 −0 fundamentals/calculate-absolute/starter.py
+7 −0 fundamentals/is-even/description.md
+0 −0 fundamentals/is-even/io.json
+2 −2 fundamentals/is-even/meta.json
+3 −0 fundamentals/is-even/starter.py
+0 −25 level_0/1-function-def/description.md
+0 −6 level_0/1-function-def/io.json
+0 −10 level_0/1-function-def/meta.json
+0 −0 level_0/1-function-def/starter.py
+0 −54 level_0/10-logical-ops/description.md
+0 −38 level_0/10-logical-ops/io.json
+0 −10 level_0/10-logical-ops/meta.json
+0 −0 level_0/10-logical-ops/starter.py
+0 −53 level_0/11-if-elif-else/description.md
+0 −18 level_0/11-if-elif-else/io.json
+0 −10 level_0/11-if-elif-else/meta.json
+0 −0 level_0/11-if-elif-else/starter.py
+0 −43 level_0/2-params-return/description.md
+0 −22 level_0/2-params-return/io.json
+0 −10 level_0/2-params-return/meta.json
+0 −0 level_0/2-params-return/starter.py
+0 −35 level_0/3-types/description.md
+0 −18 level_0/3-types/io.json
+0 −10 level_0/3-types/meta.json
+0 −3 level_0/3-types/starter.py
+0 −29 level_0/4-math-ops-1/description.md
+0 −22 level_0/4-math-ops-1/io.json
+0 −10 level_0/4-math-ops-1/meta.json
+0 −0 level_0/4-math-ops-1/starter.py
+0 −22 level_0/5-math-ops-2/description.md
+0 −26 level_0/5-math-ops-2/io.json
+0 −10 level_0/5-math-ops-2/meta.json
+0 −0 level_0/5-math-ops-2/starter.py
+0 −33 level_0/6-string-concat-1/description.md
+0 −8 level_0/6-string-concat-1/io.json
+0 −10 level_0/6-string-concat-1/meta.json
+0 −0 level_0/6-string-concat-1/starter.py
+0 −20 level_0/7-string-concat-2/description.md
+0 −22 level_0/7-string-concat-2/io.json
+0 −10 level_0/7-string-concat-2/meta.json
+0 −0 level_0/7-string-concat-2/starter.py
+0 −19 level_0/8-f-strings/description.md
+0 −10 level_0/8-f-strings/meta.json
+0 −0 level_0/8-f-strings/starter.py
+0 −28 level_0/9-comparison-ops/description.md
+0 −22 level_0/9-comparison-ops/io.json
+0 −10 level_0/9-comparison-ops/meta.json
+0 −0 level_0/9-comparison-ops/starter.py
+0 −8 level_0/calculate-absolute/description.md
+0 −0 level_0/calculate-absolute/starter.py
+0 −8 level_0/is-even/description.md
+0 −0 level_0/is-even/starter.py
+1 −1 list_2_iterating/same-value/io.json
+7 −0 logic/two-or-three/description.md
+42 −0 logic/two-or-three/io.json
+10 −0 logic/two-or-three/meta.json
+3 −0 logic/two-or-three/starter.py
+4 −0 string_1/greeting/description.md
+0 −0 string_1/greeting/io.json
+10 −0 string_1/greeting/meta.json
+3 −0 string_1/greeting/starter.py
+2 −0 string_1/html-tagged/description.md
+15 −0 string_1/html-tagged/io.json
+8 −0 string_1/html-tagged/meta.json
+3 −0 string_1/html-tagged/starter.py
+6 −9 validate_problems.py
2 changes: 1 addition & 1 deletion src/routes/BlogPostView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default function BlogPostView() {
</Button>
</Box>

<Sheet sx={{ border: 2, borderRadius: 10, p: 2, display: "flex", flexDirection: "column", gap: 1, width: "75%" }}>
<Sheet sx={{ border: 2, borderRadius: 10, p: 2, display: "flex", flexDirection: "column", gap: 1, width: "60%" }}>
<Box sx={{ width: "100%", flexDirection: "column", gap: 1 }}>
<Box>
<Typography level="h2">{currBlog.meta.title}</Typography>
Expand Down
81 changes: 41 additions & 40 deletions src/routes/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ export default function App() {
const navigate = useNavigate();

const { session, userData, isAdmin, isRecoverySession, fetchProfile } = useAuth();

useEffect(() => {
if(isRecoverySession){
if (isRecoverySession) {
navigate('/auth/change-password', { replace: true });
}
}, [navigate, isRecoverySession]);

const { progress, contractProgress, fetchProgress } = useContractData(session);
const {
activeSession, sessionId, sessionDuration,sessionRemainingSeconds,plannedExerciseCount,
sessionTimerRunning, endSession,formatTime, } = useSessionManagement(session);
activeSession, sessionId, sessionDuration, sessionRemainingSeconds, plannedExerciseCount,
sessionTimerRunning, endSession, formatTime, setActiveSession } = useSessionManagement(session);

const [problemSessionStats, setProblemSessionStats] = useState<Record<string, ProblemSessionStats>>({});

Expand Down Expand Up @@ -118,28 +118,28 @@ export default function App() {
.sort((a, b) => a.localeCompare(b));

const specialCategories: string[] = [];
if(problems.some(p => p.meta.question_type[0] === "haystack")) specialCategories.push("haystack");
if(problems.some(p => p.meta.question_type[0] === "mutation")) specialCategories.push("mutation");
if (problems.some(p => p.meta.question_type[0] === "haystack")) specialCategories.push("haystack");
if (problems.some(p => p.meta.question_type[0] === "mutation")) specialCategories.push("mutation");
return ['blogs', ...getCategoryListOrdered(categories), ...specialCategories];
}, [problems]);

// keybinds navigation
// TODO: single source of truth for this?
const handleKeyPress = useCallback((event: KeyboardEvent) => {
// Ctrl + D opens Drawer
if(event.ctrlKey && event.key === "d"){
if (event.ctrlKey && event.key === "d") {
event.preventDefault();
setDrawerOpen(o => !o);
}

if(drawerOpen){
if (drawerOpen) {
// left / right opens category list
// unless the category has tabs, in which case left / right navigates through them
// if on the leftmost tab, left opens the category list
if(event.key === "ArrowLeft"){
if(availableTabs.length > 0){
if (event.key === "ArrowLeft") {
if (availableTabs.length > 0) {
const currTabIndex = availableTabs.indexOf(selectedTab);
if(currTabIndex <= 0){
if (currTabIndex <= 0) {
// on leftmost tab - open category list
setKbSelectedCategory(activeCategory);
setCategoryOpen(true);
Expand All @@ -153,29 +153,29 @@ export default function App() {
setCategoryOpen(true);
}
}
if(event.key === "ArrowRight"){
if(categoryOpen) {
if (event.key === "ArrowRight") {
if (categoryOpen) {
setCategoryOpen(false);
} else if(availableTabs.length > 0) {
} else if (availableTabs.length > 0) {
const currTabIndex = availableTabs.indexOf(selectedTab);
if(currTabIndex < availableTabs.length - 1) {
if (currTabIndex < availableTabs.length - 1) {
setSelectedTab(availableTabs[currTabIndex + 1]);
}
// on rightmost tab — do nothing
}
}

if(categoryOpen){
if (categoryOpen) {
// up / down selects category
if(event.key === "ArrowUp"){
if (event.key === "ArrowUp") {
event.preventDefault();
const currentIndex = allCategories.indexOf(kbSelectedCategory ?? "");
const prevIndex = currentIndex <= 0
const prevIndex = currentIndex <= 0
? allCategories.length - 1
: currentIndex - 1;
setKbSelectedCategory(allCategories[prevIndex]);
}
if(event.key === "ArrowDown"){
if (event.key === "ArrowDown") {
event.preventDefault();
const currentIndex = allCategories.indexOf(kbSelectedCategory ?? "");
const nextIndex = currentIndex >= allCategories.length - 1
Expand All @@ -190,26 +190,26 @@ export default function App() {
if (kbSelectedCategory) handleSelectedCategory(kbSelectedCategory);
}
}
else{
if(activeCategory === 'blogs'){
else {
if (activeCategory === 'blogs') {
// navigating through blog posts
const blogSlugs = searchedBlogs
.filter(b => {
// filters by selectedTab if there are any
return availableTabs.length > 0
return availableTabs.length > 0
&& b.meta.category === selectedTab.toLowerCase();
})
.map(b => b.meta.blog_slug);
// up / down selects blog post
if(event.key === "ArrowUp"){
if (event.key === "ArrowUp") {
event.preventDefault();
const currentIndex = blogSlugs.indexOf(kbSelectedBlog ?? "");
const prevIndex = currentIndex <= 0
? blogSlugs.length - 1
: currentIndex - 1;
setKbSelectedBlog(blogSlugs[prevIndex]);
}
if(event.key === "ArrowDown"){
if (event.key === "ArrowDown") {
event.preventDefault();
const currentIndex = blogSlugs.indexOf(kbSelectedBlog ?? "");
const nextIndex = currentIndex >= blogSlugs.length - 1
Expand All @@ -219,9 +219,9 @@ export default function App() {
}

// select blog post
if(event.key === "Enter"){
if (event.key === "Enter") {
event.preventDefault();
if(kbSelectedBlog){
if (kbSelectedBlog) {
navigate(`/blogs/${kbSelectedBlog}`);
setDrawerOpen(false);
}
Expand All @@ -240,35 +240,35 @@ export default function App() {
})
.filter(p => {
// filters by selectedTab if there are any
if(availableTabs.length > 0){
if (availableTabs.length > 0) {
return categorizeCategories(p) === selectedTab;
}
return p;
})
.map(p => p.meta.name);

// up / down selects problem
if(event.key === "ArrowUp"){
if (event.key === "ArrowUp") {
event.preventDefault();
const currentIndex = categoryProblems.indexOf(kbSelectedProblem ?? "");
const prevIndex = currentIndex <= 0
? categoryProblems.length - 1
const prevIndex = currentIndex <= 0
? categoryProblems.length - 1
: currentIndex - 1;
setKbSelectedProblem(categoryProblems[prevIndex]);
}
if(event.key === "ArrowDown"){
if (event.key === "ArrowDown") {
event.preventDefault();
const currentIndex = categoryProblems.indexOf(kbSelectedProblem ?? "");
const nextIndex = currentIndex >= categoryProblems.length - 1
const nextIndex = currentIndex >= categoryProblems.length - 1
? 0
: currentIndex + 1;
setKbSelectedProblem(categoryProblems[nextIndex]);
}

// select new problem
if(event.key === "Enter"){
if (event.key === "Enter") {
event.preventDefault();
if(kbSelectedProblem){
if (kbSelectedProblem) {
handleSelectedProblem(kbSelectedProblem);
navigate(`/problems/${kbSelectedProblem}`);
}
Expand All @@ -280,26 +280,26 @@ export default function App() {

// on selecting new category or tab, select first problem / blog available
useEffect(() => {
if(activeCategory === 'blogs'){
if (activeCategory === 'blogs') {
const tabBlogs = searchedBlogs
.filter(b => {
return b.meta.category === selectedTab.toLowerCase();
})
.map(b => b.meta.blog_slug);

const first = tabBlogs[0] ?? null;
setKbSelectedBlog(first);
} else {
const tabProblems = sortedProblems
.filter(p => {
const questionType = p.meta.question_type[0];
const cat = questionType === "coding"
? p.meta.category
const cat = questionType === "coding"
? p.meta.category
: questionType;
return cat === activeCategory;
})
.filter(p => {
if(availableTabs.length > 0) return categorizeCategories(p) === selectedTab;
if (availableTabs.length > 0) return categorizeCategories(p) === selectedTab;
return p;
})
.map(p => p.meta.name);
Expand Down Expand Up @@ -352,6 +352,7 @@ export default function App() {
userData={userData}
isAdmin={isAdmin}
signOut={signOut}
setActiveSession={setActiveSession}
/>

<AppHeader />
Expand Down
Loading