final TestDeliverySettingsTemplate template  final TestDeliverySettings target
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/services/AssessmentManagementService.java
target.setAuthorMode(template.isAuthorMode());
        target.setTitle(template.getTitle().trim());
void mergeTestDeliverySettings(final TestDeliverySettingsTemplate template, final TestDeliverySettings target)
final TestDeliverySettings template  final TestDeliverySettingsTemplate target
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/services/AssessmentManagementService.java
target.setAuthorMode(template.isAuthorMode());
        target.setTitle(template.getTitle());
    // CRUD for Delivery
    public Delivery lookupDelivery(final long did)
        final Delivery delivery = deliveryDao.requireFindById(did);
        ensureCallerMayAccess(delivery.getAssessment());
        return delivery;
    public Delivery lookupOwnDelivery(final long did)
        final Delivery delivery = deliveryDao.requireFindById(did);
        ensureCallerOwns(delivery.getAssessment());
        return delivery;
    /** Creates a new {@link Delivery
void mergeTestDeliverySettings(final TestDeliverySettings template, final TestDeliverySettingsTemplate target)
final Assessment assessment 
            final DeliverySettings deliverySettings  final DeliveryTemplate template
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/services/AssessmentManagementService.java
final Delivery delivery = new Delivery();
        delivery.setDeliverySettings(deliverySettings);
        deliveryDao.persist(delivery);
    public Delivery updateDelivery(final long did, final DeliveryTemplate template)
        validateDeliveryTemplate(template);
        final Delivery delivery = lookupOwnDelivery(did);
        final Assessment assessment = delivery.getAssessment();
        ensureCallerMayChange(assessment);
        final DeliverySettings deliverySettings = lookupAndMatchDeliverySettings(dsid, assessment);
        delivery.setDeliverySettings(deliverySettings);
        deliveryDao.update(delivery);
    private void validateDeliveryTemplate(final DeliveryTemplate template)
    public Delivery createDemoDelivery(final Assessment assessment)
        DeliverySettings deliverySettings = assessment.getDefaultDeliverySettings();
            deliverySettings = requireFirstDeliverySettings(caller, assessment.getAssessmentType());
    public Delivery createDemoDelivery(final Assessment assessment, final DeliverySettings deliverySettings)
        Assert.notNull(deliverySettings, "deliverySettings");
        ensureCompatible(deliverySettings, assessment);
        final Delivery delivery = new Delivery();
        delivery.setDeliverySettings(deliverySettings);
        deliveryDao.persist(delivery);
    public DeliverySettings requireFirstDeliverySettings(final User owner, final AssessmentObjectType assessmentType) {
        /* See if there are already suitable settings created */
        final DeliverySettings firstDeliverySettings = deliverySettingsDao.getFirstForOwner(owner, assessmentType);
        if (firstDeliverySettings!=null) {
            return firstDeliverySettings;
Delivery createDelivery(final Assessment assessment,
            final DeliverySettings deliverySettings, final DeliveryTemplate template)
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/services/AssessmentManagementService.java
final TestDeliverySettingsTemplate template = new TestDeliverySettingsTemplate();
        template.setAuthorMode(true);
        template.setTitle("Item Delivery Settings");
        return template;
TestDeliverySettingsTemplate createTestDeliverySettingsTemplate()
=most recent
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/services/EntityGraphService.java
@link AssessmentPackage
the current (=most recent)
final CandidateSession candidateItemSession
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/services/candidate/CandidateItemDeliveryService.java
final CandidateSession candidateItemSession = candidateItemEvent.getCandidateSession();
        final Delivery itemDelivery = candidateItemSession.getDelivery();
        final DeliverySettings itemDeliverySettings = itemDelivery.getDeliverySettings();
        final CandidateSession candidateItemSession = candidateItemEvent.getCandidateSession();
        final Delivery itemDelivery = candidateItemSession.getDelivery();
        final DeliverySettings itemDeliverySettings = itemDelivery.getDeliverySettings();
        final CandidateSession candidateSession = lookupCandidateItemSession(xid, sessionToken);
    public CandidateItemAttempt handleAttempt(final CandidateSession candidateItemSession,
        final Delivery itemDelivery = candidateItemSession.getDelivery();
        final boolean attemptAllowed = itemSessionController.isAttemptAllowed(itemDelivery.getDeliverySettings().getMaxAttempts());
     * Closes the {@link CandidateSession
double computeItemSessionDuration(final CandidateSession candidateItemSession)
final InstructorUser systemDefaultUser
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/tools/services/BootstrapServices.java
deliverySettingsDao.persist(fullSettings);
        deliverySettingsDao.persist(summativeSettings);
void importDefaultItemDeliverySettings(final InstructorUser systemDefaultUser)
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/domain/entities/ItemDeliverySettings.java
return id;
Long getId()
final Long id
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/domain/entities/ItemDeliverySettings.java
this.id = id;
void setId(final Long id)
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/domain/entities/ItemDeliverySettings.java
return owner;
User getOwner()
final User owner
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/domain/entities/ItemDeliverySettings.java
this.owner = owner;
void setOwner(final User owner)
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/domain/entities/ItemDeliverySettings.java
return ObjectUtilities.safeClone(creationTime);
Date getCreationTime()
final Date creationTime
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/domain/entities/ItemDeliverySettings.java
this.creationTime = ObjectUtilities.safeClone(creationTime);
void setCreationTime(final Date creationTime)
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/domain/entities/ItemDeliverySettings.java
return title;
String getTitle()
final String title
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/domain/entities/ItemDeliverySettings.java
this.title = title;
void setTitle(final String title)
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/domain/entities/ItemDeliverySettings.java
return isPublic;
boolean isPublic()
final boolean isPublic
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/domain/entities/ItemDeliverySettings.java
this.isPublic = isPublic;
    public boolean isAuthorMode() {
        return authorMode;
void setPublic(final boolean isPublic)
final boolean authorMode
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/domain/entities/ItemDeliverySettings.java
this.authorMode = authorMode;
void setAuthorMode(final boolean authorMode)
=most recent
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/services/EntityGraphService.java
@link AssessmentPackage
the current (=most recent)
final CandidateItemSession candidateItemSession
qtiworks-engine/src/main/java/uk/ac/ed/ph/qtiworks/services/candidate/CandidateItemDeliveryService.java
final CandidateItemSession candidateItemSession = candidateItemEvent.getCandidateItemSession();
        final ItemDelivery itemDelivery = candidateItemSession.getItemDelivery();
        final ItemDeliverySettings itemDeliverySettings = itemDelivery.getItemDeliverySettings();
        final CandidateItemSession candidateItemSession = candidateItemEvent.getCandidateItemSession();
        final ItemDelivery itemDelivery = candidateItemSession.getItemDelivery();
        final ItemDeliverySettings itemDeliverySettings = itemDelivery.getItemDeliverySettings();
        final CandidateItemSession candidateSession = lookupCandidateItemSession(xid, sessionToken);
    public CandidateItemAttempt handleAttempt(final CandidateItemSession candidateItemSession,
        final ItemDelivery itemDelivery = candidateItemSession.getItemDelivery();
        final boolean attemptAllowed = itemSessionController.isAttemptAllowed(itemDelivery.getItemDeliverySettings().getMaxAttempts());
     * Closes the {@link CandidateItemSession
double computeItemSessionDuration(final CandidateItemSession candidateItemSession)