Skip to content
Open
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
4 changes: 3 additions & 1 deletion client/src/Utils/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,8 @@ export const updateActivityDetails = async (
link,
scienceComponents,
makingComponents,
computationComponents
computationComponents,
autoGrading
) =>
makeRequest({
method: PUT,
Expand All @@ -491,6 +492,7 @@ export const updateActivityDetails = async (
scienceComponents,
makingComponents,
computationComponents,
autoGrading
},
auth: true,
error: 'Failed to update unit',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';

const ArduinoVerify = ({ setHoverVerify, handleVerify }) => {
return (
<div>
<svg
version='1.0'
xmlns='http://www.w3.org/2000/svg'
width='50px'
height='20px'
align='left'
viewBox='450 280 300 300'
preserveAspectRatio='xMidYMid'
onMouseEnter={() => setHoverVerify(true)}
onMouseLeave={() => setHoverVerify(false)}
className='hvr-infos'
onClick={handleVerify}
>
<metadata>
Created by potrace 1.10, written by Peter Selinger 2001-2011
</metadata>
<g
transform='matrix(0.1, 0, 0, -0.1, 0, 1200)'
fill='#000000'
stroke='none'
>
<path d='M5087 8435 c-402 -76 -715 -349 -821 -716 -82 -283 -38 -600 116 -834 119 -182 308 -325 527 -400 238 -81 536 -75 782 15 231 84 467 265 619 473 30 42 57 76 61 76 3 1 23 -25 46 -56 372 -525 992 -713 1508 -459 205 101 359 253 455 451 79 161 95 237 95 445 0 202 -16 278 -90 435 -229 488 -821 709 -1345 503 -103 -40 -208 -100 -299 -169 -94 -71 -253 -234 -319 -329 l-49 -70 -36 53 c-187 283 -473 491 -780 568 -110 28 -358 35 -470 14z m373 -371 c90 -23 240 -94 320 -154 129 -95 265 -256 349 -410 l39 -73 -29 -50 c-187 -316 -439 -514 -728 -573 -112 -22 -278 -15 -371 16 -269 90 -429 316 -430 607 -1 345 216 594 570 657 47 9 215 -3 280 -20z m2160 0 c36 -8 103 -33 150 -56 68 -32 102 -57 167 -123 129 -128 183 -262 183 -450 0 -118 -18 -202 -61 -288 -211 -421 -804 -477 -1197 -112 -79 73 -174 199 -231 307 l-44 84 41 82 c142 285 378 490 636 553 91 23 268 24 356 3z' />
<path d='M5004 7527 c-3 -8 -4 -54 -2 -103 l3 -89 318 -3 317 -2 0 105 0 105 -315 0 c-253 0 -317 -3 -321 -13z' />
<path d='M7310 7655 l0 -105 -110 0 -110 0 0 -110 0 -110 110 0 110 0 0 -100 0 -100 105 0 105 0 0 100 0 100 105 0 105 0 0 110 0 110 -105 0 -105 0 0 105 0 105 -105 0 -105 0 0 -105z' />
</g>
</svg>
</div>
);
};

export default ArduinoVerify;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useRef, useState, useReducer } from 'react';
import '../../ActivityLevels.less';
import { compileArduinoCode, handleSave } from '../../Utils/helpers';
import { compileArduinoCode, getArduino, handleSave } from '../../Utils/helpers';
import { message, Spin, Row, Col, Alert, Dropdown, Menu } from 'antd';
import { getSaves } from '../../../../Utils/requests';
import CodeModal from '../modals/CodeModal';
Expand All @@ -14,6 +14,7 @@ import {
handleOpenConnection,
} from '../../Utils/consoleHelpers';
import ArduinoLogo from '../Icons/ArduinoLogo';
import ArduinoVerify from '../Icons/ArduinoVerify';
import PlotterLogo from '../Icons/PlotterLogo';
import { useNavigate } from 'react-router-dom';

Expand All @@ -23,6 +24,7 @@ export default function StudentCanvas({ activity }) {
const [hoverSave, setHoverSave] = useState(false);
const [hoverUndo, setHoverUndo] = useState(false);
const [hoverRedo, setHoverRedo] = useState(false);
const [hoverVerify, setHoverVerify] = useState(false);
const [hoverCompile, setHoverCompile] = useState(false);
const [hoverImage, setHoverImage] = useState(false);
const [hoverConsole, setHoverConsole] = useState(false);
Expand Down Expand Up @@ -298,6 +300,47 @@ export default function StudentCanvas({ activity }) {
setShowPlotter(false);
}
};
const handleVerify = async () => {
if (showConsole || showPlotter) {
message.warning(
'Close Serial Monitor and Serial Plotter before uploading your code'
);
} else {
//if (typeof window['port'] === 'undefined') {
// await connectToPort();
//}
//if (typeof window['port'] === 'undefined') {
// message.error('Fail to select serial device');
// return;
//}
// call Virtual Compiler
const arduinoCode = getArduino(workspaceRef.current, false);
console.log('Start');
console.log(arduinoCode);
console.log('End');

//const runCode = async() => {
// Compile the Arduino source code
// Take the source code, and translate into machine code
const result = await fetch('https://hexi.wokwi.com/build', {
method: 'post',
body: JSON.stringify({sketch: arduinoCode}),// This is the code we want to translate as a JSON object
headers: {
'Content-Type': 'application/json',
},
});
const {hex, stderr} = await result.json();
if(!hex) { // If no hex is returned, then there was a compile error
alert(stderr);
return;
}
else {
console.log('Compile Successful!');
}

//}
}
};
const handleCompile = async () => {
if (showConsole || showPlotter) {
message.warning(
Expand Down Expand Up @@ -463,6 +506,15 @@ export default function StudentCanvas({ activity }) {
id='action-btn-container'
className='flex space-around'
>
<ArduinoVerify
setHoverVerify={setHoverVerify}
handleVerify={handleVerify}
/>
{hoverVerify && (
<div className='popup ModalCompile'>
Verify code
</div>
)}
<ArduinoLogo
setHoverCompile={setHoverCompile}
handleCompile={handleCompile}
Expand Down
43 changes: 41 additions & 2 deletions client/src/views/Mentor/Classroom/Home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ import MentorSubHeader from '../../../../components/MentorSubHeader/MentorSubHea
import DisplayCodeModal from './DisplayCodeModal';
import MentorActivityDetailModal from './MentorActivityDetailModal';
import LessonModuleModal from './LessonModuleSelect/LessonModuleModal';
import { message, Tag } from 'antd';
import { message, Tag, Radio } from 'antd';
import { useNavigate } from 'react-router-dom';
import setStandard from './SetStandard';
import SetStandard from './SetStandard';

export default function Home({ classroomId, viewing }) {
const [classroom, setClassroom] = useState({});
const [activities, setActivities] = useState([]);
const [gradeId, setGradeId] = useState(null);
const [activeLessonModule, setActiveLessonModule] = useState(null);
const [activityDetailsVisible, setActivityDetailsVisible] = useState(false)
const [autoGradingValues, setAutoGradingValues] = useState({});
const navigate = useNavigate();

const SCIENCE = 1;
Expand All @@ -41,6 +44,14 @@ export default function Home({ classroomId, viewing }) {
message.error(lsRes.err);
}
const activityRes = await getLessonModuleActivities(lsRes.data.id);
activityRes.data.map((activity) => {
setAutoGradingValues((prevAutoGradingValues) => ({
...prevAutoGradingValues,
[activity.id]: activity.autoGrading,
}));
console.log(autoGradingValues[activity.id])
return null; // Make sure to include a return statement in the map function
});
if (activityRes) setActivities(activityRes.data);
else {
message.error(activityRes.err);
Expand All @@ -54,6 +65,10 @@ export default function Home({ classroomId, viewing }) {
fetchData();
}, [classroomId]);

useEffect(()=>{
console.log()
})

const handleViewActivity = (activity, name) => {
activity.lesson_module_name = name;
localStorage.setItem('sandbox-activity', JSON.stringify(activity));
Expand Down Expand Up @@ -153,14 +168,24 @@ export default function Home({ classroomId, viewing }) {
Demo Template
</button>
)}
{autoGradingValues[activity.id] ? <SetStandard
learningStandard={activeLessonModule}
selectActivity={activity}
activityDetailsVisible={false}
setActivityDetailsVisible={false}
setActivities={setActivities}
viewing={false}
autoGrading={autoGradingValues[activity.id] || true}
/> :
<MentorActivityDetailModal
learningStandard={activeLessonModule}
selectActivity={activity}
activityDetailsVisible={false}
setActivityDetailsVisible={false}
setActivities={setActivities}
viewing={false}
/>
autoGrading={autoGradingValues[activity.id] || false}
/>}
</div>
<div id='view-activity-info'>
<p>
Expand Down Expand Up @@ -226,6 +251,20 @@ export default function Home({ classroomId, viewing }) {
);
})}
</p>
<p>
<Radio.Group
onChange={(e) => {
const newAutoGradingValues = { ...autoGradingValues };
newAutoGradingValues[activity.id] = e.target.value;
setAutoGradingValues(newAutoGradingValues);

}}
value={autoGradingValues[activity.id]}
>
<Radio value={false}>The activity will be manually graded.</Radio>
<Radio value={true}>The activity will be autograded.</Radio>
</Radio.Group>
</p>
{activity.link ? (
<p>
<strong>Link to Additional Information: </strong>
Expand Down
Loading