Skip to content

Commit

Permalink
Merge branch 'main' into brightspace_cron
Browse files Browse the repository at this point in the history
  • Loading branch information
CK-7vn authored Dec 10, 2024
2 parents 4c21ba8 + 7cbf102 commit f246b35
Show file tree
Hide file tree
Showing 27 changed files with 418 additions and 387 deletions.
40 changes: 20 additions & 20 deletions backend/seeder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,8 @@ var coursesStr string = `
"external_url": "https://canvas.staging.unlockedlabs.xyz/courses/105",
"alt_name": "BOT101",
"total_progress_milestones": 12,
"start_dt": "2024-09-01",
"stop_dt": "2025-01-05"
"start_dt": "2024-09-01T00:00:00.000Z",
"end_dt": "2025-01-05T00:00:00.000Z"
},
{
"provider_platform_id": 1,
Expand All @@ -501,8 +501,8 @@ var coursesStr string = `
"external_url": "https://canvas.staging.unlockedlabs.xyz/courses/106",
"alt_name": "CRJ201",
"total_progress_milestones": 10,
"start_dt": "2024-11-15",
"stop_dt": "2024-12-15"
"start_dt": "2024-11-15T00:00:00.000Z",
"end_dt": "2024-12-15T00:00:00.000Z"
},
{
"provider_platform_id": 1,
Expand All @@ -515,8 +515,8 @@ var coursesStr string = `
"external_url": "https://canvas.staging.unlockedlabs.xyz/courses/104",
"alt_name": "PHI101",
"total_progress_milestones": 10,
"start_dt": "2024-10-07",
"stop_dt": "2025-03-04"
"start_dt": "2024-10-07T00:00:00.000Z",
"end_dt": "2025-03-04T00:00:00.000Z"
},
{
"provider_platform_id": 1,
Expand All @@ -529,8 +529,8 @@ var coursesStr string = `
"external_url": "https://canvas.staging.unlockedlabs.xyz/courses/104",
"alt_name": "MATH301",
"total_progress_milestones": 10,
"start_dt": "2024-09-22",
"stop_dt": "2025-02-25"
"start_dt": "2024-09-22T00:00:00.000Z",
"end_dt": "2025-02-25T00:00:00.000Z"
},
{
"provider_platform_id": 1,
Expand All @@ -543,8 +543,8 @@ var coursesStr string = `
"external_url": "https://canvas.staging.unlockedlabs.xyz/courses/106",
"alt_name": "CS101",
"total_progress_milestones": 12,
"start_dt": "2024-11-08",
"stop_dt": "2025-06-05"
"start_dt": "2024-11-08T00:00:00.000Z",
"end_dt": "2025-06-05T00:00:00.000Z"
},
{
"provider_platform_id": 1,
Expand All @@ -557,8 +557,8 @@ var coursesStr string = `
"external_url": "https://canvas.staging.unlockedlabs.xyz/courses/105",
"alt_name": "MKT101",
"total_progress_milestones": 8,
"start_dt": "2024-10-27",
"stop_dt": "2025-05-05"
"start_dt": "2024-10-27T00:00:00.000Z",
"end_dt": "2025-05-05T00:00:00.000Z"
},
{
"provider_platform_id": 1,
Expand All @@ -571,8 +571,8 @@ var coursesStr string = `
"external_url": "https://canvas.staging.unlockedlabs.xyz/courses/106",
"alt_name": "PSY101",
"total_progress_milestones": 8,
"start_dt": "2024-12-01",
"stop_dt": "2025-05-05"
"start_dt": "2024-12-01T00:00:00.000Z",
"end_dt": "2025-05-05T00:00:00.000Z"
},
{
"provider_platform_id": 1,
Expand All @@ -585,8 +585,8 @@ var coursesStr string = `
"external_url": "https://canvas.staging.unlockedlabs.xyz/courses/105",
"alt_name": "ENV201",
"total_progress_milestones": 14,
"start_dt": "2024-01-15",
"stop_dt": "2025-05-01"
"start_dt": "2024-01-15T00:00:00.000Z",
"end_dt": "2025-05-01T00:00:00.000Z"
},
{
"provider_platform_id": 1,
Expand All @@ -599,8 +599,8 @@ var coursesStr string = `
"external_url": "https://canvas.staging.unlockedlabs.xyz/courses/104",
"alt_name": "PHY101",
"total_progress_milestones": 11,
"start_dt": "2024-08-01",
"stop_dt": "2024-10-05"
"start_dt": "2024-08-01T00:00:00.000Z",
"end_dt": "2024-10-05T00:00:00.000Z"
},
{
"provider_platform_id": 1,
Expand All @@ -613,7 +613,7 @@ var coursesStr string = `
"external_url": "https://canvas.staging.unlockedlabs.xyz/courses/106",
"alt_name": "ART201",
"total_progress_milestones": 10,
"start_dt": "2025-02-01",
"stop_dt": "2025-06-05"
"start_dt": "2025-02-01T00:00:00.000Z",
"end_dt": "2025-06-05T00:00:00.000Z"
}
]`
12 changes: 12 additions & 0 deletions backend/src/database/open_content.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ import (
log "github.com/sirupsen/logrus"
)

func (db *DB) GetOpenContent(all bool) ([]models.OpenContentProvider, error) {
tx := db.Model(&models.OpenContentProvider{})
if !all {
tx = tx.Where("currently_enabled = ?", true)
}
openContent := make([]models.OpenContentProvider, 0, 3)
if err := tx.Find(&openContent).Error; err != nil {
return nil, newNotFoundDBError(err, "open_content_providers")
}
return openContent, nil
}

func (db *DB) FindKolibriInstance() (*models.ProviderPlatform, error) {
kolibri := models.ProviderPlatform{}
if err := db.First(&kolibri, "type = ?", "kolibri").Error; err != nil {
Expand Down
15 changes: 15 additions & 0 deletions backend/src/handlers/open_content_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,30 @@ package handlers
import (
"UnlockEdv2/src/models"
"net/http"
"strings"
)

func (srv *Server) registerOpenContentRoutes() []routeDef {
axx := models.Feature(models.OpenContentAccess)
return []routeDef{
{"GET /api/open-content/favorites", srv.handleGetUserFavoriteOpenContent, false, axx},
{"GET /api/open-content", srv.handleIndexOpenContent, false, axx},
}
}

func (srv *Server) handleIndexOpenContent(w http.ResponseWriter, r *http.Request, log sLog) error {
only := r.URL.Query().Get("all")
var all bool
if userIsAdmin(r) && strings.ToLower(strings.TrimSpace(only)) == "true" {
all = true
}
content, err := srv.Db.GetOpenContent(all)
if err != nil {
return newDatabaseServiceError(err)
}
return writeJsonResponse(w, http.StatusOK, content)
}

func (srv *Server) handleGetUserFavoriteOpenContent(w http.ResponseWriter, r *http.Request, log sLog) error {
page, perPage := srv.getPaginationInfo(r)
total, favorites, err := srv.Db.GetUserFavorites(srv.getUserID(r), page, perPage)
Expand Down
21 changes: 4 additions & 17 deletions backend/tasks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,10 @@ func main() {
log.Errorf("Task %v has no job", task.ID)
continue
}
if task.Provider != nil && task.Provider.Type == models.Brightspace {
brightspaceCron := fmt.Sprintf("0 %d * * * ", brightspaceHour)
brightspaceHour++
if brightspaceHour > 23 {
brightspaceHour = 1
}
_, err := scheduler.NewJob(gocron.CronJob(brightspaceCron, false), gocron.NewTask(runner.runTask, &task))
if err != nil {
log.Errorf("Failed to create job: %v, err")
continue
}
} else {
_, err := scheduler.NewJob(gocron.CronJob(task.Job.Schedule, false), gocron.NewTask(runner.runTask, &task))
if err != nil {
log.Errorf("Failed to create job: %v", err)
continue
}
_, err := scheduler.NewJob(gocron.CronJob(task.Job.Schedule, false), gocron.NewTask(runner.runTask, &task))
if err != nil {
log.Errorf("Failed to create job: %v", err)
continue
}
}
runner.execute()
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/Components/FeatureLevelCheckboxes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function FeatureLevelCheckboxes({
toaster(resp.message, ToastState.success);
const user = await fetchUser();
setUser(user);
navigate('/admin-dashboard');
navigate('/authcallback');
};

return (
Expand All @@ -74,13 +74,13 @@ export default function FeatureLevelCheckboxes({
/>
<CheckboxGeneric
name="provider_platforms"
label="Provider Platform Integrations"
label="Connected Learning"
checked={getCheckboxChecked(FeatureAccess.ProviderAccess)}
onChange={handleFeatureToggle}
/>
<CheckboxGeneric
name="program_management"
label="Program Management"
label="Program Hub"
checked={getCheckboxChecked(FeatureAccess.ProgramAccess)}
onChange={handleFeatureToggle}
/>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/Components/LibraryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default function LibraryCard({
alt={`${library.title} thumbnail`}
/>
</figure>
<h3 className="w-3/4 body my-auto">{library.title}</h3>
<h3 className="w-3/4 body my-auto mr-7">{library.title}</h3>
</div>
{role != UserRole.Student && (
<div
Expand All @@ -82,7 +82,7 @@ export default function LibraryCard({
{/* don't display the favorite toggle when admin is viewing in student view*/}
<ULIComponent
tooltipClassName="absolute right-2 top-2 z-100"
iconClassName={`w-6 h-6 ${AdminRoles.includes(role) ? (library.favorites.length > 0 ? 'text-primary-yellow' : '') : library.favorites.length > 0 ? 'text-primary-yellow' : ''}`}
iconClassName={`w-6 h-6 ${library.favorites.length > 0 && 'text-primary-yellow'}`}
icon={
AdminRoles.includes(role)
? library.favorites.length > 0
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/Components/LibraryLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function LibaryLayout({
}, [filterLibrariesAdmin, filterLibraries, searchTerm]);

return (
<div className="w-full flex flex-col p-8 gap-8">
<>
<div className="flex flex-row gap-4">
<SearchBar
searchTerm={searchTerm}
Expand Down Expand Up @@ -125,6 +125,6 @@ export default function LibaryLayout({
/>
</div>
)}
</div>
</>
);
}
Loading

0 comments on commit f246b35

Please sign in to comment.