Skip to content

Commit

Permalink
Merge branch 'master' into fix/users-search-by-fullname
Browse files Browse the repository at this point in the history
  • Loading branch information
valerydluski authored Aug 13, 2023
2 parents da7ccda + 4d47dd9 commit eaafc41
Show file tree
Hide file tree
Showing 76 changed files with 3,309 additions and 1,543 deletions.
694 changes: 689 additions & 5 deletions client/src/api/api.ts

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions client/src/components/Sider/data/menuItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import NotificationFilled from '@ant-design/icons/NotificationFilled';
import ProfileFilled from '@ant-design/icons/ProfileFilled';
import TeamOutlined from '@ant-design/icons/TeamOutlined';
import UserOutlined from '@ant-design/icons/UserOutlined';
import FileTextOutlined from '@ant-design/icons/FileTextOutlined';
import { DiscordOutlined } from 'components/Icons/DiscordOutlined';
import { Session } from 'components/withSession';
import {
Expand Down Expand Up @@ -128,6 +129,13 @@ const adminMenuItems: AdminMenuItemsData[] = [
href: '/admin/notifications',
access: session => isAdmin(session),
},
{
name: 'Propmts',
key: 'prompts',
icon: <FileTextOutlined />,
href: '/admin/prompts',
access: session => isAdmin(session),
},
];

export function getAdminMenuItems(session: Session): MenuItemsRenderData[] {
Expand Down
105 changes: 32 additions & 73 deletions client/src/components/Student/AssignStudentModal.tsx
Original file line number Diff line number Diff line change
@@ -1,91 +1,50 @@
import { Button, Modal, Row, Typography, message } from 'antd';
import * as React from 'react';
import { Modal, Typography, message } from 'antd';
import { StudentSearch } from 'components/StudentSearch';
import { useCallback, useState } from 'react';
import { CourseService } from 'services/course';

const { Text } = Typography;

type State = {
isModalOpened: boolean;
studentGithubId: string | null;
};

type Props = {
mentorGithuId: string;
mentorGithuId: string | null;
courseId: number;
open: boolean;
onClose: () => void;
};

class AssignStudentModal extends React.PureComponent<Props, State> {
state: State = {
isModalOpened: false,
studentGithubId: null,
};

openModal = () => {
this.setState({ isModalOpened: true });
};

closeModal = () => {
this.setState({ isModalOpened: false });
};

addStudent = async () => {
const { mentorGithuId } = this.props;
const { studentGithubId } = this.state;
export function AssignStudentModal(props: Props) {
const [studentGithubId, setStudentGithubId] = useState<string | null>(null);

const addStudent = useCallback(async () => {
if (!studentGithubId) {
return;
}

this.reset();

try {
await new CourseService(this.props.courseId).updateStudent(studentGithubId, { mentorGithuId });
message.success('Success');
await new CourseService(props.courseId).updateStudent(studentGithubId, { mentorGithuId: props.mentorGithuId });
props.onClose();
message.success('Student has been added to mentor');
} catch (e) {
message.error(`${e}`);
}
};

reset = () => {
this.setState({ isModalOpened: false, studentGithubId: null });
};

handleStudentSelect = (githubId: string) => {
this.setState({ studentGithubId: githubId ?? null });
};

render() {
const { mentorGithuId, courseId } = this.props;
const { isModalOpened } = this.state;

return (
<>
<Button type="link" shape="circle" onClick={this.openModal}>
Add Student
</Button>
<Modal
title={
<>
Assign Student to <Text underline>{mentorGithuId}</Text>
</>
}
open={isModalOpened}
onOk={this.addStudent}
onCancel={this.reset}
>
<Row>
<StudentSearch
style={{ width: '100%' }}
keyField="githubId"
onChange={this.handleStudentSelect}
courseId={courseId}
/>
</Row>
</Modal>
</>
);
}
}, [props.mentorGithuId, studentGithubId]);

return (
<Modal
title={
<>
<Text>Assign Student to</Text> <Text underline>{props.mentorGithuId}</Text>
</>
}
open={props.open}
onOk={addStudent}
onCancel={props.onClose}
>
<StudentSearch
style={{ width: '100%' }}
keyField="githubId"
onChange={setStudentGithubId}
courseId={props.courseId}
/>
</Modal>
);
}

export default AssignStudentModal;
2 changes: 1 addition & 1 deletion client/src/components/Student/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default as AssignStudentModal } from './AssignStudentModal';
export { AssignStudentModal } from './AssignStudentModal';
export { DashboardDetails } from './DashboardDetails';
115 changes: 63 additions & 52 deletions client/src/modules/AutoTest/components/Question/Question.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Typography, Form, Row, Checkbox, Radio, Col, Space } from 'antd';
import { SelfEducationQuestionSelectedAnswersDto } from 'api';
import css from 'styled-jsx/css';

const { Title } = Typography;

Expand All @@ -13,60 +14,70 @@ function Question({ question: selfEducationQuestion, questionIndex }: Props): JS
const Element = multiple ? Checkbox : Radio;

return (
<Form.Item
label={
<Row>
<Col>
<Title level={5}>{question}</Title>
</Col>
<Col span={24}>
{questionImage && (
<img
src={questionImage}
style={{
width: '100%',
maxWidth: '700px',
marginBottom: '10px',
}}
/>
)}
</Col>
</Row>
}
name={`answer-${questionIndex}`}
valuePropName="checked"
>
<Element.Group value={selectedAnswers as any}>
{answers?.map((answer, answerIndex) => {
const checked = Array.isArray(selectedAnswers)
? selectedAnswers?.includes(answerIndex)
: selectedAnswers === answerIndex;
<div className="question">
<Form.Item
label={
<Row>
<Col>
<Title level={5}>{question}</Title>
</Col>
<Col span={24}>
{questionImage && (
<img
src={questionImage}
style={{
width: '100%',
maxWidth: '700px',
marginBottom: '10px',
}}
/>
)}
</Col>
</Row>
}
name={`answer-${questionIndex}`}
valuePropName="checked"
>
<Element.Group value={selectedAnswers as any}>
<Space direction="vertical" size="small">
{answers?.map((answer, answerIndex) => {
const checked = Array.isArray(selectedAnswers)
? selectedAnswers?.includes(answerIndex)
: selectedAnswers === answerIndex;

return (
<Space.Compact block key={answerIndex} direction="vertical">
<Element value={answerIndex} checked={checked}>
{answersType === 'image' ? (
<>
({answerIndex + 1}){' '}
<img
src={answer}
style={{
width: '100%',
maxWidth: '400px',
marginBottom: '10px',
}}
/>
</>
) : (
answer
)}
</Element>
</Space.Compact>
);
})}
</Element.Group>
</Form.Item>
return (
<Element key={answerIndex} value={answerIndex} checked={checked}>
{answersType === 'image' ? (
<>
({answerIndex + 1}){' '}
<img
src={answer}
style={{
width: '100%',
maxWidth: '400px',
marginBottom: '10px',
}}
/>
</>
) : (
answer
)}
</Element>
);
})}
</Space>
</Element.Group>
</Form.Item>
<style jsx>{styles}</style>
</div>
);
}

const styles = css`
.question :global(.ant-radio) {
align-self: flex-start !important;
margin-top: 3px !important;
}
`;

export default Question;
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useMemo } from 'react';
import { SelfEducationQuestionWithIndex, SelfEducationQuestion } from 'services/course';
import shuffle from 'lodash/shuffle';
import { CourseTaskVerifications } from 'modules/AutoTest/types';
import css from 'styled-jsx/css';

type SelfEducationProps = {
courseTask: CourseTaskVerifications;
Expand All @@ -24,7 +25,7 @@ function SelfEducation({ courseTask }: SelfEducationProps) {
);

return (
<>
<div className="self-education">
<Paragraph>To submit the task answer the questions.</Paragraph>
{randomQuestions?.map(
({ question, answers, multiple, questionImage, answersType, index: questionIndex }, idx) => {
Expand Down Expand Up @@ -58,9 +59,9 @@ function SelfEducation({ courseTask }: SelfEducationProps) {
>
{multiple ? (
<Checkbox.Group>
{answers?.map((answer, answerIndex) => (
<Space.Compact block key={answerIndex} direction="vertical">
<Checkbox value={answerIndex}>
<Space direction="vertical" size="small">
{answers?.map((answer, answerIndex) => (
<Checkbox key={answerIndex} value={answerIndex}>
{answersType === 'image' ? (
<>
({answerIndex + 1}){' '}
Expand All @@ -77,14 +78,14 @@ function SelfEducation({ courseTask }: SelfEducationProps) {
answer
)}
</Checkbox>
</Space.Compact>
))}
))}
</Space>
</Checkbox.Group>
) : (
<Radio.Group>
{answers?.map((answer, index) => (
<Row key={index}>
<Radio value={index}>
<Space direction="vertical" size="small">
{answers?.map((answer, index) => (
<Radio key={index} value={index}>
{answersType === 'image' ? (
<>
({index + 1}){' '}
Expand All @@ -101,16 +102,24 @@ function SelfEducation({ courseTask }: SelfEducationProps) {
answer
)}
</Radio>
</Row>
))}
))}
</Space>
</Radio.Group>
)}
</Form.Item>
);
},
)}
</>
<style jsx>{styles}</style>
</div>
);
}

const styles = css`
.self-education :global(.ant-radio) {
align-self: flex-start !important;
margin-top: 3px !important;
}
`;

export default SelfEducation;
Loading

0 comments on commit eaafc41

Please sign in to comment.