Skip to content

Commit c748409

Browse files
committed
Adding canViewMeasuredValues flag in assignment edit form so the teacher can choose whether students see absolute memory and time values in the test results.
1 parent ac97779 commit c748409

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

src/components/forms/EditAssignmentForm/EditAssignmentForm.js

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export const prepareInitialValues = lruMemoize(
5858
solutionFilesLimit = null,
5959
solutionSizeLimit = null,
6060
canViewLimitRatios = true,
61+
canViewMeasuredValues = false,
6162
canViewJudgeStdout = false,
6263
canViewJudgeStderr = false,
6364
isBonus = false,
@@ -84,6 +85,7 @@ export const prepareInitialValues = lruMemoize(
8485
solutionFilesLimit,
8586
solutionSizeLimit: solutionSizeLimit && Math.ceil(solutionSizeLimit / 1024), // B -> KiB
8687
canViewLimitRatios,
88+
canViewMeasuredValues,
8789
canViewJudgeStdout,
8890
canViewJudgeStderr,
8991
isBonus,
@@ -118,6 +120,7 @@ export const transformSubmittedData = ({
118120
solutionFilesLimit,
119121
solutionSizeLimit,
120122
canViewLimitRatios,
123+
canViewMeasuredValues,
121124
canViewJudgeStdout,
122125
canViewJudgeStderr,
123126
isBonus,
@@ -143,6 +146,7 @@ export const transformSubmittedData = ({
143146
solutionFilesLimit,
144147
solutionSizeLimit: solutionSizeLimit ? solutionSizeLimit * 1024 : null, // if not null, convert KiB -> B
145148
canViewLimitRatios,
149+
canViewMeasuredValues: canViewLimitRatios && canViewMeasuredValues,
146150
canViewJudgeStdout,
147151
canViewJudgeStderr,
148152
isBonus,
@@ -325,6 +329,7 @@ class EditAssignmentForm extends Component {
325329
deadlines,
326330
runtimeEnvironments,
327331
visibility,
332+
canViewLimitRatios,
328333
showSendNotification,
329334
submitButtonMessages = SUBMIT_BUTTON_MESSAGES_DEFAULT,
330335
mergeJudgeLogs,
@@ -626,7 +631,7 @@ class EditAssignmentForm extends Component {
626631

627632
<Container fluid>
628633
<Row>
629-
<Col md={mergeJudgeLogs ? 6 : 12} lg={mergeJudgeLogs ? 6 : 4}>
634+
<Col md={6} xl={mergeJudgeLogs ? 4 : 6}>
630635
<Field
631636
name="canViewLimitRatios"
632637
component={CheckboxField}
@@ -647,7 +652,29 @@ class EditAssignmentForm extends Component {
647652
}
648653
/>
649654
</Col>
650-
<Col md={6} lg={mergeJudgeLogs ? 6 : 4}>
655+
<Col md={6} xl={mergeJudgeLogs ? 4 : 6}>
656+
<Field
657+
name="canViewMeasuredValues"
658+
component={CheckboxField}
659+
onOff
660+
disabled={!canViewLimitRatios}
661+
label={
662+
<span>
663+
<FormattedMessage
664+
id="app.editAssignmentForm.canViewMeasuredValues"
665+
defaultMessage="Show absolute measurements"
666+
/>
667+
<Explanation id="canViewMeasuredValuesExplanation">
668+
<FormattedMessage
669+
id="app.editAssignmentForm.canViewMeasuredValuesExplanation"
670+
defaultMessage="Whether the students can see the measured execution time and consumed memory in absolute units (not just as a relative ratio of the test limits)."
671+
/>
672+
</Explanation>
673+
</span>
674+
}
675+
/>
676+
</Col>
677+
<Col md={6} xl={mergeJudgeLogs ? 4 : 6}>
651678
<Field
652679
name="canViewJudgeStdout"
653680
component={CheckboxField}
@@ -685,7 +712,7 @@ class EditAssignmentForm extends Component {
685712
</Col>
686713

687714
{!mergeJudgeLogs && (
688-
<Col md={6} lg={4}>
715+
<Col md={6}>
689716
<Field
690717
name="canViewJudgeStderr"
691718
component={CheckboxField}
@@ -891,6 +918,7 @@ EditAssignmentForm.propTypes = {
891918
deadlines: PropTypes.string,
892919
runtimeEnvironments: PropTypes.array,
893920
visibility: PropTypes.string,
921+
canViewLimitRatios: PropTypes.bool,
894922
showSendNotification: PropTypes.bool,
895923
submitButtonMessages: PropTypes.object,
896924
mergeJudgeLogs: PropTypes.bool.isRequired,

src/locales/cs.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@
311311
"app.editAssignmentForm.canViewJudgeStdoutExplanation": "Pokud je přepínač nastaven, zpřístupní primární logy sudího (stdout) studentům. Vezměte na vědomí, že zveřejnění logů dá studentům potřebné prostředky, aby mohli získat testovací vstupy, což nemusí být u některých úloh žádoucí.",
312312
"app.editAssignmentForm.canViewLimitRatios": "Viditelnost paměti a času",
313313
"app.editAssignmentForm.canViewLimitRatiosExplanation": "Zda studenti vidí dobu běhu a spotřebovanou paměť svých řešení. Naměřené hodnoty jsou uvedeny relativně vůči nastaveným limitům, tedy studenti nevidí absolutní čísla ale pouze poměr v procentech.",
314+
"app.editAssignmentForm.canViewMeasuredValues": "Zobrazit absolutní hodnoty",
315+
"app.editAssignmentForm.canViewMeasuredValuesExplanation": "Zda studenti vidí absolutní hodnoty doby běhu a spotřebované paměťi (ne pouze relativní poměr vůči nastaveným limitům testů).",
314316
"app.editAssignmentForm.deadlines.dual": "Dva termíny",
315317
"app.editAssignmentForm.deadlines.dual.explanation": "Zadaná úloha má dva termíny odevzdání a dva bodové limity. Řešení odevzdaná před prvním termínem jsou hodnocena body v rozsahu prvního limitu, řešení odevzdaná mezi danými termíny jsou hodnocena body v rozsahu druhého limitu. Řešení odevzdaná po druhém termínu nedostanou žádné body.",
316318
"app.editAssignmentForm.deadlines.interpolated": "Dva termíny s interpolací",

src/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@
311311
"app.editAssignmentForm.canViewJudgeStdoutExplanation": "If set, judge primary logs (stdout) are visible to students. Please note that publishing the logs also provides means for the students to access the inputs which may not be desriable for some categories of exercises.",
312312
"app.editAssignmentForm.canViewLimitRatios": "Visibility of memory and time",
313313
"app.editAssignmentForm.canViewLimitRatiosExplanation": "Whether the students can see the measured execution time and consumed memory of their solutions. The measurements are displayed relatively to the established limits, so the students do not see the absolute values but only a percentage.",
314+
"app.editAssignmentForm.canViewMeasuredValues": "Show absolute measurements",
315+
"app.editAssignmentForm.canViewMeasuredValuesExplanation": "Whether the students can see the measured execution time and consumed memory in absolute units (not just as a relative ratio of the test limits).",
314316
"app.editAssignmentForm.deadlines.dual": "Dual deadlines",
315317
"app.editAssignmentForm.deadlines.dual.explanation": "The assignment has two deadlines and two max. points limits. Solutions submitted before the first deadline are awarded points up to the first limit, solutions between the two deadlines are awarded points up to the second limit. No points are granted for solutions after the second deadline.",
316318
"app.editAssignmentForm.deadlines.interpolated": "Dual deadlines interpolated",

src/pages/EditAssignment/EditAssignment.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class EditAssignment extends Component {
107107
runtimeEnvironments,
108108
visibility,
109109
visibleFrom,
110+
canViewLimitRatios,
110111
} = this.props;
111112

112113
return (
@@ -185,6 +186,7 @@ class EditAssignment extends Component {
185186
visibility={visibility}
186187
showSendNotification={showSendNotification(assignment, visibility, visibleFrom)}
187188
mergeJudgeLogs={assignment.mergeJudgeLogs}
189+
canViewLimitRatios={canViewLimitRatios}
188190
/>
189191
)}
190192
</ResourceRenderer>
@@ -238,6 +240,7 @@ EditAssignment.propTypes = {
238240
deadlines: PropTypes.string,
239241
visibility: PropTypes.string,
240242
visibleFrom: PropTypes.object,
243+
canViewLimitRatios: PropTypes.bool,
241244
allowVisibleFrom: PropTypes.bool,
242245
exerciseSync: PropTypes.func.isRequired,
243246
validateAssignment: PropTypes.func.isRequired,
@@ -261,6 +264,7 @@ export default withLinks(
261264
visibility: editAssignmentFormSelector(state, 'visibility'),
262265
allowVisibleFrom: editAssignmentFormSelector(state, 'allowVisibleFrom'),
263266
visibleFrom: editAssignmentFormSelector(state, 'visibleFrom'),
267+
canViewLimitRatios: editAssignmentFormSelector(state, 'canViewLimitRatios'),
264268
};
265269
},
266270
(dispatch, { params: { assignmentId } }) => ({

0 commit comments

Comments
 (0)