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

staging new updated #1552

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 10 additions & 12 deletions Package/opigno/tincan/src/Score.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,16 @@ public function getMin() {
* @return self
*/
public function setMax($value) {
//removing the code to avoid the exception with 0 score , it can be revesed if future

// if (isset($this->raw) && $value < $this->raw) {
// throw new InvalidArgumentException(
// sprintf("Value must be greater than or equal to 'raw' (%s) [%s]", $this->raw, $value)
// );
// }
// if (isset($this->min) && $value <= $this->min) {
// throw new InvalidArgumentException(
// sprintf("Value must be greater than 'min' (%s) [%s]", $this->min, $value)
// );
// }
if (isset($this->raw) && $value < $this->raw) {
throw new InvalidArgumentException(
sprintf("Value must be greater than or equal to 'raw' (%s) [%s]", $this->raw, $value)
);
}
if (isset($this->min) && $value <= $this->min) {
throw new InvalidArgumentException(
sprintf("Value must be greater than 'min' (%s) [%s]", $this->min, $value)
);
}
$this->max = (float) $value;
return $this;
}
Expand Down
374 changes: 184 additions & 190 deletions app/Http/Controllers/Api/V1/CurrikiGo/ExtractXAPIJSONController.php

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions app/Http/Controllers/Api/V1/CurrikiGo/LmsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,11 @@ public function teams(TeamsSearchRequest $request)
*/
public function independentActivities(IndependentActivityForDeeplink $request)
{
$settings = LmsSetting::where('lti_client_id', $request->lti_client_id)->where('lms_login_id', 'ilike', $request->user_email);
$orgs = $settings->pluck('organization_id');
$user = $settings->first();
if ($orgs) {
return IndependentActivityResource::collection($this->independentActivityRepository->independentActivities($request, $user->user_id, $orgs));
$orgs = LmsSetting::where('lti_client_id', $request->lti_client_id)->where('lms_login_id', 'ilike', $request->user_email)->pluck('organization_id');
$user = User::where('email', strtolower($request->user_email))->first();
if($user){
return IndependentActivityResource::collection($this->independentActivityRepository->independentActivities($request, $user->id, $orgs));
}

return response([
'data' => ['Could not find any independent activity. Please try again later.'],
], 400);
Expand Down
9 changes: 1 addition & 8 deletions app/Http/Controllers/Api/V1/H5pController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use App\Repositories\CurrikiGo\ContentUserDataGo\ContentUserDataGoRepositoryInterface;
use App\CurrikiGo\Brightcove\Client;
use App\CurrikiGo\Brightcove\Videos\UpdateVideoTags;
use App\Models\Organization;

/**
* @group 12. H5P
Expand Down Expand Up @@ -100,14 +99,8 @@ public function create(Request $request)
}

$parameters = '{"params":{},"metadata":{}}';

$display_options = $core->getDisplayOptionsForEdit(NULL);
if ($request->get('organizationId')) {
$organization = Organization::find($request->get('organizationId'));
if($organization) {
$display_options['export'] = $organization->h5p_reuse_option;
$display_options['embed'] = $organization->h5p_embed_option;
}
}
$lib = $request->get('libraryName');
// view Get the file and settings to print from
$settings = $h5p::get_editor($content = null, $lib);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,10 +653,7 @@ public function h5p(IndependentActivity $independent_activity)
$content['library']['majorVersion'] . '.' . $content['library']['minorVersion']
));
$user_data = $user->only(['id', 'name', 'email']);
if($independent_activity->organization_id) {
$settings['contents']['cid-' . $content['id']]['displayOptions']['export'] = $independent_activity->organization->h5p_reuse_option;
$settings['contents']['cid-' . $content['id']]['displayOptions']['embed'] = $independent_activity->organization->h5p_embed_option;
}

$h5p_data = ['settings' => $settings, 'user' => $user_data, 'embed_code' => $embed_code];
return response([
'independent-activity' => new H5pIndependentActivityResource($independent_activity, $h5p_data)
Expand Down
41 changes: 17 additions & 24 deletions app/Http/Controllers/Api/V1/MicroSoftTeamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,12 @@ public function getAccessToken(Request $request)
*/
public function getAccessTokenViaCode(GetTokenViaCode $request)
{
$accessToken = $this->microsoftTeamRepository->getTokenViaCode($request);

if ($accessToken && array_key_exists('access_token', $accessToken)) {
$request['token'] = $accessToken['access_token'];
$getSubmission = $this->microsoftTeamRepository->getSubmission($request);
$accessToken = $this->microsoftTeamRepository->getTokenViaCode($request);

if ($getSubmission && array_key_exists('status', $getSubmission)) {
if ($accessToken && array_key_exists('access_token', $accessToken)) {
$request['token'] = $accessToken['access_token'];
$getSubmission = $this->microsoftTeamRepository->getSubmission($request);

return response([
'status_code' => 200,
'message' => 'Token fetched successfully.',
Expand All @@ -146,17 +145,11 @@ public function getAccessTokenViaCode(GetTokenViaCode $request)
'refresh_token' => $accessToken['refresh_token']
], 200);
}

return response([
'status_code' => 424,
'errors' => $getSubmission['error'],
], 500);
}
return response([
'status_code' => 424,
'errors' => $accessToken['error'],
'message' => $accessToken['error_description']
], 500);
'errors' => $accessToken['error'],
'message' => $accessToken['error_description']
], 500);
}

/**
Expand Down Expand Up @@ -268,16 +261,16 @@ public function getUserPofile(GetUserProfileRequest $request)
if ($accessToken && array_key_exists('access_token', $accessToken)) {
$getProfile = $this->microsoftTeamRepository->getUserProfile($accessToken['access_token']);

return response([
'profile' => $getProfile,
], 200);
} else {
return response([
'status_code' => 424,
'errors' => $accessToken['error'],
'message' => $accessToken['error_description']
], 500);
if ($getProfile && array_key_exists('displayName', $getProfile)) {
return response([
'profile' => $getProfile,
], 200);
}
}

return response([
'profile' => 'Something went wrong with the login code or token, unable to fetch user profile',
], 400);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/Auth/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ public function ltiSsoLogin1p0(SsoLoginRequest $request) {
$user = $this->userRepository->create([
'first_name' => $result['first_name'],
'last_name' => $result['last_name'],
'email' => strtolower($result['user_email']),
'email' => $result['user_email'],
'password' => Hash::make($password),
'remember_token' => Str::random(64),
'email_verified_at' => now(),
Expand All @@ -913,7 +913,7 @@ public function ltiSsoLogin1p0(SsoLoginRequest $request) {
}

$default_lms_setting = $default_lms_setting->toArray();
$default_lms_setting['lms_login_id'] = strtolower($user['user_email']);
$default_lms_setting['lms_login_id'] = $user['user_email'];
$user->lmssetting()->create($default_lms_setting);

$user->ssoLogin()->create([
Expand Down Expand Up @@ -949,7 +949,7 @@ public function ltiSsoLogin1p0(SsoLoginRequest $request) {
], 404);
}
$default_lms_setting = $default_lms_setting->toArray();
$default_lms_setting['lms_login_id'] = strtolower($user['user_email']);
$default_lms_setting['lms_login_id'] = $user['user_email'];
$newly_created_setting = $user->lmssetting()->create($default_lms_setting);

$organization = $this->organizationRepository->find($newly_created_setting->id);
Expand Down
1 change: 0 additions & 1 deletion app/Http/Requests/V1/GetTokenViaCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function rules()
'classId' => 'required',
'assignmentId' => 'required',
'submissionId' => 'required',
'tenantId' => 'required',
];
}
}
4 changes: 1 addition & 3 deletions app/Http/Requests/V1/SuborganizationSave.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ public function rules()
'secondary_font_family' => 'string|nullable|max:255',
'auto_approve' => 'boolean|nullable',
'activity_title_text' => 'string|nullable|max:255',
'activity_title_placeholder' => 'string|nullable|max:255',
'h5p_embed_option' => 'boolean|nullable',
'h5p_reuse_option' => 'boolean|nullable'
'activity_title_placeholder' => 'string|nullable|max:255'
];
}

Expand Down
4 changes: 1 addition & 3 deletions app/Http/Requests/V1/SuborganizationUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ public function rules()
'secondary_font_family' => 'string|nullable|max:255',
'auto_approve' => 'boolean|nullable',
'activity_title_text' => 'string|nullable|max:255',
'activity_title_placeholder' => 'string|nullable|max:255',
'h5p_embed_option' => 'boolean|nullable',
'h5p_reuse_option' => 'boolean|nullable'
'activity_title_placeholder' => 'string|nullable|max:255'
];
}

Expand Down
4 changes: 1 addition & 3 deletions app/Http/Resources/V1/OrganizationResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ public function toArray($request)
'msteam_activity_visibility' => $this->msteam_activity_visibility,
'auto_approve' => $this->auto_approve,
'activity_title_text' => $this->activity_title_text,
'activity_title_placeholder' => $this->activity_title_placeholder,
'h5p_reuse_option' => $this->h5p_reuse_option,
'h5p_embed_option' => $this->h5p_embed_option
'activity_title_placeholder' => $this->activity_title_placeholder
];
}
}
3 changes: 0 additions & 3 deletions app/Models/GoogleClassroom.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,8 @@ public static function boot()

self::creating(function(GoogleClassroom $gclassData) {
$gclassData->curriki_teacher_email = strtolower($gclassData->curriki_teacher_email);
$gclassData->teacher_group_email = strtolower($gclassData->teacher_group_email);
$gclassData->course_group_email = strtolower($gclassData->course_group_email);
});
}

/**
* Get the user_id for the teacher
*/
Expand Down
4 changes: 1 addition & 3 deletions app/Models/Organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ class Organization extends Model
'msteam_activity_visibility',
'auto_approve',
'activity_title_text',
'activity_title_placeholder',
'h5p_embed_option',
'h5p_reuse_option'
'activity_title_placeholder'
];

/**
Expand Down
16 changes: 7 additions & 9 deletions app/Repositories/ActivityItem/ActivityItemRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ public function getAll($suborganization, $data)

if (isset($data['skipPagination']) && $data['skipPagination'] === 'true') {
return $query->where('organization_id', $suborganization->id)
->where('is_active', true)
->orderBy('order', 'ASC')
->orderBy('title', 'ASC')
->get();
->orderBy('order', 'ASC')
->orderBy('title', 'ASC')
->get();
}
if (isset($data['filter']) && $data['filter'] !== '') {
$query = $query->whereHas('activityType', function ($qry) use ($data) {
$qry->where('id', $data['filter']);
$qry->where('id',$data['filter']);
});
}
$perPage = isset($data['size']) ? $data['size'] : config('constants.default-pagination-per-page');
Expand All @@ -56,10 +55,9 @@ public function getAll($suborganization, $data)
}

return $query->where('organization_id', $suborganization->id)
->where('is_active', true)
->orderBy('order', 'ASC')
->orderBy('title', 'ASC')
->paginate($perPage)->withQueryString();
->orderBy('order', 'ASC')
->orderBy('title', 'ASC')
->paginate($perPage)->withQueryString();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions app/Repositories/MicrosoftTeam/MicrosoftTeamRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function getToken($code)
*/
public function getTokenViaCode($request)
{
$apiURL = $this->loginUrl . '/' . $request->tenantId . '/oauth2/v2.0/token';

$postInput = [
'grant_type' => 'authorization_code',
'client_id' => $this->clientId,
Expand All @@ -103,7 +103,7 @@ public function getTokenViaCode($request)
'X-header' => 'value'
];

$response = Http::asForm()->withOptions(["verify"=>false])->post($apiURL, $postInput);
$response = Http::asForm()->withOptions(["verify"=>false])->post($this->apiURL, $postInput);

$statusCode = $response->status();
$responseBody = json_decode($response->getBody(), true);
Expand Down Expand Up @@ -418,7 +418,7 @@ private function getUserDetails($token)
*/
public function getUserProfile($token)
{
$apiURL = $this->landingUrl . '/me';
$apiURL = $this->landingUrl . '/profile';
$headers = [
'Content-length' => 0,
'Content-type' => 'application/json',
Expand Down
15 changes: 6 additions & 9 deletions app/Repositories/Organization/OrganizationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ public function fetchOrganizationUsers($data, $organization)
$organizationUsers = $organizationUsers->orderBy($data['order_by_column'], $orderByType);
}

$organizationUsers = $organizationUsers->withCount([
return $organizationUsers->withCount([
'projects' => function ($query) use ($organization) {
$query->where('organization_id', $organization->id);
},
Expand All @@ -790,17 +790,14 @@ public function fetchOrganizationUsers($data, $organization)
'groups' => function ($query) use ($organization) {
$query->where('organization_id', $organization->id);
}
]);

if (isset($data['query']) && $data['query'] !== '') {
$organizationUsers = $organizationUsers->where(function ($query) use ($data) {
])
->when($data['query'] ?? null, function ($query) use ($data) {
$query->where('email', 'like', '%' . str_replace("_", "\_", strtolower($data['query'])) . '%');
$query->orWhere('first_name', 'iLike', '%' . $data['query'] . '%');
$query->orWhere('last_name', 'iLike', '%' . $data['query'] . '%');
});
}

return $organizationUsers->paginate($perPage)->withQueryString();
return $query;
})
->paginate($perPage)->withQueryString();
}

/**
Expand Down
3 changes: 1 addition & 2 deletions app/Repositories/Project/ProjectRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ public function fetchByLtiClient($lti_client_id)
*/
public function fetchByLtiClientAndEmail($lti_client_id, $user_email, $searchTerm, $lms_organization_id)
{
return $this->model->whereIn('organization_id', $lms_organization_id)->where('name', 'iLIKE', '%' . $searchTerm . '%')
->where('team_id', null)->whereHas('users', function ($query_user) use ($lti_client_id, $user_email) {
return $this->model->whereIn('organization_id', $lms_organization_id)->where('name', 'iLIKE', '%' . $searchTerm . '%')->whereHas('users', function ($query_user) use ($lti_client_id, $user_email) {
$query_user->whereHas('lmssetting', function ($query_lmssetting) use ($lti_client_id, $user_email) {
$query_lmssetting->where('lti_client_id', $lti_client_id);
$query_lmssetting->where('lms_login_id', 'ilike', $user_email);
Expand Down
2 changes: 1 addition & 1 deletion app/Services/LearnerRecordStoreService.php
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ public function findGroupingInfo(array $other)
];
if (!empty($other)) {
$attempt_pattern = "/\/activity\/(\d*)\/submission\/(.*)\/(\d*)/";
$class_pattern = "/\/(gclass|lti)\/(.*)/";
$class_pattern = "/\/(gclass|lti)\/(\d*)/";
$matches = [];
$class_matches = [];
// Other regexes saved for later.
Expand Down
4 changes: 2 additions & 2 deletions charts/curriki/templates/api-ing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ metadata:
spec:
tls:
- hosts:
- stage.currikistudio.org
- {{.Values.host}}
secretName: letsencrypt
rules:
- host: stage.currikistudio.org
- host: {{.Values.host}}
http:
paths:
- pathType: Prefix
Expand Down
Loading