Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cur 4158 develop pull to resolve conflict #1345

Open
wants to merge 20 commits into
base: feature/CUR-4133-indp-act-architecture-change-parent-branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ed83490
CUR-4054-create save token api (#1313)
shaheen7890 Sep 22, 2022
85f40b6
[CUR-4157] Regenerate the API Docmentation
basit-tkxel Sep 23, 2022
5ee7b72
CUR-4156 - Add due date and retry logic on create assignment (#1317)
shaheen7890 Sep 23, 2022
928d10f
Merge pull request #1315 from ActiveLearningStudio/feature/api-docume…
basit-tkxel Sep 23, 2022
cae5ba9
CUR-3978 implement default UI and backend permissions for all default…
waleed-backend Sep 23, 2022
0aff248
CUR-4122 column layout upgrade (#1319)
basit-tkxel Sep 23, 2022
0845735
Feature/cur 4122 columlayout upgrade (#1322)
basit-tkxel Sep 26, 2022
705a838
Feature/cur 4122 columlayout upgrade (#1323)
basit-tkxel Sep 26, 2022
da58769
Fixed the Migration issue
basit-tkxel Sep 26, 2022
6062075
Merge pull request #1324 from ActiveLearningStudio/fix/CUR-4122-migra…
basit-tkxel Sep 26, 2022
8dc79b2
Feature/cur 4002 publish activity to canvas (#1288)
AqibYounasAtTkxel Sep 26, 2022
2350448
CUR-4163-add background job for publishing (#1325)
shaheen7890 Sep 26, 2022
a71e2e1
CUR 4173 Moodle publish: "Publishing...." appears forever when publis…
AqibYounasAtTkxel Sep 27, 2022
efef039
Adding new interactive book v1.6 (#1333)
yuvaraj-curriki Sep 28, 2022
ea95ecb
CUR-4097: Implement the Smithsonian Images API's. (#1332)
asimsarwar Sep 28, 2022
d0c04ba
CUR-4179 add ms teams fileds in organizations (#1336)
shaheen7890 Sep 29, 2022
8f513fc
Add visibilty fields on ms team in admin panel (#1344)
shaheen7890 Sep 29, 2022
a4ff556
CUR-4199 update get content list api w.r.t search param. (#1342)
asimsarwar Sep 29, 2022
a9e1e66
Merge branch 'develop' of https://github.com/ActiveLearningStudio/Act…
AqibYounasAtTkxel Sep 29, 2022
0ad8c05
CUR 4158 pushing canvas publish code because frontend is updated now
AqibYounasAtTkxel Sep 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ MSTEAMS_TENANT_ID=
MSTEAMS_OAUTH_URL=
MSTEAMS_LANDING_URL=
MSTEAMS_REDIRECT_URL=
ASSIGNMENT_DUE_DATE_DAYS=

#true for only vivensity
GCR_ENV_PERMISSION_VIV=true

#Smithsonian Open Access API
SMITHSONIAN_API_BASE_URL=
SMITHSONIAN_API_KEY=
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ private function findLibraryDependencies($machineName, $library, $core, $paramet
}
}


// Order dependencies by weight
$orderedDependencies = array();
for ($i = 1, $s = count($dependencies); $i <= $s; $i++) {
Expand Down
114 changes: 114 additions & 0 deletions app/CurrikiGo/Canvas/Commands/CreateAssignmentCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php

namespace App\CurrikiGo\Canvas\Commands;

use App\CurrikiGo\Canvas\Contracts\Command;

/**
* This class handles fetching Course details in Canvas LMS
*/
class CreateAssignmentCommand implements Command
{
/**
* API URL
*
* @var string
*/
public $apiURL;
/**
* Access Token for api requests
*
* @var string
*/
public $accessToken;
/**
* HTTP Client instance
*
* @var \GuzzleHttp\Client
*/
public $httpClient;
/**
* Course Id
*
* @var int
*/
private $courseId;
/**
* Request Assignment Group Id
*
* @var array
*/
private $assignmentGroupId;
/**
* Request new assignment name
*
* @var array
*/
private $assignmentName;
/**
* Id of activity in curriki
*
* @var array
*/
private $currikiActivityId;

/**
* Creates an instance of the command class
*
* @param int $courseId
* @param string $queryString
* @return void
*/
public function __construct($courseId, $assignmentGroupId, $assignmentName, $currikiActivityId)
{
$this->courseId = $courseId;
$this->assignmentGroupId = $assignmentGroupId;
$this->assignmentName = $assignmentName;
$this->currikiActivityId = $currikiActivityId;
$this->endpoint = config('constants.canvas_api_endpoints.create_assignment');
$this->courseData = $this->prepareCourseData($assignmentGroupId, $assignmentName, $this->currikiActivityId);
}

/**
* Execute an API request for fetching course details
*
* @return string|null
*/
public function execute()
{
$assignment = $this->courseData;
$response = null;
try {
$response = $this->httpClient->request('POST', $this->apiURL . '/courses/' . $this->courseId . '/' . $this->endpoint, [
'headers' => ['Authorization' => "Bearer {$this->accessToken}"],
'json' => ['assignment' => $assignment]
])->getBody()->getContents();
$response = json_decode($response);
} catch (Exception $ex) {
}

return $response;
}

/**
* Prepare course data for API payload
*
* @param array $data
* @return array
*/
public function prepareCourseData($assignmentGroupId, $assignmentGroupName, $currikiActivityId)
{
$assignment = [];
$assignment["name"] = $assignmentGroupName;
$assignment['assignment_group_id'] = $assignmentGroupId;
$assignment['self_signup'] = 'enabled';
$assignment['position'] = 1;
$assignment['submission_types'][] = 'external_tool';
$assignment['return_type'] = 'lti_launch_url';
$assignment['workflow_state'] = 'published';
$assignment['points_possible'] = 100;
$assignment['published'] = true;
$assignment['external_tool_tag_attributes']['url'] = config('constants.curriki-tsugi-host') . "?activity=" . $currikiActivityId;
return $assignment;
}
}
87 changes: 87 additions & 0 deletions app/CurrikiGo/Canvas/Commands/CreateAssignmentGroupsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

namespace App\CurrikiGo\Canvas\Commands;

use App\CurrikiGo\Canvas\Contracts\Command;

/**
* This class handles fetching Course details in Canvas LMS
*/
class CreateAssignmentGroupsCommand implements Command
{
/**
* API URL
*
* @var string
*/
public $apiURL;
/**
* Access Token for api requests
*
* @var string
*/
public $accessToken;
/**
* HTTP Client instance
*
* @var \GuzzleHttp\Client
*/
public $httpClient;
/**
* Course Id
*
* @var int
*/
private $courseId;
/**
* Request queryString
*
* @var array
*/
private $assignmentGroupName;

/**
* Creates an instance of the command class
*
* @param int $courseId
* @param string $queryString
* @return void
*/
public function __construct($courseId, $assignmentGroupName)
{
$this->courseId = $courseId;
$this->endpoint = config('constants.canvas_api_endpoints.assignment_groups');
$this->courseData = $this->prepareCourseData($assignmentGroupName);
}

/**
* Execute an API request for fetching course details
*
* @return string|null
*/
public function execute()
{
$response = null;
try {
$response = $this->httpClient->request('POST', $this->apiURL . '/courses/' . $this->courseId . '/' . $this->endpoint, [
'headers' => ['Authorization' => "Bearer {$this->accessToken}"],
'json' => $this->courseData
])->getBody()->getContents();
$response = json_decode($response);
} catch (Exception $ex) {
}

return $response;
}

/**
* Prepare course data for API payload
*
* @param array $data
* @return array
*/
public function prepareCourseData($assignmentGroupName)
{
return ["name" => $assignmentGroupName];
}
}
25 changes: 13 additions & 12 deletions app/CurrikiGo/Canvas/Commands/CreateCourseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class CreateCourseCommand implements Command
* @param array $sisId
* @return void
*/
public function __construct($accountId, $courseData, $sisId)
public function __construct($courseName, $accountId)
{
$this->accountId = $accountId;
$this->courseData = $this->prepareCourseData($courseData, $sisId);
$this->courseData = $this->prepareCourseData($courseName);
}

/**
Expand All @@ -62,14 +62,16 @@ public function __construct($accountId, $courseData, $sisId)
public function execute()
{
$response = null;
try {
try {
$response = $this->httpClient->request('POST', $this->apiURL . '/accounts/' . $this->accountId . '/courses', [
'headers' => ['Authorization' => "Bearer {$this->accessToken}", 'Accept' => 'application/json'],
'json' => $this->courseData
])->getBody()->getContents();
'headers' => ['Authorization' => "Bearer {$this->accessToken}", 'Accept' => 'application/json'],
'json' => $this->courseData
])->getBody()->getContents();
$response = json_decode($response);
} catch (Exception $ex) {}

}
catch (Exception $ex) {
}

return $response;
}

Expand All @@ -79,12 +81,11 @@ public function execute()
* @param array $data
* @return array
*/
public function prepareCourseData($data, $sisId)
public function prepareCourseData($courseName)
{
$course["name"] = $data['name'];
$short_name = strtolower(implode('-', explode(' ', $data['name'])));
$course["name"] = $courseName;
$short_name = strtolower(implode('-', explode(' ', $courseName)));
$course["course_code"] = $short_name;
$course["sis_course_id"] = $sisId;
$course["license"] = "public_domain";
$course["public_syllabus_to_auth"] = true;
$course["public_description"] = $course["name"] . " by CurrikiStudio";
Expand Down
61 changes: 61 additions & 0 deletions app/CurrikiGo/Canvas/Commands/GetAllCoursesCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace App\CurrikiGo\Canvas\Commands;

use App\CurrikiGo\Canvas\Contracts\Command;

/**
* This class handles fetching courses in Canvas LMS
*/
class GetAllCoursesCommand implements Command
{
/**
* API URL
*
* @var string
*/
public $apiURL;
/**
* Access Token for api requests
*
* @var string
*/
public $accessToken;
/**
* HTTP Client instance
*
* @var \GuzzleHttp\Client
*/
public $httpClient;

/**
* Creates an instance of the command class
*
* @param int $accountId
* @param string $programName
* @return void
*/
public function __construct()
{
}

/**
* Execute an API request for getting courses
*
* @return string|null
*/
public function execute()
{
$response = null;
try {
$url = $this->apiURL . '/courses' . '?per_page=1000';
$response = $this->httpClient->request('GET', $url, [
'headers' => ['Authorization' => "Bearer {$this->accessToken}", 'Accept' => 'application/json']
])->getBody()->getContents();
$response = json_decode($response);
} catch (Exception $ex) {
}

return $response;
}
}
Loading