diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..13ade57 --- /dev/null +++ b/.env.example @@ -0,0 +1,64 @@ +APP_NAME=Laravel +APP_ENV=local +APP_KEY=base64:saRB6NSd4S80J/Uc/gkKeGQpX3iNYw34h664jj6age8= +APP_DEBUG=true +APP_URL=http://localhost + +LOG_CHANNEL=stack +LOG_DEPRECATIONS_CHANNEL=null +LOG_LEVEL=debug + +DB_CONNECTION=mysql +DB_HOST=mysql +DB_PORT=3306 +DB_DATABASE=middleware +DB_USERNAME=sail +DB_PASSWORD=password + +BROADCAST_DRIVER=log +CACHE_DRIVER=file +FILESYSTEM_DISK=local +QUEUE_CONNECTION=sync +SESSION_DRIVER=database +SESSION_LIFETIME=120 + +MEMCACHED_HOST=127.0.0.1 + +REDIS_HOST=redis +REDIS_PASSWORD=null +REDIS_PORT=6379 + +MAIL_MAILER=smtp +MAIL_HOST=mailpit +MAIL_PORT=1025 +MAIL_USERNAME=null +MAIL_PASSWORD=null +MAIL_ENCRYPTION=null +MAIL_FROM_ADDRESS="hello@example.com" +MAIL_FROM_NAME="${APP_NAME}" + +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_DEFAULT_REGION=us-east-1 +AWS_BUCKET= +AWS_USE_PATH_STYLE_ENDPOINT=false + +PUSHER_APP_ID= +PUSHER_APP_KEY= +PUSHER_APP_SECRET= +PUSHER_HOST= +PUSHER_PORT=443 +PUSHER_SCHEME=https +PUSHER_APP_CLUSTER=mt1 + +VITE_APP_NAME="${APP_NAME}" +VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" +VITE_PUSHER_HOST="${PUSHER_HOST}" +VITE_PUSHER_PORT="${PUSHER_PORT}" +VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" +VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" + +SCOUT_DRIVER=meilisearch +MEILISEARCH_HOST=http://meilisearch:7700 + +MEILISEARCH_NO_ANALYTICS=false diff --git a/app/Enums/ProviderUserResourseStatus.php b/app/Enums/ProviderUserResourseStatus.php deleted file mode 100644 index 69185ab..0000000 --- a/app/Enums/ProviderUserResourseStatus.php +++ /dev/null @@ -1,9 +0,0 @@ ->>>>>> 3336b14 (fix: naming issues in CanvasUtil):middleware/app/Http/Controllers/Controller.php class Controller extends BaseController { diff --git a/app/Http/Controllers/Api/V1/PlatformConnectionController.php b/app/Http/Controllers/Api/V1/PlatformConnectionController.php index d1da041..a434c59 100644 --- a/app/Http/Controllers/Api/V1/PlatformConnectionController.php +++ b/app/Http/Controllers/Api/V1/PlatformConnectionController.php @@ -1,7 +1,5 @@ >>>>>>> b6e704f (move to namespace):middleware/app/Http/Controllers/api/V1/PlatformConnectionController.php -use Illuminate\Http\Request; -use App\Http\Controllers\Controller; -use App\Models\PlatformConnection; ->>>>>>> 0feb532 (fix items in review with nokie. PR closes UN-102):middleware/app/Http/Controllers/PlatformConnectionController.php - class PlatformConnectionController extends Controller { /* Get all platform connections */ //************************************************************* -<<<<<<< HEAD:app/Http/Controllers/Api/V1/PlatformConnectionController.php - // GET: /api/platform_connection/ + // GET: /api/v1/platform_connection/ // Request $req example: // { "consumer_id": 1 } // ************************************************************* public function index(): \Illuminate\Http\Resources\Json\AnonymousResourceCollection { return PlatformConnectionResource::collection(PlatformConnection::all()); -======= - //GET: /api/platform_connection/ - // Request $req example: - // { "consumer_id": 1 } - // ************************************************************* - public function index(): \Illuminate\Http\JsonResponse - { - try { - $platform_connections = PlatformConnection::all(['*'])->toArray(); - return response()->json($platform_connections); - } catch (\Exception) { - return response()->json(['error' => 'Invalid request body'], 401); - } ->>>>>>> 0feb532 (fix items in review with nokie. PR closes UN-102):middleware/app/Http/Controllers/PlatformConnectionController.php } /* Create a new platform connection */ //************************************************************* -<<<<<<< HEAD:app/Http/Controllers/Api/V1/PlatformConnectionController.php // POST: /api/v1/platform_connection/ // PlatformConnectionRequest $req example: // { "consumer_id": 1, "provider_id": 1, "state": "enabled" } @@ -70,36 +42,10 @@ public function store(StorePlatformConnectionRequest $req): PlatformConnectionRe return new PlatformConnectionResource($platform_connection); } catch (\Exception) { return response()->json(INVALID_REQUEST_BODY, 401); -======= - //POST: /api/platform_connection/ - // Request $req example: - // { "consumer_id": 1, "provider_id": 1, "state": "enabled" } - // ************************************************************* - public function store(Request $req): \Illuminate\Http\JsonResponse - { - try { - $consumer_id = $req->input('consumer_id'); - $provider_id = $req->input('provider_id'); - $state = $req->input('state'); - } catch (\Exception) { - return response()->json(['error' => 'Invalid request body'], 401); - } - try { - $platform_connection = PlatformConnection::create([ - 'consumer_id' => $consumer_id, - 'provider_id' => $provider_id, - 'state' => $state, - ]); - return response()->json($platform_connection); - } catch (\Exception) { - return response()->json(['error' => 'Invalid request body'], 401); ->>>>>>> 0feb532 (fix items in review with nokie. PR closes UN-102):middleware/app/Http/Controllers/PlatformConnectionController.php } } - // Get a specific platform connection by consumer or provider id // ************************************************************* -<<<<<<< HEAD:app/Http/Controllers/Api/V1/PlatformConnectionController.php // GET: /api/v1/platform_connection/{id} // Request $req example: // "consumer_id": 1 || "provider_id": 1 @@ -125,56 +71,14 @@ public function update(UpdatePlatformConnectionRequest $req): PlatformConnection $validated = $req->validated(); $PlatformConnection = PlatformConnection::where($validated)->first(); $PlatformConnection->state = $validated['state']; - return new PlatformConnectionResource($PlatformConnection->save()); if (!$PlatformConnection) { return response()->json(['error' => 'No matching platform connection found'], 401); -======= - // GET: /api/platform_connection/{id} - // Request $req example: - // "consumer_id": 1 || "provider_id": 1 - // ************************************************************* - public function show(Request $req): \Illuminate\Http\JsonResponse - { - if ($req->input('provider_id') != null) { - $platform_connection = PlatformConnection::where('platform_id', $req->input('platform_id'))->first(); - } else { - $platform_connection = PlatformConnection::where('consumer_id', $req->input('consumer_id'))->first(); - } - if (!$platform_connection) { - return response()->json(['error' => 'Invalid request body'], 401); - } - return response()->json_encode($platform_connection, JSON_PRETTY_PRINT); - } - - // Update a platform connection - // ************************************************************* - // PUT: /api/platform_connection/{request_body} - // Request $req example: - // { "consumer_id": 1, "provider_id": 1, "state": "enabled" } - // ************************************************************* - public function update(Request $req): \Illuminate\Http\JsonResponse - { - try { - $consumer_id = $req->input('consumer_id'); - $provider_id = $req->input('provider_id'); - $state = $req->input('state'); - } catch (\Exception) { - return response()->json(['error' => 'Invalid request body'], 401); - } - try { - $platform_connection = PlatformConnection::where('consumer_id', $consumer_id)->where('provider_id', $provider_id)->first(); - $platform_connection->state = $state; - $platform_connection->save(); - return response()->json($platform_connection); - } catch (\Exception) { - return response()->json(['error' => 'Invalid request body'], 401); ->>>>>>> 0feb532 (fix items in review with nokie. PR closes UN-102):middleware/app/Http/Controllers/PlatformConnectionController.php } + return new PlatformConnectionResource($PlatformConnection->save()); } // Delete a platform connection // ************************************************************* -<<<<<<< HEAD:app/Http/Controllers/Api/V1/PlatformConnectionController.php // DELETE: /api/v1/platform_connection/{request_body} // Request $req example: // { "consumer_id": 1, "provider_id": 1 } @@ -186,26 +90,6 @@ public function delete(ShowPlatformConnectionRequest $req): \Illuminate\Http\Jso return response()->json(['success' => 'Platform connection deleted successfully'], 200); } catch (\Exception) { return response()->json(INVALID_REQUEST_BODY, 401); -======= - // DELETE: /api/platform_connection/{request_body} - // Request $req example: - // { "consumer_id": 1, "provider_id": 1 } - // ************************************************************* - public function delete(Request $req): \Illuminate\Http\JsonResponse - { - try { - $consumer_id = $req->input('consumer_id'); - $provider_id = $req->input('provider_id'); - } catch (\Exception) { - return response()->json(['error' => 'Invalid request body'], 401); - } - try { - $platform_connection = PlatformConnection::where('consumer_id', $consumer_id)->where('provider_id', $provider_id)->first(); - $platform_connection->delete(); - return response()->json(['status' => 'success']); - } catch (\Exception) { - return response()->json(['error' => 'Invalid request body'], 401); ->>>>>>> 0feb532 (fix items in review with nokie. PR closes UN-102):middleware/app/Http/Controllers/PlatformConnectionController.php } } } diff --git a/app/Http/Controllers/Api/V1/ProviderPlatformController.php b/app/Http/Controllers/Api/V1/ProviderPlatformController.php index 56a6b07..e089b6a 100644 --- a/app/Http/Controllers/Api/V1/ProviderPlatformController.php +++ b/app/Http/Controllers/Api/V1/ProviderPlatformController.php @@ -1,6 +1,5 @@ first(); + $providerPlatform = ProviderPlatform::where('id', $request->id)->first(); if ($providerPlatform) { return new ProviderPlatformResource($providerPlatform); } else { @@ -61,7 +60,7 @@ public function store(StoreProviderPlatformRequest $req): ProviderPlatformResour // @return JsonResponse // Request $request // **************************************************** - public function update(StoreProviderPlatformRequest $request) + public function update(StoreProviderPlatformRequest $request): ProviderPlatformResource|\Illuminate\Http\JsonResponse { $validated = $request->validated(); $providerPlatform = ProviderPlatform::where($validated)->first(); @@ -79,9 +78,9 @@ public function update(StoreProviderPlatformRequest $request) // Request $req example: // { "provider_id": 1 } // **************************************************** - public function destroy(Request $request, $providerId): \Illuminate\Http\JsonResponse + public function destroy(Request $request): \Illuminate\Http\JsonResponse { - $providerPlatform = ProviderPlatform::where('id', $providerId)->first(); + $providerPlatform = ProviderPlatform::where('id', $request->input('id'))->first(); if (!$providerPlatform) { return response()->json(['error' => 'Invalid provider ID'], 401); } else { @@ -89,13 +88,4 @@ public function destroy(Request $request, $providerId): \Illuminate\Http\JsonRes return response()->json(json_encode($providerPlatform)); } } -======= -namespace App\Http\Controllers; - -use Illuminate\Http\Request; - -class ProviderPlatformController extends Controller -{ - // ->>>>>>> 8b2e792 (fix: upgraded to meet schema):middleware/app/Http/Controllers/ProviderPlatformController.php } diff --git a/app/Models/LTIAccount.php b/app/Models/LTIAccount.php deleted file mode 100644 index 73f644a..0000000 --- a/app/Models/LTIAccount.php +++ /dev/null @@ -1,125 +0,0 @@ -id = $id; - $this->name = $name; - $this->uuid = $uuid; - $this->parentAccountId = $parentAccountId; - $this->rootAccountId = $rootAccountId; - $this->workflowState = $workflowState; - } - - public function checkAndInsert() - { - $user = self::where('id', $this->getId()) - ->where('name', $this->getAccountName()) - ->where('uuid', $this->getUuid()) - ->where('parentAccountId', $this->getParentAccountId()) - ->where('rootAccountId', $this->getRootAccountId()) - ->where('workflowState', $this->getWorkflowState()) - ->first(); - - if (!$user) { - self::create([ - 'id' => $this->getId(), - 'name' => $this->getName(), - 'uuid' => $this->getUuid(), - 'parentAccountId' => $this->getParentAccountId(), - 'rootAccountId' => $this->getRootAccountId(), - 'workflowState' => $this->getWorkflowState(), - ]); - return true; // Data inserted - } - - return false; // Data already exists - } - public function setId($id) - { - $this->id = $id; - } - - public function setName($name) - { - $this->name = $name; - } - - public function setUuid($uuid) - { - $this->uuid = $uuid; - } - - public function setParentAccountId($id) - { - $this->parentAccountId = $id; - } - - public function setRootAccountId($id) - { - $this->rootAccountId = $id; - } - - public function setWorkflowState($state) - { - $this->workflowState = $state; - } - public function getId() - { - return $this->id; - } - - public function getName() - { - return $this->name; - } - - public function getUuid() - { - return $this->uuid; - } - - public function getParentAccountId() - { - return $this->parentAccountId; - } - - public function getRootAccountId() - { - return $this->rootAccountId; - } - - public function getWorkflowState() - { - return $this->workflowState; - } -} diff --git a/app/Models/LtiProvider.php b/app/Models/LtiProvider.php deleted file mode 100644 index 37b1719..0000000 --- a/app/Models/LtiProvider.php +++ /dev/null @@ -1,30 +0,0 @@ -where('accountName', $accountName) - ->where('ltiAccount', $ltiAccount) - ->first(); - - if (!$provider) { - self::create([ - 'providerID' => $providerID, - 'accountName' => $accountName, - 'ltiAccount' => $ltiAccount, - ]); - return true; // Data inserted - } - - return false; // Data already exists - } -} diff --git a/app/Models/PlatformConnection.php b/app/Models/PlatformConnection.php index 8d58e47..b0a8e4c 100644 --- a/app/Models/PlatformConnection.php +++ b/app/Models/PlatformConnection.php @@ -4,7 +4,6 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -<<<<<<< HEAD:app/Models/PlatformConnection.php use Illuminate\Database\Eloquent\Relations\BelongsTo; /** @@ -20,10 +19,11 @@ class PlatformConnection extends Model use HasFactory; protected $fillable = [ + 'consumer_platform_id', + 'provider_platform_id', 'state', - 'consumer_platform', - 'provider_platform', ]; + public function consumerPlatform(): BelongsTo { return $this->belongsTo(ConsumerPlatform::class); @@ -37,10 +37,4 @@ public function __construct(array $attributes = []) { parent::__construct($attributes); } -======= - -class PlatformConnection extends Model -{ - use HasFactory; ->>>>>>> 8b2e792 (fix: upgraded to meet schema):middleware/app/Models/PlatformConnection.php } diff --git a/app/Models/ProviderPlatform.php b/app/Models/ProviderPlatform.php index b6a62c7..1974120 100644 --- a/app/Models/ProviderPlatform.php +++ b/app/Models/ProviderPlatform.php @@ -3,7 +3,6 @@ namespace App\Models; - use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; @@ -12,8 +11,6 @@ class ProviderPlatform extends Model { use HasFactory; - protected $table = 'providers'; - protected $fillable = [ 'id', 'type', diff --git a/app/Models/ProviderResource.php b/app/Models/ProviderResource.php deleted file mode 100644 index 085ba47..0000000 --- a/app/Models/ProviderResource.php +++ /dev/null @@ -1,26 +0,0 @@ ->>>>>> 8b2e792 (fix: upgraded to meet schema):middleware/app/Models/ProviderResource.php -} diff --git a/app/Models/ProviderUserResource.php b/app/Models/ProviderUserResource.php deleted file mode 100644 index 49770e6..0000000 --- a/app/Models/ProviderUserResource.php +++ /dev/null @@ -1,31 +0,0 @@ - ProviderUserResourceStatus::class, - ]; - - public function __construct(array $attributes = []) - { - parent::__construct($attributes); - // we need to link the provdider id to the PlatformProvider Model - // and the provider_resource_id to the ProviderResource Model - $this->belongsTo(PlatformProvider::class, 'provider_id', 'id'); - $this->belongsTo(ProviderResource::class, 'provider_resource_id', 'id'); - $this->belongsTo(ProviderUser::class, 'user_id', 'id'); - } -} diff --git a/app/Services/CanvasServices.php b/app/Services/CanvasServices.php index d046a55..23b7c6b 100644 --- a/app/Services/CanvasServices.php +++ b/app/Services/CanvasServices.php @@ -5,7 +5,6 @@ use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; use App\Models\ProviderPlatform; -<<<<<<< HEAD:app/Services/CanvasServices.php use Psr\Http\Message\ResponseInterface; use App\Http\Requests\StudentEnrollmentRequest; @@ -29,8 +28,7 @@ const GRADEABLE_STUDENTS = 'gradeable_students/'; const READ = 'read/'; const ANONYMOUS_SUBMISSIONS = 'anonymous_submissions/'; -======= ->>>>>>> b6e704f (move to namespace):middleware/app/Services/CanvasServices.php + use App\Models\ProviderUserResource; class CanvasServices @@ -74,8 +72,6 @@ public function getBaseUrl(): string return $this->base_url; } -<<<<<<< HEAD:app/Services/CanvasServices.php - /* Helper function to return an HTTP client set with access key * @return GuzzleHttp\Client */ @@ -122,8 +118,6 @@ public static function byProviderId(int $providerId): CanvasServices | \InvalidA /** * validate and format the account ID parameter for API URLs -======= ->>>>>>> 0feb532 (fix items in review with nokie. PR closes UN-102):middleware/app/Services/CanvasServices.php // Turns a canvas specific course into a LTI deep linking JSON structure /*************************************************************** * @param string $courseId @@ -152,10 +146,6 @@ public static function encodeDeepLinkingJson(string $courseId, string $courseNam return json_encode($response); } -<<<<<<< HEAD:app/Services/CanvasServices.php -<<<<<<< HEAD:app/Services/CanvasServices.php -======= ->>>>>>> b6e704f (move to namespace):middleware/app/Services/CanvasServices.php /** * Retrive all user enrollments for a given provider (cached) * @param string $userId @@ -200,11 +190,6 @@ public function updateProviderUserResources(string $userId): void } } -<<<<<<< HEAD:app/Services/CanvasServices.php -======= ->>>>>>> 0feb532 (fix items in review with nokie. PR closes UN-102):middleware/app/Services/CanvasServices.php -======= ->>>>>>> b6e704f (move to namespace):middleware/app/Services/CanvasServices.php // constructor for when we already have the providerId public static function getByProviderId($providerId): CanvasServices | \InvalidArgumentException { @@ -332,7 +317,6 @@ public function showUserDetails(string $userId = 'self'): mixed $response = $this->client->get($base_url); } catch (RequestException $e) { throw new \Exception(API_ERROR . $e->getMessage()); - } return self::handleResponse($response); } diff --git a/app/Services/ConsumerPlatformServices.php b/app/Services/ConsumerPlatformServices.php deleted file mode 100644 index d6e4faf..0000000 --- a/app/Services/ConsumerPlatformServices.php +++ /dev/null @@ -1,17 +0,0 @@ -type = $type; - $consumerPlatform->name = $name; - $consumerPlatform->api_key = $api_key; - $consumerPlatform->base_url = $base_url; - $consumerPlatform->save(); - return $consumerPlatform; - } -} diff --git a/app/Services/ProviderPlatformServices.php b/app/Services/ProviderPlatformServices.php deleted file mode 100644 index 628554e..0000000 --- a/app/Services/ProviderPlatformServices.php +++ /dev/null @@ -1,100 +0,0 @@ -first(); - if (!$provider) { - throw new \InvalidArgumentException('Invalid provider ID'); - } - return new \CanvasServices($provider->provider_id, $provider->account_id, $provider->access_key, $provider->base_url); - } - - // Creates a new Provider Platform - /********************************************** - * - * @param int $accountId - * @param string $type - * @param string $accountName - * @param string $accessKey - * @param string $baseUrl - * @param string $iconUrl - * @return JsonResponse - * @throws \InvalidArgumentException - * - ************************************************/ - // Registers a new Provider Platform, returns the provider ID - public static function createProviderPlatform(int $accountId, string $type, string $accountName, string $accessKey, string $baseUrl, string $iconUrl): \Illuminate\Http\JsonResponse - { - // Check if the provider already exists in the database, these fields are unique - $existingProvider = ProviderPlatform::where([ - 'base_url' => $baseUrl, - 'account_id' => $accountId, - 'type' => $type, - 'account_name' => $accountName, - ])->first(); - - if (!$existingProvider) { - // Create a new provider instance and save it to the database - $newProvider = new ProviderPlatform([ - 'accountId' => $accountId, - 'account_name' => $accountName, - 'access_key' => $accessKey, - 'base_url' => $baseUrl, - 'icon_url' => $iconUrl, - ]); - $newProvider->save(); - return response()->json(json_encode($newProvider, JSON_PRETTY_PRINT)); - } else { - return response()->json(json_encode($existingProvider, JSON_PRETTY_PRINT)); - } - } - - public static function formatLtiDeepLinkFromCanvasCourse(string $canvasCourseJSON, string $baseUrl) - { - $canvasCourseData = json_decode($canvasCourseJSON, true); - // Mimick the LTI deep linking structure - $ltiDeepLink = [ - "type" => "ltiResourceLink", - "title" => $canvasCourseData["name"], - "text" => $canvasCourseData["public_description"], - "url" => $baseUrl . "/courses/" . $canvasCourseData["id"], - "custom" => [ - "courseId" => $canvasCourseData["id"], - ], - ]; - // Convert the array to JSON - $ltiDeepLinkJSON = json_encode($ltiDeepLink, JSON_PRETTY_PRINT); - - return $ltiDeepLinkJSON; - } - - - /*************************************************************** - * Create a new PlatformConnection and register the connection * - *************************************************************** - * @param int $consumerPlatformId - * @param int $providerPlatformId - * @return PlatformConnection - */ - public static function createPlatformConnection(int $consumerPlatformId, int $providerPlatformId): PlatformConnection - { - $connection = new PlatformConnection(); - $connection->consumer_platform_id = $consumerPlatformId; - $connection->provider_platform_id = $providerPlatformId; - $connection->state = 'disabled'; - $connection->save(); - - return $connection; - } -} diff --git a/config/lti.php b/config/lti.php deleted file mode 100644 index 3aee581..0000000 --- a/config/lti.php +++ /dev/null @@ -1,43 +0,0 @@ - [ - 'signature_method' => env('LTI13_SIGNATURE_METHOD', 'RS256'), - 'key_id' => env('LTI13_KEY_ID', 'key-1'), - 'rsa_public_key' => env('LTI13_RSA_PUBLIC_KEY'), - 'rsa_private_key' => env('LTI13_RSA_PRIVATE_KEY'), - 'auto_register_deployment_id' => env('LTI13_AUTO_REGISTER_DEPLOYMENT_ID', false), - 'required_scopes' => [ - // sample scope URLs - //"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem", - //"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly", - //"https://purl.imsglobal.org/spec/lti-ags/scope/score", - //"https://purl.imsglobal.org/spec/lti-nrps/scope/contextmembership.readonly", - ] - ], - -]; \ No newline at end of file diff --git a/storage/database.sqlite b/storage/database.sqlite index 71cbb9e..f3560c2 100644 Binary files a/storage/database.sqlite and b/storage/database.sqlite differ