Skip to content

Commit

Permalink
breaking: Added value type override for export
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkoelle committed May 22, 2021
1 parent f4e556a commit ebf7367
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 9 deletions.
7 changes: 5 additions & 2 deletions app/exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default class Exporter {
arg.parser,
arg.corrections,
arg.conditionalComments,
arg.valueTypeOverwrite,
sender
)
.then((v) => {
Expand All @@ -53,6 +54,7 @@ export default class Exporter {
parserType: ParserType,
corrections: Correction[],
conditionalComments: ConditionalComment[] = [],
valueTypeOverwrite: string | undefined,
webContents: WebContents
) {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -104,7 +106,7 @@ export default class Exporter {

const content = parser.serialize(
c,
serializeCorrection(c, conditionalComments)
serializeCorrection(c, valueTypeOverwrite, conditionalComments)
);

// Add submission files folder
Expand Down Expand Up @@ -132,14 +134,15 @@ export default class Exporter {
workspace: string,
parser: Parser,
corrections: Correction[],
valueTypeOverwrite: string | undefined,
conditionalComments: ConditionalComment[] = []
) {
const zip = new AdmZip();

corrections.forEach((c) => {
const content = parser.serialize(
c,
serializeCorrection(c, conditionalComments)
serializeCorrection(c, valueTypeOverwrite, conditionalComments)
);

// Add rating file
Expand Down
3 changes: 3 additions & 0 deletions app/modals/ExportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ const ExportModal: FC<ExportModalProps> = ({ ...props }) => {
conditionalComments: settings.conditionalCommentEnabled
? settings.conditionalComments
: [],
valueTypeOverwrite: settings.valueTypeOverrideEnabled
? settings.valueTypeOverride
: undefined,
});
}
}
Expand Down
8 changes: 4 additions & 4 deletions app/modals/SettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import DialogContent from '@material-ui/core/DialogContent';
import { Divider } from '@material-ui/core';
import { ModalProps } from './ModalProvider';
import DialogTitleWithCloseIcon from './DialogTitleWithCloseIcon';
import GeneralSettingsList from '../features/settings/GeneralSettingsList';
import BackupSettingsList from '../features/settings/BackupSettingsList';
import MediaViewerSettingsList from '../features/settings/MediaViewerSettingsList';
import ExportSettingsList from '../features/settings/ExportSettingsList';
import GeneralSettingsList from './settings/GeneralSettingsList';
import BackupSettingsList from './settings/BackupSettingsList';
import MediaViewerSettingsList from './settings/MediaViewerSettingsList';
import ExportSettingsList from './settings/ExportSettingsList';

type SettingsModalProps = ModalProps;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
List,
ListItem,
ListSubheader,
TextField,
Collapse,
} from '@material-ui/core';

import React from 'react';
Expand Down Expand Up @@ -33,6 +35,47 @@ const ExportSettingsList = () => {
<OutputFormatSelect />
</ListItemSecondaryAction>
</ListItem>
<ListItem>
<ListItemText
primary="Value Type Overwrite"
secondary="Enable overwrite for the value type e.g. points"
/>
<ListItemSecondaryAction>
<Switch
edge="end"
onChange={() =>
dispatch(
settingsSetExport({
...settings,
valueTypeOverrideEnabled: !settings.valueTypeOverrideEnabled,
})
)
}
checked={settings.valueTypeOverrideEnabled}
/>
</ListItemSecondaryAction>
</ListItem>
<Collapse in={settings.valueTypeOverrideEnabled}>
<ListItem>
<ListItemText primary="" secondary="" />
<ListItemSecondaryAction>
<TextField
label="Value Type"
variant="outlined"
size="small"
value={settings.valueTypeOverride}
onChange={(event) =>
dispatch(
settingsSetExport({
...settings,
valueTypeOverride: event.target.value,
})
)
}
/>
</ListItemSecondaryAction>
</ListItem>
</Collapse>
<ListItem>
<ListItemText
primary="Conditional Comment"
Expand All @@ -53,13 +96,13 @@ const ExportSettingsList = () => {
/>
</ListItemSecondaryAction>
</ListItem>
{settings.conditionalCommentEnabled && (
<Collapse in={settings.conditionalCommentEnabled}>
<ListItem>
<ConditionalCommentSettings
showLabel={settings.conditionalCommentEnabled}
/>
</ListItem>
)}
</Collapse>
</List>
);
};
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions app/model/SettingsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export interface MediaViewerSettings {

export interface ExportSettings {
outputFormat: ParserType;
valueTypeOverrideEnabled: boolean;
valueTypeOverride: string;
conditionalCommentEnabled: boolean;
conditionalComments: ConditionalComment[];
}
Expand Down Expand Up @@ -46,6 +48,8 @@ const settingsSlice = createSlice({
},
export: {
outputFormat: ParserType.Uni2Work,
valueTypeOverrideEnabled: true,
valueTypeOverride: 'Punkte',
conditionalCommentEnabled: true,
conditionalComments: [
{ text: 'Gut!', minPercentage: 0.5 },
Expand Down
9 changes: 8 additions & 1 deletion app/utils/Formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export function getConditionalCommentForValue(

export function serializeCorrection(
correction: Correction,
valueTypeOverwrite: string | undefined,
conditionalComments: ConditionalComment[] = []
): string {
const ratings: Rating[] = correction.ratings ? correction.ratings : [];
Expand All @@ -151,7 +152,13 @@ export function serializeCorrection(
: [];
const serializedTasks =
tasks && ratings
? serializeTasks(tasks, ratings, correction.submission.sheet.valueType)
? serializeTasks(
tasks,
ratings,
valueTypeOverwrite !== undefined
? valueTypeOverwrite
: correction.submission.sheet.valueType
)
: '';
const serializedAnnotation =
correction.annotation && correction.annotation.text.trim().length > 0
Expand Down

0 comments on commit ebf7367

Please sign in to comment.