Skip to content

Commit 50c6002

Browse files
author
Binon
committed
removed the hardcoded url in moodle entrolled course
1 parent 2294afd commit 50c6002

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

LearningHub.Nhs.WebUI/Services/MoodleHttpClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class MoodleHttpClient : IMoodleHttpClient, IDisposable
2626
public MoodleHttpClient(HttpClient httpClient, IConfiguration config)
2727
{
2828
this.httpClient = httpClient;
29-
this.moodleAPIBaseUrl = config["MoodleAPIConfig:BaseUrl"];
29+
this.moodleAPIBaseUrl = config["MoodleAPIConfig:BaseUrl"] + "webservice/rest/server.php";
3030
this.moodleAPIMoodleWSRestFormat = config["MoodleAPIConfig:MoodleWSRestFormat"];
3131
this.moodleAPIWSToken = config["MoodleAPIConfig:WSToken"];
3232
}

LearningHub.Nhs.WebUI/Views/Home/_CourseEnrolled.cshtml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
@using LearningHub.Nhs.WebUI.Extensions
33
@using LearningHub.Nhs.WebUI.Helpers
44
@model MoodleCourseResponseViewModel
5+
@inject Microsoft.Extensions.Configuration.IConfiguration Configuration;
6+
57
@{
68
bool providerExists = false;
79
string cardStyle = "card-provider-details--blank";
810

9-
string GetUrl(int courseId)
11+
string GetMoodleCourseUrl(int courseId)
1012
{
11-
string host = $"http://localhost";
13+
var apiBaseUrl = Configuration["MoodleAPIConfig:BaseUrl"];
1214
string path = $"course/view.php";
13-
string returnUrl = $@"{host}/{path}?id={courseId}";
15+
string returnUrl = $@"{apiBaseUrl}/{path}?id={courseId}";
1416

1517
return returnUrl;
1618
}
@@ -47,7 +49,7 @@
4749

4850
<div class="nhsuk-card__content dashboard-card-content">
4951
<h3 class="nhsuk-card__heading nhsuk-heading-m">
50-
<a class="nhsuk-card__link" href="@GetUrl(Model.Id.Value)">@Model.DisplayName</a>
52+
<a class="nhsuk-card__link" href="@GetMoodleCourseUrl(Model.Id.Value)">@Model.DisplayName</a>
5153
</h3>
5254
<div class="nhsuk-card__description dashboard-card-body">
5355

0 commit comments

Comments
 (0)