Skip to content

Commit

Permalink
Merge pull request #278 from matematikk-mooc/KURSP-854-cs-blade
Browse files Browse the repository at this point in the history
KURSP-864: course settings blade
  • Loading branch information
manilpit authored Sep 19, 2023
2 parents 1a70db7 + c452d5e commit 670dfc2
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 9 deletions.
22 changes: 14 additions & 8 deletions app/Http/Controllers/Lti3Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Services\AdminDashboardService;
use App\Services\DashboardService;
use App\Services\SurveyService;
use App\Services\CourseSettingsService;
use GuzzleHttp\Client;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
Expand Down Expand Up @@ -53,7 +54,7 @@ public function index(Request $request)
* @throws LtiException
*/
public function launch(Request $request)
{
{
$config_directory = $request->query("config_directory", "configs");
logger("LTI3Controller config directory:". $config_directory);
$launch = LTI\LTI_Message_Launch::new(new LTI3_Database($config_directory));
Expand All @@ -70,6 +71,7 @@ public function launch(Request $request)
$surveyMode = config('constants.options.SURVEY_MODE');
$adminDashboardMode = config('constants.options.ADMIN_DASHBOARD_MODE');
$kpasMode = $request->query("kpasMode", $roleMode);
$courseSettingsMode = config('constants.options.COURSE_SETTINGS_MODE');
if ($launch->is_resource_launch()) {
logger('Resource Launch!');
} else if ($launch->is_deep_link_launch()) {
Expand All @@ -95,13 +97,13 @@ public function launch(Request $request)
->withRequest($request);
} else {
logger('Unknown launch type');
}
}

$settings = $launch->get_launch_data()['https://purl.imsglobal.org/spec/lti/claim/custom'];
logger("SETTINGS:" . print_r($settings, true));

$settings["canvas_user_id"] = (string)$settings['canvas_user_id'];

$kpasUserView = "group_management";
if(isset($settings['kpas_user_view'])) {
$kpasUserView = (string)$settings['kpas_user_view'];
Expand Down Expand Up @@ -131,7 +133,7 @@ public function launch(Request $request)

logger("Lti3Middleware has settings.");

$settings = session()->get('settings');
$settings = session()->get('settings');
if ($kpasMode == $diplomaMode) {
$downloadLink = true;
logger("embed diploma");
Expand All @@ -143,7 +145,7 @@ public function launch(Request $request)
}

return $diplomaService->getDiplomaHtml($settings, $downloadLink, $hasDeservedDiploma);
}
}
else if($kpasMode == $statisticsMode) {
$statisticsService = new StatisticsService();
return $statisticsService->getStatisticsHtml($settings);
Expand All @@ -160,6 +162,10 @@ public function launch(Request $request)
$adminDashboardService = new AdminDashboardService();
return $adminDashboardService->getAdminDashboardBlade($settings);
}
else if($kpasMode == $courseSettingsMode) {
$courseSettingsService = new CourseSettingsService();
return $courseSettingsService->getCourseSettingsBlade($settings);
}

if ($kpasUserView == 'user_management') {
logger("Display user management view.");
Expand All @@ -168,7 +174,7 @@ public function launch(Request $request)
return view('lti.index');
}



/**
* Get categories for a given course from canvas api
Expand Down Expand Up @@ -253,7 +259,7 @@ public function kpas_settings()
public function diplomaPdf(Request $request)
{
logger("Diploma");
$settings = session()->get('settings');
$settings = session()->get('settings');
logger($settings);

$diplomaService = new DiplomaService();
Expand All @@ -263,7 +269,7 @@ public function diplomaPdf(Request $request)

//To make images/ references work.
$dompdf->getOptions()->setChroot(public_path());

//To make external references to css etc. work.
$dompdf->getOptions()->set('isRemoteEnabled', true);
$downloadLink = false;
Expand Down
14 changes: 14 additions & 0 deletions app/Services/CourseSettingsService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
namespace App\Services;


class CourseSettingsService
{

public function getCourseSettingsBlade($settings) {
logger("getCourseSettingsData");

return view('main.coursesettings')->withSettings($settings);
}

}
3 changes: 2 additions & 1 deletion config/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'STATISTICS_MODE' => 2,
'DASHBOARD_MODE' => 3,
'SURVEY_MODE' => 4,
'ADMIN_DASHBOARD_MODE' => 5
'ADMIN_DASHBOARD_MODE' => 5,
'COURSE_SETTINGS_MODE' => 6,
]
];
30 changes: 30 additions & 0 deletions resources/views/main/coursesettings.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@php use App\Repositories\CourseSettingsRepository; use App\Models\CourseSettings; use App\Models\CourseFilter; use App\Models\CourseCategory; use App\Models\Filter; use App\Models\Category; @endphp
@extends('layouts.app')

@section('content')
@php
$course_id = intval($settings["custom_canvas_course_id"]);
$courseSettingsRepository = new CourseSettingsRepository();
$courseSettings = $courseSettingsRepository->getCourseSettings($course_id);
$filters = $courseSettingsRepository->getFilters();
$categories = $courseSettingsRepository->getCategories();
@endphp

<h1>Filters</h1>
@php
var_dump($filters);
@endphp

<h1>Categories</h1>
@php
var_dump($categories);
@endphp

@endsection

@section('scripts')
<script>window.cookie = '{{ session()->getId() }}';</script>
@endsection

0 comments on commit 670dfc2

Please sign in to comment.