Skip to content

Commit

Permalink
Merge branch 'release/2.16.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin McFadden committed Jan 15, 2025
2 parents ed7c458 + 532980a commit d71b10b
Show file tree
Hide file tree
Showing 137 changed files with 4,534 additions and 1,252 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- run: composer install --no-interaction --prefer-dist --ignore-platform-reqs
- run: |
php --version
composer config "http-basic.nova.laravel.com" "${{ secrets.NOVA_USERNAME }}" "${{ secrets.NOVA_LICENSE_KEY }}"
composer install --no-interaction --prefer-dist --ignore-platform-reqs
- name: Build
run: docker compose build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ dist
.temp
/cypress/**/routes.json
/cypress/**/__diff_output__
auth.json
11 changes: 11 additions & 0 deletions app/Constants/LTIGradeMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Constants;

class LTIGradeMode
{
// how the LMS should handle grades for a chime
const NO_GRADES = "no_grades";
const ONE_GRADE = "one_grade";
const MULTIPLE_GRADES = "multiple_grades";
}
12 changes: 12 additions & 0 deletions app/Constants/LTIGradeOptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Constants;

class LTIGradeOptions
{
public const FULL_CREDIT_FOR_INCORRECT = 0;

public const NO_CREDIT_FOR_INCORRECT = 1;

public const HALF_CREDIT_FOR_INCORRECT = 2;
}
138 changes: 0 additions & 138 deletions app/Http/Controllers/Admin/UsersController.php

This file was deleted.

49 changes: 27 additions & 22 deletions app/Http/Controllers/ChimeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,25 +176,11 @@ public function getUsers(Request $req) {
}
}

public function syncUsers(Chime $chime, Request $req) {
$user = Auth::user();
// check perm

$users = $req->get('users');
$mappedUsers = array_reduce($users, function($result, $u) {
$result[$u['id']] = ["permission_number" => $u['permission_number']];
return $result;
});

$chime->users()->sync($mappedUsers);
$chime->save();
return response()->json(["success"=>true]);
}

public function updateChimeUser(Request $request, Chime $chime, User $user)
{
abort_unless(Auth::user()->canEditChime($chime->id), 403);
$request->validate([

$validated = $request->validate([
'permission_number' => [
'required',
'integer',
Expand All @@ -206,7 +192,7 @@ public function updateChimeUser(Request $request, Chime $chime, User $user)
]);

$chime->users()->updateExistingPivot($user->id, [
'permission_number' => $request->input('permission_number')
'permission_number' => $validated['permission_number']
]);

return response()->json(["success"=>true]);
Expand Down Expand Up @@ -560,6 +546,11 @@ public function exportChime(Chime $chime, Request $req) {

$headers = ['Student', 'ID', 'SIS User ID', 'SIS Login ID', 'Section'];
$secondHeaders = ['Points Possible', '','','',''];
// add response date info to question_full and session responses, since those aren't canvas compatible anyways
if($exportType == "question_full" || $exportType == "question_sessions") {
$headers[] = 'Latest Response Date';
$secondHeaders[] = '';
}


switch ($exportType) {
Expand Down Expand Up @@ -630,18 +621,26 @@ public function exportChime(Chime $chime, Request $req) {
$row[] = '';
$row[] = $participant->email;
$row[] = '';
$mostRecentDate = null;
$userResponseRows = array();
foreach($folderArray as $folderId => $folderInfo) {
foreach($folderInfo["folder"]->questions()->orderBy("order")->get() as $question) {
$userResponses = $question->sessions->flatmap(function($value) use ($participant) {
return $value->responses->where("user_id", $participant->id);
});
$row[] = $this->getRowForResponses($userResponses);
$mostRecentDate = max($mostRecentDate, $userResponses->max("created_at"));
$userResponseRows[] = $this->getRowForResponses($userResponses);
}
}
// we have to shift how we write these to avoid some copy pasta with our loops
$row[] = $mostRecentDate;
foreach($userResponseRows as $response) {
$row[] = $response;
}
fputcsv($file, $row);
}
break;
case 'question_only':
case 'question_only':
foreach($folderArray as $folderId => $folderInfo) {

foreach($folderInfo["folder"]->questions()->orderBy("order")->get() as $question) {
Expand All @@ -653,7 +652,7 @@ public function exportChime(Chime $chime, Request $req) {

}
break;
case 'question_sessions':
case 'question_sessions':

foreach($questionArray as $questionId => $questionText) {
$headers[] = $questionText;
Expand All @@ -669,17 +668,23 @@ public function exportChime(Chime $chime, Request $req) {
$row[] = '';
$row[] = $participant->email;
$row[] = '';
$mostRecentDate = null;
$userResponseRows = array();
foreach($folderArray as $folderId => $folderInfo) {
foreach($folderInfo["folder"]->questions()->orderBy("order")->get() as $question) {

foreach($question->sessions as $session) {
$userResponses = $session->responses->where("user_id", $participant->id);
$row[] = $this->getRowForResponses($userResponses);

$userResponseRows[] = $this->getRowForResponses($userResponses);
$mostRecentDate = max($mostRecentDate, $userResponses->max('created_at'));
}

}
}
$row[] = $mostRecentDate;
foreach($userResponseRows as $response) {
$row[] = $response;
}
fputcsv($file, $row);
}
break;
Expand Down
49 changes: 26 additions & 23 deletions app/Http/Controllers/FolderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

namespace App\Http\Controllers;

use App\Chime;
use Illuminate\Http\Request;
use App\Events\EndSession;
use App\Folder;
use Illuminate\Support\Facades\Auth;

class FolderController extends Controller
{

Expand Down Expand Up @@ -73,34 +77,33 @@ public function createQuestion(Request $req) {
}
}

public function importQuestions(Request $req, $chime, $folder) {
$user = $req->user();
$localChime = (
$user
->chimes()
->where('chime_id', $chime->id)
->first());

if ($localChime != null && $localChime->pivot->permission_number >= 300) {
public function importQuestions(Request $req, Chime $chime, Folder $folder)
{
$validated = $req->validate([
'folder_id' => 'required|integer|exists:folders,id'
]);

$sourceFolder = \App\Folder::find($req->get("folder_id"));
if(!$sourceFolder) {
return response('Could not find source folder', 403);
}
foreach($sourceFolder->questions as $question) {
$newQuestion = $question->replicate();
$newQuestion->folder()->associate($folder);
$newQuestion->current_session_id = null;
$newQuestion->save();
$user = Auth::user();
$sourceFolder = Folder::find($validated['folder_id']);
$sourceChime = $sourceFolder->chime;

}
return response()->json(["success" => true]);
// verify that the user has edit permissions on
// both the current folder and the source folder
abort_unless($user->canEditChime($chime->id) && $user->canEditChime($sourceChime->id), 403, 'Invalid Permissions to Import Questions');

}
else {
return response('Invalid Permissions to Import Questions', 403);
$currentOrderIndex = $folder->questions->max('order') ?? 0;

foreach ($sourceFolder->questions->sortBy('order') as $question) {
$currentOrderIndex += 1;

$newQuestion = $question->replicate();
$newQuestion->folder()->associate($folder);
$newQuestion->current_session_id = null;
$newQuestion->order = $currentOrderIndex;
$newQuestion->save();
}

return response()->json(["success" => true]);
}

public function updateQuestion(Request $req) {
Expand Down
9 changes: 3 additions & 6 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Chime;
use Auth;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Http\Request;

class HomeController extends Controller
{

public function index(Request $req)
public function index(Request $request)
{
return view('app', ['user' => $req->user()]);
return view('app', ['user' => $request->user()]);
}


// call this URL with target=<target> to force a login and redirect
public function loginAndRedirect(Request $req)
{
Expand Down
Loading

0 comments on commit d71b10b

Please sign in to comment.