Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 14 additions & 2 deletions src/components/groups/assignments/create-challenge.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const styles = {
const auth = getAuth();

export default function Createchall(props) {

const pages = [
{
name: 'Create Assignment',
Expand All @@ -36,13 +37,15 @@ export default function Createchall(props) {
click: () => {},
},
];

const [contentPreview, setContentPreview] = useState('');
const [penalty, setPenalty] = useState([0, 0, 0]);
const [hints, setHints] = useState([
'No hints set',
'No hints set',
'No hints set',
]);

const [solution, setSolution] = useState('');
const [difficulty, setDifficulty] = useState('Easy');
const [category, setCategory] = useState('forensics');
Expand Down Expand Up @@ -100,13 +103,15 @@ export default function Createchall(props) {
const uploadChallenge = async (fileId) => {
try {
const nConfig = newConfig.replace('\n', ' && ');
let new_solution = props.assignmentInfo.option !== "dynamicLab" ? solution : "";

const challengeInfo = {
name: newChallengeName,
category: [category],
hints,
penalty,
content: contentPreview,
solution,
solution: new_solution,
difficulty,
category,
commands: nConfig,
Expand All @@ -116,7 +121,10 @@ export default function Createchall(props) {
const classCode = window.location.pathname.split('/')[2];
const assignmentInfo = props.assignmentInfo;
const url = `${process.env.NEXT_PUBLIC_API_URL}/classroom-assignments/create-new-assignment/${classCode}`;
const data = await request(url, 'POST', { challengeInfo, assignmentInfo, username: localStorage.getItem('username') });
const data = await request(url, 'POST', {
challengeInfo, assignmentInfo,
username: localStorage.getItem('username')
});
if (data && data.success) {
toast.success('Assignment Created', {
position: 'bottom-right',
Expand Down Expand Up @@ -394,6 +402,8 @@ export default function Createchall(props) {
</div>
</div>

{
props.assignmentInfo && props.assignmentInfo.option !== "dynamicLab" && (
<div className="900 mt-5 rounded-sm bg-neutral-800/40 shadow-lg">
<h3 className="mt-6 rounded-t-lg bg-blue-800 px-4 py-1.5 text-xl font-medium leading-6 text-white">
Challenge Solution
Expand All @@ -408,6 +418,8 @@ export default function Createchall(props) {
></textarea>
</div>
</div>
)
}

<div className="900 mt-5 rounded-sm bg-neutral-800/40 shadow-lg">
<h3 className="mt-6 rounded-t-lg bg-blue-800 px-4 py-1.5 text-xl font-medium leading-6 text-white">
Expand Down
32 changes: 29 additions & 3 deletions src/components/groups/assignments/createAssignment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function CreateGroup(props) {
const [displayExistingChallenge, setDisplayExistingChallenge] =
useState(false);
const [displayCustomChallenge, setDisplayCustomChallenge] = useState(false);
const [displayDynamicLab, setDisplayDynamicLab] = useState(false);

const [errMessage, setErrMessage] = useState([]);

Expand Down Expand Up @@ -120,6 +121,8 @@ export default function CreateGroup(props) {
setDisplayExistingChallenge(true);
} else if (selectedOption === 'customChallenge') {
setDisplayCustomChallenge(true);
} else if(selectedOption === 'dynamicLab') {
setDisplayDynamicLab(true);
} else {
setErrMessage('Please select an assignment type');
}
Expand All @@ -137,6 +140,7 @@ export default function CreateGroup(props) {
assignmentPoints,
selectedCategory,
latePenalty: parseInt(latePenalty),
option: selectedOption
}}
setDisplay={setDisplayExistingChallenge}
/>
Expand All @@ -153,10 +157,28 @@ export default function CreateGroup(props) {
assignmentPoints,
selectedCategory,
latePenalty: parseInt(latePenalty),
option: selectedOption
}}
setDisplay={setDisplayCustomChallenge}
/>
);
} else if(displayDynamicLab) {
return (
<CreateChallenge
assignmentInfo={{
classCode: props.classCode,
title,
description,
time,
dueDate,
assignmentPoints,
selectedCategory,
latePenalty: parseInt(latePenalty),
option: selectedOption
}}
setDisplay={setDisplayDynamicLab}
/>
);
}

return (
Expand Down Expand Up @@ -408,12 +430,16 @@ export default function CreateGroup(props) {
</h1>
</div>
<div
className={`bg-neutral-900 px-2 py-2 text-center`}
// onClick={() => setSelectedOption('dynamicLab')}
className={`cursor-pointer bg-neutral-800 px-2 py-2 text-center ${
selectedOption === 'dynamicLab'
? 'border-2 border-blue-600'
: 'border-2 border-neutral-800 hover:border-neutral-900 hover:bg-neutral-900'
}`}
onClick={() => setSelectedOption('dynamicLab')}
>
<i className="fas fa-robot text-3xl text-green-500"></i>
<h1 className="text-lg font-semibold">
Dynamic Lab (Coming Soon)
Dynamic Lab
</h1>
<h1 className="text-sm">
Create a simulated Cybersecurity environent graded by AI{' '}
Expand Down
Loading