Skip to content

Commit

Permalink
Merge branch 'release/2.15.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin McFadden committed Oct 26, 2024
2 parents 99c5512 + a476f4e commit ed7c458
Show file tree
Hide file tree
Showing 69 changed files with 3,300 additions and 1,419 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,27 @@ jobs:
- run: composer install --no-interaction --prefer-dist --ignore-platform-reqs

- name: Build
run: docker-compose build
run: docker compose build

- name: Start
run: docker-compose up -d
run: docker compose up -d

- name: Check
run: |
docker-compose ps --all
docker compose ps --all
- run: docker-compose exec -T app ./bin/ci.sh
- run: docker compose exec -T app ./bin/ci.sh
- run: npm ci
- run: npm run build
- run: docker-compose exec -T app php artisan key:generate
- run: docker-compose exec -T app php artisan migrate:fresh
- run: docker-compose exec -T app php artisan db:seed
- run: docker compose exec -T app php artisan key:generate
- run: docker compose exec -T app php artisan migrate:fresh
- run: docker compose exec -T app php artisan db:seed

- name: Lint code
run: docker-compose exec -T app npm run lint
run: docker compose exec -T app npm run lint

- name: Run unit tests with Jest
run: docker-compose exec -T app npm run test:unit
run: docker compose exec -T app npm run test:unit

- name: Run E2E tests with Cypress
uses: cypress-io/github-action@v6
Expand All @@ -64,18 +64,18 @@ jobs:
config: baseUrl=http://localhost

- name: Upload test screenshots if any
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots

- name: Upload snapshots
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-snapshots
path: cypress/snapshots

- name: Execute Unit tests via PHPUnit
run: docker-compose exec -T app php artisan test
run: docker compose exec -T app php artisan test
4 changes: 3 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"trailingComma": "es5"
}
35 changes: 26 additions & 9 deletions app/Http/Controllers/LTI13Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Packback\Lti1p3\LtiException;
use \App\LTI13ResourceLink;
use \App\Library\LTI13Processor;
use Log;

class LTI13Handler extends Controller
{
Expand Down Expand Up @@ -98,6 +99,7 @@ public function launch() {
$contextData = $launchData["https://purl.imsglobal.org/spec/lti/claim/context"];
$endpointData = $launchData["https://purl.imsglobal.org/spec/lti-ags/claim/endpoint"];
$resourceData = $launchData["https://purl.imsglobal.org/spec/lti/claim/resource_link"];

$presentationData = $launchData["https://purl.imsglobal.org/spec/lti/claim/launch_presentation"];

$returnURL = explode("external_content", $presentationData["return_url"])[0];
Expand Down Expand Up @@ -162,7 +164,7 @@ public function launch() {
$chime->lti_return_url = $returnURL;
$chime->users()->syncWithoutDetaching([Auth::user()->id=> ['permission_number' => 300]]);
$chime->save();

$resourceData = $this->fixResourceDataUsingAGS($chime, $resourceData);
// if they've launched from an assignment, we can get them to the right folder
if(isset($endpointData["lineitem"]) && $chime->lti_grade_mode == LTI13ResourceLink::LTI_GRADE_MODE_MULTIPLE_GRADES) {

Expand Down Expand Up @@ -194,7 +196,7 @@ public function launch() {
$chime->save();

$similarChimes = $this->getSimilarChimes($chime);

$resourceData = $this->fixResourceDataUsingAGS($chime, $resourceData);
$chime->users()->syncWithoutDetaching([Auth::user()->id=> ['permission_number' => 300]]);
return view("ltiSelectionPrompt", ["ltiLaunch"=>["similar_chimes"=>$similarChimes], "chime"=>$chime, "resource_link_pk"=>null, "lti_resource_title"=>$resourceData["title"], "saveTarget"=>'ltisettings13.update']);
}
Expand All @@ -211,7 +213,7 @@ public function launch() {
$chime->users()->attach(Auth::user(), ['permission_number' => 300]);
;
$similarChimes = $this->getSimilarChimes($chime);

$resourceData = $this->fixResourceDataUsingAGS($chime, $resourceData);
// return \Redirect::to("/chime/" . $chime->id. "/folder/" . $folder->id);
return view("ltiSelectionPrompt", ["ltiLaunch"=>["similar_chimes"=>$similarChimes], "chime"=>$chime , "resource_link_pk"=>null, "lti_resource_title"=>$resourceData["title"], "saveTarget"=>'ltisettings13.update']);
}
Expand All @@ -224,12 +226,9 @@ public function launch() {
]);
}
else {
$chime->users()->syncWithoutDetaching([Auth::user()->id=> ['permission_number' => 100]]);
$chime->users()->syncWithoutDetaching([Auth::user()->id=> ['permission_number' => 100]]);
}

$chime->lti13_resource_link_id = $resourceLink->id;
$chime->save();

$resourceData = $this->fixResourceDataUsingAGS($chime, $resourceData);
$folderId = null;
$folder = null;
$courseHasNonLTIFolders = false;
Expand Down Expand Up @@ -262,6 +261,24 @@ public function launch() {

}

private function fixResourceDataUsingAGS(Chime $chime, array $resourceData) {
if(isset($resourceData['title']) && $resourceData['title'] != "") {
return $resourceData;
}
$ags = LTI13Processor::getAGS($chime);
$lineItems = $ags->getLineItems();

foreach($lineItems as $lineItem) {
if($lineItem["resourceLinkId"] == $resourceData["id"]) {
Log::error("Resource data title was empty, so we're using the line item title", ["resourceData"=>$resourceData, "lineItem"=>$lineItem]);
$resourceData["title"] = $lineItem["label"];
return $resourceData;
}
}
return $resourceData;

}

public function saveLTISettings(Request $req, Chime $chime) {

$chime->fill($req->all());
Expand Down Expand Up @@ -435,7 +452,7 @@ private function getSimilarChimes($chime) {
return false;
}
$courseName = $explodedName[0] . " " . $explodedName[1] . "%";
$similarChimes = Auth::user()->chimes()->where("name", "like", $courseName)->where("chimes.id", "!=", $chime->id)->get();
$similarChimes = Auth::user()->chimes()->where("name", "like", $courseName)->where("chimes.id", "!=", $chime->id)->whereNotNull('lti_course_title')->get();
if($similarChimes->count() == 0) {
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Kernel extends HttpKernel {
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'shibinjection' => \App\Http\Middleware\ShibInjection::class
'shibinjection' => \App\Http\Middleware\ShibInjection::class,
'limit.json.size' => \App\Http\Middleware\LimitJsonSize::class,
];
}
29 changes: 29 additions & 0 deletions app/Http/Middleware/LimitJsonSize.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class LimitJsonSize
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next, ?int $maxSize = 10240): Response
{
$requestSize = strlen($request->getContent());

if ($requestSize > $maxSize && $request->isJson()) {
return response()->json([
'message' => 'The JSON data must not be larger than'
. ($maxSize / 1024) . 'KB.'
], 413);
}

return $next($request);
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"spatie/laravel-ignition": "^2.0",
"appzcoder/crud-generator": "^3.0",
"barryvdh/laravel-debugbar": "^3.2",
"barryvdh/laravel-ide-helper": "^2.10",
"barryvdh/laravel-ide-helper": "^3.0",
"deployer/deployer": "^7.0",
"filp/whoops": "~2.0",
"laracasts/cypress": "^3.0",
Expand Down
Loading

0 comments on commit ed7c458

Please sign in to comment.