Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/answers visualization #14

Merged
merged 15 commits into from
Sep 21, 2021
Merged

Conversation

cicerotcv
Copy link
Contributor

Updates:

  • new page to display exercise's answers;
  • src/helpers to store useful functions;
  • new routes in /src/services/routes;

Comment on lines +28 to +29
summary?: ISummary;
long_answer?: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

what's the difference between summary and long_answer when it's not a multiple choices question?

Copy link
Contributor

Choose a reason for hiding this comment

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

In code questions, for example, long_answer includes the students code while summary has the number of passing tests and some other things about the result (don't really remember hehe).

I don't know where is the best place to discuss this, but I'm thinking that maybe it would be better to have input and result attributes instead of summary and long_answer. What do you think @igordsm?

<Link
to={routes.INSTRUCTOR_HOME}
className="bg-gray-100 text-blue-500 px-4 py-2">
<b>{t("Go back")}</b>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need a back button?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Igor gave me a layout suggestion, so I think this button will probably be gone in the next PR

import { memo, useMemo } from "react";
import { Bar, Doughnut } from "react-chartjs-2";

interface IAnswersChartProps {
Copy link
Contributor

Choose a reason for hiding this comment

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

Great! This should be a naming convention. I've created issue #16 to fix the previous code.

)}

{!!textAnswers.length && (
<Container>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can extract a component here. What do you think @cicerotcv?

}

// docs for customisation: https://github.com/reactchartjs/react-chartjs-2
function UnmemoizedAnswersChart({
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a nice component. Could you write a story for this component? Also, some tests would be nice is there anything that is testable here? You can check the Button component for some examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it be more appropriate to move it to /components?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I guess it makes sense. Also, what do you think about renaming this component? I don't see anything that is specific to "answers". Since you are moving it to /components, what about picking a more generic name?


return (
<div className="flex flex-cols align-center justify-center">
<div style={{ maxHeight: 300 }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

This and the style in the div below should be based on the theme in some way. If none of tailwinds defaults work in this case you can define some extensions on tailwind.config.js.

useEffect(() => {
if (loading) return;
setNumUniqueUsers(summaryList.length);
setNumSubmissions(
summaryList
.map((answerSummary) => answerSummary.answer_count)
.reduce((a, b) => a + b, 0),
.reduce((a, b) => a + b, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if you erased this manually or if it was some formatter, but this is the reason we keep the trailing commas.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was done by vscode formatter, but I've just set it to allow trailing commas

);
}

export const AnswersChart = memo(UnmemoizedAnswersChart);
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't know this. Thanks! Created issue #18

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good practice for Pure Components specially if they are costly to render

Copy link
Contributor

Choose a reason for hiding this comment

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

That's great, thanks for the reference! I've updated #18 with your reference

@@ -10,6 +10,7 @@
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"downlevelIteration": true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

Copy link
Contributor

@toshikurauchi toshikurauchi left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@toshikurauchi toshikurauchi merged commit 93582aa into main Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants