ijeffro /
laralocker
| 1 | <?php |
||||
| 2 | namespace LearningLocker\StatementForwarding; |
||||
| 3 | |||||
| 4 | use Curatr\Object\Completion\Types; |
||||
|
0 ignored issues
–
show
|
|||||
| 5 | use Curatr\ObjectCompletionCriterion; |
||||
|
0 ignored issues
–
show
The type
Curatr\ObjectCompletionCriterion was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 6 | use GuzzleHttp\Exception\RequestException; |
||||
|
0 ignored issues
–
show
The type
GuzzleHttp\Exception\RequestException was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 7 | use GuzzleHttp\Exception\ClientException; |
||||
|
0 ignored issues
–
show
The type
GuzzleHttp\Exception\ClientException was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 8 | |||||
| 9 | class Query { |
||||
| 10 | |||||
| 11 | const COMMENT = "AUTOGENERATED BY - DO NOT MANUALLY AMEND"; |
||||
| 12 | |||||
| 13 | /** |
||||
| 14 | * Generate the Statement Forward Query |
||||
| 15 | * based on the Object Completion Criteria |
||||
| 16 | */ |
||||
| 17 | public static function statementForward($org_id) { |
||||
| 18 | $criteria = ObjectCompletionCriterion::where('org_id', $org_id)->whereHas(\Object::class, function($q){ |
||||
| 19 | $q->where("completion_type", Types::XAPI); |
||||
| 20 | })->with('object')->get(); |
||||
| 21 | |||||
| 22 | if (sizeof($criteria) === 0 ){ |
||||
| 23 | // if there are no criteria |
||||
| 24 | return false; |
||||
| 25 | } else { |
||||
| 26 | //if there is criteria |
||||
| 27 | $queries = []; |
||||
| 28 | |||||
| 29 | foreach ($criteria as $criterion) { |
||||
| 30 | $course = $criterion->object->course; |
||||
| 31 | if (empty($course) || ($course && !empty($course->deleted_at))) { |
||||
| 32 | continue; |
||||
| 33 | } |
||||
| 34 | $criteriaQuery = []; |
||||
| 35 | $criteriaQuery['$comment'] = 'id:' . $criterion->id . ', object_id:' . $criterion->object_id; |
||||
| 36 | $activity_id = $criterion->use_curatr_activity ? $criterion->object->getXapiUrl(true, true) : $criterion->activity_id; |
||||
| 37 | $criteriaQuery['statement.object.id'] = $activity_id; |
||||
| 38 | if (!empty($criterion->verb)) $criteriaQuery['statement.verb.id'] = $criterion->verb; |
||||
| 39 | if (!empty($criterion->completion)) $criteriaQuery['statement.result.completion'] = true; |
||||
| 40 | if (!empty($criterion->success)) $criteriaQuery['statement.result.success'] = true; |
||||
| 41 | if (is_numeric($criterion->raw)) $criteriaQuery['statement.result.score.raw'] = ['$gte' => floatval($criterion->raw)]; |
||||
| 42 | if (is_numeric($criterion->scaled)) $criteriaQuery['statement.result.score.scaled'] = ['$gte' => floatval($criterion->scaled)]; |
||||
| 43 | |||||
| 44 | if (sizeof($criteriaQuery) > 0) { |
||||
| 45 | $queries[] = $criteriaQuery; |
||||
| 46 | } |
||||
| 47 | } |
||||
| 48 | if (sizeof($queries) === 0 ){ |
||||
| 49 | // if there are no quries |
||||
| 50 | return false; |
||||
| 51 | } |
||||
| 52 | |||||
| 53 | $query = [ |
||||
| 54 | '$comment' => self::COMMENT, |
||||
| 55 | '$or'=>$queries |
||||
| 56 | ]; |
||||
| 57 | } |
||||
| 58 | |||||
| 59 | return json_encode($query); |
||||
| 60 | } |
||||
| 61 | |||||
| 62 | /** |
||||
| 63 | * Get the Learning Locker Statement Forward by ID. |
||||
| 64 | * |
||||
| 65 | * @param $id |
||||
| 66 | * @return $response |
||||
|
0 ignored issues
–
show
|
|||||
| 67 | */ |
||||
| 68 | protected function get() { |
||||
| 69 | try { |
||||
| 70 | $url = $this->endpoint . $this->api . $this->v2 . $this->query . '/'; |
||||
|
0 ignored issues
–
show
|
|||||
| 71 | $request = $this->getClient()->get($url, [ |
||||
|
0 ignored issues
–
show
The method
getClient() does not exist on LearningLocker\StatementForwarding\Query.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 72 | 'auth' => $this->getAuth(), |
||||
|
0 ignored issues
–
show
The method
getAuth() does not exist on LearningLocker\StatementForwarding\Query.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 73 | 'headers' => [ |
||||
| 74 | 'content-type' => 'application/json' |
||||
| 75 | ], |
||||
| 76 | ]); |
||||
| 77 | |||||
| 78 | if($request->getStatusCode() === 404) { |
||||
| 79 | throw new ClientException('There was a issue connecting to Learning Locker.'); |
||||
| 80 | } |
||||
| 81 | $response = $request->json(); |
||||
| 82 | } catch (ClientException $e) { |
||||
| 83 | return $e; |
||||
| 84 | } |
||||
| 85 | |||||
| 86 | return $response; |
||||
| 87 | } |
||||
| 88 | |||||
| 89 | } |
||||
| 90 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths