Conditions | 5 |
Paths | 12 |
Total Lines | 65 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
14 | public function convert($outdir, $objQuizz) |
||
15 | { |
||
16 | $rt = new Assesment13ResourceFile(); |
||
17 | $title = $objQuizz['title']; |
||
18 | $rt->setTitle($title); |
||
19 | |||
20 | // Metadata. |
||
21 | $metadata = new CcAssesmentMetadata(); |
||
22 | $rt->setMetadata($metadata); |
||
23 | $metadata->enableFeedback(); |
||
24 | $metadata->enableHints(); |
||
25 | $metadata->enableSolutions(); |
||
26 | // Attempts. |
||
27 | $maxAttempts = $objQuizz['max_attempt']; |
||
28 | |||
29 | if ($maxAttempts > 0) { |
||
30 | // Qti does not support number of specific attempts bigger than 5 (??) |
||
31 | if ($maxAttempts > 5) { |
||
32 | $maxAttempts = CcQtiValues::unlimited; |
||
|
|||
33 | } |
||
34 | $metadata->setMaxattempts($maxAttempts); |
||
35 | } |
||
36 | |||
37 | // Time limit must be converted into minutes. |
||
38 | $timelimit = $objQuizz['expired_time']; |
||
39 | |||
40 | if ($timelimit > 0) { |
||
41 | $metadata->setTimelimit($timelimit); |
||
42 | $metadata->enableLatesubmissions(false); |
||
43 | } |
||
44 | |||
45 | $contextid = $objQuizz['source_id']; |
||
46 | |||
47 | $result = CcHelpers::processLinkedFiles($objQuizz['comment'], |
||
48 | $this->manifest, |
||
49 | $this->rootpath, |
||
50 | $contextid, |
||
51 | $outdir); |
||
52 | |||
53 | CcAssesmentHelper::addAssesmentDescription($rt, $result[0], CcQtiValues::HTMLTYPE); |
||
54 | |||
55 | // Section. |
||
56 | $section = new CcAssesmentSection(); |
||
57 | $rt->setSection($section); |
||
58 | // Process the actual questions. |
||
59 | $ndeps = CcAssesmentHelper::processQuestions($objQuizz, |
||
60 | $this->manifest, |
||
61 | $section, |
||
62 | $this->rootpath, |
||
63 | $contextid, |
||
64 | $outdir |
||
65 | ); |
||
66 | |||
67 | if ($ndeps === false) { |
||
68 | // No exportable questions in quiz or quiz has no questions |
||
69 | // so just skip it. |
||
70 | return true; |
||
71 | } |
||
72 | // Store any additional dependencies. |
||
73 | $deps = array_merge($result[1], $ndeps); |
||
74 | |||
75 | // Store everything. |
||
76 | $this->store($rt, $outdir, $title, $deps); |
||
77 | |||
78 | return true; |
||
79 | } |
||
81 |