Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions LearningHub.Nhs.WebUI/Controllers/Api/ScormController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,10 @@ private async Task<SCO> GetSco(int resourceReferenceId)
// 1. StudentDataMasteryScore, StudentDataMaxTimeAllowed, StudentDataTimeLimitAction, Credit
sco.Credit = "credit";
sco.CommentsFromLms = ScormContansts.CommentsFromLMS;
sco.LaunchData = rv.ScormDetails.ScormManifest.LaunchData ?? ScormContansts.LaunchData;
sco.StudentDataMasteryScore = rv.ScormDetails.ScormManifest.MasteryScore ?? ScormContansts.StudentDataMasteryScore;
sco.StudentDataMaxTimeAllowed = rv.ScormDetails.ScormManifest.MaxTimeAllowed ?? ScormContansts.StudentDataMaxTimeAllowed;
sco.StudentDataTimeLimitAction = rv.ScormDetails.ScormManifest.TimeLimitAction ?? ScormContansts.StudentDataTimeLimitAction;
sco.LaunchData = rv?.ScormDetails?.ScormManifest?.LaunchData ?? ScormContansts.LaunchData;
sco.StudentDataMasteryScore = rv?.ScormDetails?.ScormManifest?.MasteryScore ?? ScormContansts.StudentDataMasteryScore;
sco.StudentDataMaxTimeAllowed = rv?.ScormDetails?.ScormManifest?.MaxTimeAllowed ?? ScormContansts.StudentDataMaxTimeAllowed;
sco.StudentDataTimeLimitAction = rv?.ScormDetails?.ScormManifest?.TimeLimitAction ?? ScormContansts.StudentDataTimeLimitAction;

// 2. LessonLocation, ScoreRaw, SuspendData, Entry
// If previous Scorm Activity was "incomplete" then offer pick-up from previous lesson location.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ public interface IResourceVersionRepository : IGenericRepository<ResourceVersion
/// <returns>The <see cref="Task"/>.</returns>
Task<ResourceVersion> GetCurrentForResourceAsync(int resourceId);

/// <summary>
/// The get current resource for resourceid async.
/// </summary>
/// <param name="resourceId">The resource Id.</param>
/// <returns>The <see cref="Task"/>.</returns>
Task<ResourceVersion> GetCurrentResourceDetailsAsync(int resourceId);

/// <summary>
/// The get current published for resource async.
/// </summary>
Expand All @@ -73,6 +80,13 @@ public interface IResourceVersionRepository : IGenericRepository<ResourceVersion
/// <returns>The <see cref="Task"/>.</returns>
Task<ResourceVersion> GetCurrentForResourceReferenceIdAsync(int resourceReferenceId);

/// <summary>
/// The get current resource for resource reference id async.
/// </summary>
/// <param name="resourceReferenceId">The resource reference id.</param>
/// <returns>The <see cref="Task"/>.</returns>
Task<ResourceVersion> GetCurrentResourceForResourceReferenceIdAsync(int resourceReferenceId);

/// <summary>
/// The get current published for resource reference id async.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,30 @@ public async Task<ResourceVersion> GetCurrentForResourceAsync(int resourceId)
&& !r.Deleted);
}

/// <summary>
/// The get current for resource async.
/// </summary>
/// <param name="resourceId">The resource id.</param>
/// <returns>The <see cref="Task"/>.</returns>
public async Task<ResourceVersion> GetCurrentResourceDetailsAsync(int resourceId)
{
return await this.DbContext.ResourceVersion.AsNoTracking()
.Include(r => r.Resource)
.Include(r => r.Publication).AsNoTracking()
.Include(r => r.ResourceVersionKeyword).AsNoTracking()
.Include(r => r.ResourceVersionAuthor).AsNoTracking()
.Include(r => r.ResourceVersionFlag).AsNoTracking()
.Include(r => r.ResourceVersionEvent).AsNoTracking()
.Include(r => r.ResourceLicence).AsNoTracking()
.Include(r => r.CreateUser).AsNoTracking()
.Include(r => r.ResourceVersionProvider).ThenInclude(r => r.Provider).AsNoTracking()
.OrderByDescending(r => r.Id)
.FirstOrDefaultAsync(r => r.ResourceId == resourceId
&& r.VersionStatusEnum != VersionStatusEnum.FailedToPublish
&& r.VersionStatusEnum != VersionStatusEnum.Draft
&& !r.Deleted);
}

/// <summary>
/// The get current published for resource async.
/// </summary>
Expand Down Expand Up @@ -233,6 +257,25 @@ public async Task<ResourceVersion> GetCurrentForResourceReferenceIdAsync(int res
return retVal;
}

/// <summary>
/// The get current for resource reference id async.
/// </summary>
/// <param name="resourceReferenceId">The resource reference id.</param>
/// <returns>The <see cref="Task"/>.</returns>
public async Task<ResourceVersion> GetCurrentResourceForResourceReferenceIdAsync(int resourceReferenceId)
{
ResourceVersion retVal = null;

var or = this.DbContext.ResourceReference.OrderByDescending(r => r.Id).FirstOrDefault(x => x.OriginalResourceReferenceId == resourceReferenceId);

if (or != null)
{
retVal = await this.GetCurrentResourceDetailsAsync(or.ResourceId);
}

return retVal;
}

/// <summary>
/// The get current published for resource reference id async.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion WebAPI/LearningHub.Nhs.Services/ActivityService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public async Task<ScormActivityViewModel> LaunchScormActivity(int currentUserId,
var scormActivitySummary = this.scormActivityRepository.GetScormActivitySummary(currentUserId, launchScormActivityViewModel.ResourceReferenceId);
var scormActivityId = this.scormActivityRepository.Create(currentUserId, launchScormActivityViewModel.ResourceReferenceId);

var resourceVersion = await this.resourceVersionRepository.GetCurrentForResourceReferenceIdAsync(launchScormActivityViewModel.ResourceReferenceId);
var resourceVersion = await this.resourceVersionRepository.GetCurrentResourceForResourceReferenceIdAsync(launchScormActivityViewModel.ResourceReferenceId);
var activeContent = new ActiveContentViewModel()
{
ScormActivityId = scormActivityId,
Expand Down