diff --git a/src/components/codeEditors/aceEditors/simpleAceEditor.tsx b/src/components/codeEditors/aceEditors/simpleAceEditor.tsx index 191d2eac29d381dbdb3aad70239e0f01d5dc7fb5..5df1595003e0dbd24ea5dad577123c04b0394d43 100644 --- a/src/components/codeEditors/aceEditors/simpleAceEditor.tsx +++ b/src/components/codeEditors/aceEditors/simpleAceEditor.tsx @@ -238,12 +238,17 @@ class SimpleAceEditor extends React.Component<Props, any> { const editorTabs = AceEditorsStorageHelper.getEditor(this.props.id) + //can happen if we cleared all AceEditorsStorageHelper + if (!editorTabs) return + const wrapperTab = editorTabs.find(p => p.tab.id === this.props.editorTab.id) if (!wrapperTab) { Logger.error('could not find editor tab!') return } + if (!this.aceEditorWrapper.editor) return + this.aceEditorWrapper.editor.$blockScrolling = Infinity const newVal = this.aceEditorWrapper.editor.getValue() diff --git a/src/components/sites/tutorViewSite/feedbackPanel/feedbackEditorView.tsx b/src/components/sites/tutorViewSite/feedbackPanel/feedbackEditorView.tsx index 54d725f28f549d2081d47f84454c2144c992ba42..6cd7efb53bae78edd9295cb5a5dcdb055d5ea61d 100644 --- a/src/components/sites/tutorViewSite/feedbackPanel/feedbackEditorView.tsx +++ b/src/components/sites/tutorViewSite/feedbackPanel/feedbackEditorView.tsx @@ -4,7 +4,7 @@ import {bindActionCreators, Dispatch} from "redux"; import {returntypeof} from 'react-redux-typescript'; import {RootState} from '../../../../state/reducers' import SimpleCodeEditorWrapper from '../../../codeEditors/simpleCodeEditorWrapper' -import {tutorFeedbackEditorDebounceInMs} from '../../../../constants' +import {tutorFeedbackEditorDebounceInMs, tutorViewTutorFeedbackForStudentEditor} from '../../../../constants' import {setFeedbackForStudent} from '../../../../state/actions/tutorViewSite/sub/setAssessmentActions' import {EditorTab} from '../../../codeEditors/multiTabCodeEditorProps' import {KnownInternalTestTypes} from '../../../../types/testTypes' @@ -14,6 +14,7 @@ import { aceTestProtocolLanguage, aceTextLanguage } from '../../../../helpers/editorHelper' +import {AceEditorsStorageHelper} from '../../../codeEditors/aceEditors/aceEditorsStorageHelper' export interface MyProps { //readonly test: string @@ -40,13 +41,15 @@ const dispatchProps = returntypeof(mapDispatchToProps); type Props = typeof stateProps & typeof dispatchProps; -const tutorFeedbackEditor = 'tutorFeedbackEditor' - class FeedbackEditorView extends React.Component<Props, any> { render(): JSX.Element { + //when we load (also when we click next/previous) submission we clear all AceEditorsStorageHelper + //when we load the tutor view with the initial submission we init the feedback editor with the initial feedback (empty) + //and we switch to that empty feedback (ace session) + const tempEditorTab: EditorTab = { - id: 0, + id: 0, //this.props.assessment.userId content: (this.props.assessment !== null && this.props.assessment.feedbackForStudent !== null) ? this.props.assessment.feedbackForStudent : '', @@ -58,11 +61,25 @@ class FeedbackEditorView extends React.Component<Props, any> { isContentVisibleForUser: true, } + const editorTabs = AceEditorsStorageHelper.getEditor(tutorViewTutorFeedbackForStudentEditor) + + if (editorTabs && editorTabs.length === 1 && editorTabs[0].tab.id === -1) { + //this was set by the initial tutor view load with the default assessment + //because we mounted the feedback editor and then changed tabs... + AceEditorsStorageHelper.removeEditor(tutorViewTutorFeedbackForStudentEditor) + AceEditorsStorageHelper.addEditor(tutorViewTutorFeedbackForStudentEditor, tempEditorTab) + + } else if (editorTabs === undefined) { //when we load another submission but the feedback editor is visible --> no mount --> no default session + //so create a default session (simple editor will re-use the this session if the associated tab has the same id) + //this allows us to clear all e.g. undo else we would undo and get the previous/next submission feedback + AceEditorsStorageHelper.addEditor(tutorViewTutorFeedbackForStudentEditor, tempEditorTab) + } + return ( <div className="fh" style={{overflow: 'hidden'}}> <SimpleCodeEditorWrapper - id={tutorFeedbackEditor} + id={tutorViewTutorFeedbackForStudentEditor} editorTab={tempEditorTab} onBlur={(content: string, editorTabId: number) => { this.props.setFeedbackForStudent(content) diff --git a/src/constants.ts b/src/constants.ts index 5be2f39cd3e0cfc6761a25bd4a0752e955dc0879..cc214edb813d9d82625ff8257f2921d8c30e2131 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -13,7 +13,7 @@ import Logger from './helpers/logger' * y - breaking changes / new features * z - fixes, small changes */ -export const versionString = '2.5.8' +export const versionString = '2.5.9' export const supportMail = 'yapex@informatik.uni-halle.de' @@ -375,6 +375,7 @@ export const tutorViewEditorPanelViewEditorId = 'tutorViewEditorPanelViewEditorI export const tutorViewUserSolutionEditorPanelViewEditorId = 'tutorViewUserSolutionEditorPanelViewEditorId' export const tutorViewUserAfterSolutionEditorPanelViewEditorId = 'tutorViewUserAfterSolutionEditorPanelViewEditorId' export const tutorViewCodeTemplateEditorPanelViewEditorId = 'tutorViewCodeTemplateEditorPanelViewEditorId' +export const tutorViewTutorFeedbackForStudentEditor = 'tutorViewTutorFeedbackEditor' /** diff --git a/src/state/actions/tutorViewSite/tutorViewSiteActions.ts b/src/state/actions/tutorViewSite/tutorViewSiteActions.ts index f29864ef965db80ab7248615c5d085ab2e7283ef..ca3e2899c7fbed20413c5fef3caf3c16c1e331ca 100644 --- a/src/state/actions/tutorViewSite/tutorViewSiteActions.ts +++ b/src/state/actions/tutorViewSite/tutorViewSiteActions.ts @@ -361,7 +361,7 @@ function _loadTutorViewData(releaseId: number, userId: number, pLangId: number): const plang = pLangs.find(p => p.id === userSolution.pLangId) if (!plang) { - Logger.error('[tutorViewSiteActions] could not find plant for user solution') + Logger.error('[tutorViewSiteActions] could not find plang for user solution') } const tabs = userSolution.solutionFiles.map<AceStoredTabLike>(p => { @@ -382,7 +382,7 @@ function _loadTutorViewData(releaseId: number, userId: number, pLangId: number): const plang = pLangs.find(p => p.id === tutorSolution.pLangId) if (!plang) { - Logger.error('[tutorViewSiteActions] could not find plant for tutor solution') + Logger.error('[tutorViewSiteActions] could not find plang for tutor solution') } const tabs = tutorSolution.solutionFiles.map<AceStoredTabLike>(p => { @@ -407,7 +407,7 @@ function _loadTutorViewData(releaseId: number, userId: number, pLangId: number): const plang = pLangs.find(p => p.id === selectedCodeTemplate.pLangId) if (!plang) { - Logger.error('[tutorViewSiteActions] could not find plant for code template') + Logger.error('[tutorViewSiteActions] could not find plang for code template') } const tabs = selectedCodeTemplate.templateFiles.map<AceStoredTabLike>(p => { @@ -458,7 +458,7 @@ function _loadTutorViewData(releaseId: number, userId: number, pLangId: number): const plang = pLangs.find(p => p.id === userAfterSolution.pLangId) if (!plang) { - Logger.error('[tutorViewSiteActions] could not find plant for user after solution') + Logger.error('[tutorViewSiteActions] could not find plang for user after solution') } const tabs = userAfterSolution.solutionFiles.map<AceStoredTabLike>(p => { diff --git a/src/types/submissions.ts b/src/types/submissions.ts index e3d5c760e9f7c02cadb50a49a310fbd50c2429b1..12653acb03b547f3518d75b5442efda0a545987d 100644 --- a/src/types/submissions.ts +++ b/src/types/submissions.ts @@ -97,7 +97,7 @@ export interface AssessmentFullBase { * IF a user solved the exercise with different p langs then this does not count separate because * all restrictions are stored at the participation (e.g. time) and thus the p lang does not matter! * - * CAN be -1 on error + * CAN be -1 on error or on unset (heavy to compute...) */ readonly participationCount: number