Skip to content

Commit f629282

Browse files
authored
Merge pull request #466 from TechnologyEnhancedLearning/RC
Merge RC changes to Virgo
2 parents b6367ac + a327295 commit f629282

File tree

4 files changed

+62
-5
lines changed

4 files changed

+62
-5
lines changed

LearningHub.Nhs.WebUI/Controllers/Api/ScormController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,10 @@ private async Task<SCO> GetSco(int resourceReferenceId)
335335
// 1. StudentDataMasteryScore, StudentDataMaxTimeAllowed, StudentDataTimeLimitAction, Credit
336336
sco.Credit = "credit";
337337
sco.CommentsFromLms = ScormContansts.CommentsFromLMS;
338-
sco.LaunchData = rv.ScormDetails.ScormManifest.LaunchData ?? ScormContansts.LaunchData;
339-
sco.StudentDataMasteryScore = rv.ScormDetails.ScormManifest.MasteryScore ?? ScormContansts.StudentDataMasteryScore;
340-
sco.StudentDataMaxTimeAllowed = rv.ScormDetails.ScormManifest.MaxTimeAllowed ?? ScormContansts.StudentDataMaxTimeAllowed;
341-
sco.StudentDataTimeLimitAction = rv.ScormDetails.ScormManifest.TimeLimitAction ?? ScormContansts.StudentDataTimeLimitAction;
338+
sco.LaunchData = rv?.ScormDetails?.ScormManifest?.LaunchData ?? ScormContansts.LaunchData;
339+
sco.StudentDataMasteryScore = rv?.ScormDetails?.ScormManifest?.MasteryScore ?? ScormContansts.StudentDataMasteryScore;
340+
sco.StudentDataMaxTimeAllowed = rv?.ScormDetails?.ScormManifest?.MaxTimeAllowed ?? ScormContansts.StudentDataMaxTimeAllowed;
341+
sco.StudentDataTimeLimitAction = rv?.ScormDetails?.ScormManifest?.TimeLimitAction ?? ScormContansts.StudentDataTimeLimitAction;
342342

343343
// 2. LessonLocation, ScoreRaw, SuspendData, Entry
344344
// If previous Scorm Activity was "incomplete" then offer pick-up from previous lesson location.

WebAPI/LearningHub.Nhs.Repository.Interface/Resources/IResourceVersionRepository.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ public interface IResourceVersionRepository : IGenericRepository<ResourceVersion
5959
/// <returns>The <see cref="Task"/>.</returns>
6060
Task<ResourceVersion> GetCurrentForResourceAsync(int resourceId);
6161

62+
/// <summary>
63+
/// The get current resource for resourceid async.
64+
/// </summary>
65+
/// <param name="resourceId">The resource Id.</param>
66+
/// <returns>The <see cref="Task"/>.</returns>
67+
Task<ResourceVersion> GetCurrentResourceDetailsAsync(int resourceId);
68+
6269
/// <summary>
6370
/// The get current published for resource async.
6471
/// </summary>
@@ -73,6 +80,13 @@ public interface IResourceVersionRepository : IGenericRepository<ResourceVersion
7380
/// <returns>The <see cref="Task"/>.</returns>
7481
Task<ResourceVersion> GetCurrentForResourceReferenceIdAsync(int resourceReferenceId);
7582

83+
/// <summary>
84+
/// The get current resource for resource reference id async.
85+
/// </summary>
86+
/// <param name="resourceReferenceId">The resource reference id.</param>
87+
/// <returns>The <see cref="Task"/>.</returns>
88+
Task<ResourceVersion> GetCurrentResourceForResourceReferenceIdAsync(int resourceReferenceId);
89+
7690
/// <summary>
7791
/// The get current published for resource reference id async.
7892
/// </summary>

WebAPI/LearningHub.Nhs.Repository/Resources/ResourceVersionRepository.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,30 @@ public async Task<ResourceVersion> GetCurrentForResourceAsync(int resourceId)
160160
&& !r.Deleted);
161161
}
162162

163+
/// <summary>
164+
/// The get current for resource async.
165+
/// </summary>
166+
/// <param name="resourceId">The resource id.</param>
167+
/// <returns>The <see cref="Task"/>.</returns>
168+
public async Task<ResourceVersion> GetCurrentResourceDetailsAsync(int resourceId)
169+
{
170+
return await this.DbContext.ResourceVersion.AsNoTracking()
171+
.Include(r => r.Resource)
172+
.Include(r => r.Publication).AsNoTracking()
173+
.Include(r => r.ResourceVersionKeyword).AsNoTracking()
174+
.Include(r => r.ResourceVersionAuthor).AsNoTracking()
175+
.Include(r => r.ResourceVersionFlag).AsNoTracking()
176+
.Include(r => r.ResourceVersionEvent).AsNoTracking()
177+
.Include(r => r.ResourceLicence).AsNoTracking()
178+
.Include(r => r.CreateUser).AsNoTracking()
179+
.Include(r => r.ResourceVersionProvider).ThenInclude(r => r.Provider).AsNoTracking()
180+
.OrderByDescending(r => r.Id)
181+
.FirstOrDefaultAsync(r => r.ResourceId == resourceId
182+
&& r.VersionStatusEnum != VersionStatusEnum.FailedToPublish
183+
&& r.VersionStatusEnum != VersionStatusEnum.Draft
184+
&& !r.Deleted);
185+
}
186+
163187
/// <summary>
164188
/// The get current published for resource async.
165189
/// </summary>
@@ -233,6 +257,25 @@ public async Task<ResourceVersion> GetCurrentForResourceReferenceIdAsync(int res
233257
return retVal;
234258
}
235259

260+
/// <summary>
261+
/// The get current for resource reference id async.
262+
/// </summary>
263+
/// <param name="resourceReferenceId">The resource reference id.</param>
264+
/// <returns>The <see cref="Task"/>.</returns>
265+
public async Task<ResourceVersion> GetCurrentResourceForResourceReferenceIdAsync(int resourceReferenceId)
266+
{
267+
ResourceVersion retVal = null;
268+
269+
var or = this.DbContext.ResourceReference.OrderByDescending(r => r.Id).FirstOrDefault(x => x.OriginalResourceReferenceId == resourceReferenceId);
270+
271+
if (or != null)
272+
{
273+
retVal = await this.GetCurrentResourceDetailsAsync(or.ResourceId);
274+
}
275+
276+
return retVal;
277+
}
278+
236279
/// <summary>
237280
/// The get current published for resource reference id async.
238281
/// </summary>

WebAPI/LearningHub.Nhs.Services/ActivityService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ public async Task<ScormActivityViewModel> LaunchScormActivity(int currentUserId,
438438
var scormActivitySummary = this.scormActivityRepository.GetScormActivitySummary(currentUserId, launchScormActivityViewModel.ResourceReferenceId);
439439
var scormActivityId = this.scormActivityRepository.Create(currentUserId, launchScormActivityViewModel.ResourceReferenceId);
440440

441-
var resourceVersion = await this.resourceVersionRepository.GetCurrentForResourceReferenceIdAsync(launchScormActivityViewModel.ResourceReferenceId);
441+
var resourceVersion = await this.resourceVersionRepository.GetCurrentResourceForResourceReferenceIdAsync(launchScormActivityViewModel.ResourceReferenceId);
442442
var activeContent = new ActiveContentViewModel()
443443
{
444444
ScormActivityId = scormActivityId,

0 commit comments

Comments
 (0)