Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 15 additions & 4 deletions client/src/modules/AutoTest/components/TaskCard/TaskCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Card, Col, Divider, Row, Tag, Typography } from 'antd';
import { Button, Card, Col, Divider, Row, Tag, Tooltip, Typography } from 'antd';
import Link from 'next/link';
import { getAutoTestTaskRoute } from 'services/routes';
import { TaskCardColumn, TaskDeadlineDate } from '..';
Expand All @@ -11,6 +11,7 @@ const { Title, Paragraph } = Typography;
export interface TaskCardProps {
courseTask: CourseTaskVerifications;
course: Course;
isAvailableTab: boolean;
}

function getStatusTag(state: CourseTaskState) {
Expand All @@ -24,11 +25,14 @@ function getStatusTag(state: CourseTaskState) {
}
}

function TaskCard({ courseTask, course }: TaskCardProps) {
const { id, name, studentStartDate, studentEndDate, verifications, state, descriptionUrl } = courseTask;
function TaskCard({ courseTask, course, isAvailableTab }: TaskCardProps) {
const { id, name, studentStartDate, studentEndDate, verifications, state, descriptionUrl, publicAttributes } =
courseTask;
const { attemptsCount, explanation } = useAttemptsMessage(courseTask);

const score = verifications?.[0]?.score ?? null;
const isMinimumScoreDone = score >= publicAttributes.tresholdPercentage;
console.log(isMinimumScoreDone);
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove this


const columns = [
{
Expand Down Expand Up @@ -77,10 +81,17 @@ function TaskCard({ courseTask, course }: TaskCardProps) {
{explanation}
</Paragraph>
</Col>
<Col span={24}>
<Col span={24} style={{ display: 'flex', justifyContent: 'space-between' }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Will Col + Row work instead?

<Link href={getAutoTestTaskRoute(course.alias, id)} legacyBehavior>
<Button type="primary">Open Task</Button>
</Link>
{!isAvailableTab && (
<Tooltip title="move to the 'Done' tab">
<Button type="primary" onClick={() => console.log('moveToDone')} disabled={!isMinimumScoreDone}>
Done Task
</Button>
</Tooltip>
)}
</Col>
</Row>
<Divider />
Expand Down
3 changes: 2 additions & 1 deletion client/src/modules/AutoTest/pages/AutoTests/AutoTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function AutoTests() {
const [activeTab, setActiveTab] = useState(CourseTaskStatus.Available);
const statuses = useMemo(() => tasks?.map(t => t.status) || [], [tasks]);
const filteredTasks = useMemo(() => tasks?.filter(t => t.status === activeTab) || [], [tasks, activeTab]);
const isAvailableTab = activeTab === CourseTaskStatus.Available ? false : true;
Copy link
Contributor

Choose a reason for hiding this comment

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

this naming is confusing, isAvailableTab = true when active tab != "Available"


return (
<PageLayout loading={false} title="Auto-tests" withMargin={false} showCourseName>
Expand All @@ -32,7 +33,7 @@ function AutoTests() {
<Row gutter={[24, 24]} style={{ padding: '0 16px', marginRight: 0 }}>
{filteredTasks.map(courseTask => (
<Col {...RESPONSIVE_COLUMNS} key={courseTask.id}>
<TaskCard courseTask={courseTask} course={course} />
<TaskCard courseTask={courseTask} course={course} isAvailableTab={isAvailableTab} />
</Col>
))}
</Row>
Expand Down
Loading