Skip to content

SAK-50233 Samigo Gradebook Assignments download zip with all rubrics #13717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ public final class AssignmentConstants {
public static final String PROP_INLINE_SUBMISSION = "assignment_submission_attachment_is_inline";
public static final String ZIP_COMMENT_FILE_TYPE = ".txt";
public static final String ZIP_SUBMITTED_TEXT_FILE_TYPE = ".html";
public static final String ZIP_PDF_FILE_TYPE = ".pdf";

public static final String NEW_ASSIGNMENT_USE_REVIEW_SERVICE = "new_assignment_use_review_service";
public static final String NEW_ASSIGNMENT_ALLOW_STUDENT_VIEW = "new_assignment_allow_student_view";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package org.sakaiproject.assignment.api;

import static org.sakaiproject.assignment.api.AssignmentServiceConstants.REFERENCE_ROOT;
import static org.sakaiproject.assignment.api.AssignmentServiceConstants.REF_TYPE_ASSIGNMENT;
import static org.sakaiproject.assignment.api.AssignmentServiceConstants.REF_TYPE_CONTENT;

import lombok.AccessLevel;
import lombok.Builder;
Expand Down Expand Up @@ -65,9 +67,9 @@ public String toString() {
// peer review type
reference = reference + Entity.SEPARATOR + "peer_review";
break;
case "a":
case REF_TYPE_ASSIGNMENT:
// assignment type
case "c":
case REF_TYPE_CONTENT:
// assignment content type
// deprecated using assignment type
default:
Expand Down
6 changes: 6 additions & 0 deletions assignment/api/src/resources/assignment.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,12 @@ option.pointsoverride=Adjust individual student scores
option.hidepoints=Hide point values (feedback only)
option.studentpreview=Hide Rubric from student
grading_rubric=Grading Rubric
rubrics.submitter.download=Download rubrics

zip.timestamp=timestamp
zip.feedback_text=feedbackText
zip.comments=comments
zip.rubrics=rubric

# table toolbar common messages
view.label=View
Expand Down
6 changes: 6 additions & 0 deletions assignment/api/src/resources/assignment_ca.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,12 @@ option.pointsoverride=Ajusta les puntuacions individuals dels estudiants
option.hidepoints=Amaga les puntuacions (nom\u00e9s comentaris)
option.studentpreview=Amaga la r\u00fabrica a l\u2019estudiant
grading_rubric=R\u00fabrica per a qualificar
rubrics.submitter.download=Descarregar r\u00fabriques

zip.timestamp=marcaDeTemps
zip.feedback_text=comentarisDeRetroalimentacio
zip.comments=comentaris
zip.rubrics=rubrica

# table toolbar common messages
view.label=Mostra
Expand Down
9 changes: 7 additions & 2 deletions assignment/api/src/resources/assignment_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ settings.access.checkFailure=Comprobaci\u00f3n fallida, no hay respuesta del ser

selected.group=Grupo seleccionado
selected.groups=Grupo(s) seleccionado(s)
selected.groups.without.gradebook = Has seleccionado grupos sin gradebook existente, por favor revisa la configuración.
selected.groups.without.gradebook = Has seleccionado grupos sin gradebook existente, por favor revisa la configuraci�n.

submission.inline=Respuesta enviada
grade.type.unknown=Tipo de nota desconocido
Expand Down Expand Up @@ -1195,8 +1195,13 @@ dont.associate.label=No utilizar r\u00fabricas para evaluar esta tarea
associate.label=Utilice una de las siguientes r\u00fabricas para evaluar esta tarea
option.pointsoverride=Ajustar notas individuales de estudiantes
option.hidepoints=Ocultar valores de puntuaci\u00f3n (solo en feedback)
option.studentpreview=Ocultar r\u00fabrica al alumnado
grading_rubric=Evaluaci\u00f3n de r\u00fabricas
rubrics.submitter.download=Descargar r\u00fabricas

zip.timestamp=marcaDeTiempo
zip.feedback_text=comentariosAdicionales
zip.comments=comentarios
zip.rubrics=rubrica

# table toolbar common messages
view.label=Vista
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import static org.sakaiproject.assignment.api.model.Assignment.Access.*;

import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -89,6 +91,7 @@
import org.sakaiproject.assignment.api.model.AssignmentSubmissionSubmitter;
import org.sakaiproject.assignment.api.model.AssignmentSupplementItemAttachment;
import org.sakaiproject.assignment.api.model.AssignmentSupplementItemService;
import org.sakaiproject.assignment.api.model.PeerAssessmentItem;
import org.sakaiproject.assignment.api.persistence.AssignmentRepository;
import org.sakaiproject.assignment.api.reminder.AssignmentDueReminderService;
import org.sakaiproject.assignment.api.taggable.AssignmentActivityProducer;
Expand Down Expand Up @@ -149,6 +152,7 @@
import org.sakaiproject.messaging.api.MessageMedium;
import org.sakaiproject.messaging.api.UserMessagingService;
import org.sakaiproject.rubrics.api.RubricsService;
import org.sakaiproject.rubrics.api.beans.AssociationTransferBean;
import org.sakaiproject.rubrics.api.model.ToolItemRubricAssociation;
import org.sakaiproject.search.api.SearchService;
import org.sakaiproject.site.api.Group;
Expand Down Expand Up @@ -640,6 +644,7 @@ public HttpAccess getHttpAccess() {
} else {
// determine the type of download to create using the reference that was requested
AssignmentReferenceReckoner.AssignmentReference refReckoner = AssignmentReferenceReckoner.reckoner().reference(ref.getReference()).reckon();

if (REFERENCE_ROOT.equals("/" + refReckoner.getType())) {
// don't process any references that are not of type assignment
switch (refReckoner.getSubtype()) {
Expand Down Expand Up @@ -2286,6 +2291,7 @@ public void getSubmissionsZip(OutputStream out, String reference, String query)
boolean withFeedbackText = false;
boolean withFeedbackComment = false;
boolean withFeedbackAttachment = false;
boolean withRubrics = false;
boolean withoutFolders = false;
boolean includeNotSubmitted = false;
String gradeFileFormat = "csv";
Expand Down Expand Up @@ -2325,6 +2331,8 @@ public void getSubmissionsZip(OutputStream out, String reference, String query)
} else if (token.contains("feedbackAttachments")) {
// feedback attachment
withFeedbackAttachment = true;
} else if (token.contains("rubrics")) {
withRubrics = true;
} else if (token.contains("withoutFolders")) {
// feedback attachment
withoutFolders = true;
Expand Down Expand Up @@ -2392,6 +2400,7 @@ public void getSubmissionsZip(OutputStream out, String reference, String query)
withFeedbackText,
withFeedbackComment,
withFeedbackAttachment,
withRubrics,
gradeFileFormat,
includeNotSubmitted);

Expand Down Expand Up @@ -2433,6 +2442,7 @@ public void getSubmissionsZip(OutputStream out, String reference, String query)
withFeedbackText,
withFeedbackComment,
withFeedbackAttachment,
withRubrics,
withoutFolders,
gradeFileFormat,
includeNotSubmitted,
Expand Down Expand Up @@ -3489,7 +3499,7 @@ private void removeAssociatedAnnouncementItem(AnnouncementChannel channel, Assig
}

// TODO zipSubmissions and zipGroupSubmissions should be combined
private void zipSubmissions(String assignmentReference, String assignmentTitle, Assignment.GradeType gradeType, Assignment.SubmissionType typeOfSubmission, Iterator submissions, OutputStream outputStream, StringBuilder exceptionMessage, boolean withStudentSubmissionText, boolean withStudentSubmissionAttachment, boolean withGradeFile, boolean withFeedbackText, boolean withFeedbackComment, boolean withFeedbackAttachment, boolean withoutFolders, String gradeFileFormat, boolean includeNotSubmitted, String siteId) {
private void zipSubmissions(String assignmentReference, String assignmentTitle, Assignment.GradeType gradeType, Assignment.SubmissionType typeOfSubmission, Iterator submissions, OutputStream outputStream, StringBuilder exceptionMessage, boolean withStudentSubmissionText, boolean withStudentSubmissionAttachment, boolean withGradeFile, boolean withFeedbackText, boolean withFeedbackComment, boolean withFeedbackAttachment, boolean withRubrics, boolean withoutFolders, String gradeFileFormat, boolean includeNotSubmitted, String siteId) {
ZipOutputStream out = null;

boolean isAdditionalNotesEnabled = false;
Expand Down Expand Up @@ -3644,7 +3654,7 @@ private void zipSubmissions(String assignmentReference, String assignmentTitle,

// record submission timestamp
if (!withoutFolders && s.getSubmitted() && s.getDateSubmitted() != null) {
final String zipEntryName = submittersName + "timestamp.txt";
final String zipEntryName = submittersName + resourceLoader.getString("zip.timestamp") + AssignmentConstants.ZIP_COMMENT_FILE_TYPE;
final String textEntryString = s.getDateSubmitted().toString();
createTextZipEntry(out, zipEntryName, textEntryString);
}
Expand All @@ -3667,7 +3677,7 @@ private void zipSubmissions(String assignmentReference, String assignmentTitle,
// include student submission feedback text
if (withFeedbackText) {
// create a feedbackText file into zip
final String zipEntryName = submittersName + "feedbackText.html";
final String zipEntryName = submittersName + resourceLoader.getString("zip.feedback_text") + AssignmentConstants.ZIP_SUBMITTED_TEXT_FILE_TYPE;
final String textEntryString = s.getFeedbackText();
createTextZipEntry(out, zipEntryName, textEntryString);
}
Expand Down Expand Up @@ -3695,7 +3705,7 @@ private void zipSubmissions(String assignmentReference, String assignmentTitle,

if (withFeedbackComment) {
// the comments.txt file to show instructor's comments
final String zipEntryName = submittersName + "comments" + AssignmentConstants.ZIP_COMMENT_FILE_TYPE;
final String zipEntryName = submittersName + resourceLoader.getString("zip.comments") + AssignmentConstants.ZIP_COMMENT_FILE_TYPE;
final String textEntryString = formattedText.encodeUnicode(s.getFeedbackComment());
createTextZipEntry(out, zipEntryName, textEntryString);
}
Expand All @@ -3713,6 +3723,19 @@ private void zipSubmissions(String assignmentReference, String assignmentTitle,

// add all feedback attachment folder
zipAttachments(out, submittersName, feedbackSubAttachmentFolder, s.getFeedbackAttachments());
}

String assignmentId = s.getAssignment().getId();

Optional<AssociationTransferBean> optAssociation = rubricsService.getAssociationForToolAndItem(AssignmentConstants.TOOL_ID, assignmentId, siteId);

if (withRubrics && optAssociation.isPresent()) {
byte[] pdf = rubricsService.createPdf(siteId, optAssociation.get().getRubricId(), AssignmentServiceConstants.ASSIGNMENT_TOOL_ID, assignmentId, s.getId());

final ZipEntry zipEntryPdf = new ZipEntry(submittersName + resourceLoader.getString("zip.rubrics") + AssignmentConstants.ZIP_PDF_FILE_TYPE);

out.putNextEntry(zipEntryPdf);
out.write(pdf);
out.closeEntry();
}
} // if
Expand Down Expand Up @@ -3805,7 +3828,7 @@ private void zipSubmissions(String assignmentReference, String assignmentTitle,
}

// TODO zipSubmissions and zipGroupSubmissions should be combined
protected void zipGroupSubmissions(String assignmentReference, String assignmentTitle, String gradeTypeString, Assignment.SubmissionType typeOfSubmission, Iterator submissions, OutputStream outputStream, StringBuilder exceptionMessage, boolean withStudentSubmissionText, boolean withStudentSubmissionAttachment, boolean withGradeFile, boolean withFeedbackText, boolean withFeedbackComment, boolean withFeedbackAttachment, String gradeFileFormat, boolean includeNotSubmitted) {
protected void zipGroupSubmissions(String assignmentReference, String assignmentTitle, String gradeTypeString, Assignment.SubmissionType typeOfSubmission, Iterator submissions, OutputStream outputStream, StringBuilder exceptionMessage, boolean withStudentSubmissionText, boolean withStudentSubmissionAttachment, boolean withGradeFile, boolean withFeedbackText, boolean withFeedbackComment, boolean withFeedbackAttachment, boolean withRubrics, String gradeFileFormat, boolean includeNotSubmitted) {
ZipOutputStream out = null;
try {
out = new ZipOutputStream(outputStream);
Expand Down Expand Up @@ -3886,7 +3909,7 @@ protected void zipGroupSubmissions(String assignmentReference, String assignment

// record submission timestamp
if (s.getSubmitted() && s.getDateSubmitted() != null) {
createTextZipEntry(out, submittersName + "timestamp.txt", s.getDateSubmitted().toString());
createTextZipEntry(out, submittersName + resourceLoader.getString("zip.timestamp") + AssignmentConstants.ZIP_COMMENT_FILE_TYPE, s.getDateSubmitted().toString());
}

// create the folder structure - named after the submitter's name
Expand All @@ -3901,7 +3924,7 @@ protected void zipGroupSubmissions(String assignmentReference, String assignment
// include student submission feedback text
if (withFeedbackText) {
// create a feedbackText file into zip
createTextZipEntry(out, submittersName + "feedbackText.html", s.getFeedbackText());
createTextZipEntry(out, submittersName + resourceLoader.getString("zip.feedback_text") + AssignmentConstants.ZIP_SUBMITTED_TEXT_FILE_TYPE, s.getFeedbackText());
}
}

Expand All @@ -3918,7 +3941,7 @@ protected void zipGroupSubmissions(String assignmentReference, String assignment

if (withFeedbackComment) {
// the comments.txt file to show instructor's comments
final String zipEntryName = submittersName + "comments" + AssignmentConstants.ZIP_COMMENT_FILE_TYPE;
final String zipEntryName = submittersName + resourceLoader.getString("zip.comments") + AssignmentConstants.ZIP_COMMENT_FILE_TYPE;
final String textEntryString = formattedText.encodeUnicode(s.getFeedbackComment());
createTextZipEntry(out, zipEntryName, textEntryString);
}
Expand All @@ -3933,9 +3956,25 @@ protected void zipGroupSubmissions(String assignmentReference, String assignment
out.closeEntry();
}

Assignment assignment = s.getAssignment();
String assignmentId = assignment.getId();
String siteId = assignment.getContext();

Optional<AssociationTransferBean> optAssociation = rubricsService.getAssociationForToolAndItem(AssignmentConstants.TOOL_ID, assignmentId, siteId);

if (withRubrics && optAssociation.isPresent()) {
byte[] pdf = rubricsService.createPdf(siteId, optAssociation.get().getRubricId(), AssignmentServiceConstants.ASSIGNMENT_TOOL_ID, assignmentId, s.getId());

final ZipEntry zipEntryPdf = new ZipEntry(submittersName + resourceLoader.getString("zip.rubrics") + AssignmentConstants.ZIP_PDF_FILE_TYPE);

out.putNextEntry(zipEntryPdf);
out.write(pdf);
out.closeEntry();
}

if (!submittersString.toString().trim().isEmpty()) {
// the comments.txt file to show instructor's comments
final String zipEntryName = submittersName + "members" + AssignmentConstants.ZIP_COMMENT_FILE_TYPE;
final String zipEntryName = submittersName + resourceLoader.getString("zip.comments") + AssignmentConstants.ZIP_COMMENT_FILE_TYPE;
final String textEntryString = formattedText.encodeUnicode(submittersString.toString());
createTextZipEntry(out, zipEntryName, textEntryString);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,20 @@
import org.sakaiproject.assignment.api.model.PeerAssessmentAttachment;
import org.sakaiproject.assignment.api.model.PeerAssessmentItem;
import org.sakaiproject.assignment.api.reminder.AssignmentDueReminderService;
import org.sakaiproject.assignment.api.sort.AssignmentComparator;
import org.sakaiproject.assignment.api.taggable.AssignmentActivityProducer;
import org.sakaiproject.assignment.taggable.tool.DecoratedTaggingProvider;
import org.sakaiproject.assignment.taggable.tool.DecoratedTaggingProvider.Pager;
import org.sakaiproject.assignment.taggable.tool.DecoratedTaggingProvider.Sort;
import org.sakaiproject.assignment.tool.AssignmentAction.SubmitterSubmission;
import org.sakaiproject.assignment.tool.AssignmentAction.UploadGradeWrapper;
import org.sakaiproject.authz.api.AuthzGroup;
import org.sakaiproject.authz.api.AuthzGroupService;
import org.sakaiproject.authz.api.GroupNotDefinedException;
import org.sakaiproject.authz.api.Member;
import org.sakaiproject.authz.api.Role;
import org.sakaiproject.authz.api.SecurityAdvisor;
import org.sakaiproject.authz.api.SecurityAdvisor.SecurityAdvice;
import org.sakaiproject.authz.api.SecurityService;
import org.tsugi.lti.LTIUtil;
import org.tsugi.lti13.LTICustomVars;
Expand Down Expand Up @@ -5098,6 +5102,7 @@ private String build_instructor_grade_assignment_context(VelocityPortlet portlet
// append the group info to the end
accessPointUrl = accessPointUrl.concat(view);
}

context.put("accessPointUrl", accessPointUrl);

state.setAttribute(NEW_ASSIGNMENT_CHECK_ANONYMOUS_GRADING, assignmentService.assignmentUsesAnonymousGrading(assignment));
Expand Down Expand Up @@ -6079,7 +6084,11 @@ private String build_instructor_download_upload_all(VelocityPortlet portlet, Con

String assignmentRef = (String) state.getAttribute(EXPORT_ASSIGNMENT_REF);
Assignment a = getAssignment(assignmentRef, "build_instructor_download_upload_all", state);

if (a != null) {
Optional<AssociationTransferBean> optAssociation = rubricsService.getAssociationForToolAndItem(AssignmentConstants.TOOL_ID, a.getId(), a.getContext());
context.put("hasRubric", optAssociation.isPresent() && optAssociation.get().getRubricId() != null);

context.put("accessPointUrl", serverConfigurationService.getAccessUrl().concat(assignmentRef));

Assignment.SubmissionType submissionType = a.getTypeOfSubmission();
Expand Down
Loading
Loading