From ca599d3af2b2c3752d73320bd60eca6865bcb9d9 Mon Sep 17 00:00:00 2001 From: Carter Mayeux <159168644+cmayeux05@users.noreply.github.com> Date: Wed, 15 May 2024 16:56:08 -0500 Subject: [PATCH] fix csv replay to increment arduino code --- client/src/views/Replay/Replay.jsx | 21 ++++++++++++++++--- .../1.0.0/full_documentation.json | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/client/src/views/Replay/Replay.jsx b/client/src/views/Replay/Replay.jsx index 7f2b3f5d..64c01fd0 100644 --- a/client/src/views/Replay/Replay.jsx +++ b/client/src/views/Replay/Replay.jsx @@ -12,7 +12,7 @@ import NavBar from '../../components/NavBar/NavBar'; import { Table } from 'antd'; import { getSave } from '../../Utils/requests'; import { CSVDownloader } from 'react-papaparse'; -import { getArduino, getXml } from '../../components/DayPanels/Utils/helpers.js'; +import { getArduino, getArduinoXML } from '../../components/DayPanels/Utils/helpers.js'; const TIME_LINE_SIZE = 25; const timelineReducer = (timeline, action) => { @@ -70,6 +70,7 @@ const timelineReducer = (timeline, action) => { const Replay = () => { const { saveID } = useParams(); const workspaceRef = useRef(null); + const workspaceRefdummy = useRef(null); const [replay, setReplay] = useState([]); const [isPlaying, setIsPlaying] = useState(false); const [playbackRef, setPlaybackRef] = useState(null); @@ -128,18 +129,21 @@ const Replay = () => { value: save.data.replay ? save.data.replay.length : 0, }); //set log - let data = save.data.replay.map((item, index) => { + let data = save.data.replay.map((item, index) => + { return { key: index, blockId: item.blockId, blockType: item.blockType, timestamp: item.timestamp, action: item.action, + xml: item.xml, }; }); setLogData(data); setCsvData(data.slice(0).reverse()); + //console.log('csvlogdata: ', csvData); setCsvFilename( `${save.data.student.name}_${save.data.created_at}_code_replay` ); @@ -151,6 +155,16 @@ const Replay = () => { getReplay(); }, []); + const findMyArduino = (xml) => { + workspaceRefdummy.current = window.Blockly.inject('root', { + toolbox: document.getElementById('toolbox'), + readOnly: true, + }); + const my_arduino = getArduinoXML(xml, workspaceRefdummy.current); + workspaceRefdummy.current.dispose(); + return my_arduino + }; + const columns = [ { title: 'No.', @@ -400,7 +414,8 @@ const Replay = () => { action: log.action, 'block type': log.blockType, 'block id': log.blockId, - 'arduino code': getArduino(workspaceRef.current, false), + 'xml': log.xml, + 'arduino code': findMyArduino(log.xml), }; }); }} diff --git a/server/extensions/documentation/documentation/1.0.0/full_documentation.json b/server/extensions/documentation/documentation/1.0.0/full_documentation.json index 3655495a..1311890e 100755 --- a/server/extensions/documentation/documentation/1.0.0/full_documentation.json +++ b/server/extensions/documentation/documentation/1.0.0/full_documentation.json @@ -14,7 +14,7 @@ "name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html" }, - "x-generation-date": "05/12/2024 9:04:36 PM" + "x-generation-date": "05/15/2024 9:33:55 PM" }, "x-strapi-config": { "path": "/documentation",