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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public async Task<Course> GetCourse(string source, string id) {
var course = new Course {
Source = source,
Title = courseraCourse.Title,
Url = "https://www.coursera.com" + courseraCourse.Url,
Url = "https://www.coursera.org" + courseraCourse.Url,
Id = source + "-" + courseraCourse.Id,
PlatformType = PlatformTypes.Coursera,
ImageUrl = courseraCourse.ImageUrl,
Expand Down
1 change: 1 addition & 0 deletions ProgramInformationV2.Data/FieldList/CourseGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public CourseGroup() {
new() { Title = "Title", CategoryType = CategoryType.Course, FieldType = FieldType.General, IsRequired = true, InitialDescription = "Name your course. This will appear when users search for courses. -- Do not include the rubric or course number, as it will be added to the title when displayed." },
new() { Title = "Rubric", CategoryType = CategoryType.Course, FieldType = FieldType.General },
new() { Title = "Course Number", CategoryType = CategoryType.Course, FieldType = FieldType.General },
new() { Title = "Platform Type", CategoryType = CategoryType.Course, FieldType = FieldType.General },
new() { Title = "Summary", CategoryType = CategoryType.Course, FieldType = FieldType.General, InitialDescription = "Briefly summarize the course. This will appear when users search courses; they will read a brief summary of the course before clicking into the course page." },
new() { Title = "Description", CategoryType = CategoryType.Course, FieldType = FieldType.General, InitialDescription = "This text should describe the course. It will be on the course page." },
new() { Title = "Information", CategoryType = CategoryType.Course, FieldType = FieldType.General, InitialDescription = "For example: 3 undergraduate hours. 2 or 4 graduate hours." },
Expand Down
7 changes: 5 additions & 2 deletions ProgramInformationV2.Function/GetCourses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
[OpenApiParameter(name: "skills", In = ParameterLocation.Query, Required = false, Type = typeof(string), Description = "A list of skills the course will give you. You can separate the skills by the characters '[-]'.")]
[OpenApiParameter(name: "departments", In = ParameterLocation.Query, Required = false, Type = typeof(string), Description = "A list of departments the course is in. You can separate the departments by the characters '[-]'.")]
[OpenApiParameter(name: "q", In = ParameterLocation.Query, Required = false, Type = typeof(string), Description = "A full text search string -- it will search the title and description for the search querystring.")]
[OpenApiParameter(name: "platform", In = ParameterLocation.Query, Required = false, Type = typeof(string), Description = "Either 'coursera', 'campus', 'custom', 'moodle' for platform type.")]
[OpenApiParameter(name: "period", In = ParameterLocation.Query, Required = false, Type = typeof(string), Description = "Either 'upcoming' (future courses), 'current' (courses that are going on now), or 'open' (courses that are going on now or in the future).")]
[OpenApiParameter(name: "formats", In = ParameterLocation.Query, Required = false, Type = typeof(string), Description = "Either 'On-Campus', 'Online', 'Off-Campus', or 'Hybrid'. Can choose multiple by separating them with the characters '[-]'")]
[OpenApiParameter(name: "rubric", In = ParameterLocation.Query, Required = false, Type = typeof(string), Description = "The course rubric.")]
Expand All @@ -105,13 +106,15 @@
var take = requestHelper.GetInteger(req, "take", 1000);
var skip = requestHelper.GetInteger(req, "skip");
var period = requestHelper.GetRequest(req, "period", false);

if (!Enum.TryParse(requestHelper.GetRequest(req, "platform", false), true, out PlatformTypes platform)) {
platform = PlatformTypes.None;
}
var isUpcoming = period.Equals("upcoming") || period.Equals("open");
var isCurrent = period.Equals("current") || period.Equals("open");

requestHelper.Validate();
var response = req.CreateResponse(HttpStatusCode.OK);
await response.WriteAsJsonAsync(await _courseGetter.GetCourses(source, query, tags, tags2, tags3, skills, departments, formats, rubric, terms, isUpcoming, isCurrent, take, skip));
await response.WriteAsJsonAsync(await _courseGetter.GetCourses(source, query, tags, tags2, tags3, skills, departments, formats, rubric, platform, terms, isUpcoming, isCurrent, take, skip));
return response;
}

Expand All @@ -121,7 +124,7 @@
[OpenApiParameter(name: "q", In = ParameterLocation.Query, Required = false, Type = typeof(string), Description = "A full text search string for autocomplete.")]
[OpenApiParameter(name: "take", In = ParameterLocation.Query, Required = false, Type = typeof(int), Description = "How many suggestions do you want? Defaults to 10.")]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "text/plain", bodyType: typeof(IEnumerable<string>), Description = "An array of strings")]
public async Task<HttpResponseData> Suggest([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestData req) {

Check warning on line 127 in ProgramInformationV2.Function/GetCourses.cs

View workflow job for this annotation

GitHub Actions / build-and-deploy

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 127 in ProgramInformationV2.Function/GetCourses.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
_logger.LogInformation("Called ProgramSuggest.");
var requestHelper = RequestHelperFactory.Create();
requestHelper.Initialize(req);
Expand Down
5 changes: 3 additions & 2 deletions ProgramInformationV2.Search/Getters/CourseGetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public async Task<Course> GetCourseBySection(string sectionId) {
return response.IsValid ? response.Documents.FirstOrDefault() ?? new Course() : new Course();
}

public async Task<SearchObject<Course>> GetCourses(string source, string search, IEnumerable<string> tags, IEnumerable<string> tags2, IEnumerable<string> tags3, IEnumerable<string> skills, IEnumerable<string> departments, IEnumerable<string> formats, string rubric, IEnumerable<string> terms, bool isUpcoming, bool isCurrent, int take, int skip) {
public async Task<SearchObject<Course>> GetCourses(string source, string search, IEnumerable<string> tags, IEnumerable<string> tags2, IEnumerable<string> tags3, IEnumerable<string> skills, IEnumerable<string> departments, IEnumerable<string> formats, string rubric, PlatformTypes platform, IEnumerable<string> terms, bool isUpcoming, bool isCurrent, int take, int skip) {
var response = await _openSearchClient.SearchAsync<Course>(s => s.Index(UrlTypes.Courses.ConvertToUrlString())
.Skip(skip)
.Size(take)
Expand All @@ -66,7 +66,8 @@ public async Task<SearchObject<Course>> GetCourses(string source, string search,
f => departments.Any() ? f.Terms(m => m.Field(fld => fld.DepartmentList).Terms(departments)) : f.MatchAll(),
f => skills.Any() ? f.Terms(m => m.Field(fld => fld.SkillList).Terms(skills)) : f.MatchAll(),
f => formats.Any() ? f.Terms(m => m.Field(fld => fld.Formats).Terms(formats)) : f.MatchAll(),
f => rubric.Any() ? f.Term(m => m.Field(fld => fld.Rubric).Value(rubric)) : f.MatchAll(),
f => !string.IsNullOrWhiteSpace(rubric) ? f.Term(m => m.Field(fld => fld.Rubric).Value(rubric)) : f.MatchAll(),
f => platform != PlatformTypes.None ? f.Term(m => m.Field(fld => fld.PlatformType).Value(platform)) : f.MatchAll(),
f => terms.Any() ? f.Terms(m => m.Field(fld => fld.Terms).Terms(terms)) : f.MatchAll(),
f => isUpcoming ? f.Term(m => m.Field(fld => fld.IsUpcoming).Value(true)) : f.MatchAll(),
f => isCurrent ? f.Term(m => m.Field(fld => fld.IsCurrent).Value(true)) : f.MatchAll())
Expand Down
14 changes: 14 additions & 0 deletions ProgramInformationV2/Components/Controls/PlatformSelectList.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@using ProgramInformationV2.Search.Models
@if (GetFieldItemActive()) {
<ilw-content>
<div class="ils-input-entry">
<label for="@Id">@Title</label>
<select id="@Id" type="text" @bind="Value" @bind:after="Layout.SetDirty">
@foreach (var enumtype in Enum.GetValues<PlatformTypes>()) {
<option value="@enumtype">@enumtype.ConvertToSingleString()</option>
}
</select>
<p>@GetFieldItemDescription()</p>
</div>
</ilw-content>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Microsoft.AspNetCore.Components;
using ProgramInformationV2.Components.Layout;
using ProgramInformationV2.Data.FieldList;
using ProgramInformationV2.Search.Models;

namespace ProgramInformationV2.Components.Controls {
public partial class PlatformSelectList {
private PlatformTypes? _value;

[Parameter]
public IEnumerable<FieldItem> FieldItems { get; set; } = default!;

public string Id => Title.Replace(" ", "_").ToLowerInvariant();

[CascadingParameter]
public SidebarLayout Layout { get; set; } = default!;

[Parameter]
public string Title { get; set; } = "";

[Parameter]
public PlatformTypes? Value {
get => _value;
set {
if (_value == value)
return;
if (Layout != null)
Layout.SetDirty();
_value = value;
ValueChanged.InvokeAsync(value.HasValue ? value.Value : PlatformTypes.None);
}
}

[Parameter]
public EventCallback<PlatformTypes> ValueChanged { get; set; }

public bool GetFieldItemActive() => FieldItems == null ? false : FieldItems.FirstOrDefault(f => f.Title == Title)?.ShowItem ?? true;

public string GetFieldItemDescription() => FieldItems == null ? "" : FieldItems.FirstOrDefault(f => f.Title == Title)?.Description ?? "";

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
@layout SidebarLayout

<PageTitle>Import a Coursera Course</PageTitle>
<style>
.container {
padding: 20px;
border: 1px solid var(--il-blue);
}
</style>
<ilw-content>
<h1>Import a Coursera Course</h1>
@if (_useCourses.HasValue && _useCourses.Value)
Expand All @@ -20,7 +14,7 @@
<button class="ilw-button" @onclick="Search">Search for Courses</button>
@if (ListOfCourseraCourses != null && ListOfCourseraCoursesSelected != null)
{
<div class="container">
<div class="container-coursera">
<div class="ils-input-entry">
<label for="options">Coursera Courses</label>
<select id="options" type="text" @bind="ListOfCourseraCourseId" size="10" style="width: 100%;">
Expand All @@ -35,7 +29,7 @@
</div>
</div>
</div>
<div class="container">
<div class="container-coursera">
<div class="ils-input-entry">
<label for="optionsselected">Selected Courses</label>
<select id="optionsselected" type="text" @bind="ListOfCourseraCourseIdSelected" size="10" style="width: 100%;">
Expand Down
1 change: 1 addition & 0 deletions ProgramInformationV2/Components/Pages/Course/General.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<MediumText Title="Title" FieldItems="FieldItems" @bind-Value="CourseItem.CourseTitle"></MediumText>
<SmallText Title="Rubric" FieldItems="FieldItems" @bind-Value="CourseItem.Rubric"></SmallText>
<SmallText Title="Course Number" FieldItems="FieldItems" @bind-Value="CourseItem.CourseNumber"></SmallText>
<PlatformSelectList Title="Platform Type" FieldItems="FieldItems" @bind-Value="CourseItem.PlatformType"></PlatformSelectList>
<LargeText Title="Summary" FieldItems="FieldItems" @bind-Value="CourseItem.SummaryText"></LargeText>
<LargeText Title="Description" FieldItems="FieldItems" @bind-Value="CourseItem.Description"></LargeText>
<LargeText Title="Information" FieldItems="FieldItems" @bind-Value="CourseItem.Information"></LargeText>
Expand Down
6 changes: 6 additions & 0 deletions ProgramInformationV2/wwwroot/css/boxes.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,9 @@ div.button-group {
div.button-group button {
max-height: 40px;
}

div.container-coursera {
padding: 20px;
border: 1px solid var(--il-blue);
margin: 15px 0;
}
Loading