Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/sakaiproject/sakai
Browse files Browse the repository at this point in the history
  • Loading branch information
steveswinsburg committed Mar 13, 2018
2 parents b70e7fa + 0044d48 commit c76cb2b
Show file tree
Hide file tree
Showing 6,284 changed files with 84,971 additions and 49,405 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
5 changes: 5 additions & 0 deletions assignment/bundles/resources/assignment.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1043,3 +1043,8 @@ grades.late=Late submission
grades.lateness.late=Late
grades.lateness.ontime=On time
grades.lateness.unknown=Unknown

asn.edit.selectall = Select All Groups
asn.edit.selectone = You must select at least one group
asn.edit.allselected = All the groups are selected
asn.edit.groupsselected = groups selected
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@
import org.sakaiproject.exception.PermissionException;
import org.sakaiproject.exception.ServerOverloadException;
import org.sakaiproject.exception.TypeException;
import org.sakaiproject.memory.api.MemoryService;
import org.sakaiproject.service.gradebook.shared.GradeDefinition;
import org.sakaiproject.service.gradebook.shared.GradebookExternalAssessmentService;
import org.sakaiproject.service.gradebook.shared.GradebookNotFoundException;
Expand Down Expand Up @@ -157,7 +156,10 @@
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.Assert;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
Expand Down Expand Up @@ -194,7 +196,7 @@ public class AssignmentServiceImpl implements AssignmentService, EntityTransferr
@Setter private GradeSheetExporter gradeSheetExporter;
@Setter private LearningResourceStoreService learningResourceStoreService;
@Setter private LinkMigrationHelper linkMigrationHelper;
@Setter private MemoryService memoryService;
@Setter private TransactionTemplate transactionTemplate;
@Setter private ResourceLoader resourceLoader;
@Setter private SecurityService securityService;
@Setter private SessionManager sessionManager;
Expand All @@ -205,13 +207,9 @@ public class AssignmentServiceImpl implements AssignmentService, EntityTransferr
@Setter private UserDirectoryService userDirectoryService;
@Setter private UserTimeService userTimeService;

private DateTimeFormatter dateTimeFormatter;
private boolean allowSubmitByInstructor;

public void init() {
log.info("init()");
dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");

allowSubmitByInstructor = serverConfigurationService.getBoolean("assignments.instructor.submit.for.student", true);
if (!allowSubmitByInstructor) {
log.info("Instructor submission of assignments is disabled - add assignments.instructor.submit.for.student=true to sakai config to enable");
Expand Down Expand Up @@ -488,11 +486,16 @@ public HttpAccess getHttpAccess() {
res.setContentType("application/zip");
res.setHeader("Content-Disposition", "attachment; filename = bulk_download.zip");

try (OutputStream out = res.getOutputStream()) {
getSubmissionsZip(out, ref.getReference(), queryString);
} catch (Exception ignore) {
log.warn("Could not stream the zip of submissions for reference: {}", ref.getReference());
}
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
try (OutputStream out = res.getOutputStream()) {
getSubmissionsZip(out, ref.getReference(), queryString);
} catch (Exception ignore) {
log.warn("Could not stream the zip of submissions for reference: {}", ref.getReference());
}
}
});
} else {
// if subtype is assignment and there is no assignmentId then were downloading grades
res.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
Expand Down Expand Up @@ -1028,19 +1031,17 @@ public AssignmentSubmission addSubmission(String assignmentId, String submitter)
return null;
}

if (!submissionSubmitters.isEmpty()) {
String currentUser = sessionManager.getCurrentSessionUserId();
// identify who the submittee is using the session
submissionSubmitters.stream().filter(s -> s.getSubmitter().equals(currentUser)).findFirst().ifPresent(s -> s.setSubmittee(true));
String currentUser = sessionManager.getCurrentSessionUserId();
// identify who the submittee is using the session
submissionSubmitters.stream().filter(s -> s.getSubmitter().equals(currentUser)).findFirst().ifPresent(s -> s.setSubmittee(true));

assignmentRepository.newSubmission(assignment, submission, Optional.of(submissionSubmitters), Optional.empty(), Optional.empty(), Optional.empty());
assignmentRepository.newSubmission(assignment, submission, Optional.of(submissionSubmitters), Optional.empty(), Optional.empty(), Optional.empty());

String submissionReference = AssignmentReferenceReckoner.reckoner().submission(submission).reckon().getReference();
eventTrackingService.post(eventTrackingService.newEvent(AssignmentConstants.EVENT_ADD_ASSIGNMENT_SUBMISSION, submissionReference, true));
String submissionReference = AssignmentReferenceReckoner.reckoner().submission(submission).reckon().getReference();
eventTrackingService.post(eventTrackingService.newEvent(AssignmentConstants.EVENT_ADD_ASSIGNMENT_SUBMISSION, submissionReference, true));

log.debug("New submission: {} added to assignment: {}", submission.getId(), assignmentId);
return submission;
}
log.debug("New submission: {} added to assignment: {}", submission.getId(), assignmentId);
return submission;
} catch (IdUnusedException iue) {
log.warn("A submission cannot be added to an unknown assignment: {}", assignmentId);
}
Expand Down Expand Up @@ -1759,7 +1760,7 @@ public String assignmentReference(String id) {

@Override
public String submissionReference(String context, String id, String assignmentId) {
return AssignmentReferenceReckoner.reckoner().context(context).id(id).container(assignmentId).reckon().getReference();
return AssignmentReferenceReckoner.reckoner().context(context).id(id).container(assignmentId).subtype("s").reckon().getReference();
}

@Override
Expand Down Expand Up @@ -2179,7 +2180,10 @@ public String escapeInvalidCharsEntry(String accentedString) {

@Override
public boolean assignmentUsesAnonymousGrading(Assignment assignment) {
return Boolean.valueOf(assignment.getProperties().get(AssignmentServiceConstants.NEW_ASSIGNMENT_CHECK_ANONYMOUS_GRADING));
if (assignment != null) {
return Boolean.valueOf(assignment.getProperties().get(AssignmentServiceConstants.NEW_ASSIGNMENT_CHECK_ANONYMOUS_GRADING));
}
return false;
}

@Override
Expand Down Expand Up @@ -2646,7 +2650,7 @@ private void removeAssociatedTaggingItem(Assignment assignment) {

private void removeAssociatedGradebookItem(Assignment assignment, String context) {
String associatedGradebookAssignment = assignment.getProperties().get(AssignmentServiceConstants.PROP_ASSIGNMENT_ASSOCIATE_GRADEBOOK_ASSIGNMENT);
if (associatedGradebookAssignment != null) {
if (StringUtils.startsWith(associatedGradebookAssignment, REFERENCE_ROOT)) {
try {
boolean isExternalAssignmentDefined = gradebookExternalAssessmentService.isExternalAssignmentDefined(context, associatedGradebookAssignment);
if (isExternalAssignmentDefined) {
Expand Down Expand Up @@ -3592,8 +3596,8 @@ public Map<String, String> transferCopyEntitiesRefMigrator(String fromContext, S
nProperties.remove(ResourceProperties.PROP_ASSIGNMENT_DUEDATE_CALENDAR_EVENT_ID);

// gradebook-integration link
String associatedGradebookAssignment = StringUtils.trimToNull(nProperties.get(PROP_ASSIGNMENT_ASSOCIATE_GRADEBOOK_ASSIGNMENT));
if (associatedGradebookAssignment != null) {
String associatedGradebookAssignment = nProperties.get(PROP_ASSIGNMENT_ASSOCIATE_GRADEBOOK_ASSIGNMENT);
if (StringUtils.startsWith(associatedGradebookAssignment, REFERENCE_ROOT)) {
// see if the old assignment's associated gradebook item is an internal gradebook entry or externally defined
boolean isExternalAssignmentDefined = gradebookExternalAssessmentService.isExternalAssignmentDefined(oAssignment.getContext(), associatedGradebookAssignment);
if (isExternalAssignmentDefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public void getGradesSpreadsheet(final OutputStream out, final String reference,
try {
// numeric cell type?
String grade = null;
if (StringUtils.trimToNull(a.getProperties().get(AssignmentServiceConstants.PROP_ASSIGNMENT_ASSOCIATE_GRADEBOOK_ASSIGNMENT)) != null) {
if (StringUtils.startsWith(a.getProperties().get(AssignmentServiceConstants.PROP_ASSIGNMENT_ASSOCIATE_GRADEBOOK_ASSIGNMENT), AssignmentServiceConstants.REFERENCE_ROOT)) {
grade = assignmentService.getGradeForUserInGradeBook(submission.getAssignment().getId(), userId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ private Assignment assignmentReintegration(O11Assignment assignment, O11Assignme
assignment.getGroups().forEach(g -> a.getGroups().add(g.getAuthzGroup()));
}

// remove any properties that are null or blank
properties.values().removeIf(StringUtils::isBlank);

return a;
}

Expand Down Expand Up @@ -500,6 +503,9 @@ private AssignmentSubmission submissionReintegration(Assignment assignment, O11S
// Add any remaining undefined keys as properties
extraKeys.forEach(k -> properties.put(k, (String) submissionAny.get(k)));

// remove any properties that are null or blank
properties.values().removeIf(StringUtils::isBlank);

return s;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
import org.sakaiproject.site.api.SiteService;
import org.sakaiproject.time.api.UserTimeService;
import org.sakaiproject.tool.api.SessionManager;
import org.sakaiproject.user.api.UserDirectoryService;
import org.sakaiproject.user.api.UserNotDefinedException;
import org.sakaiproject.util.ResourceLoader;
import org.sakaiproject.util.api.FormattedText;
Expand All @@ -90,7 +89,6 @@ public class AssignmentServiceTest extends AbstractTransactionalJUnit4SpringCont
@Autowired private AssignmentService assignmentService;
@Autowired private EntityManager entityManager;
@Autowired private ServerConfigurationService serverConfigurationService;
@Autowired private UserDirectoryService userDirectoryService;
@Autowired private SiteService siteService;
@Autowired private FormattedText formattedText;
@Resource(name = "org.sakaiproject.time.api.UserTimeService")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.sakaiproject.event.api.EventTrackingService;
import org.sakaiproject.event.api.LearningResourceStoreService;
import org.sakaiproject.hibernate.AssignableUUIDGenerator;
import org.sakaiproject.memory.api.MemoryService;
import org.sakaiproject.service.gradebook.shared.GradebookExternalAssessmentService;
import org.sakaiproject.service.gradebook.shared.GradebookService;
import org.sakaiproject.site.api.SiteService;
Expand Down Expand Up @@ -206,11 +205,6 @@ public GradeSheetExporter gradeSheetExporter() {
return mock(GradeSheetExporter.class);
}

@Bean(name = "org.sakaiproject.memory.api.MemoryService")
public MemoryService memoryService() {
return mock(MemoryService.class);
}

@Bean(name = "org.sakaiproject.site.api.SiteService")
public SiteService siteService() {
return mock(SiteService.class);
Expand Down
6 changes: 5 additions & 1 deletion assignment/impl/src/webapp/WEB-INF/components.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@
<property name="gradeSheetExporter" ref="org.sakaiproject.assignment.impl.GradeSheetExporter"/>
<property name="learningResourceStoreService" ref="org.sakaiproject.event.api.LearningResourceStoreService"/>
<property name="linkMigrationHelper" ref="org.sakaiproject.util.api.LinkMigrationHelper"/>
<property name="memoryService" ref="org.sakaiproject.memory.api.MemoryService"/>
<property name="transactionTemplate">
<bean class="org.springframework.transaction.support.TransactionTemplate">
<property name="transactionManager" ref="org.sakaiproject.springframework.orm.hibernate.GlobalTransactionManager"/>
</bean>
</property>
<property name="resourceLoader" ref="org.sakaiproject.util.ResourceLoader.assignment"/>
<property name="securityService" ref="org.sakaiproject.authz.api.SecurityService"/>
<property name="sessionManager" ref="org.sakaiproject.tool.api.SessionManager"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.sakaiproject.assignment.api.AssignmentConstants;
import org.sakaiproject.assignment.api.AssignmentReferenceReckoner;
import org.sakaiproject.assignment.api.AssignmentService;
Expand Down Expand Up @@ -810,7 +811,7 @@ public SimpleAssignment(Assignment a) {

String gradebookAssignmentProp = a.getProperties().get(AssignmentServiceConstants.PROP_ASSIGNMENT_ASSOCIATE_GRADEBOOK_ASSIGNMENT);
if (gradebookService.isGradebookDefined(a.getContext())) {
if (gradebookAssignmentProp != null) {
if (StringUtils.startsWith(gradebookAssignmentProp, AssignmentServiceConstants.REFERENCE_ROOT)) {
// try to get internal gradebook assignment first
org.sakaiproject.service.gradebook.shared.Assignment gAssignment = gradebookService.getAssignment(a.getContext(), gradebookAssignmentProp);
if (gAssignment != null) {
Expand Down
Loading

0 comments on commit c76cb2b

Please sign in to comment.