@@ -96,6 +96,7 @@ const AssessmentWorkspace: React.FC<AssessmentWorkspaceProps> = props => {
9696 const [ sessionId , setSessionId ] = useState ( '' ) ;
9797 const [ isSubmitted , setIsSubmitted ] = useState ( false ) ;
9898 const { isMobileBreakpoint } = useResponsive ( ) ;
99+ const isVscode = useTypedSelector ( state => state . vscode . isVscode ) ;
99100
100101 const assessment = useTypedSelector ( state => state . session . assessments [ props . assessmentId ] ) ;
101102 const assessmentOverviews = useTypedSelector ( state => state . session . assessmentOverviews ) ;
@@ -244,10 +245,10 @@ const AssessmentWorkspace: React.FC<AssessmentWorkspaceProps> = props => {
244245 useEffect ( ( ) => {
245246 if ( ! selectedTab ) return ;
246247
247- if ( ! isMobileBreakpoint && mobileOnlyTabIds . includes ( selectedTab ) ) {
248+ if ( ( ! isMobileBreakpoint || isVscode ) && mobileOnlyTabIds . includes ( selectedTab ) ) {
248249 setSelectedTab ( SideContentType . questionOverview ) ;
249250 }
250- } , [ isMobileBreakpoint , props , selectedTab , setSelectedTab ] ) ;
251+ } , [ isMobileBreakpoint , isVscode , props , selectedTab , setSelectedTab ] ) ;
251252
252253 /* ==================
253254 onChange handlers
@@ -391,7 +392,40 @@ const AssessmentWorkspace: React.FC<AssessmentWorkspaceProps> = props => {
391392 ) ;
392393 handleClearContext ( question . library , true ) ;
393394 handleUpdateHasUnsavedChanges ( false ) ;
394- sendToWebview ( Messages . NewEditor ( `assessment${ assessment . id } ` , props . questionId , '' ) ) ;
395+
396+ const chapter = question . library . chapter ;
397+ const questionType = question . type ;
398+
399+ switch ( questionType ) {
400+ case QuestionTypes . mcq :
401+ const mcqQuestionData = question ;
402+ sendToWebview (
403+ Messages . McqQuestion (
404+ workspaceLocation ,
405+ `assessment${ assessment . id } ` ,
406+ mcqQuestionData . id ,
407+ chapter ,
408+ mcqQuestionData . choices . map ( choice => choice . content )
409+ )
410+ ) ;
411+ break ;
412+ case QuestionTypes . programming || QuestionTypes . voting :
413+ const prepend = question . prepend ;
414+ const code = question . answer ?? question . solutionTemplate ;
415+ const breakpoints = editorTabs [ 0 ] ?. breakpoints ?? [ ] ;
416+ sendToWebview (
417+ Messages . NewEditor (
418+ workspaceLocation ,
419+ `assessment${ assessment . id } ` ,
420+ props . questionId ,
421+ chapter ,
422+ prepend ,
423+ code ,
424+ breakpoints
425+ )
426+ ) ;
427+ break ;
428+ }
395429 if ( options . editorValue ) {
396430 // TODO: Hardcoded to make use of the first editor tab. Refactoring is needed for this workspace to enable Folder mode.
397431 handleEditorValueChange ( 0 , options . editorValue ) ;
@@ -416,6 +450,20 @@ const AssessmentWorkspace: React.FC<AssessmentWorkspaceProps> = props => {
416450 const handleContestEntryClick = ( _submissionId : number , answer : string ) => {
417451 // TODO: Hardcoded to make use of the first editor tab. Refactoring is needed for this workspace to enable Folder mode.
418452 handleEditorValueChange ( 0 , answer ) ;
453+ // Hacky way to view the editor, might cause issues
454+ const breakpoints = editorTabs [ 0 ] ?. breakpoints ?? [ ] ;
455+ sendToWebview (
456+ Messages . NewEditor (
457+ workspaceLocation ,
458+ `submission${ _submissionId } ` ,
459+ questionId ,
460+ question . library . chapter ,
461+ '' ,
462+ answer ,
463+ breakpoints
464+ )
465+ ) ;
466+ //
419467 } ;
420468
421469 const tabs : SideContentTab [ ] = [
@@ -736,9 +784,10 @@ const AssessmentWorkspace: React.FC<AssessmentWorkspaceProps> = props => {
736784 ) ;
737785
738786 return {
739- editorButtons : ! isMobileBreakpoint
740- ? [ runButton , saveButton , resetButton , chapterSelect ]
741- : [ saveButton , resetButton ] ,
787+ editorButtons :
788+ ! isMobileBreakpoint || isVscode
789+ ? [ runButton , saveButton , resetButton , chapterSelect ]
790+ : [ saveButton , resetButton ] ,
742791 flowButtons : [ previousButton , questionView , nextButton ]
743792 } ;
744793 } ;
@@ -885,6 +934,14 @@ It is safe to close this window.`}
885934 ( assessment ! . questions [ questionId ] as IProgrammingQuestion ) . solutionTemplate
886935 ) ;
887936 handleUpdateHasUnsavedChanges ( true ) ;
937+ if ( isVscode ) {
938+ sendToWebview (
939+ Messages . ResetEditor (
940+ workspaceLocation ,
941+ ( assessment ! . questions [ questionId ] as IProgrammingQuestion ) . solutionTemplate
942+ )
943+ ) ;
944+ }
888945 } }
889946 options = { { minimal : false , intent : Intent . DANGER } }
890947 />
@@ -968,7 +1025,7 @@ It is safe to close this window.`}
9681025 { submissionOverlay }
9691026 { overlay }
9701027 { resetTemplateOverlay }
971- { ! isMobileBreakpoint ? (
1028+ { isVscode || ! isMobileBreakpoint ? (
9721029 < Workspace { ...workspaceProps } />
9731030 ) : (
9741031 < MobileWorkspace { ...mobileWorkspaceProps } />
0 commit comments