Skip to content

Commit

Permalink
Revert "change problems solved count for instructors"
Browse files Browse the repository at this point in the history
This reverts commit 3dd44dc.
  • Loading branch information
alasdairwilson committed Nov 3, 2023
1 parent 3dd44dc commit 719e33b
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions components/EventItemView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,21 @@ import { Material } from 'lib/material'
import { EventFull, Event, Problem } from 'lib/types'
import { basePath } from 'lib/basePath'
import { EventItem } from '@prisma/client';
import { useSession } from 'next-auth/react'
import { uniq } from 'cypress/types/lodash';

type EventItemProps = {
material: Material,
item: EventItem,
problems?: Problem[],
}

const EventItemView: React.FC<EventItemProps> = ({ material, item, problems }) => {

const { data: session } = useSession()

const EventView: React.FC<EventItemProps> = ({ material, item, problems }) => {
const split = item.section.split('.')
let url = ''
let name = `Error: ${item.section}`
let key = item.id
let indent = 0


let itemProblems: string[] = []
if (split.length === 3) {
const [theme, course, section] = split;
Expand All @@ -49,25 +44,10 @@ const EventItemView: React.FC<EventItemProps> = ({ material, item, problems }) =
}
let isCompleted = false;
let completedLabel = '';

const uniqueUsers = new Set();
let uniqueUsersCount = 0;
if (problems !== undefined && itemProblems.length > 0) {
problems.forEach((problem) => {
uniqueUsers.add(problem.userEmail);
});
uniqueUsersCount = uniqueUsers.size;
const completedProblems = problems.filter((p) => p.section === item.section && itemProblems.includes(p.tag) && p.complete);
if (uniqueUsersCount > 1) {
// if you are an instructor then you get a total count of problems completed / total problems available to all students
completedLabel = `[${completedProblems.length}/${itemProblems.length * uniqueUsersCount}]`
isCompleted = completedProblems.length === (itemProblems.length * uniqueUsersCount);
}
else {
// if you are a student then you get a count of problems completed / total problems available to just you
completedLabel = `[${completedProblems.length}/${itemProblems.length}]`
isCompleted = completedProblems.length === itemProblems.length;
}
completedLabel = `[${completedProblems.length}/${itemProblems.length}]`;
isCompleted = completedProblems.length === itemProblems.length;
}


Expand All @@ -78,4 +58,4 @@ const EventItemView: React.FC<EventItemProps> = ({ material, item, problems }) =
)
}

export default EventItemView
export default EventView

0 comments on commit 719e33b

Please sign in to comment.