Skip to content

Commit

Permalink
SAK-46415 Assignments can't submit video recordings (sakaiproject#10020)
Browse files Browse the repository at this point in the history
Attachment validation has recently been added to more places, so it
makes sense to include the video check in there (previously it was just
on one step as it doesn't allow preview or save as draft).
  • Loading branch information
bgarciaentornos authored Nov 15, 2021
1 parent d8f5a2e commit 64ca416
Showing 1 changed file with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5787,9 +5787,9 @@ public void doConfirm_submission(RunData data) {
}
state.setAttribute(ResourceProperties.ASSIGNMENT_INPUT_ADD_TIME_SPENT, timeSpent);

// get attachment input and generate alert message according to assignment submission type
checkSubmissionTextAttachmentInput(data, state, a, text);
state.setAttribute(PREVIEW_SUBMISSION_ATTACHMENTS, state.getAttribute(ATTACHMENTS));
// get attachment input and generate alert message according to assignment submission type
checkSubmissionTextAttachmentInput(data, state, a, text, false);

if (state.getAttribute(STATE_MESSAGE) == null) {
state.setAttribute(STATE_MODE, MODE_STUDENT_CONFIRM_SUBMISSION);
Expand Down Expand Up @@ -5828,7 +5828,7 @@ public void doPreview_submission(RunData data) {
state.setAttribute(AssignmentConstants.SUBMISSION_REVIEW_SERVICE_EULA_AGREEMENT, eulaAgreementYes);

// get attachment input and generate alert message according to assignment submission type
checkSubmissionTextAttachmentInput(data, state, a, text);
checkSubmissionTextAttachmentInput(data, state, a, text, false);
state.setAttribute(PREVIEW_SUBMISSION_ATTACHMENTS, state.getAttribute(ATTACHMENTS));

String timeSpent = params.getCleanString(ResourceProperties.ASSIGNMENT_INPUT_ADD_TIME_SPENT);
Expand Down Expand Up @@ -6520,17 +6520,8 @@ private void post_save_submission(RunData data, boolean post) {
text = null;
}

if (typeOfSubmission == Assignment.SubmissionType.VIDEO_SUBMISSION) {
// Get the video from the current attachments or get the video from the form post.
List<Reference> v = post ? (List<Reference>) state.getAttribute(ATTACHMENTS) : this.getVideoAttachments(data, state, a);
if ((v == null) || (v.size() != 1)) {
addAlert(state, rb.getString("youmust9"));
}
state.setAttribute(PREVIEW_SUBMISSION_ATTACHMENTS, v);
} else {
// get attachment input and generate alert message according to assignment submission type
checkSubmissionTextAttachmentInput(data, state, a, text);
}
// get attachment input and generate alert message according to assignment submission type
checkSubmissionTextAttachmentInput(data, state, a, text, post);
}
if ((state.getAttribute(STATE_MESSAGE) == null) && (a != null)) {
AssignmentSubmission submission;
Expand Down Expand Up @@ -6933,7 +6924,7 @@ private void adjustAttachmentsToSingleUpload(RunData data, SessionState state, A
}

private void checkSubmissionTextAttachmentInput(RunData data,
SessionState state, Assignment assignment, String text) {
SessionState state, Assignment assignment, String text, boolean post) {
// SAK-26329 - determine if the submission has text
boolean textIsEmpty = isHtmlEmpty(text);
if (assignment != null) {
Expand All @@ -6956,6 +6947,13 @@ private void checkSubmissionTextAttachmentInput(RunData data,
if (v.size() != 1) {
addAlert(state, rb.getString("youmust8"));
}
} else if (submissionType == Assignment.SubmissionType.VIDEO_SUBMISSION) {
// get the video from the form post
List<Reference> v = post ? (List<Reference>) state.getAttribute(ATTACHMENTS) : this.getVideoAttachments(data, state, assignment);
if ((v == null) || (v.size() != 1)) {
addAlert(state, rb.getString("youmust9"));
}
state.setAttribute(PREVIEW_SUBMISSION_ATTACHMENTS, v);
} else {
// for the inline and attachment submission / other submission types
// There must be at least one thing submitted: inline text or at least one attachment
Expand Down

0 comments on commit 64ca416

Please sign in to comment.