Conditions | 13 |
Paths | 5 |
Total Lines | 76 |
Code Lines | 54 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
71 | public function init($submission, $options = []): ?edulegit_submission_entity { |
||
72 | if (empty($submission) || empty($submission->assignment) || empty($submission->userid)) { |
||
73 | return null; |
||
74 | } |
||
75 | $edulegitsubmission = $this->get_or_create_edulegit_submission($submission); |
||
76 | if (!$edulegitsubmission) { |
||
77 | return null; |
||
78 | } |
||
79 | |||
80 | $assignment = $this->repository->get_assignment_info($submission->assignment); |
||
81 | |||
82 | $callbackurl = new \moodle_url('/mod/assign/submission/edulegit/callback.php'); |
||
|
|||
83 | |||
84 | $autoplagiarismcheck = (bool) $this->config->get_plugin_or_global_config('enable_plagiarism'); |
||
85 | $autoaicheck = (bool) $this->config->get_plugin_or_global_config('enable_ai'); |
||
86 | $mustrecordevents = (bool) $this->config->get_plugin_or_global_config('enable_plagiarism'); |
||
87 | $mustrecordscreen = (bool) $this->config->get_plugin_or_global_config('enable_screen'); |
||
88 | $mustrecordcamera = (bool) $this->config->get_plugin_or_global_config('enable_camera'); |
||
89 | $mustrecognizeattentionmap = (bool) $this->config->get_plugin_or_global_config('enable_attention'); |
||
90 | |||
91 | $data = [ |
||
92 | 'meta' => [ |
||
93 | 'callbackUrl' => $callbackurl, |
||
94 | 'moodle' => $this->config->get_release(), |
||
95 | 'plugin' => $this->config->get_plugin_release(), |
||
96 | ], |
||
97 | 'user' => [ |
||
98 | 'externalId' => (int) $submission->userid, |
||
99 | 'email' => $options['user']?->email ?? null, |
||
100 | 'firstName' => $options['user']?->firstname ?? null, |
||
101 | 'lastName' => $options['user']?->lastname ?? null, |
||
102 | ], |
||
103 | 'taskUser' => [ |
||
104 | 'externalId' => (int) $edulegitsubmission->id, |
||
105 | ], |
||
106 | 'task' => [ |
||
107 | 'externalId' => (int) $assignment->id, |
||
108 | 'title' => $assignment->name ?: $assignment->id, |
||
109 | 'text' => $assignment->activity ?: ($assignment->intro ?? ''), |
||
110 | 'description' => ($assignment->intro ?? ''), |
||
111 | 'startedAt' => $assignment->allowsubmissionsfromdate ?? null, |
||
112 | 'finishedAt' => $assignment->duedate ?? ($assignment->gradingduedate ?? null), |
||
113 | ], |
||
114 | 'course' => [ |
||
115 | 'externalId' => (int) $assignment->course, |
||
116 | 'title' => $assignment->course_fullname ?: $assignment->course_shortname, |
||
117 | 'text' => $assignment->course_summary ?? '', |
||
118 | 'startedAt' => $assignment->course_startdate ?? null, |
||
119 | 'finishedAt' => $assignment->course_enddate ?? null, |
||
120 | 'setting' => [ |
||
121 | 'autoPlagiarismCheck' => $autoplagiarismcheck, |
||
122 | 'autoAiCheck' => $autoaicheck, |
||
123 | 'mustRecordEvents' => $mustrecordevents, |
||
124 | 'mustRecordScreen' => $mustrecordscreen, |
||
125 | 'mustRecordCamera' => $mustrecordcamera, |
||
126 | 'mustRecognizeAttentionMap' => $mustrecognizeattentionmap, |
||
127 | ], |
||
128 | ], |
||
129 | ]; |
||
130 | |||
131 | $response = $this->client->init_assignment($data); |
||
132 | |||
133 | $payload = $response->get_payload(); |
||
134 | $responseobject = $payload->data ?? null; |
||
135 | |||
136 | // Handle API service errors. |
||
137 | if (!$response->get_success() || empty($payload->success) || !$responseobject) { |
||
138 | $error = $payload->error ?? ($response->get_error() ?: 'EduLegit service error.'); |
||
139 | |||
140 | $edulegitsubmission->status = 0; |
||
141 | $edulegitsubmission->error = $error; |
||
142 | |||
143 | return $this->repository->update_submission($edulegitsubmission) ? $edulegitsubmission : null; |
||
144 | } |
||
145 | |||
146 | return $this->sync_submission_edulegit_response($submission, $responseobject); |
||
147 | } |
||
220 |
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