diff --git a/website/src/components/RatingRadioGroup.tsx b/website/src/components/RatingRadioGroup.tsx
new file mode 100644
index 00000000..33043883
--- /dev/null
+++ b/website/src/components/RatingRadioGroup.tsx
@@ -0,0 +1,53 @@
+import { chakra, Box, HStack, useRadio, useRadioGroup } from "@chakra-ui/react";
+
+const RatingRadioButton = (props) => {
+ const { option, ...radioProps } = props;
+ const { getInputProps, getCheckboxProps } = useRadio(radioProps);
+
+ const input = getInputProps();
+ const checkbox = getCheckboxProps();
+
+ return (
+
+
+
+ {option}
+
+
+ );
+};
+
+const RatingRadioGroup = (props) => {
+ const { min, max, onChange, ...rest } = props;
+ const { value, getRadioProps, getRootProps } = useRadioGroup({
+ defaultValue: min,
+ onChange: onChange,
+ });
+ const options = Array.from(new Array(1 + max - min), (x, i) => i + min);
+
+ return (
+
+ {options.map((option) => (
+
+ ))}
+
+ );
+};
+
+export default RatingRadioGroup;
diff --git a/website/src/pages/grading/grade-output.tsx b/website/src/pages/grading/grade-output.tsx
index 792212f0..5fabe7ba 100644
--- a/website/src/pages/grading/grade-output.tsx
+++ b/website/src/pages/grading/grade-output.tsx
@@ -1,9 +1,11 @@
+import { HStack, Textarea } from "@chakra-ui/react";
import { QuestionMarkCircleIcon } from "@heroicons/react/20/solid";
import { useSession, signIn, signOut } from "next-auth/react";
import { useEffect, useRef, useState } from "react";
-import useSWRImmutable from "swr/immutable";
import useSWRMutation from "swr/mutation";
+import useSWRImmutable from "swr/immutable";
+import RatingRadioGroup from "src/components/RatingRadioGroup";
import fetcher from "src/lib/fetcher";
import poster from "src/lib/poster";
@@ -11,6 +13,7 @@ const GradeOutput = () => {
// Use an array of tasks that record the sequence of steps until a task is
// deemed complete.
const [tasks, setTasks] = useState([]);
+ const [rating, setRating] = useState(0);
// A quick reference to the input element. This should be factored into the
// component doing the actual task rendering.
@@ -42,7 +45,7 @@ const GradeOutput = () => {
trigger({
id: t.id,
content: {
- rating: 2,
+ rating: rating,
},
});
};
@@ -51,128 +54,98 @@ const GradeOutput = () => {
* TODO: Make this a nicer loading screen.
*/
if (tasks.length == 0) {
- return (
- <>
-
- >
- );
+ return ;
}
return (
- <>
-
- {/* Instrunction and Output panels */}
-
-
- {/* Instruction panel */}
-
-
-
Instruction
-
- {tasks[0].task.full_text}
-
+
+ {/* Instrunction and Output panels */}
+
+
+ {/* Instruction panel */}
+
+
+
Instruction
+
+ {tasks[0].task.full_text}
+
- {/* Output panel */}
-
-
-
Output
-
- {tasks[0].task.summary}
-
-
- {/* Form wrap*/}
-
-
Rating
-
(1 = worst, 7 = best)
+ {/* Output panel */}
+
+
+
Output
+
{tasks[0].task.summary}
+
+ {/* Form wrap*/}
+
+
Rating
+
+ ({tasks[0].task.scale.min} = worst, {tasks[0].task.scale.max} = best)
+
- {/* Rating buttons */}
-
-
-
-
-
-
-
-
-
-
-
- {/* Annotation checkboxes */}
-
-
- {ANNOTATION_FLAGS.map((option, i) => {
- return ;
- })}
-
-
+ {/* Rating buttons */}
-
+
-
-
- {/* Info & controls */}
-
-
-
-
- Prompt
-
-
{tasks[0].id}
+ {/* Annotation checkboxes */}
+
+
+ {ANNOTATION_FLAGS.map((option, i) => {
+ return ;
+ })}
+
-
-
- Output
-
-
{tasks.length === 2 ? tasks[1].id : "Submit your answer"}
+
+
+
+
- {/* Skip / Submit controls */}
-
-
-
+ {/* Info & controls */}
+
+
+
+
+ Prompt
+
+ {tasks[0].id}
-
-
- >
+
+
+ Output
+
+ {tasks.length === 2 ? tasks[1].id : "Submit your answer"}
+
+
+
+ {/* Skip / Submit controls */}
+
+
+
+
+
+
);
};
export default GradeOutput;
-function RatingButton(props: { rating: number; active: boolean }): JSX.Element {
- const activeClasses =
- "inline-flex items-center mx-2 rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2";
- const inactiveClasses =
- "inline-flex items-center mx-2 rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2";
- return (
-
- );
-}
-
function AnnotationCheckboxLi(props: { option: annotationBool }): JSX.Element {
let AdditionalExplanation = null;
if (props.option.additionalExplanation) {