Skip to content

Commit

Permalink
Teacher Tool: Run Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
thsparks committed Mar 6, 2024
1 parent 038ac49 commit 2a0ded6
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 66 deletions.
25 changes: 12 additions & 13 deletions teachertool/src/components/CriteriaEvalResultDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ interface CriteriaEvalResultProps {
}

const itemIdToCriteriaResult: pxt.Map<EvaluationStatus> = {
"evaluating": EvaluationStatus.InProgress,
"notevaluated": EvaluationStatus.CompleteWithNoResult,
"fail": EvaluationStatus.Fail,
"pass": EvaluationStatus.Pass,
"pending": EvaluationStatus.Pending
}
evaluating: EvaluationStatus.InProgress,
notevaluated: EvaluationStatus.CompleteWithNoResult,
fail: EvaluationStatus.Fail,
pass: EvaluationStatus.Pass,
pending: EvaluationStatus.Pending,
};

const criteriaResultToItemId: pxt.Map<string> = {
[EvaluationStatus.InProgress]: "evaluating",
[EvaluationStatus.CompleteWithNoResult]: "notevaluated",
[EvaluationStatus.Fail]: "fail",
[EvaluationStatus.Pass]: "pass",
[EvaluationStatus.Pending]: "pending"
}
[EvaluationStatus.Pending]: "pending",
};

const dropdownItems: DropdownItem[] = [
{
Expand All @@ -42,7 +42,6 @@ const dropdownItems: DropdownItem[] = [
id: "fail",
title: lf("needs work"),
label: lf("needs work"),

},
{
id: "pass",
Expand All @@ -54,7 +53,7 @@ const dropdownItems: DropdownItem[] = [
title: lf("not started"),
label: lf("not started"),
},
]
];

export const CriteriaEvalResultDropdown: React.FC<CriteriaEvalResultProps> = ({ result, criteriaId }) => {
const selectedResult = useMemo(() => criteriaResultToItemId[result], [result]);
Expand All @@ -65,7 +64,7 @@ export const CriteriaEvalResultDropdown: React.FC<CriteriaEvalResultProps> = ({
selectedId={selectedResult}
className={classList("rounded", selectedResult)}
items={dropdownItems}
onItemSelected={(id) => setEvalResultOutcome(criteriaId, itemIdToCriteriaResult[id])}
onItemSelected={id => setEvalResultOutcome(criteriaId, itemIdToCriteriaResult[id])}
/>
)
}
);
};
38 changes: 18 additions & 20 deletions teachertool/src/components/CriteriaResultEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const AddNotesButton: React.FC<AddNotesButtonProps> = ({ criteriaId, setShowInpu
/>
</div>
);
}
};

interface CriteriaResultNotesProps {
criteriaId: string;
Expand All @@ -58,8 +58,8 @@ const CriteriaResultNotes: React.FC<CriteriaResultNotesProps> = ({ criteriaId, n
intervalMs={500}
/>
</div>
)
}
);
};

interface CriteriaResultEntryProps {
criteriaId: string;
Expand All @@ -80,23 +80,21 @@ export const CriteriaResultEntry: React.FC<CriteriaResultEntryProps> = ({ criter

return (
<>
{ criteriaTemplateString.current && (
<div className={css["specific-criteria-result"]} key={criteriaId}>
<div className={css["result-details"]}>
<h4 className={css["block-id-label"]}>
{criteriaTemplateString.current}
</h4>
<CriteriaEvalResultDropdown result={teacherTool.evalResults[criteriaId].result} criteriaId={criteriaId} />
</div>
<div className={css["result-notes"]}>
{!showInput && <AddNotesButton criteriaId={criteriaId} setShowInput={setShowInput} />}
{showInput && <CriteriaResultNotes criteriaId={criteriaId} />}
</div>
{criteriaTemplateString.current && (
<div className={css["specific-criteria-result"]} key={criteriaId}>
<div className={css["result-details"]}>
<h4 className={css["block-id-label"]}>{criteriaTemplateString.current}</h4>
<CriteriaEvalResultDropdown
result={teacherTool.evalResults[criteriaId].result}
criteriaId={criteriaId}
/>
</div>
)
}
<div className={css["result-notes"]}>
{!showInput && <AddNotesButton criteriaId={criteriaId} setShowInput={setShowInput} />}
{showInput && <CriteriaResultNotes criteriaId={criteriaId} />}
</div>
</div>
)}
</>


);
}
};
8 changes: 2 additions & 6 deletions teachertool/src/components/EvalResultDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { useContext } from "react";
import css from "./styling/EvalResultDisplay.module.scss";
import { AppStateContext } from "../state/appStateContext";
import { CriteriaResultEntry } from "./CriteriaResultEntry";
import { QRCodeSVG } from "qrcode.react"
import { QRCodeSVG } from "qrcode.react";
import { getProjectLink } from "../utils";


const ResultsHeader: React.FC = () => {
const { state: teacherTool } = useContext(AppStateContext);

Expand All @@ -28,7 +27,6 @@ const ResultsHeader: React.FC = () => {
);
};


export const EvalResultDisplay: React.FC<{}> = () => {
const { state: teacherTool } = useContext(AppStateContext);

Expand All @@ -38,9 +36,7 @@ export const EvalResultDisplay: React.FC<{}> = () => {
<div className={css["eval-results-container"]}>
<ResultsHeader />
{Object.keys(teacherTool.evalResults ?? {}).map(criteriaInstanceId => {
return (
<CriteriaResultEntry criteriaId={criteriaInstanceId} key={criteriaInstanceId} />
)
return <CriteriaResultEntry criteriaId={criteriaInstanceId} key={criteriaInstanceId} />;
})}
</div>
)}
Expand Down
6 changes: 2 additions & 4 deletions teachertool/src/components/PrintButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ export const PrintButton: React.FC<PrintButtonProps> = ({ printRef, onHandlePrin
content: () => printRef.current,
onAfterPrint: onHandlePrint,
});
return (
<Toolbar.Button icon="fas fa-print" title={lf("Print")} onClick={handlePrint} />
)
}
return <Toolbar.Button icon="fas fa-print" title={lf("Print")} onClick={handlePrint} />;
};
6 changes: 3 additions & 3 deletions teachertool/src/state/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ type SetAutorun = ActionBase & {
type SetEvalResultsBatch = ActionBase & {
type: "SET_EVAL_RESULTS_BATCH";
criteriaResults: pxt.Map<CriteriaResult>;
}
};

type ClearAllEvalResultNotes = ActionBase & {
type: "CLEAR_ALL_EVAL_RESULT_NOTES";
}
};

/**
* Union of all actions
Expand Down Expand Up @@ -137,7 +137,7 @@ const setProjectMetadata = (metadata: ProjectData | undefined): SetProjectMetada
const setEvalResult = (criteriaInstanceId: string, result: CriteriaResult): SetEvalResult => ({
type: "SET_EVAL_RESULT",
criteriaInstanceId,
result
result,
});

const clearEvalResult = (criteriaInstanceId: string): ClearEvalResult => ({
Expand Down
2 changes: 1 addition & 1 deletion teachertool/src/state/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function reducer(state: AppState, action: Action): AppState {
case "CLEAR_ALL_EVAL_RESULT_NOTES": {
const evalResults = { ...state.evalResults };
for (const result of Object.keys(evalResults)) {
evalResults[result].notes = ""
evalResults[result].notes = "";
}
return {
...state,
Expand Down
3 changes: 1 addition & 2 deletions teachertool/src/transforms/initNewProjectResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { stateAndDispatch } from "../state";
import { setEvalResultsPending } from "./setEvalResultsPending";
import * as Actions from "../state/actions";


export function initNewProjectResults() {
const { dispatch } = stateAndDispatch();
setEvalResultsPending({ overwriteExistingEntries: true });
dispatch(Actions.clearAllEvalResultNotes());
}
}
2 changes: 1 addition & 1 deletion teachertool/src/transforms/loadProjectMetadataAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function loadProjectMetadataAsync(inputText: string, shareLink: str
const projectData = {
...projMeta,
inputText,
}
};
dispatch(Actions.setProjectMetadata(projectData));
initNewProjectResults();
logDebug(`Loaded project metadata: ${JSON.stringify(projMeta)}`);
Expand Down
2 changes: 1 addition & 1 deletion teachertool/src/transforms/setEvalResultNotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function setEvalResultNotes(criteriaId: string, notes: string) {

const newCriteriaEvalResult = {
...teacherTool.evalResults[criteriaId],
notes
notes,
};
dispatch(Actions.setEvalResult(criteriaId, newCriteriaEvalResult));
}
4 changes: 2 additions & 2 deletions teachertool/src/transforms/setEvalResultOutcome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function setEvalResultOutcome(criteriaId: string, result: EvaluationStatu

const newCriteriaEvalResult = {
...teacherTool.evalResults[criteriaId],
result
result,
};
dispatch(Actions.setEvalResult(criteriaId, newCriteriaEvalResult));
}
}
14 changes: 8 additions & 6 deletions teachertool/src/transforms/setEvalResultsPending.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { EvaluationStatus, CriteriaResult } from "../types/criteria";
import { Rubric } from "../types/rubric";
import * as Actions from "../state/actions";


export function setEvalResultsPending({ overwriteExistingEntries, rubric }: {
overwriteExistingEntries?: boolean,
rubric?: Rubric
export function setEvalResultsPending({
overwriteExistingEntries,
rubric,
}: {
overwriteExistingEntries?: boolean;
rubric?: Rubric;
}): void {
const { state: teachertool, dispatch } = stateAndDispatch();
let allEvalResults: pxt.Map<CriteriaResult> = {};
Expand All @@ -18,7 +20,7 @@ export function setEvalResultsPending({ overwriteExistingEntries, rubric }: {
}
}
if (!overwriteExistingEntries) {
allEvalResults = { ...teachertool.evalResults, ...allEvalResults } ;
allEvalResults = { ...teachertool.evalResults, ...allEvalResults };
}
dispatch(Actions.setEvalResultsBatch(allEvalResults));
}
}
2 changes: 1 addition & 1 deletion teachertool/src/transforms/setRubric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import { setEvalResultsPending } from "./setEvalResultsPending";
export function setRubric(rubric: Rubric) {
const { dispatch } = stateAndDispatch();
dispatch(Actions.setRubric(rubric));
setEvalResultsPending({rubric});
setEvalResultsPending({ rubric });
AutorunService.poke();
}
4 changes: 2 additions & 2 deletions teachertool/src/types/criteria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ export enum EvaluationStatus {
Fail,
CompleteWithNoResult,
InProgress,
Pending
Pending,
}

export interface CriteriaResult {
result: EvaluationStatus;
notes?: string;
}
}
3 changes: 1 addition & 2 deletions teachertool/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ export type CarouselCardSet = {

export type RequestStatus = "init" | "loading" | "error" | "success";


export type ProjectData = pxt.Cloud.JsonScript & {
inputText: string;
}
};
export type ConfirmationModalOptions = {
title: string;
message: string;
Expand Down
3 changes: 1 addition & 2 deletions teachertool/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ export const isRubricResourceCard = (card: any): card is CarouselRubricResourceC
return typeof card === "object" && card.cardType === "rubric-resource";
};


export function getProjectLink(inputText: string): string {
const hasMakeCode = inputText?.indexOf("makecode") !== -1;
return hasMakeCode ? inputText : `https://makecode.com/${inputText}`;
}
}

0 comments on commit 2a0ded6

Please sign in to comment.