Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,52 @@ export default function QuestionTab({
</p>
</div>

{/* Difficulty */}
<div className="flex flex-col gap-2">
<Label
htmlFor="difficulty"
className="text-md font-semibold text-foreground"
>
Difficulty
</Label>
<Input
id="difficulty"
className="w-1/4"
value={question?.difficulty ?? "0.0000"}
disabled
readOnly
/>
<p className="text-xs text-muted-foreground">
The difficulty of the question as given on question upload.
</p>
</div>
{/* Correct Answer Rate / Difficulty */}
{(() => {
if (question && question.selection_frequency > 0) {
return (
<div className="flex flex-col gap-2">
<Label
htmlFor="selection-frequency"
className="text-md font-semibold text-foreground"
>
Correct Answer Rate
</Label>
<Input
id="selection-frequency"
className="w-1/4"
value={question.selection_frequency}
disabled
readOnly
/>
<p className="text-xs text-muted-foreground">
The percentage of students who answered this question correctly.
</p>
Comment thread
DaiIshida4869 marked this conversation as resolved.
</div>
);
} else {
return (
<div className="flex flex-col gap-2">
<Label
htmlFor="difficulty"
className="text-md font-semibold text-foreground"
>
Difficulty
</Label>
<Input
id="difficulty"
className="w-1/4"
value={question?.difficulty ?? "0.0000"}
disabled
readOnly
/>
<p className="text-xs text-muted-foreground">
The difficulty of the question as given on question upload.
</p>
</div>
);
}
})()}

{/* Unit */}
<div className="flex flex-col gap-2">
Expand Down
10 changes: 5 additions & 5 deletions src/components/macfast/questions-filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export function QuestionsFilter({
}: QuestionsFilterProps) {
const [open, setOpen] = useState(false);
const [sliderValue, setSliderValue] = useState([
filters.min_difficulty ?? 0,
filters.max_difficulty ?? 1,
filters.min_selection_frequency ?? 0,
filters.max_selection_frequency ?? 1,
]);

const debouncedFilterChange = useMemo(
Expand All @@ -44,8 +44,8 @@ export function QuestionsFilter({
const maxVal = value[1] < 1 ? value[1] : undefined;
onFilterChange({
...filters,
min_difficulty: minVal,
max_difficulty: maxVal,
min_selection_frequency: minVal,
max_selection_frequency: maxVal,
});
}, 300),
[filters, onFilterChange],
Expand Down Expand Up @@ -118,7 +118,7 @@ export function QuestionsFilter({
<div className="space-y-3">
<div className="flex justify-between items-center">
<Label className="text-xs font-semibold text-muted-foreground uppercase tracking-wider">
Difficulty
Correct Answer Rate
</Label>
<span className="text-sm text-muted-foreground">
{sliderValue[0].toFixed(2)} - {sliderValue[1].toFixed(2)}
Expand Down
31 changes: 21 additions & 10 deletions src/components/macfast/questions-item/questions-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,27 @@ function QuestionItem({
</Badge>
)}

<Badge
variant="secondary"
className="text-muted-foreground whitespace-nowrap"
>
<Star
fill="currentColor"
className="inline-block mr-1 h-3 w-3 text-primary-hover"
/>
Difficulty {question.difficulty}
</Badge>
{(() => {
let badgeText: string;
if (question.selection_frequency > 0) {
badgeText = `Correct Answer Rate ${question.selection_frequency}`;
} else {
badgeText = `Difficulty ${question.difficulty}`;
}
Comment thread
DaiIshida4869 marked this conversation as resolved.

return (
<Badge
variant="secondary"
className="text-muted-foreground whitespace-nowrap"
>
<Star
fill="currentColor"
className="inline-block mr-1 h-3 w-3 text-primary-hover"
/>
{badgeText}
</Badge>
);
})()}

{question.is_flagged && (
<Badge variant="destructive">
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/useCourseQuestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ export function useCourseQuestions({
queryParams.append("is_flagged", filters.is_flagged.toString());
}

if (filters.min_difficulty !== undefined) {
queryParams.append("difficulty__gte", filters.min_difficulty.toString());
if (filters.min_selection_frequency !== undefined) {
queryParams.append("selection_frequency__gte", filters.min_selection_frequency.toString());
}

if (filters.max_difficulty !== undefined) {
queryParams.append("difficulty__lte", filters.max_difficulty.toString());
if (filters.max_selection_frequency !== undefined) {
queryParams.append("selection_frequency__lte", filters.max_selection_frequency.toString());
}

if (filters.subtopic_name) {
Expand Down
1 change: 1 addition & 0 deletions src/types/Question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ interface Question {
serial_number: string;
content: string;
difficulty: number;
selection_frequency: number;
Comment thread
DaiIshida4869 marked this conversation as resolved.
is_flagged: boolean;
is_active: boolean;
is_verified: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/types/QuestionFilters.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interface QuestionFilters {
is_verified?: boolean | null;
is_flagged?: boolean | null;
min_difficulty?: number;
max_difficulty?: number;
min_selection_frequency?: number;
max_selection_frequency?: number;
subtopic_name?: string | null;
}
Loading