@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | public $name; |
16 | 16 | public $description; |
17 | 17 | |
18 | - /** |
|
19 | - * Constructor of the class Category |
|
18 | + /** |
|
19 | + * Constructor of the class Category |
|
20 | 20 | */ |
21 | 21 | public function __construct() |
22 | 22 | { |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | return false; |
50 | 50 | } |
51 | 51 | |
52 | - /** |
|
52 | + /** |
|
53 | 53 | * add TestCategory in the database if name doesn't already exists |
54 | - */ |
|
54 | + */ |
|
55 | 55 | public function addCategoryInBDD() |
56 | 56 | { |
57 | 57 | $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $category = $this->getCategory($id); |
111 | 111 | |
112 | 112 | if ($category) { |
113 | - $sql = "DELETE FROM $table |
|
113 | + $sql = "DELETE FROM $table |
|
114 | 114 | WHERE id= $id AND c_id=".$course_id; |
115 | 115 | Database::query($sql); |
116 | 116 | |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | return false; |
135 | - } |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
137 | + /** |
|
138 | 138 | * Modify category name or description of category with id=in_id |
139 | - */ |
|
139 | + */ |
|
140 | 140 | public function modifyCategory() |
141 | 141 | { |
142 | 142 | $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
@@ -167,30 +167,30 @@ discard block |
||
167 | 167 | } |
168 | 168 | |
169 | 169 | return false; |
170 | - } |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
172 | + /** |
|
173 | 173 | * Gets the number of question of category id=in_id |
174 | - */ |
|
174 | + */ |
|
175 | 175 | public function getCategoryQuestionsNumber() |
176 | 176 | { |
177 | - $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
178 | - $in_id = intval($this->id); |
|
179 | - $sql = "SELECT count(*) AS nb |
|
177 | + $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
178 | + $in_id = intval($this->id); |
|
179 | + $sql = "SELECT count(*) AS nb |
|
180 | 180 | FROM $table |
181 | 181 | WHERE category_id=$in_id AND c_id=".api_get_course_int_id(); |
182 | - $res = Database::query($sql); |
|
183 | - $row = Database::fetch_array($res); |
|
182 | + $res = Database::query($sql); |
|
183 | + $row = Database::fetch_array($res); |
|
184 | 184 | |
185 | - return $row['nb']; |
|
186 | - } |
|
185 | + return $row['nb']; |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
188 | + /** |
|
189 | 189 | * Return an array of all Category objects in the database |
190 | - * If in_field=="" Return an array of all category objects in the database |
|
191 | - * Otherwise, return an array of all in_field value |
|
192 | - * in the database (in_field = id or name or description) |
|
193 | - * |
|
190 | + * If in_field=="" Return an array of all category objects in the database |
|
191 | + * Otherwise, return an array of all in_field value |
|
192 | + * in the database (in_field = id or name or description) |
|
193 | + * |
|
194 | 194 | * @param string $in_field |
195 | 195 | * @param int $courseId |
196 | 196 | * @return array |
@@ -493,10 +493,10 @@ discard block |
||
493 | 493 | * @param int exercise |
494 | 494 | * @param array $check_in_question_list |
495 | 495 | * @param array $categoriesAddedInExercise |
496 | - * |
|
497 | - * @param int $exerciseId |
|
498 | - * @return array |
|
499 | - */ |
|
496 | + * |
|
497 | + * @param int $exerciseId |
|
498 | + * @return array |
|
499 | + */ |
|
500 | 500 | static function getQuestionsByCat( |
501 | 501 | $exerciseId, |
502 | 502 | $check_in_question_list = array(), |
@@ -622,9 +622,9 @@ discard block |
||
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
625 | - * Display signs [+] and/or (>0) after question title if question has options |
|
626 | - * scoreAlwaysPositive and/or uncheckedMayScore |
|
627 | - */ |
|
625 | + * Display signs [+] and/or (>0) after question title if question has options |
|
626 | + * scoreAlwaysPositive and/or uncheckedMayScore |
|
627 | + */ |
|
628 | 628 | public function displayQuestionOption($in_objQuestion) |
629 | 629 | { |
630 | 630 | if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) { |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | * key of $tabCategoryQuestions are the category id (0 for not in a category) |
641 | 641 | * value is the array of question id of this category |
642 | 642 | * Sort question by Category |
643 | - */ |
|
643 | + */ |
|
644 | 644 | public static function sortTabByBracketLabel($in_tab) |
645 | 645 | { |
646 | 646 | $tabResult = array(); |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | * count the number of questions in all categories, and return the max |
694 | 694 | * @param int $exerciseId |
695 | 695 | * @author - hubert borderiou |
696 | - */ |
|
696 | + */ |
|
697 | 697 | public static function getNumberMaxQuestionByCat($exerciseId) |
698 | 698 | { |
699 | 699 | $res_num_max = 0; |
@@ -8,19 +8,19 @@ |
||
8 | 8 | */ |
9 | 9 | class DataForm extends FormValidator |
10 | 10 | { |
11 | - const TYPE_IMPORT = 1; |
|
12 | - const TYPE_EXPORT = 2; |
|
13 | - const TYPE_EXPORT_PDF = 3; |
|
11 | + const TYPE_IMPORT = 1; |
|
12 | + const TYPE_EXPORT = 2; |
|
13 | + const TYPE_EXPORT_PDF = 3; |
|
14 | 14 | |
15 | - /** |
|
16 | - * Builds a form containing form items based on a given parameter |
|
17 | - * @param int form_type 1=import, 2=export |
|
18 | - * @param obj cat_obj the category object |
|
19 | - * @param obj res_obj the result object |
|
20 | - * @param string form name |
|
21 | - * @param method |
|
22 | - * @param action |
|
23 | - */ |
|
15 | + /** |
|
16 | + * Builds a form containing form items based on a given parameter |
|
17 | + * @param int form_type 1=import, 2=export |
|
18 | + * @param obj cat_obj the category object |
|
19 | + * @param obj res_obj the result object |
|
20 | + * @param string form name |
|
21 | + * @param method |
|
22 | + * @param action |
|
23 | + */ |
|
24 | 24 | public function __construct($form_type, $form_name, $method = 'post', $action = null, $target = '', $locked_status) |
25 | 25 | { |
26 | 26 | parent:: __construct($form_name, $method, $action, $target); |
@@ -70,7 +70,7 @@ |
||
70 | 70 | $htmlHeadXtra[] = '<style> |
71 | 71 | body { background: none;} |
72 | 72 | </style>'; |
73 | - Display::display_reduced_header(); |
|
73 | + Display::display_reduced_header(); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | $message = Session::read('attempt_remaining'); |
@@ -20,140 +20,140 @@ discard block |
||
20 | 20 | { |
21 | 21 | public $js_id; |
22 | 22 | public $answer; |
23 | - /** |
|
24 | - * Returns the HTML + JS flow corresponding to one question |
|
25 | - * |
|
26 | - * @param int $questionId The question ID |
|
27 | - * @param bool $standalone (ie including XML tag, DTD declaration, etc) |
|
28 | - * @param int $js_id The JavaScript ID for this question. |
|
29 | - * Due to the nature of interactions, we must have a natural sequence for |
|
30 | - * questions in the generated JavaScript. |
|
31 | - * @param integer $js_id |
|
23 | + /** |
|
24 | + * Returns the HTML + JS flow corresponding to one question |
|
25 | + * |
|
26 | + * @param int $questionId The question ID |
|
27 | + * @param bool $standalone (ie including XML tag, DTD declaration, etc) |
|
28 | + * @param int $js_id The JavaScript ID for this question. |
|
29 | + * Due to the nature of interactions, we must have a natural sequence for |
|
30 | + * questions in the generated JavaScript. |
|
31 | + * @param integer $js_id |
|
32 | 32 | * @return string|array |
33 | - */ |
|
34 | - public static function export_question($questionId, $standalone = true, $js_id) |
|
35 | - { |
|
36 | - $question = new ScormQuestion(); |
|
37 | - $qst = $question->read($questionId); |
|
38 | - if (!$qst) { |
|
39 | - return ''; |
|
40 | - } |
|
41 | - $question->id = $qst->id; |
|
42 | - $question->js_id = $js_id; |
|
43 | - $question->type = $qst->type; |
|
44 | - $question->question = $qst->question; |
|
45 | - $question->description = $qst->description; |
|
46 | - $question->weighting=$qst->weighting; |
|
47 | - $question->position=$qst->position; |
|
48 | - $question->picture=$qst->picture; |
|
49 | - $assessmentItem = new ScormAssessmentItem($question, $standalone); |
|
50 | - |
|
51 | - return $assessmentItem->export(); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Include the correct answer class and create answer |
|
56 | - */ |
|
57 | - public function setAnswer() |
|
58 | - { |
|
59 | - switch ($this->type) { |
|
60 | - case MCUA: |
|
61 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
62 | - $this->answer->questionJSId = $this->js_id; |
|
63 | - break; |
|
64 | - case MCMA: |
|
65 | - case GLOBAL_MULTIPLE_ANSWER: |
|
66 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
67 | - $this->answer->questionJSId = $this->js_id; |
|
68 | - break; |
|
69 | - case TF: |
|
70 | - $this->answer = new ScormAnswerTrueFalse($this->id); |
|
71 | - $this->answer->questionJSId = $this->js_id; |
|
72 | - break; |
|
73 | - case FIB: |
|
74 | - $this->answer = new ScormAnswerFillInBlanks($this->id); |
|
75 | - $this->answer->questionJSId = $this->js_id; |
|
76 | - break; |
|
77 | - case MATCHING: |
|
78 | - case MATCHING_DRAGGABLE: |
|
79 | - case DRAGGABLE: |
|
80 | - $this->answer = new ScormAnswerMatching($this->id); |
|
81 | - $this->answer->questionJSId = $this->js_id; |
|
82 | - break; |
|
83 | - case ORAL_EXPRESSION: |
|
84 | - case FREE_ANSWER: |
|
85 | - $this->answer = new ScormAnswerFree($this->id); |
|
86 | - $this->answer->questionJSId = $this->js_id; |
|
87 | - break; |
|
88 | - case HOT_SPOT: |
|
89 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
90 | - $this->answer->questionJSId = $this->js_id; |
|
91 | - break; |
|
92 | - case MULTIPLE_ANSWER_COMBINATION: |
|
93 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
94 | - $this->answer->questionJSId = $this->js_id; |
|
95 | - break; |
|
96 | - case HOT_SPOT_ORDER: |
|
97 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
98 | - $this->answer->questionJSId = $this->js_id; |
|
99 | - break; |
|
100 | - case HOT_SPOT_DELINEATION: |
|
101 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
102 | - $this->answer->questionJSId = $this->js_id; |
|
103 | - break; |
|
104 | - // not supported |
|
105 | - case UNIQUE_ANSWER_NO_OPTION: |
|
106 | - case MULTIPLE_ANSWER_TRUE_FALSE: |
|
107 | - case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE: |
|
108 | - case UNIQUE_ANSWER_IMAGE: |
|
109 | - case CALCULATED_ANSWER: |
|
110 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
111 | - $this->answer->questionJSId = $this->js_id; |
|
112 | - break; |
|
113 | - default: |
|
114 | - $this->answer = new stdClass(); |
|
115 | - $this->answer->questionJSId = $this->js_id; |
|
116 | - break; |
|
117 | - } |
|
118 | - |
|
119 | - return true; |
|
120 | - } |
|
121 | - |
|
122 | - function export() |
|
123 | - { |
|
124 | - $html = $this->getQuestionHTML(); |
|
125 | - $js = $this->getQuestionJS(); |
|
126 | - |
|
127 | - if (is_object($this->answer) && $this->answer instanceof Answer) { |
|
128 | - list($js2, $html2) = $this->answer->export(); |
|
129 | - $js .= $js2; |
|
130 | - $html .= $html2; |
|
131 | - } else { |
|
132 | - throw new \Exception('Question not supported. Exercise: '.$this->selectTitle()); |
|
133 | - } |
|
134 | - |
|
135 | - return array($js, $html); |
|
136 | - } |
|
137 | - |
|
138 | - function createAnswersForm($form) |
|
139 | - { |
|
140 | - return true; |
|
141 | - } |
|
142 | - |
|
143 | - function processAnswersCreation($form) |
|
144 | - { |
|
145 | - return true; |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * Returns an HTML-formatted question |
|
150 | - */ |
|
151 | - function getQuestionHTML() |
|
152 | - { |
|
33 | + */ |
|
34 | + public static function export_question($questionId, $standalone = true, $js_id) |
|
35 | + { |
|
36 | + $question = new ScormQuestion(); |
|
37 | + $qst = $question->read($questionId); |
|
38 | + if (!$qst) { |
|
39 | + return ''; |
|
40 | + } |
|
41 | + $question->id = $qst->id; |
|
42 | + $question->js_id = $js_id; |
|
43 | + $question->type = $qst->type; |
|
44 | + $question->question = $qst->question; |
|
45 | + $question->description = $qst->description; |
|
46 | + $question->weighting=$qst->weighting; |
|
47 | + $question->position=$qst->position; |
|
48 | + $question->picture=$qst->picture; |
|
49 | + $assessmentItem = new ScormAssessmentItem($question, $standalone); |
|
50 | + |
|
51 | + return $assessmentItem->export(); |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Include the correct answer class and create answer |
|
56 | + */ |
|
57 | + public function setAnswer() |
|
58 | + { |
|
59 | + switch ($this->type) { |
|
60 | + case MCUA: |
|
61 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
62 | + $this->answer->questionJSId = $this->js_id; |
|
63 | + break; |
|
64 | + case MCMA: |
|
65 | + case GLOBAL_MULTIPLE_ANSWER: |
|
66 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
67 | + $this->answer->questionJSId = $this->js_id; |
|
68 | + break; |
|
69 | + case TF: |
|
70 | + $this->answer = new ScormAnswerTrueFalse($this->id); |
|
71 | + $this->answer->questionJSId = $this->js_id; |
|
72 | + break; |
|
73 | + case FIB: |
|
74 | + $this->answer = new ScormAnswerFillInBlanks($this->id); |
|
75 | + $this->answer->questionJSId = $this->js_id; |
|
76 | + break; |
|
77 | + case MATCHING: |
|
78 | + case MATCHING_DRAGGABLE: |
|
79 | + case DRAGGABLE: |
|
80 | + $this->answer = new ScormAnswerMatching($this->id); |
|
81 | + $this->answer->questionJSId = $this->js_id; |
|
82 | + break; |
|
83 | + case ORAL_EXPRESSION: |
|
84 | + case FREE_ANSWER: |
|
85 | + $this->answer = new ScormAnswerFree($this->id); |
|
86 | + $this->answer->questionJSId = $this->js_id; |
|
87 | + break; |
|
88 | + case HOT_SPOT: |
|
89 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
90 | + $this->answer->questionJSId = $this->js_id; |
|
91 | + break; |
|
92 | + case MULTIPLE_ANSWER_COMBINATION: |
|
93 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
94 | + $this->answer->questionJSId = $this->js_id; |
|
95 | + break; |
|
96 | + case HOT_SPOT_ORDER: |
|
97 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
98 | + $this->answer->questionJSId = $this->js_id; |
|
99 | + break; |
|
100 | + case HOT_SPOT_DELINEATION: |
|
101 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
102 | + $this->answer->questionJSId = $this->js_id; |
|
103 | + break; |
|
104 | + // not supported |
|
105 | + case UNIQUE_ANSWER_NO_OPTION: |
|
106 | + case MULTIPLE_ANSWER_TRUE_FALSE: |
|
107 | + case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE: |
|
108 | + case UNIQUE_ANSWER_IMAGE: |
|
109 | + case CALCULATED_ANSWER: |
|
110 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
111 | + $this->answer->questionJSId = $this->js_id; |
|
112 | + break; |
|
113 | + default: |
|
114 | + $this->answer = new stdClass(); |
|
115 | + $this->answer->questionJSId = $this->js_id; |
|
116 | + break; |
|
117 | + } |
|
118 | + |
|
119 | + return true; |
|
120 | + } |
|
121 | + |
|
122 | + function export() |
|
123 | + { |
|
124 | + $html = $this->getQuestionHTML(); |
|
125 | + $js = $this->getQuestionJS(); |
|
126 | + |
|
127 | + if (is_object($this->answer) && $this->answer instanceof Answer) { |
|
128 | + list($js2, $html2) = $this->answer->export(); |
|
129 | + $js .= $js2; |
|
130 | + $html .= $html2; |
|
131 | + } else { |
|
132 | + throw new \Exception('Question not supported. Exercise: '.$this->selectTitle()); |
|
133 | + } |
|
134 | + |
|
135 | + return array($js, $html); |
|
136 | + } |
|
137 | + |
|
138 | + function createAnswersForm($form) |
|
139 | + { |
|
140 | + return true; |
|
141 | + } |
|
142 | + |
|
143 | + function processAnswersCreation($form) |
|
144 | + { |
|
145 | + return true; |
|
146 | + } |
|
147 | + |
|
148 | + /** |
|
149 | + * Returns an HTML-formatted question |
|
150 | + */ |
|
151 | + function getQuestionHTML() |
|
152 | + { |
|
153 | 153 | $title = $this->selectTitle(); |
154 | 154 | $description = $this->selectDescription(); |
155 | - $cols = 2; |
|
156 | - $s = '<tr> |
|
155 | + $cols = 2; |
|
156 | + $s = '<tr> |
|
157 | 157 | <td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;"> |
158 | 158 | '.$title.' |
159 | 159 | </td> |
@@ -163,16 +163,16 @@ discard block |
||
163 | 163 | <i>'.$description.'</i> |
164 | 164 | </td> |
165 | 165 | </tr>'; |
166 | - return $s; |
|
167 | - } |
|
166 | + return $s; |
|
167 | + } |
|
168 | 168 | |
169 | - /** |
|
170 | - * Return the JavaScript code bound to the question |
|
171 | - */ |
|
172 | - public function getQuestionJS() |
|
173 | - { |
|
174 | - $weight = $this->selectWeighting(); |
|
175 | - $js = 'questions.push('.$this->js_id.');'."\n"; |
|
169 | + /** |
|
170 | + * Return the JavaScript code bound to the question |
|
171 | + */ |
|
172 | + public function getQuestionJS() |
|
173 | + { |
|
174 | + $weight = $this->selectWeighting(); |
|
175 | + $js = 'questions.push('.$this->js_id.');'."\n"; |
|
176 | 176 | |
177 | 177 | switch ($this->type) { |
178 | 178 | case ORAL_EXPRESSION: |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $script .= file_get_contents(api_get_path(LIBRARY_PATH) . 'wami-recorder/gui.js'); |
182 | 182 | $js .= $script;*/ |
183 | 183 | break; |
184 | - case HOT_SPOT: |
|
184 | + case HOT_SPOT: |
|
185 | 185 | //put the max score to 0 to avoid discounting the points of |
186 | 186 | //non-exported quiz types in the SCORM |
187 | 187 | $weight = 0; |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | } |
190 | 190 | $js .= 'questions_score_max['.$this->js_id.'] = '.$weight.";"; |
191 | 191 | |
192 | - return $js; |
|
193 | - } |
|
192 | + return $js; |
|
193 | + } |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -200,29 +200,29 @@ discard block |
||
200 | 200 | */ |
201 | 201 | class ScormAnswerMultipleChoice extends Answer |
202 | 202 | { |
203 | - /** |
|
204 | - * Return HTML code for possible answers |
|
205 | - */ |
|
206 | - function export() |
|
207 | - { |
|
208 | - $js = ''; |
|
209 | - $html = '<tr><td colspan="2"><table width="100%">'; |
|
210 | - $type = $this->getQuestionType(); |
|
211 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'; |
|
212 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'; |
|
203 | + /** |
|
204 | + * Return HTML code for possible answers |
|
205 | + */ |
|
206 | + function export() |
|
207 | + { |
|
208 | + $js = ''; |
|
209 | + $html = '<tr><td colspan="2"><table width="100%">'; |
|
210 | + $type = $this->getQuestionType(); |
|
211 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'; |
|
212 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'; |
|
213 | 213 | |
214 | 214 | $jstmpw .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'; |
215 | 215 | |
216 | - //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM |
|
217 | - //if ($type == MCMA || $type == MULTIPLE_ANSWER_COMBINATION ) { |
|
218 | - if ($type == MCMA) { |
|
216 | + //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM |
|
217 | + //if ($type == MCMA || $type == MULTIPLE_ANSWER_COMBINATION ) { |
|
218 | + if ($type == MCMA) { |
|
219 | 219 | $id = 1; |
220 | - $jstmp = ''; |
|
221 | - $jstmpc = ''; |
|
220 | + $jstmp = ''; |
|
221 | + $jstmpc = ''; |
|
222 | 222 | foreach ($this->answer as $i => $answer) { |
223 | - $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i; |
|
224 | - $html .= |
|
225 | - '<tr> |
|
223 | + $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i; |
|
224 | + $html .= |
|
225 | + '<tr> |
|
226 | 226 | <td align="center" width="5%"> |
227 | 227 | <input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" /> |
228 | 228 | </td> |
@@ -231,19 +231,19 @@ discard block |
||
231 | 231 | </td> |
232 | 232 | </tr>'; |
233 | 233 | |
234 | - $jstmp .= $i.','; |
|
234 | + $jstmp .= $i.','; |
|
235 | 235 | if ($this->correct[$i]) { |
236 | 236 | $jstmpc .= $i.','; |
237 | 237 | } |
238 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";"; |
|
238 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";"; |
|
239 | 239 | $jstmpw .= 'questions_answers_correct['.$this->questionJSId.']['.$i.'] = '.$this->correct[$i].';'; |
240 | - $id++; |
|
241 | - } |
|
242 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
240 | + $id++; |
|
241 | + } |
|
242 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
243 | 243 | $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n"; |
244 | - $js .= $jstmpw; |
|
245 | - } elseif ($type == MULTIPLE_ANSWER_COMBINATION) { |
|
246 | - $js = ''; |
|
244 | + $js .= $jstmpw; |
|
245 | + } elseif ($type == MULTIPLE_ANSWER_COMBINATION) { |
|
246 | + $js = ''; |
|
247 | 247 | $id = 1; |
248 | 248 | $jstmp = ''; |
249 | 249 | $jstmpc = ''; |
@@ -270,15 +270,15 @@ discard block |
||
270 | 270 | $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'; |
271 | 271 | $js .= 'questions_types['.$this->questionJSId.'] = "exact";'; |
272 | 272 | $js .= $jstmpw; |
273 | - } else { |
|
274 | - $id = 1; |
|
275 | - $jstmp = ''; |
|
276 | - $jstmpc = ''; |
|
273 | + } else { |
|
274 | + $id = 1; |
|
275 | + $jstmp = ''; |
|
276 | + $jstmpc = ''; |
|
277 | 277 | foreach ($this->answer as $i => $answer) { |
278 | 278 | $identifier = 'question_'.$this->questionJSId.'_unique_'.$i; |
279 | - $identifier_name = 'question_'.$this->questionJSId.'_unique_answer'; |
|
280 | - $html .= |
|
281 | - '<tr> |
|
279 | + $identifier_name = 'question_'.$this->questionJSId.'_unique_answer'; |
|
280 | + $html .= |
|
281 | + '<tr> |
|
282 | 282 | <td align="center" width="5%"> |
283 | 283 | <input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="checkbox"/> |
284 | 284 | </td> |
@@ -286,22 +286,22 @@ discard block |
||
286 | 286 | <label for="'.$identifier.'">' . Security::remove_XSS($this->answer[$i]) . '</label> |
287 | 287 | </td> |
288 | 288 | </tr>'; |
289 | - $jstmp .= $i.','; |
|
289 | + $jstmp .= $i.','; |
|
290 | 290 | if ($this->correct[$i]) { |
291 | 291 | $jstmpc .= $i; |
292 | 292 | } |
293 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";"; |
|
293 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";"; |
|
294 | 294 | $jstmpw .= 'questions_answers_correct['.$this->questionJSId.']['.$i.'] = '.$this->correct[$i].';'; |
295 | - $id++; |
|
296 | - } |
|
297 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'; |
|
298 | - $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'; |
|
299 | - $js .= $jstmpw; |
|
300 | - } |
|
301 | - $html .= '</table></td></tr>'; |
|
302 | - |
|
303 | - return array($js, $html); |
|
304 | - } |
|
295 | + $id++; |
|
296 | + } |
|
297 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'; |
|
298 | + $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'; |
|
299 | + $js .= $jstmpw; |
|
300 | + } |
|
301 | + $html .= '</table></td></tr>'; |
|
302 | + |
|
303 | + return array($js, $html); |
|
304 | + } |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
@@ -310,21 +310,21 @@ discard block |
||
310 | 310 | */ |
311 | 311 | class ScormAnswerTrueFalse extends Answer |
312 | 312 | { |
313 | - /** |
|
314 | - * Return the XML flow for the possible answers. |
|
315 | - * That's one <response_lid>, containing several <flow_label> |
|
316 | - * |
|
317 | - * @author Amand Tihon <[email protected]> |
|
318 | - */ |
|
319 | - function export() |
|
320 | - { |
|
321 | - $js = ''; |
|
322 | - $html = '<tr><td colspan="2"><table width="100%">'; |
|
323 | - $identifier = 'question_'.$this->questionJSId.'_tf'; |
|
324 | - $identifier_true = $identifier.'_true'; |
|
325 | - $identifier_false = $identifier.'_false'; |
|
326 | - $html .= |
|
327 | - '<tr> |
|
313 | + /** |
|
314 | + * Return the XML flow for the possible answers. |
|
315 | + * That's one <response_lid>, containing several <flow_label> |
|
316 | + * |
|
317 | + * @author Amand Tihon <[email protected]> |
|
318 | + */ |
|
319 | + function export() |
|
320 | + { |
|
321 | + $js = ''; |
|
322 | + $html = '<tr><td colspan="2"><table width="100%">'; |
|
323 | + $identifier = 'question_'.$this->questionJSId.'_tf'; |
|
324 | + $identifier_true = $identifier.'_true'; |
|
325 | + $identifier_false = $identifier.'_false'; |
|
326 | + $html .= |
|
327 | + '<tr> |
|
328 | 328 | <td align="center" width="5%"> |
329 | 329 | <input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" /> |
330 | 330 | </td> |
@@ -332,8 +332,8 @@ discard block |
||
332 | 332 | <label for="'.$identifier_true.'">' . get_lang('True') . '</label> |
333 | 333 | </td> |
334 | 334 | </tr>'; |
335 | - $html .= |
|
336 | - '<tr> |
|
335 | + $html .= |
|
336 | + '<tr> |
|
337 | 337 | <td align="center" width="5%"> |
338 | 338 | <input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" /> |
339 | 339 | </td> |
@@ -341,20 +341,20 @@ discard block |
||
341 | 341 | <label for="'.$identifier_false.'">' . get_lang('False') . '</label> |
342 | 342 | </td> |
343 | 343 | </tr></table></td></tr>'; |
344 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n"; |
|
345 | - $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n"; |
|
346 | - if ($this->response === 'TRUE') { |
|
347 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
|
348 | - } else { |
|
349 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n"; |
|
350 | - } |
|
351 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
352 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
353 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n"; |
|
354 | - $js .= $jstmpw; |
|
355 | - |
|
356 | - return array($js, $html); |
|
357 | - } |
|
344 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n"; |
|
345 | + $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n"; |
|
346 | + if ($this->response === 'TRUE') { |
|
347 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
|
348 | + } else { |
|
349 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n"; |
|
350 | + } |
|
351 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
352 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
353 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n"; |
|
354 | + $js .= $jstmpw; |
|
355 | + |
|
356 | + return array($js, $html); |
|
357 | + } |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
@@ -363,76 +363,76 @@ discard block |
||
363 | 363 | */ |
364 | 364 | class ScormAnswerFillInBlanks extends Answer |
365 | 365 | { |
366 | - /** |
|
367 | - * Export the text with missing words. |
|
368 | - * |
|
369 | - * As a side effect, it stores two lists in the class : |
|
370 | - * the missing words and their respective weightings. |
|
371 | - */ |
|
372 | - function export() |
|
373 | - { |
|
374 | - global $charset; |
|
375 | - $js = ''; |
|
376 | - $html = '<tr><td colspan="2"><table width="100%">'; |
|
377 | - // get all enclosed answers |
|
378 | - $blankList = array(); |
|
379 | - // build replacement |
|
380 | - $replacementList = array(); |
|
381 | - foreach ($this->answer as $i => $answer) { |
|
382 | - $blankList[] = '['.$answer.']'; |
|
383 | - } |
|
384 | - |
|
385 | - // splits text and weightings that are joined with the character '::' |
|
386 | - list($answer,$weight)=explode('::',$answer); |
|
387 | - $weights = explode(',',$weight); |
|
388 | - // because [] is parsed here we follow this procedure: |
|
389 | - // 1. find everything between the [ and ] tags |
|
390 | - $i=1; |
|
391 | - $jstmp = ''; |
|
392 | - $jstmpc = ''; |
|
393 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
394 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
395 | - $startlocations=api_strpos($answer,'['); |
|
396 | - $endlocations=api_strpos($answer,']'); |
|
397 | - while ($startlocations !== false && $endlocations !== false) { |
|
398 | - $texstring = api_substr($answer,$startlocations,($endlocations-$startlocations)+1); |
|
399 | - $answer = api_substr_replace( |
|
366 | + /** |
|
367 | + * Export the text with missing words. |
|
368 | + * |
|
369 | + * As a side effect, it stores two lists in the class : |
|
370 | + * the missing words and their respective weightings. |
|
371 | + */ |
|
372 | + function export() |
|
373 | + { |
|
374 | + global $charset; |
|
375 | + $js = ''; |
|
376 | + $html = '<tr><td colspan="2"><table width="100%">'; |
|
377 | + // get all enclosed answers |
|
378 | + $blankList = array(); |
|
379 | + // build replacement |
|
380 | + $replacementList = array(); |
|
381 | + foreach ($this->answer as $i => $answer) { |
|
382 | + $blankList[] = '['.$answer.']'; |
|
383 | + } |
|
384 | + |
|
385 | + // splits text and weightings that are joined with the character '::' |
|
386 | + list($answer,$weight)=explode('::',$answer); |
|
387 | + $weights = explode(',',$weight); |
|
388 | + // because [] is parsed here we follow this procedure: |
|
389 | + // 1. find everything between the [ and ] tags |
|
390 | + $i=1; |
|
391 | + $jstmp = ''; |
|
392 | + $jstmpc = ''; |
|
393 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
394 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
395 | + $startlocations=api_strpos($answer,'['); |
|
396 | + $endlocations=api_strpos($answer,']'); |
|
397 | + while ($startlocations !== false && $endlocations !== false) { |
|
398 | + $texstring = api_substr($answer,$startlocations,($endlocations-$startlocations)+1); |
|
399 | + $answer = api_substr_replace( |
|
400 | 400 | $answer, |
401 | 401 | '<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />', |
402 | 402 | $startlocations, |
403 | 403 | ($endlocations-$startlocations)+1 |
404 | 404 | ); |
405 | 405 | $jstmp .= $i.','; |
406 | - if (!empty($texstring)) { |
|
407 | - $sub = api_substr($texstring, 1, -1); |
|
408 | - if (!empty($sub)) { |
|
409 | - $jstmpc .= "'" . api_htmlentities($sub, ENT_QUOTES, $charset) . "',"; |
|
410 | - } |
|
411 | - } |
|
406 | + if (!empty($texstring)) { |
|
407 | + $sub = api_substr($texstring, 1, -1); |
|
408 | + if (!empty($sub)) { |
|
409 | + $jstmpc .= "'" . api_htmlentities($sub, ENT_QUOTES, $charset) . "',"; |
|
410 | + } |
|
411 | + } |
|
412 | 412 | $my_weight = explode('@', $weights[$i - 1]); |
413 | 413 | if (count($my_weight) == 2) { |
414 | 414 | $weight_db = $my_weight[0]; |
415 | 415 | } else { |
416 | 416 | $weight_db = $my_weight[0]; |
417 | 417 | } |
418 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n"; |
|
419 | - $i++; |
|
420 | - $startlocations = api_strpos($answer, '['); |
|
421 | - $endlocations = api_strpos($answer, ']'); |
|
422 | - } |
|
418 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n"; |
|
419 | + $i++; |
|
420 | + $startlocations = api_strpos($answer, '['); |
|
421 | + $endlocations = api_strpos($answer, ']'); |
|
422 | + } |
|
423 | 423 | |
424 | - $html .= '<tr> |
|
424 | + $html .= '<tr> |
|
425 | 425 | <td> |
426 | 426 | '.$answer.' |
427 | 427 | </td> |
428 | 428 | </tr></table></td></tr>'; |
429 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n"; |
|
430 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n"; |
|
431 | - $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n"; |
|
432 | - $js .= $jstmpw; |
|
429 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n"; |
|
430 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n"; |
|
431 | + $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n"; |
|
432 | + $js .= $jstmpw; |
|
433 | 433 | |
434 | - return array($js,$html); |
|
435 | - } |
|
434 | + return array($js,$html); |
|
435 | + } |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -441,65 +441,65 @@ discard block |
||
441 | 441 | */ |
442 | 442 | class ScormAnswerMatching extends Answer |
443 | 443 | { |
444 | - /** |
|
445 | - * Export the question part as a matrix-choice, with only one possible answer per line. |
|
446 | - * @author Amand Tihon <[email protected]> |
|
447 | - */ |
|
448 | - function export() |
|
449 | - { |
|
450 | - $js = ''; |
|
451 | - $html = '<tr><td colspan="2"><table width="100%">'; |
|
452 | - // prepare list of right proposition to allow |
|
453 | - // - easiest display |
|
454 | - // - easiest randomisation if needed one day |
|
455 | - // (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...) |
|
456 | - |
|
457 | - // get max length of displayed array |
|
458 | - |
|
459 | - $nbrAnswers = $this->selectNbrAnswers(); |
|
460 | - $cpt1='A'; |
|
461 | - $cpt2=1; |
|
462 | - $Select = array(); |
|
463 | - $qId = $this->questionJSId; |
|
464 | - $s = ''; |
|
465 | - $jstmp = ''; |
|
466 | - $jstmpc = ''; |
|
467 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
468 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
469 | - |
|
470 | - for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) { |
|
471 | - $identifier = 'question_'.$qId.'_matching_'; |
|
472 | - $answer=$this->selectAnswer($answerId); |
|
473 | - $answerCorrect=$this->isCorrect($answerId); |
|
474 | - $weight=$this->selectWeighting($answerId); |
|
475 | - $jstmp .= $answerId.','; |
|
476 | - |
|
477 | - if (!$answerCorrect) { |
|
478 | - // options (A, B, C, ...) that will be put into the list-box |
|
479 | - $Select[$answerId]['Lettre']=$cpt1; |
|
480 | - // answers that will be shown at the right side |
|
481 | - $Select[$answerId]['Reponse'] = $answer; |
|
482 | - $cpt1++; |
|
483 | - } else { |
|
484 | - $s.='<tr>'; |
|
485 | - $s.='<td width="40%" valign="top"><b>'.$cpt2.'</b>. '.$answer."</td>"; |
|
486 | - $s.='<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
487 | - $s.=' <option value="0">--</option>'; |
|
488 | - // fills the list-box |
|
444 | + /** |
|
445 | + * Export the question part as a matrix-choice, with only one possible answer per line. |
|
446 | + * @author Amand Tihon <[email protected]> |
|
447 | + */ |
|
448 | + function export() |
|
449 | + { |
|
450 | + $js = ''; |
|
451 | + $html = '<tr><td colspan="2"><table width="100%">'; |
|
452 | + // prepare list of right proposition to allow |
|
453 | + // - easiest display |
|
454 | + // - easiest randomisation if needed one day |
|
455 | + // (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...) |
|
456 | + |
|
457 | + // get max length of displayed array |
|
458 | + |
|
459 | + $nbrAnswers = $this->selectNbrAnswers(); |
|
460 | + $cpt1='A'; |
|
461 | + $cpt2=1; |
|
462 | + $Select = array(); |
|
463 | + $qId = $this->questionJSId; |
|
464 | + $s = ''; |
|
465 | + $jstmp = ''; |
|
466 | + $jstmpc = ''; |
|
467 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
468 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
469 | + |
|
470 | + for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) { |
|
471 | + $identifier = 'question_'.$qId.'_matching_'; |
|
472 | + $answer=$this->selectAnswer($answerId); |
|
473 | + $answerCorrect=$this->isCorrect($answerId); |
|
474 | + $weight=$this->selectWeighting($answerId); |
|
475 | + $jstmp .= $answerId.','; |
|
476 | + |
|
477 | + if (!$answerCorrect) { |
|
478 | + // options (A, B, C, ...) that will be put into the list-box |
|
479 | + $Select[$answerId]['Lettre']=$cpt1; |
|
480 | + // answers that will be shown at the right side |
|
481 | + $Select[$answerId]['Reponse'] = $answer; |
|
482 | + $cpt1++; |
|
483 | + } else { |
|
484 | + $s.='<tr>'; |
|
485 | + $s.='<td width="40%" valign="top"><b>'.$cpt2.'</b>. '.$answer."</td>"; |
|
486 | + $s.='<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
487 | + $s.=' <option value="0">--</option>'; |
|
488 | + // fills the list-box |
|
489 | 489 | foreach ($Select as $key => $val) { |
490 | 490 | $s .= '<option value="'.$key.'">'.$val['Lettre'].'</option>'; |
491 | 491 | } // end foreach() |
492 | 492 | |
493 | - $s.='</select> </td>'; |
|
494 | - $s.='<td width="40%" valign="top">'; |
|
493 | + $s.='</select> </td>'; |
|
494 | + $s.='<td width="40%" valign="top">'; |
|
495 | 495 | if (isset($Select[$cpt2])) { |
496 | 496 | $s .= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
497 | 497 | } else { |
498 | 498 | $s .= ' '; |
499 | 499 | } |
500 | - $s.="</td></tr>"; |
|
500 | + $s.="</td></tr>"; |
|
501 | 501 | |
502 | - $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
|
502 | + $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
|
503 | 503 | |
504 | 504 | $my_weight = explode('@', $weight); |
505 | 505 | if (count($my_weight) == 2) { |
@@ -507,32 +507,32 @@ discard block |
||
507 | 507 | } else { |
508 | 508 | $weight = $my_weight[0]; |
509 | 509 | } |
510 | - $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n"; |
|
511 | - $cpt2++; |
|
512 | - |
|
513 | - // if the left side of the "matching" has been completely shown |
|
514 | - if ($answerId == $nbrAnswers) { |
|
515 | - // if there remain answers to be shown on the right side |
|
516 | - while (isset($Select[$cpt2])) { |
|
517 | - $s.= '<tr>'; |
|
518 | - $s.= '<td width="60%" colspan="2"> </td>'; |
|
519 | - $s.= '<td width="40%" valign="top">'; |
|
520 | - $s.= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
521 | - $s.= "</td></tr>"; |
|
522 | - $cpt2++; |
|
523 | - } // end while() |
|
524 | - } // end if() |
|
525 | - } |
|
526 | - } |
|
527 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
528 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
529 | - $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n"; |
|
530 | - $js .= $jstmpw; |
|
531 | - $html .= $s; |
|
532 | - $html .= '</table></td></tr>' . "\n"; |
|
533 | - |
|
534 | - return array($js, $html); |
|
535 | - } |
|
510 | + $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n"; |
|
511 | + $cpt2++; |
|
512 | + |
|
513 | + // if the left side of the "matching" has been completely shown |
|
514 | + if ($answerId == $nbrAnswers) { |
|
515 | + // if there remain answers to be shown on the right side |
|
516 | + while (isset($Select[$cpt2])) { |
|
517 | + $s.= '<tr>'; |
|
518 | + $s.= '<td width="60%" colspan="2"> </td>'; |
|
519 | + $s.= '<td width="40%" valign="top">'; |
|
520 | + $s.= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
521 | + $s.= "</td></tr>"; |
|
522 | + $cpt2++; |
|
523 | + } // end while() |
|
524 | + } // end if() |
|
525 | + } |
|
526 | + } |
|
527 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
528 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
529 | + $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n"; |
|
530 | + $js .= $jstmpw; |
|
531 | + $html .= $s; |
|
532 | + $html .= '</table></td></tr>' . "\n"; |
|
533 | + |
|
534 | + return array($js, $html); |
|
535 | + } |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
@@ -541,19 +541,19 @@ discard block |
||
541 | 541 | */ |
542 | 542 | class ScormAnswerFree extends Answer |
543 | 543 | { |
544 | - /** |
|
545 | - * Export the text with missing words. |
|
546 | - * |
|
547 | - * As a side effect, it stores two lists in the class : |
|
548 | - * the missing words and their respective weightings. |
|
549 | - * |
|
550 | - */ |
|
551 | - function export() |
|
552 | - { |
|
553 | - $js = ''; |
|
544 | + /** |
|
545 | + * Export the text with missing words. |
|
546 | + * |
|
547 | + * As a side effect, it stores two lists in the class : |
|
548 | + * the missing words and their respective weightings. |
|
549 | + * |
|
550 | + */ |
|
551 | + function export() |
|
552 | + { |
|
553 | + $js = ''; |
|
554 | 554 | $identifier = 'question_'.$this->questionJSId.'_free'; |
555 | - // currently the free answers cannot be displayed, so ignore the textarea |
|
556 | - $html = '<tr><td colspan="2">'; |
|
555 | + // currently the free answers cannot be displayed, so ignore the textarea |
|
556 | + $html = '<tr><td colspan="2">'; |
|
557 | 557 | $type = $this->getQuestionType(); |
558 | 558 | |
559 | 559 | if ($type == ORAL_EXPRESSION) { |
@@ -565,21 +565,21 @@ discard block |
||
565 | 565 | $layout = $template->get_template('document/record_audio.tpl'); |
566 | 566 | $html .= $template->fetch($layout);*/ |
567 | 567 | |
568 | - $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
568 | + $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
569 | 569 | |
570 | 570 | return array($js, $html); |
571 | 571 | } |
572 | 572 | |
573 | 573 | $html .= '<textarea minlength="20" name="'.$identifier.'" id="'.$identifier.'" ></textarea>'; |
574 | 574 | $html .= '</td></tr>'; |
575 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'; |
|
576 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = "";'; |
|
577 | - $js .= 'questions_types['.$this->questionJSId.'] = \'free\';'; |
|
578 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = "0";'; |
|
579 | - $js .= $jstmpw; |
|
580 | - |
|
581 | - return array($js, $html); |
|
582 | - } |
|
575 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'; |
|
576 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = "";'; |
|
577 | + $js .= 'questions_types['.$this->questionJSId.'] = \'free\';'; |
|
578 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = "0";'; |
|
579 | + $js .= $jstmpw; |
|
580 | + |
|
581 | + return array($js, $html); |
|
582 | + } |
|
583 | 583 | } |
584 | 584 | /** |
585 | 585 | * This class handles the SCORM export of hotpot questions |
@@ -587,63 +587,63 @@ discard block |
||
587 | 587 | */ |
588 | 588 | class ScormAnswerHotspot extends Answer |
589 | 589 | { |
590 | - /** |
|
591 | - * Returns the javascript code that goes with HotSpot exercises |
|
592 | - * @return string The JavaScript code |
|
593 | - */ |
|
594 | - function get_js_header() |
|
595 | - { |
|
596 | - if ($this->standalone) { |
|
597 | - $header = '<script>'; |
|
598 | - $header .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js'); |
|
599 | - $header .= '</script>'; |
|
600 | - //because this header closes so many times the <script> tag, we have to reopen our own |
|
601 | - $header .= '<script>'; |
|
602 | - $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
603 | - $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
604 | - $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
605 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
606 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
607 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
608 | - $header .= $jstmpw; |
|
609 | - } else { |
|
610 | - $header = ''; |
|
611 | - $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
612 | - $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
613 | - $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
614 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
615 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
616 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n"; |
|
617 | - $header .= $jstmpw; |
|
618 | - } |
|
619 | - |
|
620 | - return $header; |
|
621 | - } |
|
622 | - /** |
|
623 | - * Export the text with missing words. |
|
624 | - * |
|
625 | - * As a side effect, it stores two lists in the class : |
|
626 | - * the missing words and their respective weightings. |
|
627 | - * |
|
628 | - */ |
|
629 | - function export() |
|
630 | - { |
|
631 | - $js = $this->get_js_header(); |
|
632 | - $html = '<tr><td colspan="2"><table width="100%">'; |
|
633 | - // some javascript must be added for that kind of questions |
|
634 | - $html .= ''; |
|
635 | - |
|
636 | - // Get the answers, make a list |
|
637 | - $nbrAnswers=$this->selectNbrAnswers(); |
|
638 | - |
|
639 | - $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>'; |
|
590 | + /** |
|
591 | + * Returns the javascript code that goes with HotSpot exercises |
|
592 | + * @return string The JavaScript code |
|
593 | + */ |
|
594 | + function get_js_header() |
|
595 | + { |
|
596 | + if ($this->standalone) { |
|
597 | + $header = '<script>'; |
|
598 | + $header .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js'); |
|
599 | + $header .= '</script>'; |
|
600 | + //because this header closes so many times the <script> tag, we have to reopen our own |
|
601 | + $header .= '<script>'; |
|
602 | + $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
603 | + $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
604 | + $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
605 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
606 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
607 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
608 | + $header .= $jstmpw; |
|
609 | + } else { |
|
610 | + $header = ''; |
|
611 | + $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
612 | + $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
613 | + $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
614 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
615 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
616 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n"; |
|
617 | + $header .= $jstmpw; |
|
618 | + } |
|
619 | + |
|
620 | + return $header; |
|
621 | + } |
|
622 | + /** |
|
623 | + * Export the text with missing words. |
|
624 | + * |
|
625 | + * As a side effect, it stores two lists in the class : |
|
626 | + * the missing words and their respective weightings. |
|
627 | + * |
|
628 | + */ |
|
629 | + function export() |
|
630 | + { |
|
631 | + $js = $this->get_js_header(); |
|
632 | + $html = '<tr><td colspan="2"><table width="100%">'; |
|
633 | + // some javascript must be added for that kind of questions |
|
634 | + $html .= ''; |
|
635 | + |
|
636 | + // Get the answers, make a list |
|
637 | + $nbrAnswers=$this->selectNbrAnswers(); |
|
638 | + |
|
639 | + $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>'; |
|
640 | 640 | for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) { |
641 | 641 | $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>'; |
642 | 642 | } |
643 | 643 | $answer_list .= '</ol></div>'; |
644 | - $canClick = true; |
|
645 | - $relPath = api_get_path(REL_PATH); |
|
646 | - $html .= <<<HTML |
|
644 | + $canClick = true; |
|
645 | + $relPath = api_get_path(REL_PATH); |
|
646 | + $html .= <<<HTML |
|
647 | 647 | <tr> |
648 | 648 | <td> |
649 | 649 | <div id="hotspot-{$this->questionJSId}"></div> |
@@ -663,13 +663,13 @@ discard block |
||
663 | 663 | </td> |
664 | 664 | <tr> |
665 | 665 | HTML; |
666 | - $html .= '</table></td></tr>'; |
|
666 | + $html .= '</table></td></tr>'; |
|
667 | 667 | |
668 | - // currently the free answers cannot be displayed, so ignore the textarea |
|
669 | - $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
668 | + // currently the free answers cannot be displayed, so ignore the textarea |
|
669 | + $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
670 | 670 | |
671 | - return array($js, $html); |
|
672 | - } |
|
671 | + return array($js, $html); |
|
672 | + } |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | /** |
@@ -684,32 +684,32 @@ discard block |
||
684 | 684 | */ |
685 | 685 | class ScormAssessmentItem |
686 | 686 | { |
687 | - public $question; |
|
688 | - public $question_ident; |
|
689 | - public $answer; |
|
690 | - public $standalone; |
|
691 | - |
|
692 | - /** |
|
693 | - * Constructor. |
|
694 | - * |
|
695 | - * @param ScormQuestion $question The Question object we want to export. |
|
696 | - */ |
|
697 | - public function __construct($question, $standalone = false) |
|
698 | - { |
|
699 | - $this->question = $question; |
|
700 | - $this->question->setAnswer(); |
|
701 | - $this->questionIdent = "QST_" . $question->id ; |
|
702 | - $this->standalone = $standalone; |
|
703 | - } |
|
704 | - |
|
705 | - /** |
|
706 | - * Start the XML flow. |
|
707 | - * |
|
708 | - * This opens the <item> block, with correct attributes. |
|
709 | - * |
|
710 | - */ |
|
711 | - function start_page() |
|
712 | - { |
|
687 | + public $question; |
|
688 | + public $question_ident; |
|
689 | + public $answer; |
|
690 | + public $standalone; |
|
691 | + |
|
692 | + /** |
|
693 | + * Constructor. |
|
694 | + * |
|
695 | + * @param ScormQuestion $question The Question object we want to export. |
|
696 | + */ |
|
697 | + public function __construct($question, $standalone = false) |
|
698 | + { |
|
699 | + $this->question = $question; |
|
700 | + $this->question->setAnswer(); |
|
701 | + $this->questionIdent = "QST_" . $question->id ; |
|
702 | + $this->standalone = $standalone; |
|
703 | + } |
|
704 | + |
|
705 | + /** |
|
706 | + * Start the XML flow. |
|
707 | + * |
|
708 | + * This opens the <item> block, with correct attributes. |
|
709 | + * |
|
710 | + */ |
|
711 | + function start_page() |
|
712 | + { |
|
713 | 713 | $head = ''; |
714 | 714 | if ($this->standalone) { |
715 | 715 | $charset = 'UTF-8'; |
@@ -717,89 +717,89 @@ discard block |
||
717 | 717 | $head .= '<html>'; |
718 | 718 | } |
719 | 719 | |
720 | - return $head; |
|
721 | - } |
|
720 | + return $head; |
|
721 | + } |
|
722 | 722 | |
723 | - /** |
|
724 | - * End the XML flow, closing the </item> tag. |
|
725 | - * |
|
726 | - */ |
|
727 | - function end_page() |
|
723 | + /** |
|
724 | + * End the XML flow, closing the </item> tag. |
|
725 | + * |
|
726 | + */ |
|
727 | + function end_page() |
|
728 | + { |
|
729 | + if ($this->standalone) { |
|
730 | + return '</html>'; |
|
731 | + } |
|
732 | + |
|
733 | + return ''; |
|
734 | + } |
|
735 | + |
|
736 | + /** |
|
737 | + * Start document header |
|
738 | + */ |
|
739 | + function start_header() |
|
740 | + { |
|
741 | + if ($this->standalone) { |
|
742 | + return '<head>'; |
|
743 | + } |
|
744 | + |
|
745 | + return ''; |
|
746 | + } |
|
747 | + |
|
748 | + /** |
|
749 | + * Print CSS inclusion |
|
750 | + */ |
|
751 | + function css() |
|
752 | + { |
|
753 | + $css = ''; |
|
754 | + if ($this->standalone) { |
|
755 | + $css = '<style type="text/css" media="screen, projection">'; |
|
756 | + $css .= '/*<![CDATA[*/'."\n"; |
|
757 | + $css .= '/*]]>*/'."\n"; |
|
758 | + $css .= '</style>'."\n"; |
|
759 | + $css .= '<style type="text/css" media="print">'; |
|
760 | + $css .= '/*<![CDATA[*/'."\n"; |
|
761 | + $css .= '/*]]>*/'."\n"; |
|
762 | + $css .= '</style>'; |
|
763 | + } |
|
764 | + |
|
765 | + return $css; |
|
766 | + } |
|
767 | + |
|
768 | + /** |
|
769 | + * End document header |
|
770 | + */ |
|
771 | + function end_header() |
|
772 | + { |
|
773 | + if ($this->standalone) { |
|
774 | + return '</head>'; |
|
775 | + } |
|
776 | + |
|
777 | + return ''; |
|
778 | + } |
|
779 | + /** |
|
780 | + * Start the itemBody |
|
781 | + * |
|
782 | + */ |
|
783 | + function start_js() |
|
728 | 784 | { |
729 | - if ($this->standalone) { |
|
730 | - return '</html>'; |
|
731 | - } |
|
732 | - |
|
733 | - return ''; |
|
734 | - } |
|
735 | - |
|
736 | - /** |
|
737 | - * Start document header |
|
738 | - */ |
|
739 | - function start_header() |
|
740 | - { |
|
741 | - if ($this->standalone) { |
|
742 | - return '<head>'; |
|
743 | - } |
|
744 | - |
|
745 | - return ''; |
|
746 | - } |
|
747 | - |
|
748 | - /** |
|
749 | - * Print CSS inclusion |
|
750 | - */ |
|
751 | - function css() |
|
752 | - { |
|
753 | - $css = ''; |
|
754 | - if ($this->standalone) { |
|
755 | - $css = '<style type="text/css" media="screen, projection">'; |
|
756 | - $css .= '/*<![CDATA[*/'."\n"; |
|
757 | - $css .= '/*]]>*/'."\n"; |
|
758 | - $css .= '</style>'."\n"; |
|
759 | - $css .= '<style type="text/css" media="print">'; |
|
760 | - $css .= '/*<![CDATA[*/'."\n"; |
|
761 | - $css .= '/*]]>*/'."\n"; |
|
762 | - $css .= '</style>'; |
|
763 | - } |
|
764 | - |
|
765 | - return $css; |
|
766 | - } |
|
767 | - |
|
768 | - /** |
|
769 | - * End document header |
|
770 | - */ |
|
771 | - function end_header() |
|
772 | - { |
|
773 | - if ($this->standalone) { |
|
774 | - return '</head>'; |
|
775 | - } |
|
776 | - |
|
777 | - return ''; |
|
778 | - } |
|
779 | - /** |
|
780 | - * Start the itemBody |
|
781 | - * |
|
782 | - */ |
|
783 | - function start_js() |
|
784 | - { |
|
785 | 785 | $js = '<script type="text/javascript" src="assets/api_wrapper.js"></script>'; |
786 | - if ($this->standalone) { |
|
787 | - return '<script>'; |
|
788 | - } |
|
789 | - return $js; |
|
790 | - } |
|
791 | - |
|
792 | - /** |
|
793 | - * Common JS functions |
|
794 | - */ |
|
795 | - function common_js() |
|
796 | - { |
|
797 | - $js = 'var questions = new Array();'; |
|
798 | - $js .= 'var questions_answers = new Array();'; |
|
799 | - $js .= 'var questions_answers_correct = new Array();'; |
|
800 | - $js .= 'var questions_types = new Array();'; |
|
801 | - $js .= "\n" . |
|
802 | - '/** |
|
786 | + if ($this->standalone) { |
|
787 | + return '<script>'; |
|
788 | + } |
|
789 | + return $js; |
|
790 | + } |
|
791 | + |
|
792 | + /** |
|
793 | + * Common JS functions |
|
794 | + */ |
|
795 | + function common_js() |
|
796 | + { |
|
797 | + $js = 'var questions = new Array();'; |
|
798 | + $js .= 'var questions_answers = new Array();'; |
|
799 | + $js .= 'var questions_answers_correct = new Array();'; |
|
800 | + $js .= 'var questions_types = new Array();'; |
|
801 | + $js .= "\n" . |
|
802 | + '/** |
|
803 | 803 | * Assigns any event handler to any element |
804 | 804 | * @param object Element on which the event is added |
805 | 805 | * @param string Name of event |
@@ -834,79 +834,79 @@ discard block |
||
834 | 834 | addEvent(window,\'unload\',unloadPage,false); |
835 | 835 | }'."\n\n"; |
836 | 836 | |
837 | - $js .= ''; |
|
838 | - $js .= 'addEvent(window,\'load\',addListeners,false);'."\n"; |
|
837 | + $js .= ''; |
|
838 | + $js .= 'addEvent(window,\'load\',addListeners,false);'."\n"; |
|
839 | 839 | if ($this->standalone) { |
840 | 840 | return $js."\n"; |
841 | 841 | } |
842 | - return ''; |
|
843 | - } |
|
844 | - |
|
845 | - /** |
|
846 | - * End the itemBody part. |
|
847 | - * |
|
848 | - */ |
|
849 | - function end_js() |
|
850 | - { |
|
842 | + return ''; |
|
843 | + } |
|
844 | + |
|
845 | + /** |
|
846 | + * End the itemBody part. |
|
847 | + * |
|
848 | + */ |
|
849 | + function end_js() |
|
850 | + { |
|
851 | 851 | if ($this->standalone) { |
852 | 852 | return '</script>'; |
853 | 853 | } |
854 | 854 | |
855 | 855 | return ''; |
856 | - } |
|
857 | - |
|
858 | - /** |
|
859 | - * Start the itemBody |
|
860 | - * |
|
861 | - */ |
|
862 | - function start_body() |
|
863 | - { |
|
864 | - if ($this->standalone) { |
|
865 | - return '<body><form id="dokeos_scorm_form" method="post" action="">'; |
|
866 | - } |
|
867 | - |
|
868 | - return ''; |
|
869 | - } |
|
870 | - |
|
871 | - /** |
|
872 | - * End the itemBody part. |
|
873 | - * |
|
874 | - */ |
|
875 | - function end_body() |
|
876 | - { |
|
877 | - if ($this->standalone) { |
|
878 | - return '<br /><input class="btn" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>'; |
|
879 | - } |
|
880 | - |
|
881 | - return ''; |
|
882 | - } |
|
883 | - |
|
884 | - /** |
|
885 | - * Export the question as a SCORM Item. |
|
886 | - * This is a default behaviour, some classes may want to override this. |
|
887 | - * @return string|array A string, the XML flow for an Item. |
|
888 | - */ |
|
889 | - function export() |
|
890 | - { |
|
891 | - list($js, $html) = $this->question->export(); |
|
892 | - if ($this->standalone) { |
|
893 | - $res = $this->start_page() |
|
894 | - . $this->start_header() |
|
895 | - . $this->css() |
|
896 | - . $this->start_js() |
|
897 | - . $this->common_js() |
|
898 | - . $js |
|
899 | - . $this->end_js() |
|
900 | - . $this->end_header() |
|
901 | - . $this->start_body() |
|
856 | + } |
|
857 | + |
|
858 | + /** |
|
859 | + * Start the itemBody |
|
860 | + * |
|
861 | + */ |
|
862 | + function start_body() |
|
863 | + { |
|
864 | + if ($this->standalone) { |
|
865 | + return '<body><form id="dokeos_scorm_form" method="post" action="">'; |
|
866 | + } |
|
867 | + |
|
868 | + return ''; |
|
869 | + } |
|
870 | + |
|
871 | + /** |
|
872 | + * End the itemBody part. |
|
873 | + * |
|
874 | + */ |
|
875 | + function end_body() |
|
876 | + { |
|
877 | + if ($this->standalone) { |
|
878 | + return '<br /><input class="btn" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>'; |
|
879 | + } |
|
880 | + |
|
881 | + return ''; |
|
882 | + } |
|
883 | + |
|
884 | + /** |
|
885 | + * Export the question as a SCORM Item. |
|
886 | + * This is a default behaviour, some classes may want to override this. |
|
887 | + * @return string|array A string, the XML flow for an Item. |
|
888 | + */ |
|
889 | + function export() |
|
890 | + { |
|
891 | + list($js, $html) = $this->question->export(); |
|
892 | + if ($this->standalone) { |
|
893 | + $res = $this->start_page() |
|
894 | + . $this->start_header() |
|
895 | + . $this->css() |
|
896 | + . $this->start_js() |
|
897 | + . $this->common_js() |
|
898 | + . $js |
|
899 | + . $this->end_js() |
|
900 | + . $this->end_header() |
|
901 | + . $this->start_body() |
|
902 | 902 | . $html |
903 | - . $this->end_body() |
|
904 | - . $this->end_page(); |
|
905 | - return $res; |
|
906 | - } else { |
|
907 | - return array($js, $html); |
|
908 | - } |
|
909 | - } |
|
903 | + . $this->end_body() |
|
904 | + . $this->end_page(); |
|
905 | + return $res; |
|
906 | + } else { |
|
907 | + return array($js, $html); |
|
908 | + } |
|
909 | + } |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | /** |
@@ -923,103 +923,103 @@ discard block |
||
923 | 923 | */ |
924 | 924 | class ScormSection |
925 | 925 | { |
926 | - public $exercise; |
|
927 | - public $standalone; |
|
928 | - |
|
929 | - /** |
|
930 | - * Send a complete exercise in SCORM format, from its ID |
|
931 | - * |
|
932 | - * @param Exercise $exercise The exercise to export |
|
933 | - * @param boolean $standalone Wether it should include XML tag and DTD line. |
|
934 | - * @return string XML as a string, or an empty string if there's no exercise with given ID. |
|
935 | - */ |
|
936 | - public static function export_exercise_to_scorm(Exercise $exercise, $standalone = true) |
|
937 | - { |
|
938 | - $ims = new ScormSection($exercise); |
|
939 | - $xml = $ims->export($standalone); |
|
940 | - |
|
941 | - return $xml; |
|
942 | - } |
|
943 | - |
|
944 | - /** |
|
945 | - * Constructor. |
|
946 | - * @param Exercise $exe The Exercise instance to export |
|
947 | - * @author Amand Tihon <[email protected]> |
|
948 | - */ |
|
949 | - public function __construct($exe) |
|
950 | - { |
|
951 | - $this->exercise = $exe; |
|
952 | - } |
|
953 | - |
|
954 | - /** |
|
955 | - * Start the XML flow. |
|
956 | - * |
|
957 | - * This opens the <item> block, with correct attributes. |
|
958 | - * |
|
959 | - */ |
|
960 | - function start_page() |
|
961 | - { |
|
926 | + public $exercise; |
|
927 | + public $standalone; |
|
928 | + |
|
929 | + /** |
|
930 | + * Send a complete exercise in SCORM format, from its ID |
|
931 | + * |
|
932 | + * @param Exercise $exercise The exercise to export |
|
933 | + * @param boolean $standalone Wether it should include XML tag and DTD line. |
|
934 | + * @return string XML as a string, or an empty string if there's no exercise with given ID. |
|
935 | + */ |
|
936 | + public static function export_exercise_to_scorm(Exercise $exercise, $standalone = true) |
|
937 | + { |
|
938 | + $ims = new ScormSection($exercise); |
|
939 | + $xml = $ims->export($standalone); |
|
940 | + |
|
941 | + return $xml; |
|
942 | + } |
|
943 | + |
|
944 | + /** |
|
945 | + * Constructor. |
|
946 | + * @param Exercise $exe The Exercise instance to export |
|
947 | + * @author Amand Tihon <[email protected]> |
|
948 | + */ |
|
949 | + public function __construct($exe) |
|
950 | + { |
|
951 | + $this->exercise = $exe; |
|
952 | + } |
|
953 | + |
|
954 | + /** |
|
955 | + * Start the XML flow. |
|
956 | + * |
|
957 | + * This opens the <item> block, with correct attributes. |
|
958 | + * |
|
959 | + */ |
|
960 | + function start_page() |
|
961 | + { |
|
962 | 962 | $charset = 'UTF-8'; |
963 | - $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?><html>'; |
|
964 | - |
|
965 | - return $head; |
|
966 | - } |
|
967 | - |
|
968 | - /** |
|
969 | - * End the XML flow, closing the </item> tag. |
|
970 | - * |
|
971 | - */ |
|
972 | - function end_page() |
|
973 | - { |
|
974 | - return '</html>'; |
|
975 | - } |
|
976 | - |
|
977 | - /** |
|
978 | - * Start document header |
|
979 | - */ |
|
980 | - function start_header() |
|
981 | - { |
|
982 | - return '<head>'; |
|
983 | - } |
|
984 | - |
|
985 | - /** |
|
986 | - * Print CSS inclusion |
|
987 | - */ |
|
988 | - private function css() |
|
989 | - { |
|
990 | - return ''; |
|
991 | - } |
|
992 | - |
|
993 | - /** |
|
994 | - * End document header |
|
995 | - */ |
|
963 | + $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?><html>'; |
|
964 | + |
|
965 | + return $head; |
|
966 | + } |
|
967 | + |
|
968 | + /** |
|
969 | + * End the XML flow, closing the </item> tag. |
|
970 | + * |
|
971 | + */ |
|
972 | + function end_page() |
|
973 | + { |
|
974 | + return '</html>'; |
|
975 | + } |
|
976 | + |
|
977 | + /** |
|
978 | + * Start document header |
|
979 | + */ |
|
980 | + function start_header() |
|
981 | + { |
|
982 | + return '<head>'; |
|
983 | + } |
|
984 | + |
|
985 | + /** |
|
986 | + * Print CSS inclusion |
|
987 | + */ |
|
988 | + private function css() |
|
989 | + { |
|
990 | + return ''; |
|
991 | + } |
|
992 | + |
|
993 | + /** |
|
994 | + * End document header |
|
995 | + */ |
|
996 | 996 | private function end_header() |
997 | - { |
|
998 | - return '</head>'; |
|
999 | - } |
|
1000 | - |
|
1001 | - /** |
|
1002 | - * Start the itemBody |
|
1003 | - * |
|
1004 | - */ |
|
997 | + { |
|
998 | + return '</head>'; |
|
999 | + } |
|
1000 | + |
|
1001 | + /** |
|
1002 | + * Start the itemBody |
|
1003 | + * |
|
1004 | + */ |
|
1005 | 1005 | private function start_js() |
1006 | - { |
|
1007 | - return '<script>'; |
|
1008 | - } |
|
1009 | - |
|
1010 | - /** |
|
1011 | - * Common JS functions |
|
1012 | - */ |
|
1013 | - public function common_js() |
|
1014 | - { |
|
1015 | - $js = file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js'); |
|
1016 | - |
|
1017 | - $js .= 'var questions = new Array();' . "\n"; |
|
1018 | - $js .= 'var questions_answers = new Array();' . "\n"; |
|
1019 | - $js .= 'var questions_answers_correct = new Array();' . "\n"; |
|
1020 | - $js .= 'var questions_types = new Array();' . "\n"; |
|
1021 | - $js .= "\n" . |
|
1022 | - '/** |
|
1006 | + { |
|
1007 | + return '<script>'; |
|
1008 | + } |
|
1009 | + |
|
1010 | + /** |
|
1011 | + * Common JS functions |
|
1012 | + */ |
|
1013 | + public function common_js() |
|
1014 | + { |
|
1015 | + $js = file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js'); |
|
1016 | + |
|
1017 | + $js .= 'var questions = new Array();' . "\n"; |
|
1018 | + $js .= 'var questions_answers = new Array();' . "\n"; |
|
1019 | + $js .= 'var questions_answers_correct = new Array();' . "\n"; |
|
1020 | + $js .= 'var questions_types = new Array();' . "\n"; |
|
1021 | + $js .= "\n" . |
|
1022 | + '/** |
|
1023 | 1023 | * Assigns any event handler to any element |
1024 | 1024 | * @param object Element on which the event is added |
1025 | 1025 | * @param string Name of event |
@@ -1061,76 +1061,76 @@ discard block |
||
1061 | 1061 | } |
1062 | 1062 | '."\n"; |
1063 | 1063 | |
1064 | - $js .= ''; |
|
1065 | - $js .= 'addEvent(window,\'load\',addListeners,false);'."\n"; |
|
1066 | - return $js. "\n"; |
|
1067 | - } |
|
1064 | + $js .= ''; |
|
1065 | + $js .= 'addEvent(window,\'load\',addListeners,false);'."\n"; |
|
1066 | + return $js. "\n"; |
|
1067 | + } |
|
1068 | + |
|
1069 | + /** |
|
1070 | + * End the itemBody part. |
|
1071 | + * |
|
1072 | + */ |
|
1073 | + function end_js() |
|
1074 | + { |
|
1075 | + return '</script>'; |
|
1076 | + } |
|
1077 | + |
|
1078 | + /** |
|
1079 | + * Start the itemBody |
|
1080 | + * |
|
1081 | + */ |
|
1082 | + function start_body() |
|
1083 | + { |
|
1084 | + return '<body>'. |
|
1085 | + '<h1>'.$this->exercise->selectTitle().'</h1><p>'.$this->exercise->selectDescription()."</p>". |
|
1086 | + '<form id="dokeos_scorm_form" method="post" action="">'. |
|
1087 | + '<table width="100%">'; |
|
1088 | + } |
|
1089 | + |
|
1090 | + /** |
|
1091 | + * End the itemBody part. |
|
1092 | + * |
|
1093 | + */ |
|
1094 | + function end_body() |
|
1095 | + { |
|
1096 | + return '</table><br /><input class="btn btn-primary" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>'; |
|
1097 | + } |
|
1068 | 1098 | |
1069 | - /** |
|
1070 | - * End the itemBody part. |
|
1071 | - * |
|
1072 | - */ |
|
1073 | - function end_js() |
|
1099 | + /** |
|
1100 | + * Export the question as a SCORM Item. |
|
1101 | + * |
|
1102 | + * This is a default behaviour, some classes may want to override this. |
|
1103 | + * |
|
1104 | + * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
1105 | + * @return string string, the XML flow for an Item. |
|
1106 | + */ |
|
1107 | + function export() |
|
1074 | 1108 | { |
1075 | - return '</script>'; |
|
1076 | - } |
|
1077 | - |
|
1078 | - /** |
|
1079 | - * Start the itemBody |
|
1080 | - * |
|
1081 | - */ |
|
1082 | - function start_body() |
|
1083 | - { |
|
1084 | - return '<body>'. |
|
1085 | - '<h1>'.$this->exercise->selectTitle().'</h1><p>'.$this->exercise->selectDescription()."</p>". |
|
1086 | - '<form id="dokeos_scorm_form" method="post" action="">'. |
|
1087 | - '<table width="100%">'; |
|
1088 | - } |
|
1089 | - |
|
1090 | - /** |
|
1091 | - * End the itemBody part. |
|
1092 | - * |
|
1093 | - */ |
|
1094 | - function end_body() |
|
1095 | - { |
|
1096 | - return '</table><br /><input class="btn btn-primary" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>'; |
|
1097 | - } |
|
1098 | - |
|
1099 | - /** |
|
1100 | - * Export the question as a SCORM Item. |
|
1101 | - * |
|
1102 | - * This is a default behaviour, some classes may want to override this. |
|
1103 | - * |
|
1104 | - * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
1105 | - * @return string string, the XML flow for an Item. |
|
1106 | - */ |
|
1107 | - function export() |
|
1108 | - { |
|
1109 | - global $charset; |
|
1110 | - |
|
1111 | - $head = ''; |
|
1112 | - if ($this->standalone) { |
|
1113 | - $head = '<?xml version = "1.0" encoding = "' . $charset . '" standalone = "no"?>' . "\n" |
|
1114 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"; |
|
1115 | - } |
|
1116 | - |
|
1117 | - list($js, $html) = $this->export_questions(); |
|
1118 | - $res = $this->start_page() |
|
1119 | - . $this->start_header() |
|
1120 | - . $this->css() |
|
1109 | + global $charset; |
|
1110 | + |
|
1111 | + $head = ''; |
|
1112 | + if ($this->standalone) { |
|
1113 | + $head = '<?xml version = "1.0" encoding = "' . $charset . '" standalone = "no"?>' . "\n" |
|
1114 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"; |
|
1115 | + } |
|
1116 | + |
|
1117 | + list($js, $html) = $this->export_questions(); |
|
1118 | + $res = $this->start_page() |
|
1119 | + . $this->start_header() |
|
1120 | + . $this->css() |
|
1121 | 1121 | . $this->globalAssets() |
1122 | - . $this->start_js() |
|
1123 | - . $this->common_js() |
|
1124 | - . $js |
|
1125 | - . $this->end_js() |
|
1126 | - . $this->end_header() |
|
1127 | - . $this->start_body() |
|
1128 | - . $html |
|
1129 | - . $this->end_body() |
|
1130 | - . $this->end_page(); |
|
1131 | - |
|
1132 | - return $res; |
|
1133 | - } |
|
1122 | + . $this->start_js() |
|
1123 | + . $this->common_js() |
|
1124 | + . $js |
|
1125 | + . $this->end_js() |
|
1126 | + . $this->end_header() |
|
1127 | + . $this->start_body() |
|
1128 | + . $html |
|
1129 | + . $this->end_body() |
|
1130 | + . $this->end_page(); |
|
1131 | + |
|
1132 | + return $res; |
|
1133 | + } |
|
1134 | 1134 | |
1135 | 1135 | /** |
1136 | 1136 | * @return string |
@@ -1144,21 +1144,21 @@ discard block |
||
1144 | 1144 | return $assets; |
1145 | 1145 | } |
1146 | 1146 | |
1147 | - /** |
|
1148 | - * Export the questions, as a succession of <items> |
|
1149 | - * @author Amand Tihon <[email protected]> |
|
1150 | - */ |
|
1151 | - function export_questions() |
|
1152 | - { |
|
1153 | - $js = $html = ""; |
|
1154 | - $js_id = 0; |
|
1155 | - foreach ($this->exercise->selectQuestionList() as $q) { |
|
1156 | - list($jstmp, $htmltmp)= ScormQuestion::export_question($q, false, $js_id); |
|
1157 | - $js .= $jstmp."\n"; |
|
1158 | - $html .= $htmltmp."\n"; |
|
1159 | - ++$js_id; |
|
1160 | - } |
|
1161 | - |
|
1162 | - return array($js, $html); |
|
1163 | - } |
|
1147 | + /** |
|
1148 | + * Export the questions, as a succession of <items> |
|
1149 | + * @author Amand Tihon <[email protected]> |
|
1150 | + */ |
|
1151 | + function export_questions() |
|
1152 | + { |
|
1153 | + $js = $html = ""; |
|
1154 | + $js_id = 0; |
|
1155 | + foreach ($this->exercise->selectQuestionList() as $q) { |
|
1156 | + list($jstmp, $htmltmp)= ScormQuestion::export_question($q, false, $js_id); |
|
1157 | + $js .= $jstmp."\n"; |
|
1158 | + $html .= $htmltmp."\n"; |
|
1159 | + ++$js_id; |
|
1160 | + } |
|
1161 | + |
|
1162 | + return array($js, $html); |
|
1163 | + } |
|
1164 | 1164 | } |
@@ -289,7 +289,7 @@ |
||
289 | 289 | echo '<div class="actions" >'; |
290 | 290 | echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'ticket/new_ticket.php?project_id='.$projectId.'">' . |
291 | 291 | Display::return_icon('add.png', get_lang('Add'), '', '32') . |
292 | - '</a>'; |
|
292 | + '</a>'; |
|
293 | 293 | echo '</div>'; |
294 | 294 | } |
295 | 295 | } |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | class CourseRestorer |
25 | 25 | { |
26 | 26 | /** |
27 | - * The course-object |
|
28 | - */ |
|
27 | + * The course-object |
|
28 | + */ |
|
29 | 29 | public $course; |
30 | 30 | public $destination_course_info; |
31 | 31 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | 'events', |
45 | 45 | 'forum_category', |
46 | 46 | 'forums', |
47 | - // 'forum_topics', |
|
47 | + // 'forum_topics', |
|
48 | 48 | 'glossary', |
49 | 49 | 'quizzes', |
50 | 50 | 'test_category', |
@@ -112,15 +112,15 @@ discard block |
||
112 | 112 | $this->tool_copy_settings = $array; |
113 | 113 | } |
114 | 114 | |
115 | - /** |
|
116 | - * Restore a course. |
|
115 | + /** |
|
116 | + * Restore a course. |
|
117 | 117 | * |
118 | - * @param string $destination_course_code code of the Chamilo-course in |
|
119 | - * @param int $session_id |
|
120 | - * @param bool $update_course_settings Course settings are going to be restore? |
|
118 | + * @param string $destination_course_code code of the Chamilo-course in |
|
119 | + * @param int $session_id |
|
120 | + * @param bool $update_course_settings Course settings are going to be restore? |
|
121 | 121 | * @param bool $respect_base_content |
122 | 122 | * @return false|null |
123 | - */ |
|
123 | + */ |
|
124 | 124 | public function restore( |
125 | 125 | $destination_course_code = '', |
126 | 126 | $session_id = 0, |
@@ -256,17 +256,17 @@ discard block |
||
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | - /** |
|
260 | - * Restore only harmless course settings: |
|
259 | + /** |
|
260 | + * Restore only harmless course settings: |
|
261 | 261 | * course_language, visibility, department_name,department_url, |
262 | 262 | * subscribe, unsubscribe ,category_code |
263 | - * |
|
264 | - * @param string $destination_course_code |
|
265 | - */ |
|
263 | + * |
|
264 | + * @param string $destination_course_code |
|
265 | + */ |
|
266 | 266 | public function restore_course_settings($destination_course_code) |
267 | 267 | { |
268 | - $origin_course_info = api_get_course_info($destination_course_code); |
|
269 | - $course_info = $this->course->info; |
|
268 | + $origin_course_info = api_get_course_info($destination_course_code); |
|
269 | + $course_info = $this->course->info; |
|
270 | 270 | $params['course_language'] = $course_info['language']; |
271 | 271 | $params['visibility'] = $course_info['visibility']; |
272 | 272 | $params['department_name'] = $course_info['department_name']; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $params['subscribe'] = $course_info['subscribe_allowed']; |
277 | 277 | $params['unsubscribe'] = $course_info['unsubscribe']; |
278 | 278 | CourseManager::update_attributes($origin_course_info['real_id'], $params); |
279 | - } |
|
279 | + } |
|
280 | 280 | |
281 | 281 | /** |
282 | 282 | * Restore documents |
@@ -922,56 +922,56 @@ discard block |
||
922 | 922 | unset($_SESSION['new_base_foldername']); |
923 | 923 | unset($_SESSION['orig_base_foldername']); |
924 | 924 | unset($_SESSION['new_base_path']); |
925 | - } |
|
925 | + } |
|
926 | 926 | |
927 | - /** |
|
928 | - * Restore scorm documents |
|
929 | - * TODO @TODO check that the restore function with renaming doesn't break the scorm structure! |
|
927 | + /** |
|
928 | + * Restore scorm documents |
|
929 | + * TODO @TODO check that the restore function with renaming doesn't break the scorm structure! |
|
930 | 930 | * see #7029 |
931 | - */ |
|
932 | - public function restore_scorm_documents() |
|
931 | + */ |
|
932 | + public function restore_scorm_documents() |
|
933 | 933 | { |
934 | - $perm = api_get_permissions_for_new_directories(); |
|
934 | + $perm = api_get_permissions_for_new_directories(); |
|
935 | 935 | |
936 | - if ($this->course->has_resources(RESOURCE_SCORM)) { |
|
937 | - $resources = $this->course->resources; |
|
936 | + if ($this->course->has_resources(RESOURCE_SCORM)) { |
|
937 | + $resources = $this->course->resources; |
|
938 | 938 | |
939 | - foreach ($resources[RESOURCE_SCORM] as $document) { |
|
940 | - $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
941 | - @mkdir(dirname($path.$document->path), $perm, true); |
|
939 | + foreach ($resources[RESOURCE_SCORM] as $document) { |
|
940 | + $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
941 | + @mkdir(dirname($path.$document->path), $perm, true); |
|
942 | 942 | |
943 | - if (file_exists($path.$document->path)) { |
|
944 | - switch ($this->file_option) { |
|
945 | - case FILE_OVERWRITE: |
|
946 | - rmdirr($path.$document->path); |
|
943 | + if (file_exists($path.$document->path)) { |
|
944 | + switch ($this->file_option) { |
|
945 | + case FILE_OVERWRITE: |
|
946 | + rmdirr($path.$document->path); |
|
947 | 947 | copyDirTo( |
948 | 948 | $this->course->backup_path . '/' . $document->path, |
949 | 949 | $path . dirname($document->path), |
950 | 950 | false |
951 | 951 | ); |
952 | - break; |
|
953 | - case FILE_SKIP: |
|
954 | - break; |
|
952 | + break; |
|
953 | + case FILE_SKIP: |
|
954 | + break; |
|
955 | 955 | case FILE_RENAME: |
956 | - $i = 1; |
|
957 | - $ext = explode('.', basename($document->path)); |
|
958 | - if (count($ext) > 1) { |
|
959 | - $ext = array_pop($ext); |
|
960 | - $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
961 | - $ext = '.'.$ext; |
|
962 | - } else { |
|
963 | - $ext = ''; |
|
964 | - $file_name_no_ext = $document->path; |
|
965 | - } |
|
966 | - |
|
967 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
968 | - $file_exists = file_exists($path.$new_file_name); |
|
969 | - |
|
970 | - while ($file_exists) { |
|
971 | - $i ++; |
|
972 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
973 | - $file_exists = file_exists($path.$new_file_name); |
|
974 | - } |
|
956 | + $i = 1; |
|
957 | + $ext = explode('.', basename($document->path)); |
|
958 | + if (count($ext) > 1) { |
|
959 | + $ext = array_pop($ext); |
|
960 | + $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
961 | + $ext = '.'.$ext; |
|
962 | + } else { |
|
963 | + $ext = ''; |
|
964 | + $file_name_no_ext = $document->path; |
|
965 | + } |
|
966 | + |
|
967 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
968 | + $file_exists = file_exists($path.$new_file_name); |
|
969 | + |
|
970 | + while ($file_exists) { |
|
971 | + $i ++; |
|
972 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
973 | + $file_exists = file_exists($path.$new_file_name); |
|
974 | + } |
|
975 | 975 | |
976 | 976 | rename( |
977 | 977 | $this->course->backup_path . '/' . $document->path, |
@@ -987,30 +987,30 @@ discard block |
||
987 | 987 | $this->course->backup_path . '/' . $document->path |
988 | 988 | ); |
989 | 989 | |
990 | - break; |
|
991 | - } // end switch |
|
992 | - } else { |
|
990 | + break; |
|
991 | + } // end switch |
|
992 | + } else { |
|
993 | 993 | // end if file exists |
994 | 994 | copyDirTo( |
995 | 995 | $this->course->backup_path . '/' . $document->path, |
996 | 996 | $path . dirname($document->path), |
997 | 997 | false |
998 | 998 | ); |
999 | - } |
|
1000 | - } // end for each |
|
1001 | - } |
|
1002 | - } |
|
1003 | - |
|
1004 | - /** |
|
1005 | - * Restore forums |
|
1006 | - */ |
|
1007 | - public function restore_forums($sessionId = 0) |
|
999 | + } |
|
1000 | + } // end for each |
|
1001 | + } |
|
1002 | + } |
|
1003 | + |
|
1004 | + /** |
|
1005 | + * Restore forums |
|
1006 | + */ |
|
1007 | + public function restore_forums($sessionId = 0) |
|
1008 | 1008 | { |
1009 | - if ($this->course->has_resources(RESOURCE_FORUM)) { |
|
1009 | + if ($this->course->has_resources(RESOURCE_FORUM)) { |
|
1010 | 1010 | $sessionId = intval($sessionId); |
1011 | - $table_forum = Database::get_course_table(TABLE_FORUM); |
|
1012 | - $resources = $this->course->resources; |
|
1013 | - foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
|
1011 | + $table_forum = Database::get_course_table(TABLE_FORUM); |
|
1012 | + $resources = $this->course->resources; |
|
1013 | + foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
|
1014 | 1014 | $params = (array)$forum->obj; |
1015 | 1015 | $cat_id = ''; |
1016 | 1016 | if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) && |
@@ -1057,33 +1057,33 @@ discard block |
||
1057 | 1057 | Database::query($sql); |
1058 | 1058 | } |
1059 | 1059 | |
1060 | - $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id; |
|
1061 | - |
|
1062 | - $forum_topics = 0; |
|
1063 | - if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) { |
|
1064 | - foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
|
1065 | - if ($topic->obj->forum_id == $id) { |
|
1066 | - $this->restore_topic($topic_id, $new_id, $sessionId); |
|
1067 | - $forum_topics ++; |
|
1068 | - } |
|
1069 | - } |
|
1070 | - } |
|
1071 | - if ($forum_topics > 0) { |
|
1072 | - $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
|
1060 | + $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id; |
|
1061 | + |
|
1062 | + $forum_topics = 0; |
|
1063 | + if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) { |
|
1064 | + foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
|
1065 | + if ($topic->obj->forum_id == $id) { |
|
1066 | + $this->restore_topic($topic_id, $new_id, $sessionId); |
|
1067 | + $forum_topics ++; |
|
1068 | + } |
|
1069 | + } |
|
1070 | + } |
|
1071 | + if ($forum_topics > 0) { |
|
1072 | + $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
|
1073 | 1073 | WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id; |
1074 | - Database::query($sql); |
|
1075 | - } |
|
1076 | - } |
|
1077 | - } |
|
1078 | - } |
|
1079 | - |
|
1080 | - /** |
|
1081 | - * Restore forum-categories |
|
1082 | - */ |
|
1074 | + Database::query($sql); |
|
1075 | + } |
|
1076 | + } |
|
1077 | + } |
|
1078 | + } |
|
1079 | + |
|
1080 | + /** |
|
1081 | + * Restore forum-categories |
|
1082 | + */ |
|
1083 | 1083 | public function restore_forum_category($my_id = null, $sessionId = 0) |
1084 | 1084 | { |
1085 | - $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY); |
|
1086 | - $resources = $this->course->resources; |
|
1085 | + $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY); |
|
1086 | + $resources = $this->course->resources; |
|
1087 | 1087 | if (!empty($resources[RESOURCE_FORUMCATEGORY])) { |
1088 | 1088 | foreach ($resources[RESOURCE_FORUMCATEGORY] as $id => $forum_cat) { |
1089 | 1089 | if (!empty($my_id)) { |
@@ -1121,16 +1121,16 @@ discard block |
||
1121 | 1121 | } |
1122 | 1122 | } |
1123 | 1123 | } |
1124 | - } |
|
1124 | + } |
|
1125 | 1125 | |
1126 | - /** |
|
1127 | - * Restore a forum-topic |
|
1128 | - * @param false|string $forum_id |
|
1129 | - */ |
|
1126 | + /** |
|
1127 | + * Restore a forum-topic |
|
1128 | + * @param false|string $forum_id |
|
1129 | + */ |
|
1130 | 1130 | public function restore_topic($thread_id, $forum_id, $sessionId = 0) |
1131 | 1131 | { |
1132 | - $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
1133 | - $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
|
1132 | + $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
1133 | + $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
|
1134 | 1134 | |
1135 | 1135 | $params = (array)$topic->obj; |
1136 | 1136 | $params = self::DBUTF8_array($params); |
@@ -1167,27 +1167,27 @@ discard block |
||
1167 | 1167 | $sessionId |
1168 | 1168 | ); |
1169 | 1169 | |
1170 | - $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id; |
|
1171 | - $topic_replies = -1; |
|
1172 | - |
|
1173 | - foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) { |
|
1174 | - if ($post->obj->thread_id == $thread_id) { |
|
1175 | - $topic_replies++; |
|
1176 | - $this->restore_post($post_id, $new_id, $forum_id, $sessionId); |
|
1177 | - } |
|
1178 | - } |
|
1179 | - return $new_id; |
|
1180 | - } |
|
1181 | - |
|
1182 | - /** |
|
1183 | - * Restore a forum-post |
|
1184 | - * @TODO Restore tree-structure of posts. For example: attachments to posts. |
|
1185 | - * @param false|string $topic_id |
|
1186 | - */ |
|
1170 | + $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id; |
|
1171 | + $topic_replies = -1; |
|
1172 | + |
|
1173 | + foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) { |
|
1174 | + if ($post->obj->thread_id == $thread_id) { |
|
1175 | + $topic_replies++; |
|
1176 | + $this->restore_post($post_id, $new_id, $forum_id, $sessionId); |
|
1177 | + } |
|
1178 | + } |
|
1179 | + return $new_id; |
|
1180 | + } |
|
1181 | + |
|
1182 | + /** |
|
1183 | + * Restore a forum-post |
|
1184 | + * @TODO Restore tree-structure of posts. For example: attachments to posts. |
|
1185 | + * @param false|string $topic_id |
|
1186 | + */ |
|
1187 | 1187 | public function restore_post($id, $topic_id, $forum_id, $sessionId = 0) |
1188 | 1188 | { |
1189 | - $table_post = Database :: get_course_table(TABLE_FORUM_POST); |
|
1190 | - $post = $this->course->resources[RESOURCE_FORUMPOST][$id]; |
|
1189 | + $table_post = Database :: get_course_table(TABLE_FORUM_POST); |
|
1190 | + $post = $this->course->resources[RESOURCE_FORUMPOST][$id]; |
|
1191 | 1191 | $params = (array) $post->obj; |
1192 | 1192 | $params['c_id'] = $this->destination_course_id; |
1193 | 1193 | $params['forum_id'] = $forum_id; |
@@ -1223,37 +1223,37 @@ discard block |
||
1223 | 1223 | null, |
1224 | 1224 | $sessionId |
1225 | 1225 | ); |
1226 | - $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id; |
|
1226 | + $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id; |
|
1227 | 1227 | |
1228 | - return $new_id; |
|
1229 | - } |
|
1228 | + return $new_id; |
|
1229 | + } |
|
1230 | 1230 | |
1231 | - /** |
|
1232 | - * Restore links |
|
1233 | - */ |
|
1231 | + /** |
|
1232 | + * Restore links |
|
1233 | + */ |
|
1234 | 1234 | public function restore_links($session_id = 0) |
1235 | 1235 | { |
1236 | - if ($this->course->has_resources(RESOURCE_LINK)) { |
|
1237 | - $link_table = Database :: get_course_table(TABLE_LINK); |
|
1238 | - $resources = $this->course->resources; |
|
1236 | + if ($this->course->has_resources(RESOURCE_LINK)) { |
|
1237 | + $link_table = Database :: get_course_table(TABLE_LINK); |
|
1238 | + $resources = $this->course->resources; |
|
1239 | 1239 | |
1240 | - foreach ($resources[RESOURCE_LINK] as $id => $link) { |
|
1240 | + foreach ($resources[RESOURCE_LINK] as $id => $link) { |
|
1241 | 1241 | $cat_id = $this->restore_link_category( |
1242 | 1242 | $link->category_id, |
1243 | 1243 | $session_id |
1244 | 1244 | ); |
1245 | - $sql = "SELECT MAX(display_order) |
|
1245 | + $sql = "SELECT MAX(display_order) |
|
1246 | 1246 | FROM $link_table |
1247 | 1247 | WHERE |
1248 | 1248 | c_id = ".$this->destination_course_id." AND |
1249 | 1249 | category_id='" . intval($cat_id). "'"; |
1250 | - $result = Database::query($sql); |
|
1251 | - list($max_order) = Database::fetch_array($result); |
|
1250 | + $result = Database::query($sql); |
|
1251 | + list($max_order) = Database::fetch_array($result); |
|
1252 | 1252 | |
1253 | 1253 | $params = []; |
1254 | - if (!empty($session_id)) { |
|
1254 | + if (!empty($session_id)) { |
|
1255 | 1255 | $params['session_id'] = $session_id; |
1256 | - } |
|
1256 | + } |
|
1257 | 1257 | |
1258 | 1258 | $params['c_id'] = $this->destination_course_id; |
1259 | 1259 | $params['url'] = self::DBUTF8($link->url); |
@@ -1282,9 +1282,9 @@ discard block |
||
1282 | 1282 | } |
1283 | 1283 | $this->course->resources[RESOURCE_LINK][$id]->destination_id = $id; |
1284 | 1284 | } |
1285 | - } |
|
1286 | - } |
|
1287 | - } |
|
1285 | + } |
|
1286 | + } |
|
1287 | + } |
|
1288 | 1288 | |
1289 | 1289 | /** |
1290 | 1290 | * Restore a link-category |
@@ -1328,21 +1328,21 @@ discard block |
||
1328 | 1328 | return $this->course->resources[RESOURCE_LINKCATEGORY][$id]->destination_id; |
1329 | 1329 | } |
1330 | 1330 | |
1331 | - /** |
|
1332 | - * Restore tool intro |
|
1333 | - */ |
|
1331 | + /** |
|
1332 | + * Restore tool intro |
|
1333 | + */ |
|
1334 | 1334 | public function restore_tool_intro($sessionId = 0) |
1335 | 1335 | { |
1336 | - if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) { |
|
1336 | + if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) { |
|
1337 | 1337 | $sessionId = intval($sessionId); |
1338 | - $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO); |
|
1339 | - $resources = $this->course->resources; |
|
1340 | - foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) { |
|
1341 | - $sql = "DELETE FROM $tool_intro_table |
|
1338 | + $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO); |
|
1339 | + $resources = $this->course->resources; |
|
1340 | + foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) { |
|
1341 | + $sql = "DELETE FROM $tool_intro_table |
|
1342 | 1342 | WHERE |
1343 | 1343 | c_id = ".$this->destination_course_id." AND |
1344 | 1344 | id='".self::DBUTF8escapestring($tool_intro->id)."'"; |
1345 | - Database::query($sql); |
|
1345 | + Database::query($sql); |
|
1346 | 1346 | |
1347 | 1347 | $tool_intro->intro_text = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1348 | 1348 | $tool_intro->intro_text, |
@@ -1372,21 +1372,21 @@ discard block |
||
1372 | 1372 | |
1373 | 1373 | $this->course->resources[RESOURCE_TOOL_INTRO][$id]->destination_id = $id; |
1374 | 1374 | } |
1375 | - } |
|
1376 | - } |
|
1377 | - } |
|
1375 | + } |
|
1376 | + } |
|
1377 | + } |
|
1378 | 1378 | |
1379 | - /** |
|
1380 | - * Restore events |
|
1381 | - */ |
|
1379 | + /** |
|
1380 | + * Restore events |
|
1381 | + */ |
|
1382 | 1382 | public function restore_events($sessionId = 0) |
1383 | 1383 | { |
1384 | - if ($this->course->has_resources(RESOURCE_EVENT)) { |
|
1384 | + if ($this->course->has_resources(RESOURCE_EVENT)) { |
|
1385 | 1385 | $sessionId = intval($sessionId); |
1386 | - $table = Database :: get_course_table(TABLE_AGENDA); |
|
1387 | - $resources = $this->course->resources; |
|
1388 | - foreach ($resources[RESOURCE_EVENT] as $id => $event) { |
|
1389 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1386 | + $table = Database :: get_course_table(TABLE_AGENDA); |
|
1387 | + $resources = $this->course->resources; |
|
1388 | + foreach ($resources[RESOURCE_EVENT] as $id => $event) { |
|
1389 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1390 | 1390 | $event->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1391 | 1391 | $event->content, |
1392 | 1392 | $this->course->code, |
@@ -1404,7 +1404,7 @@ discard block |
||
1404 | 1404 | 'end_date' => $event->end_date, |
1405 | 1405 | 'session_id' => $sessionId |
1406 | 1406 | ]; |
1407 | - $new_event_id = Database::insert($table, $params); |
|
1407 | + $new_event_id = Database::insert($table, $params); |
|
1408 | 1408 | |
1409 | 1409 | if ($new_event_id) { |
1410 | 1410 | $sql = "UPDATE $table SET id = iid WHERE iid = $new_event_id"; |
@@ -1417,30 +1417,30 @@ discard block |
||
1417 | 1417 | $this->course->resources[RESOURCE_EVENT][$id]->destination_id = $new_event_id; |
1418 | 1418 | } |
1419 | 1419 | |
1420 | - // Copy event attachment |
|
1420 | + // Copy event attachment |
|
1421 | 1421 | |
1422 | - $origin_path = $this->course->backup_path.'/upload/calendar/'; |
|
1423 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/'; |
|
1422 | + $origin_path = $this->course->backup_path.'/upload/calendar/'; |
|
1423 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/'; |
|
1424 | 1424 | |
1425 | - if (!empty($this->course->orig)) { |
|
1425 | + if (!empty($this->course->orig)) { |
|
1426 | 1426 | |
1427 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1428 | - $sql = 'SELECT path, comment, size, filename |
|
1427 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1428 | + $sql = 'SELECT path, comment, size, filename |
|
1429 | 1429 | FROM '.$table_attachment.' |
1430 | 1430 | WHERE c_id = '.$this->destination_course_id.' AND agenda_id = '.$id; |
1431 | - $attachment_event = Database::query($sql); |
|
1432 | - $attachment_event = Database::fetch_object($attachment_event); |
|
1431 | + $attachment_event = Database::query($sql); |
|
1432 | + $attachment_event = Database::fetch_object($attachment_event); |
|
1433 | 1433 | |
1434 | - if (file_exists($origin_path.$attachment_event->path) && |
|
1434 | + if (file_exists($origin_path.$attachment_event->path) && |
|
1435 | 1435 | !is_dir($origin_path.$attachment_event->path) |
1436 | 1436 | ) { |
1437 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1438 | - $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename); |
|
1439 | - //$copy_result = true; |
|
1440 | - if ($copy_result) { |
|
1441 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1437 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1438 | + $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename); |
|
1439 | + //$copy_result = true; |
|
1440 | + if ($copy_result) { |
|
1441 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1442 | 1442 | |
1443 | - $params = [ |
|
1443 | + $params = [ |
|
1444 | 1444 | 'c_id' => $this->destination_course_id, |
1445 | 1445 | 'path' => self::DBUTF8($new_filename), |
1446 | 1446 | 'comment' => self::DBUTF8($attachment_event->comment), |
@@ -1454,17 +1454,17 @@ discard block |
||
1454 | 1454 | Database::query($sql); |
1455 | 1455 | } |
1456 | 1456 | } |
1457 | - } |
|
1458 | - } else { |
|
1459 | - // get the info of the file |
|
1460 | - if (!empty($event->attachment_path) && |
|
1457 | + } |
|
1458 | + } else { |
|
1459 | + // get the info of the file |
|
1460 | + if (!empty($event->attachment_path) && |
|
1461 | 1461 | is_file($origin_path.$event->attachment_path) && |
1462 | 1462 | is_readable($origin_path.$event->attachment_path) |
1463 | 1463 | ) { |
1464 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1465 | - $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename); |
|
1466 | - if ($copy_result) { |
|
1467 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1464 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1465 | + $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename); |
|
1466 | + if ($copy_result) { |
|
1467 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1468 | 1468 | |
1469 | 1469 | $params = [ |
1470 | 1470 | 'c_id' => $this->destination_course_id, |
@@ -1480,29 +1480,29 @@ discard block |
||
1480 | 1480 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $id"; |
1481 | 1481 | Database::query($sql); |
1482 | 1482 | } |
1483 | - } |
|
1484 | - } |
|
1485 | - } |
|
1486 | - } |
|
1487 | - } |
|
1488 | - } |
|
1489 | - |
|
1490 | - /** |
|
1491 | - * Restore course-description |
|
1492 | - */ |
|
1483 | + } |
|
1484 | + } |
|
1485 | + } |
|
1486 | + } |
|
1487 | + } |
|
1488 | + } |
|
1489 | + |
|
1490 | + /** |
|
1491 | + * Restore course-description |
|
1492 | + */ |
|
1493 | 1493 | public function restore_course_descriptions($session_id = 0) |
1494 | 1494 | { |
1495 | - if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) { |
|
1496 | - $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); |
|
1497 | - $resources = $this->course->resources; |
|
1498 | - foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) { |
|
1495 | + if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) { |
|
1496 | + $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); |
|
1497 | + $resources = $this->course->resources; |
|
1498 | + foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) { |
|
1499 | 1499 | $courseDescription = (array) $cd; |
1500 | 1500 | |
1501 | 1501 | $content = isset($courseDescription['content']) ? $courseDescription['content'] : ''; |
1502 | 1502 | $descriptionType = isset($courseDescription['description_type']) ? $courseDescription['description_type'] : ''; |
1503 | 1503 | $title = isset($courseDescription['title']) ? $courseDescription['title'] : ''; |
1504 | 1504 | |
1505 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1505 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1506 | 1506 | $description_content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1507 | 1507 | $content, |
1508 | 1508 | $this->course->code, |
@@ -1531,22 +1531,22 @@ discard block |
||
1531 | 1531 | } |
1532 | 1532 | $this->course->resources[RESOURCE_COURSEDESCRIPTION][$id]->destination_id = $id; |
1533 | 1533 | } |
1534 | - } |
|
1535 | - } |
|
1536 | - } |
|
1534 | + } |
|
1535 | + } |
|
1536 | + } |
|
1537 | 1537 | |
1538 | - /** |
|
1539 | - * Restore announcements |
|
1540 | - */ |
|
1538 | + /** |
|
1539 | + * Restore announcements |
|
1540 | + */ |
|
1541 | 1541 | public function restore_announcements($sessionId = 0) |
1542 | 1542 | { |
1543 | - if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) { |
|
1543 | + if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) { |
|
1544 | 1544 | $sessionId = intval($sessionId); |
1545 | - $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); |
|
1546 | - $resources = $this->course->resources; |
|
1547 | - foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) { |
|
1545 | + $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); |
|
1546 | + $resources = $this->course->resources; |
|
1547 | + foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) { |
|
1548 | 1548 | |
1549 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1549 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1550 | 1550 | $announcement->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1551 | 1551 | $announcement->content, |
1552 | 1552 | $this->course->code, |
@@ -1565,7 +1565,7 @@ discard block |
||
1565 | 1565 | 'session_id' => $sessionId, |
1566 | 1566 | ]; |
1567 | 1567 | |
1568 | - $new_announcement_id = Database::insert($table, $params); |
|
1568 | + $new_announcement_id = Database::insert($table, $params); |
|
1569 | 1569 | |
1570 | 1570 | if ($new_announcement_id) { |
1571 | 1571 | $sql = "UPDATE $table SET id = iid WHERE iid = $new_announcement_id"; |
@@ -1577,32 +1577,32 @@ discard block |
||
1577 | 1577 | $this->course->resources[RESOURCE_ANNOUNCEMENT][$id]->destination_id = $new_announcement_id; |
1578 | 1578 | } |
1579 | 1579 | |
1580 | - $origin_path = $this->course->backup_path.'/upload/announcements/'; |
|
1581 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/'; |
|
1580 | + $origin_path = $this->course->backup_path.'/upload/announcements/'; |
|
1581 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/'; |
|
1582 | 1582 | |
1583 | - // Copy announcement attachment file |
|
1584 | - if (!empty($this->course->orig)) { |
|
1583 | + // Copy announcement attachment file |
|
1584 | + if (!empty($this->course->orig)) { |
|
1585 | 1585 | |
1586 | - $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1587 | - $sql = 'SELECT path, comment, size, filename |
|
1586 | + $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1587 | + $sql = 'SELECT path, comment, size, filename |
|
1588 | 1588 | FROM '.$table_attachment.' |
1589 | 1589 | WHERE |
1590 | 1590 | c_id = '.$this->destination_course_id.' AND |
1591 | 1591 | announcement_id = '.$id; |
1592 | - $attachment_event = Database::query($sql); |
|
1593 | - $attachment_event = Database::fetch_object($attachment_event); |
|
1592 | + $attachment_event = Database::query($sql); |
|
1593 | + $attachment_event = Database::fetch_object($attachment_event); |
|
1594 | 1594 | |
1595 | - if (file_exists($origin_path.$attachment_event->path) && |
|
1595 | + if (file_exists($origin_path.$attachment_event->path) && |
|
1596 | 1596 | !is_dir($origin_path.$attachment_event->path) |
1597 | 1597 | ) { |
1598 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1598 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1599 | 1599 | $copy_result = copy( |
1600 | 1600 | $origin_path.$attachment_event->path, |
1601 | 1601 | $destination_path.$new_filename |
1602 | 1602 | ); |
1603 | 1603 | |
1604 | - if ($copy_result) { |
|
1605 | - $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1604 | + if ($copy_result) { |
|
1605 | + $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1606 | 1606 | |
1607 | 1607 | $params = [ |
1608 | 1608 | 'c_id' => $this->destination_course_id, |
@@ -1619,19 +1619,19 @@ discard block |
||
1619 | 1619 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId"; |
1620 | 1620 | Database::query($sql); |
1621 | 1621 | } |
1622 | - } |
|
1623 | - } |
|
1624 | - } else { |
|
1625 | - // get the info of the file |
|
1626 | - if (!empty($announcement->attachment_path) && |
|
1622 | + } |
|
1623 | + } |
|
1624 | + } else { |
|
1625 | + // get the info of the file |
|
1626 | + if (!empty($announcement->attachment_path) && |
|
1627 | 1627 | is_file($origin_path.$announcement->attachment_path) && |
1628 | 1628 | is_readable($origin_path.$announcement->attachment_path) |
1629 | 1629 | ) { |
1630 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1631 | - $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename); |
|
1630 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1631 | + $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename); |
|
1632 | 1632 | |
1633 | - if ($copy_result) { |
|
1634 | - $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1633 | + if ($copy_result) { |
|
1634 | + $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1635 | 1635 | |
1636 | 1636 | $params = [ |
1637 | 1637 | 'c_id' => $this->destination_course_id, |
@@ -1648,12 +1648,12 @@ discard block |
||
1648 | 1648 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId"; |
1649 | 1649 | Database::query($sql); |
1650 | 1650 | } |
1651 | - } |
|
1652 | - } |
|
1653 | - } |
|
1654 | - } |
|
1655 | - } |
|
1656 | - } |
|
1651 | + } |
|
1652 | + } |
|
1653 | + } |
|
1654 | + } |
|
1655 | + } |
|
1656 | + } |
|
1657 | 1657 | |
1658 | 1658 | /** |
1659 | 1659 | * Restore Quiz |
@@ -1664,13 +1664,13 @@ discard block |
||
1664 | 1664 | $session_id = 0, |
1665 | 1665 | $respect_base_content = false |
1666 | 1666 | ) { |
1667 | - if ($this->course->has_resources(RESOURCE_QUIZ)) { |
|
1668 | - $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); |
|
1669 | - $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
1670 | - $table_doc = Database :: get_course_table(TABLE_DOCUMENT); |
|
1671 | - $resources = $this->course->resources; |
|
1667 | + if ($this->course->has_resources(RESOURCE_QUIZ)) { |
|
1668 | + $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); |
|
1669 | + $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
1670 | + $table_doc = Database :: get_course_table(TABLE_DOCUMENT); |
|
1671 | + $resources = $this->course->resources; |
|
1672 | 1672 | |
1673 | - foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) { |
|
1673 | + foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) { |
|
1674 | 1674 | |
1675 | 1675 | if (isset($quiz->obj)) { |
1676 | 1676 | //For new imports |
@@ -1680,7 +1680,7 @@ discard block |
||
1680 | 1680 | $quiz->obj = $quiz; |
1681 | 1681 | } |
1682 | 1682 | |
1683 | - $doc = ''; |
|
1683 | + $doc = ''; |
|
1684 | 1684 | if (!empty($quiz->sound)) { |
1685 | 1685 | if (isset($this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]) && |
1686 | 1686 | $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) { |
@@ -1688,14 +1688,14 @@ discard block |
||
1688 | 1688 | WHERE |
1689 | 1689 | c_id = " . $this->destination_course_id . " AND |
1690 | 1690 | id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id; |
1691 | - $doc = Database::query($sql); |
|
1692 | - $doc = Database::fetch_object($doc); |
|
1693 | - $doc = str_replace('/audio/', '', $doc->path); |
|
1694 | - } |
|
1695 | - } |
|
1696 | - |
|
1697 | - if ($id != -1) { |
|
1698 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1691 | + $doc = Database::query($sql); |
|
1692 | + $doc = Database::fetch_object($doc); |
|
1693 | + $doc = str_replace('/audio/', '', $doc->path); |
|
1694 | + } |
|
1695 | + } |
|
1696 | + |
|
1697 | + if ($id != -1) { |
|
1698 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1699 | 1699 | $quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1700 | 1700 | $quiz->description, |
1701 | 1701 | $this->course->code, |
@@ -1707,13 +1707,13 @@ discard block |
||
1707 | 1707 | $quiz->start_time = $quiz->start_time == '0000-00-00 00:00:00' ? null : $quiz->start_time; |
1708 | 1708 | $quiz->end_time = $quiz->end_time == '0000-00-00 00:00:00' ? null : $quiz->end_time; |
1709 | 1709 | |
1710 | - global $_custom; |
|
1711 | - if (isset($_custom['exercises_clean_dates_when_restoring']) && |
|
1710 | + global $_custom; |
|
1711 | + if (isset($_custom['exercises_clean_dates_when_restoring']) && |
|
1712 | 1712 | $_custom['exercises_clean_dates_when_restoring'] |
1713 | 1713 | ) { |
1714 | - $quiz->start_time = null; |
|
1715 | - $quiz->end_time = null; |
|
1716 | - } |
|
1714 | + $quiz->start_time = null; |
|
1715 | + $quiz->end_time = null; |
|
1716 | + } |
|
1717 | 1717 | |
1718 | 1718 | $params = array( |
1719 | 1719 | 'c_id' => $this->destination_course_id, |
@@ -1747,10 +1747,10 @@ discard block |
||
1747 | 1747 | } |
1748 | 1748 | $params['session_id'] = $my_session_id; |
1749 | 1749 | } else { |
1750 | - if (!empty($session_id)) { |
|
1751 | - $session_id = intval($session_id); |
|
1750 | + if (!empty($session_id)) { |
|
1751 | + $session_id = intval($session_id); |
|
1752 | 1752 | $params['session_id'] = $session_id; |
1753 | - } |
|
1753 | + } |
|
1754 | 1754 | } |
1755 | 1755 | $new_id = Database::insert($table_qui, $params); |
1756 | 1756 | |
@@ -1759,15 +1759,15 @@ discard block |
||
1759 | 1759 | Database::query($sql); |
1760 | 1760 | } |
1761 | 1761 | |
1762 | - } else { |
|
1763 | - // $id = -1 identifies the fictionary test for collecting |
|
1764 | - // orphan questions. We do not store it in the database. |
|
1765 | - $new_id = -1; |
|
1766 | - } |
|
1762 | + } else { |
|
1763 | + // $id = -1 identifies the fictionary test for collecting |
|
1764 | + // orphan questions. We do not store it in the database. |
|
1765 | + $new_id = -1; |
|
1766 | + } |
|
1767 | 1767 | |
1768 | - $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id; |
|
1768 | + $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id; |
|
1769 | 1769 | |
1770 | - $order = 0; |
|
1770 | + $order = 0; |
|
1771 | 1771 | if (!empty($quiz->question_ids)) { |
1772 | 1772 | foreach ($quiz->question_ids as $index => $question_id) { |
1773 | 1773 | $qid = $this->restore_quiz_question($question_id); |
@@ -1780,31 +1780,31 @@ discard block |
||
1780 | 1780 | Database::query($sql); |
1781 | 1781 | } |
1782 | 1782 | } |
1783 | - } |
|
1784 | - } |
|
1785 | - } |
|
1783 | + } |
|
1784 | + } |
|
1785 | + } |
|
1786 | 1786 | |
1787 | - /** |
|
1788 | - * Restore quiz-questions |
|
1787 | + /** |
|
1788 | + * Restore quiz-questions |
|
1789 | 1789 | * @params int question id |
1790 | - */ |
|
1790 | + */ |
|
1791 | 1791 | public function restore_quiz_question($id) |
1792 | 1792 | { |
1793 | 1793 | $em = Database::getManager(); |
1794 | - $resources = $this->course->resources; |
|
1794 | + $resources = $this->course->resources; |
|
1795 | 1795 | $question = isset($resources[RESOURCE_QUIZQUESTION][$id]) ? $resources[RESOURCE_QUIZQUESTION][$id] : null; |
1796 | 1796 | |
1797 | - $new_id = 0; |
|
1797 | + $new_id = 0; |
|
1798 | 1798 | |
1799 | - if (is_object($question)) { |
|
1800 | - if ($question->is_restored()) { |
|
1801 | - return $question->destination_id; |
|
1802 | - } |
|
1803 | - $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
1804 | - $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
1799 | + if (is_object($question)) { |
|
1800 | + if ($question->is_restored()) { |
|
1801 | + return $question->destination_id; |
|
1802 | + } |
|
1803 | + $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
1804 | + $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
1805 | 1805 | $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); |
1806 | 1806 | |
1807 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1807 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1808 | 1808 | $question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1809 | 1809 | $question->description, |
1810 | 1810 | $this->course->code, |
@@ -1825,7 +1825,7 @@ discard block |
||
1825 | 1825 | 'extra' => self::DBUTF8($question->extra) |
1826 | 1826 | ]; |
1827 | 1827 | |
1828 | - $new_id = Database::insert($table_que, $params); |
|
1828 | + $new_id = Database::insert($table_que, $params); |
|
1829 | 1829 | |
1830 | 1830 | if ($new_id) { |
1831 | 1831 | |
@@ -1891,12 +1891,12 @@ discard block |
||
1891 | 1891 | $em->merge($quizAnswer); |
1892 | 1892 | $em->flush(); |
1893 | 1893 | } |
1894 | - } |
|
1895 | - } else { |
|
1894 | + } |
|
1895 | + } else { |
|
1896 | 1896 | $correct_answers = array(); |
1897 | - foreach ($question->answers as $index => $answer) { |
|
1897 | + foreach ($question->answers as $index => $answer) { |
|
1898 | 1898 | |
1899 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1899 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1900 | 1900 | $answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1901 | 1901 | $answer['answer'], |
1902 | 1902 | $this->course->code, |
@@ -1935,8 +1935,8 @@ discard block |
||
1935 | 1935 | } |
1936 | 1936 | |
1937 | 1937 | $correct_answers[$answerId] = $answer['correct']; |
1938 | - } |
|
1939 | - } |
|
1938 | + } |
|
1939 | + } |
|
1940 | 1940 | |
1941 | 1941 | //Current course id |
1942 | 1942 | $course_id = api_get_course_int_id(); |
@@ -2033,12 +2033,12 @@ discard block |
||
2033 | 2033 | } |
2034 | 2034 | } |
2035 | 2035 | } |
2036 | - $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; |
|
2037 | - } |
|
2038 | - return $new_id; |
|
2039 | - } |
|
2036 | + $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; |
|
2037 | + } |
|
2038 | + return $new_id; |
|
2039 | + } |
|
2040 | 2040 | |
2041 | - /** |
|
2041 | + /** |
|
2042 | 2042 | * @todo : add session id when used for session |
2043 | 2043 | */ |
2044 | 2044 | public function restore_test_category($session_id, $respect_base_content, $destination_course_code) |
@@ -2123,21 +2123,21 @@ discard block |
||
2123 | 2123 | $sessionId = intval($sessionId); |
2124 | 2124 | |
2125 | 2125 | if ($this->course->has_resources(RESOURCE_SURVEY)) { |
2126 | - $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2127 | - $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2128 | - $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2129 | - $resources = $this->course->resources; |
|
2130 | - foreach ($resources[RESOURCE_SURVEY] as $id => $survey) { |
|
2126 | + $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2127 | + $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2128 | + $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2129 | + $resources = $this->course->resources; |
|
2130 | + foreach ($resources[RESOURCE_SURVEY] as $id => $survey) { |
|
2131 | 2131 | |
2132 | - $sql = 'SELECT survey_id FROM '.$table_sur.' |
|
2132 | + $sql = 'SELECT survey_id FROM '.$table_sur.' |
|
2133 | 2133 | WHERE |
2134 | 2134 | c_id = '.$this->destination_course_id.' AND |
2135 | 2135 | code = "'.self::DBUTF8escapestring($survey->code).'" AND |
2136 | 2136 | lang = "'.self::DBUTF8escapestring($survey->lang).'" '; |
2137 | 2137 | |
2138 | - $result_check = Database::query($sql); |
|
2138 | + $result_check = Database::query($sql); |
|
2139 | 2139 | |
2140 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2140 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2141 | 2141 | $survey->title = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2142 | 2142 | $survey->title, |
2143 | 2143 | $this->course->code, |
@@ -2191,20 +2191,20 @@ discard block |
||
2191 | 2191 | 'session_id' => $sessionId |
2192 | 2192 | ]; |
2193 | 2193 | |
2194 | - //An existing survey exists with the same code and the same language |
|
2195 | - if (Database::num_rows($result_check) == 1) { |
|
2196 | - switch ($this->file_option) { |
|
2197 | - case FILE_SKIP: |
|
2198 | - //Do nothing |
|
2199 | - break; |
|
2200 | - case FILE_RENAME: |
|
2201 | - $survey_code = $survey->code.'_'; |
|
2202 | - $i=1; |
|
2203 | - $temp_survey_code = $survey_code.$i; |
|
2204 | - while (!$this->is_survey_code_available($temp_survey_code)) { |
|
2205 | - $temp_survey_code = $survey_code.++$i; |
|
2206 | - } |
|
2207 | - $survey_code = $temp_survey_code; |
|
2194 | + //An existing survey exists with the same code and the same language |
|
2195 | + if (Database::num_rows($result_check) == 1) { |
|
2196 | + switch ($this->file_option) { |
|
2197 | + case FILE_SKIP: |
|
2198 | + //Do nothing |
|
2199 | + break; |
|
2200 | + case FILE_RENAME: |
|
2201 | + $survey_code = $survey->code.'_'; |
|
2202 | + $i=1; |
|
2203 | + $temp_survey_code = $survey_code.$i; |
|
2204 | + while (!$this->is_survey_code_available($temp_survey_code)) { |
|
2205 | + $temp_survey_code = $survey_code.++$i; |
|
2206 | + } |
|
2207 | + $survey_code = $temp_survey_code; |
|
2208 | 2208 | |
2209 | 2209 | $params['code'] = $survey_code; |
2210 | 2210 | $new_id = Database::insert($table_sur, $params); |
@@ -2223,25 +2223,25 @@ discard block |
||
2223 | 2223 | Database::query($sql); |
2224 | 2224 | } |
2225 | 2225 | } |
2226 | - break; |
|
2227 | - case FILE_OVERWRITE: |
|
2228 | - // Delete the existing survey with the same code and language and import the one of the source course |
|
2229 | - // getting the information of the survey (used for when the survey is shared) |
|
2226 | + break; |
|
2227 | + case FILE_OVERWRITE: |
|
2228 | + // Delete the existing survey with the same code and language and import the one of the source course |
|
2229 | + // getting the information of the survey (used for when the survey is shared) |
|
2230 | 2230 | |
2231 | - $sql = "SELECT * FROM $table_sur |
|
2231 | + $sql = "SELECT * FROM $table_sur |
|
2232 | 2232 | WHERE |
2233 | 2233 | c_id = ".$this->destination_course_id." AND |
2234 | 2234 | survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'"; |
2235 | - $result = Database::query($sql); |
|
2236 | - $survey_data = Database::fetch_array($result,'ASSOC'); |
|
2235 | + $result = Database::query($sql); |
|
2236 | + $survey_data = Database::fetch_array($result,'ASSOC'); |
|
2237 | 2237 | |
2238 | - // if the survey is shared => also delete the shared content |
|
2239 | - if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
|
2238 | + // if the survey is shared => also delete the shared content |
|
2239 | + if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
|
2240 | 2240 | SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id); |
2241 | - } |
|
2242 | - SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
2241 | + } |
|
2242 | + SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
2243 | 2243 | |
2244 | - // Insert the new source survey |
|
2244 | + // Insert the new source survey |
|
2245 | 2245 | $new_id = Database::insert($table_sur, $params); |
2246 | 2246 | |
2247 | 2247 | if ($new_id) { |
@@ -2262,11 +2262,11 @@ discard block |
||
2262 | 2262 | Database::query($sql); |
2263 | 2263 | } |
2264 | 2264 | } |
2265 | - break; |
|
2266 | - default: |
|
2267 | - break; |
|
2268 | - } |
|
2269 | - } else { |
|
2265 | + break; |
|
2266 | + default: |
|
2267 | + break; |
|
2268 | + } |
|
2269 | + } else { |
|
2270 | 2270 | // No existing survey with the same language and the same code, we just copy the survey |
2271 | 2271 | $new_id = Database::insert($table_sur, $params); |
2272 | 2272 | |
@@ -2288,48 +2288,48 @@ discard block |
||
2288 | 2288 | Database::query($sql); |
2289 | 2289 | } |
2290 | 2290 | } |
2291 | - } |
|
2292 | - } |
|
2293 | - } |
|
2294 | - } |
|
2295 | - |
|
2296 | - /** |
|
2297 | - * Check availability of a survey code |
|
2298 | - * @param string $survey_code |
|
2299 | - */ |
|
2291 | + } |
|
2292 | + } |
|
2293 | + } |
|
2294 | + } |
|
2295 | + |
|
2296 | + /** |
|
2297 | + * Check availability of a survey code |
|
2298 | + * @param string $survey_code |
|
2299 | + */ |
|
2300 | 2300 | public function is_survey_code_available($survey_code) |
2301 | 2301 | { |
2302 | - $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2303 | - $sql = "SELECT * FROM $table_sur |
|
2302 | + $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2303 | + $sql = "SELECT * FROM $table_sur |
|
2304 | 2304 | WHERE |
2305 | 2305 | c_id = ".$this->destination_course_id." AND |
2306 | 2306 | code = '".self::DBUTF8escapestring($survey_code)."'"; |
2307 | - $result = Database::query($sql); |
|
2307 | + $result = Database::query($sql); |
|
2308 | 2308 | if (Database::num_rows($result) > 0) { |
2309 | 2309 | return false; |
2310 | 2310 | } else { |
2311 | 2311 | return true; |
2312 | 2312 | } |
2313 | - } |
|
2313 | + } |
|
2314 | 2314 | |
2315 | - /** |
|
2316 | - * Restore survey-questions |
|
2317 | - * @param string $survey_id |
|
2318 | - */ |
|
2315 | + /** |
|
2316 | + * Restore survey-questions |
|
2317 | + * @param string $survey_id |
|
2318 | + */ |
|
2319 | 2319 | public function restore_survey_question($id, $survey_id) |
2320 | 2320 | { |
2321 | - $resources = $this->course->resources; |
|
2322 | - $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
|
2321 | + $resources = $this->course->resources; |
|
2322 | + $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
|
2323 | 2323 | $new_id = 0; |
2324 | 2324 | |
2325 | - if (is_object($question)) { |
|
2326 | - if ($question->is_restored()) { |
|
2327 | - return $question->destination_id; |
|
2328 | - } |
|
2329 | - $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2330 | - $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2325 | + if (is_object($question)) { |
|
2326 | + if ($question->is_restored()) { |
|
2327 | + return $question->destination_id; |
|
2328 | + } |
|
2329 | + $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2330 | + $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2331 | 2331 | |
2332 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2332 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2333 | 2333 | $question->survey_question = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2334 | 2334 | $question->survey_question, |
2335 | 2335 | $this->course->code, |
@@ -2383,10 +2383,10 @@ discard block |
||
2383 | 2383 | } |
2384 | 2384 | $this->course->resources[RESOURCE_SURVEYQUESTION][$id]->destination_id = $new_id; |
2385 | 2385 | } |
2386 | - } |
|
2386 | + } |
|
2387 | 2387 | |
2388 | - return $new_id; |
|
2389 | - } |
|
2388 | + return $new_id; |
|
2389 | + } |
|
2390 | 2390 | |
2391 | 2391 | /** |
2392 | 2392 | * Restoring learning paths |
@@ -2397,19 +2397,19 @@ discard block |
||
2397 | 2397 | { |
2398 | 2398 | $session_id = intval($session_id); |
2399 | 2399 | |
2400 | - if ($this->course->has_resources(RESOURCE_LEARNPATH)) { |
|
2400 | + if ($this->course->has_resources(RESOURCE_LEARNPATH)) { |
|
2401 | 2401 | $table_main = Database::get_course_table(TABLE_LP_MAIN); |
2402 | 2402 | $table_item = Database::get_course_table(TABLE_LP_ITEM); |
2403 | 2403 | $table_tool = Database::get_course_table(TABLE_TOOL_LIST); |
2404 | 2404 | |
2405 | - $resources = $this->course->resources; |
|
2405 | + $resources = $this->course->resources; |
|
2406 | 2406 | |
2407 | - $origin_path = $this->course->backup_path.'/upload/learning_path/images/'; |
|
2408 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/'; |
|
2407 | + $origin_path = $this->course->backup_path.'/upload/learning_path/images/'; |
|
2408 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/'; |
|
2409 | 2409 | |
2410 | - foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) { |
|
2411 | - $condition_session = ''; |
|
2412 | - if (!empty($session_id)) { |
|
2410 | + foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) { |
|
2411 | + $condition_session = ''; |
|
2412 | + if (!empty($session_id)) { |
|
2413 | 2413 | if ($respect_base_content) { |
2414 | 2414 | $my_session_id = $lp->session_id; |
2415 | 2415 | if (!empty($lp->session_id)) { |
@@ -2420,20 +2420,20 @@ discard block |
||
2420 | 2420 | $session_id = intval($session_id); |
2421 | 2421 | $condition_session = $session_id; |
2422 | 2422 | } |
2423 | - } |
|
2424 | - |
|
2425 | - // Adding the author's image |
|
2426 | - if (!empty($lp->preview_image)) { |
|
2427 | - $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
2428 | - if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
|
2429 | - $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
|
2430 | - if ($copy_result) { |
|
2431 | - $lp->preview_image = $new_filename; |
|
2432 | - } else { |
|
2433 | - $lp->preview_image =''; |
|
2434 | - } |
|
2435 | - } |
|
2436 | - } |
|
2423 | + } |
|
2424 | + |
|
2425 | + // Adding the author's image |
|
2426 | + if (!empty($lp->preview_image)) { |
|
2427 | + $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
2428 | + if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
|
2429 | + $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
|
2430 | + if ($copy_result) { |
|
2431 | + $lp->preview_image = $new_filename; |
|
2432 | + } else { |
|
2433 | + $lp->preview_image =''; |
|
2434 | + } |
|
2435 | + } |
|
2436 | + } |
|
2437 | 2437 | |
2438 | 2438 | if ($this->add_text_in_items) { |
2439 | 2439 | $lp->name = $lp->name.' '.get_lang('CopyLabelSuffix'); |
@@ -2491,7 +2491,7 @@ discard block |
||
2491 | 2491 | $params['session_id'] = $condition_session; |
2492 | 2492 | } |
2493 | 2493 | |
2494 | - $new_lp_id = Database::insert($table_main, $params); |
|
2494 | + $new_lp_id = Database::insert($table_main, $params); |
|
2495 | 2495 | |
2496 | 2496 | if ($new_lp_id) { |
2497 | 2497 | |
@@ -2552,13 +2552,13 @@ discard block |
||
2552 | 2552 | $old_refs = array(); |
2553 | 2553 | $prerequisite_ids = array(); |
2554 | 2554 | |
2555 | - foreach ($lp->get_items() as $index => $item) { |
|
2556 | - // we set the ref code here and then we update in a for loop |
|
2557 | - $ref = $item['ref']; |
|
2555 | + foreach ($lp->get_items() as $index => $item) { |
|
2556 | + // we set the ref code here and then we update in a for loop |
|
2557 | + $ref = $item['ref']; |
|
2558 | 2558 | |
2559 | - // Dealing with path the same way as ref as some data has |
|
2559 | + // Dealing with path the same way as ref as some data has |
|
2560 | 2560 | // been put into path when it's a local resource |
2561 | - // Only fix the path for no scos |
|
2561 | + // Only fix the path for no scos |
|
2562 | 2562 | if ($item['item_type'] == 'sco') { |
2563 | 2563 | $path = $item['path']; |
2564 | 2564 | } else { |
@@ -2589,128 +2589,128 @@ discard block |
||
2589 | 2589 | 'launch_data' => self::DBUTF8($item['launch_data']), |
2590 | 2590 | ]; |
2591 | 2591 | |
2592 | - $new_item_id = Database::insert($table_item, $params); |
|
2592 | + $new_item_id = Database::insert($table_item, $params); |
|
2593 | 2593 | |
2594 | 2594 | $sql = "UPDATE $table_item SET id = iid WHERE iid = $new_item_id"; |
2595 | 2595 | Database::query($sql); |
2596 | 2596 | |
2597 | - //save a link between old and new item IDs |
|
2598 | - $new_item_ids[$item['id']] = $new_item_id; |
|
2599 | - //save a reference of items that need a parent_item_id refresh |
|
2600 | - $parent_item_ids[$new_item_id] = $item['parent_item_id']; |
|
2601 | - //save a reference of items that need a previous_item_id refresh |
|
2602 | - $previous_item_ids[$new_item_id] = $item['previous_item_id']; |
|
2603 | - //save a reference of items that need a next_item_id refresh |
|
2604 | - $next_item_ids[$new_item_id] = $item['next_item_id']; |
|
2605 | - |
|
2606 | - if (!empty($item['prerequisite'])) { |
|
2607 | - if ($lp->lp_type =='2') { |
|
2608 | - // if is an sco |
|
2609 | - $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
2610 | - } else { |
|
2611 | - $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
2612 | - } |
|
2613 | - } |
|
2614 | - |
|
2615 | - if (!empty($ref)) { |
|
2616 | - if ($lp->lp_type =='2') { |
|
2617 | - // if is an sco |
|
2618 | - $old_refs[$new_item_id]= $ref; |
|
2619 | - } elseif (isset($new_item_ids[$ref])) { |
|
2597 | + //save a link between old and new item IDs |
|
2598 | + $new_item_ids[$item['id']] = $new_item_id; |
|
2599 | + //save a reference of items that need a parent_item_id refresh |
|
2600 | + $parent_item_ids[$new_item_id] = $item['parent_item_id']; |
|
2601 | + //save a reference of items that need a previous_item_id refresh |
|
2602 | + $previous_item_ids[$new_item_id] = $item['previous_item_id']; |
|
2603 | + //save a reference of items that need a next_item_id refresh |
|
2604 | + $next_item_ids[$new_item_id] = $item['next_item_id']; |
|
2605 | + |
|
2606 | + if (!empty($item['prerequisite'])) { |
|
2607 | + if ($lp->lp_type =='2') { |
|
2608 | + // if is an sco |
|
2609 | + $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
2610 | + } else { |
|
2611 | + $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
2612 | + } |
|
2613 | + } |
|
2614 | + |
|
2615 | + if (!empty($ref)) { |
|
2616 | + if ($lp->lp_type =='2') { |
|
2617 | + // if is an sco |
|
2618 | + $old_refs[$new_item_id]= $ref; |
|
2619 | + } elseif (isset($new_item_ids[$ref])) { |
|
2620 | 2620 | $old_refs[$new_item_id]= $new_item_ids[$ref]; |
2621 | 2621 | } |
2622 | - } |
|
2622 | + } |
|
2623 | 2623 | |
2624 | - $prerequisite_ids[$new_item_id] = $item['prerequisite']; |
|
2625 | - } |
|
2624 | + $prerequisite_ids[$new_item_id] = $item['prerequisite']; |
|
2625 | + } |
|
2626 | 2626 | |
2627 | - // Updating prerequisites |
|
2628 | - foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
|
2629 | - if ($my_old_prerequisite != ''){ |
|
2630 | - $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
|
2627 | + // Updating prerequisites |
|
2628 | + foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
|
2629 | + if ($my_old_prerequisite != ''){ |
|
2630 | + $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
|
2631 | 2631 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
2632 | - Database::query($sql); |
|
2633 | - } |
|
2634 | - } |
|
2635 | - |
|
2636 | - // Updating refs |
|
2637 | - foreach ($old_refs as $key=>$my_old_ref) { |
|
2638 | - if ($my_old_ref != '') { |
|
2639 | - $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."' |
|
2632 | + Database::query($sql); |
|
2633 | + } |
|
2634 | + } |
|
2635 | + |
|
2636 | + // Updating refs |
|
2637 | + foreach ($old_refs as $key=>$my_old_ref) { |
|
2638 | + if ($my_old_ref != '') { |
|
2639 | + $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."' |
|
2640 | 2640 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
2641 | - Database::query($sql); |
|
2642 | - } |
|
2643 | - } |
|
2644 | - |
|
2645 | - foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
|
2646 | - $parent_new_id = 0; |
|
2647 | - if($parent_item_old_id != 0){ |
|
2648 | - $parent_new_id = $new_item_ids[$parent_item_old_id]; |
|
2649 | - } |
|
2650 | - $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
|
2641 | + Database::query($sql); |
|
2642 | + } |
|
2643 | + } |
|
2644 | + |
|
2645 | + foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
|
2646 | + $parent_new_id = 0; |
|
2647 | + if($parent_item_old_id != 0){ |
|
2648 | + $parent_new_id = $new_item_ids[$parent_item_old_id]; |
|
2649 | + } |
|
2650 | + $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
|
2651 | 2651 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2652 | - Database::query($sql); |
|
2653 | - } |
|
2654 | - foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
|
2655 | - $previous_new_id = 0; |
|
2656 | - if ($previous_item_old_id != 0){ |
|
2657 | - $previous_new_id = $new_item_ids[$previous_item_old_id]; |
|
2658 | - } |
|
2659 | - $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
|
2652 | + Database::query($sql); |
|
2653 | + } |
|
2654 | + foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
|
2655 | + $previous_new_id = 0; |
|
2656 | + if ($previous_item_old_id != 0){ |
|
2657 | + $previous_new_id = $new_item_ids[$previous_item_old_id]; |
|
2658 | + } |
|
2659 | + $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
|
2660 | 2660 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2661 | - Database::query($sql); |
|
2662 | - } |
|
2663 | - |
|
2664 | - foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
|
2665 | - $next_new_id = 0; |
|
2666 | - if ($next_item_old_id != 0){ |
|
2667 | - $next_new_id = $new_item_ids[$next_item_old_id]; |
|
2668 | - } |
|
2669 | - $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
|
2661 | + Database::query($sql); |
|
2662 | + } |
|
2663 | + |
|
2664 | + foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
|
2665 | + $next_new_id = 0; |
|
2666 | + if ($next_item_old_id != 0){ |
|
2667 | + $next_new_id = $new_item_ids[$next_item_old_id]; |
|
2668 | + } |
|
2669 | + $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
|
2670 | 2670 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2671 | - Database::query($sql); |
|
2672 | - } |
|
2673 | - |
|
2674 | - foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
|
2675 | - $prerequisite_new_id = 0; |
|
2676 | - if ($prerequisite_old_id != 0){ |
|
2677 | - $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
|
2678 | - } |
|
2679 | - $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
|
2671 | + Database::query($sql); |
|
2672 | + } |
|
2673 | + |
|
2674 | + foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
|
2675 | + $prerequisite_new_id = 0; |
|
2676 | + if ($prerequisite_old_id != 0){ |
|
2677 | + $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
|
2678 | + } |
|
2679 | + $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
|
2680 | 2680 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2681 | - Database::query($sql); |
|
2682 | - } |
|
2683 | - $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id; |
|
2684 | - } |
|
2685 | - } |
|
2686 | - } |
|
2687 | - |
|
2688 | - /** |
|
2689 | - * Restore works |
|
2681 | + Database::query($sql); |
|
2682 | + } |
|
2683 | + $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id; |
|
2684 | + } |
|
2685 | + } |
|
2686 | + } |
|
2687 | + |
|
2688 | + /** |
|
2689 | + * Restore works |
|
2690 | 2690 | * @deprecated use restore_works |
2691 | 2691 | * |
2692 | - */ |
|
2693 | - public function restore_student_publication($sessionId = 0) |
|
2692 | + */ |
|
2693 | + public function restore_student_publication($sessionId = 0) |
|
2694 | 2694 | { |
2695 | 2695 | $sessionId = intval($sessionId); |
2696 | 2696 | $work_assignment_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
2697 | 2697 | $work_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION); |
2698 | 2698 | $item_property_table = Database:: get_course_table(TABLE_ITEM_PROPERTY); |
2699 | 2699 | |
2700 | - // Query in student publication |
|
2701 | - $sql = 'SELECT * FROM '.$work_table.' |
|
2700 | + // Query in student publication |
|
2701 | + $sql = 'SELECT * FROM '.$work_table.' |
|
2702 | 2702 | WHERE c_id = '.$this->course_origin_id.' AND filetype = "folder" AND active IN (0, 1) '; |
2703 | 2703 | |
2704 | - $result = Database::query($sql); |
|
2705 | - $folders = Database::store_result($result, 'ASSOC'); |
|
2704 | + $result = Database::query($sql); |
|
2705 | + $folders = Database::store_result($result, 'ASSOC'); |
|
2706 | 2706 | |
2707 | - foreach ($folders as $folder) { |
|
2708 | - $old_id = $folder['id']; |
|
2707 | + foreach ($folders as $folder) { |
|
2708 | + $old_id = $folder['id']; |
|
2709 | 2709 | unset($folder['id']); |
2710 | - $folder['c_id'] = $this->destination_course_id; |
|
2710 | + $folder['c_id'] = $this->destination_course_id; |
|
2711 | 2711 | $folder['parent_id'] = 0; |
2712 | 2712 | $folder['session_id'] = $sessionId ? $sessionId : null; |
2713 | - $new_id = Database::insert($work_table, $folder); |
|
2713 | + $new_id = Database::insert($work_table, $folder); |
|
2714 | 2714 | |
2715 | 2715 | if ($new_id) { |
2716 | 2716 | // query in item property |
@@ -2769,23 +2769,23 @@ discard block |
||
2769 | 2769 | } |
2770 | 2770 | } |
2771 | 2771 | } |
2772 | - } |
|
2772 | + } |
|
2773 | 2773 | |
2774 | 2774 | $destination = '../..'.api_get_path(REL_COURSE_PATH).$this->course->destination_path.'/work/'; |
2775 | 2775 | $origin = '../..'.api_get_path(REL_COURSE_PATH).$this->course->info['path'].'/work/'; |
2776 | 2776 | self::allow_create_all_directory($origin, $destination, false); |
2777 | - } |
|
2777 | + } |
|
2778 | 2778 | |
2779 | 2779 | /** |
2780 | - * copy all directory and sub directory |
|
2781 | - * @param string The path origin |
|
2782 | - * @param string The path destination |
|
2783 | - * @param boolean Option Overwrite |
|
2784 | - * @param string $source |
|
2785 | - * @param string $dest |
|
2786 | - * @return void() |
|
2787 | - * @deprecated |
|
2788 | - */ |
|
2780 | + * copy all directory and sub directory |
|
2781 | + * @param string The path origin |
|
2782 | + * @param string The path destination |
|
2783 | + * @param boolean Option Overwrite |
|
2784 | + * @param string $source |
|
2785 | + * @param string $dest |
|
2786 | + * @return void() |
|
2787 | + * @deprecated |
|
2788 | + */ |
|
2789 | 2789 | public function allow_create_all_directory($source, $dest, $overwrite = false) |
2790 | 2790 | { |
2791 | 2791 | if (!is_dir($dest)) { |
@@ -2796,7 +2796,7 @@ discard block |
||
2796 | 2796 | if ($file != '.' && $file != '..') { |
2797 | 2797 | $path = $source . '/' . $file; |
2798 | 2798 | if (is_file($path)) { |
2799 | - /* if (!is_file($dest . '/' . $file) || $overwrite) |
|
2799 | + /* if (!is_file($dest . '/' . $file) || $overwrite) |
|
2800 | 2800 | if (!@copy($path, $dest . '/' . $file)) { |
2801 | 2801 | echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>'; |
2802 | 2802 | }*/ |
@@ -2811,12 +2811,12 @@ discard block |
||
2811 | 2811 | } |
2812 | 2812 | } |
2813 | 2813 | |
2814 | - /** |
|
2815 | - * Gets the new ID of one specific tool item from the tool name and the old ID |
|
2816 | - * @param string Tool name |
|
2817 | - * @param integer Old ID |
|
2818 | - * @return integer New ID |
|
2819 | - */ |
|
2814 | + /** |
|
2815 | + * Gets the new ID of one specific tool item from the tool name and the old ID |
|
2816 | + * @param string Tool name |
|
2817 | + * @param integer Old ID |
|
2818 | + * @return integer New ID |
|
2819 | + */ |
|
2820 | 2820 | public function get_new_id($tool, $ref) |
2821 | 2821 | { |
2822 | 2822 | // Check if the value exist in the current array. |
@@ -2838,25 +2838,25 @@ discard block |
||
2838 | 2838 | } |
2839 | 2839 | |
2840 | 2840 | return ''; |
2841 | - } |
|
2841 | + } |
|
2842 | 2842 | |
2843 | - /** |
|
2844 | - * Restore glossary |
|
2845 | - */ |
|
2843 | + /** |
|
2844 | + * Restore glossary |
|
2845 | + */ |
|
2846 | 2846 | public function restore_glossary($session_id = 0) |
2847 | 2847 | { |
2848 | - if ($this->course->has_resources(RESOURCE_GLOSSARY)) { |
|
2849 | - $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
|
2850 | - $resources = $this->course->resources; |
|
2851 | - foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) { |
|
2848 | + if ($this->course->has_resources(RESOURCE_GLOSSARY)) { |
|
2849 | + $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
|
2850 | + $resources = $this->course->resources; |
|
2851 | + foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) { |
|
2852 | 2852 | |
2853 | 2853 | $params = []; |
2854 | - if (!empty($session_id)) { |
|
2855 | - $session_id = intval($session_id); |
|
2854 | + if (!empty($session_id)) { |
|
2855 | + $session_id = intval($session_id); |
|
2856 | 2856 | $params['session_id'] = $session_id; |
2857 | - } |
|
2857 | + } |
|
2858 | 2858 | |
2859 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2859 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2860 | 2860 | $glossary->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2861 | 2861 | $glossary->description, |
2862 | 2862 | $this->course->code, |
@@ -2890,27 +2890,27 @@ discard block |
||
2890 | 2890 | |
2891 | 2891 | $this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = $my_id; |
2892 | 2892 | } |
2893 | - } |
|
2894 | - } |
|
2895 | - } |
|
2893 | + } |
|
2894 | + } |
|
2895 | + } |
|
2896 | 2896 | |
2897 | 2897 | /** |
2898 | 2898 | * @param int $session_id |
2899 | 2899 | */ |
2900 | 2900 | public function restore_wiki($session_id = 0) |
2901 | 2901 | { |
2902 | - if ($this->course->has_resources(RESOURCE_WIKI)) { |
|
2903 | - // wiki table of the target course |
|
2904 | - $table_wiki = Database :: get_course_table(TABLE_WIKI); |
|
2905 | - $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF); |
|
2902 | + if ($this->course->has_resources(RESOURCE_WIKI)) { |
|
2903 | + // wiki table of the target course |
|
2904 | + $table_wiki = Database :: get_course_table(TABLE_WIKI); |
|
2905 | + $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF); |
|
2906 | 2906 | |
2907 | - // storing all the resources that have to be copied in an array |
|
2908 | - $resources = $this->course->resources; |
|
2907 | + // storing all the resources that have to be copied in an array |
|
2908 | + $resources = $this->course->resources; |
|
2909 | 2909 | |
2910 | - foreach ($resources[RESOURCE_WIKI] as $id => $wiki) { |
|
2911 | - // the sql statement to insert the groups from the old course to the new course |
|
2910 | + foreach ($resources[RESOURCE_WIKI] as $id => $wiki) { |
|
2911 | + // the sql statement to insert the groups from the old course to the new course |
|
2912 | 2912 | |
2913 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2913 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2914 | 2914 | $wiki->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2915 | 2915 | $wiki->content, |
2916 | 2916 | $this->course->code, |
@@ -2945,7 +2945,7 @@ discard block |
||
2945 | 2945 | 'user_ip' => '' |
2946 | 2946 | ]; |
2947 | 2947 | |
2948 | - $new_id = Database::insert($table_wiki, $params); |
|
2948 | + $new_id = Database::insert($table_wiki, $params); |
|
2949 | 2949 | |
2950 | 2950 | if ($new_id) { |
2951 | 2951 | $sql = "UPDATE $table_wiki SET page_id = '$new_id', id = iid |
@@ -2975,9 +2975,9 @@ discard block |
||
2975 | 2975 | |
2976 | 2976 | Database::insert($table_wiki_conf, $params); |
2977 | 2977 | } |
2978 | - } |
|
2979 | - } |
|
2980 | - } |
|
2978 | + } |
|
2979 | + } |
|
2980 | + } |
|
2981 | 2981 | |
2982 | 2982 | /** |
2983 | 2983 | * Restore Thematics |
@@ -2985,15 +2985,15 @@ discard block |
||
2985 | 2985 | */ |
2986 | 2986 | public function restore_thematic($session_id = 0) |
2987 | 2987 | { |
2988 | - if ($this->course->has_resources(RESOURCE_THEMATIC)) { |
|
2988 | + if ($this->course->has_resources(RESOURCE_THEMATIC)) { |
|
2989 | 2989 | $table_thematic = Database::get_course_table(TABLE_THEMATIC); |
2990 | 2990 | $table_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE); |
2991 | 2991 | $table_thematic_plan = Database::get_course_table(TABLE_THEMATIC_PLAN); |
2992 | 2992 | |
2993 | - $resources = $this->course->resources; |
|
2994 | - foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) { |
|
2993 | + $resources = $this->course->resources; |
|
2994 | + foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) { |
|
2995 | 2995 | |
2996 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2996 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2997 | 2997 | $thematic->params['content'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2998 | 2998 | $thematic->params['content'], |
2999 | 2999 | $this->course->code, |
@@ -3001,13 +3001,13 @@ discard block |
||
3001 | 3001 | $this->course->backup_path, |
3002 | 3002 | $this->course->info['path'] |
3003 | 3003 | ); |
3004 | - $thematic->params['c_id'] = $this->destination_course_id; |
|
3005 | - unset($thematic->params['id']); |
|
3004 | + $thematic->params['c_id'] = $this->destination_course_id; |
|
3005 | + unset($thematic->params['id']); |
|
3006 | 3006 | unset($thematic->params['iid']); |
3007 | 3007 | |
3008 | - $last_id = Database::insert($table_thematic, $thematic->params, false); |
|
3008 | + $last_id = Database::insert($table_thematic, $thematic->params, false); |
|
3009 | 3009 | |
3010 | - if ($last_id) { |
|
3010 | + if ($last_id) { |
|
3011 | 3011 | |
3012 | 3012 | $sql = "UPDATE $table_thematic SET id = iid WHERE iid = $last_id"; |
3013 | 3013 | Database::query($sql); |
@@ -3020,12 +3020,12 @@ discard block |
||
3020 | 3020 | api_get_user_id() |
3021 | 3021 | ); |
3022 | 3022 | |
3023 | - foreach ($thematic->thematic_advance_list as $thematic_advance) { |
|
3024 | - unset($thematic_advance['id']); |
|
3023 | + foreach ($thematic->thematic_advance_list as $thematic_advance) { |
|
3024 | + unset($thematic_advance['id']); |
|
3025 | 3025 | unset($thematic_advance['iid']); |
3026 | - $thematic_advance['attendance_id'] = 0; |
|
3027 | - $thematic_advance['thematic_id'] = $last_id; |
|
3028 | - $thematic_advance['c_id'] = $this->destination_course_id; |
|
3026 | + $thematic_advance['attendance_id'] = 0; |
|
3027 | + $thematic_advance['thematic_id'] = $last_id; |
|
3028 | + $thematic_advance['c_id'] = $this->destination_course_id; |
|
3029 | 3029 | |
3030 | 3030 | $my_id = Database::insert( |
3031 | 3031 | $table_thematic_advance, |
@@ -3033,7 +3033,7 @@ discard block |
||
3033 | 3033 | false |
3034 | 3034 | ); |
3035 | 3035 | |
3036 | - if ($my_id) { |
|
3036 | + if ($my_id) { |
|
3037 | 3037 | |
3038 | 3038 | $sql = "UPDATE $table_thematic_advance SET id = iid WHERE iid = $my_id"; |
3039 | 3039 | Database::query($sql); |
@@ -3045,17 +3045,17 @@ discard block |
||
3045 | 3045 | 'ThematicAdvanceAdded', |
3046 | 3046 | api_get_user_id() |
3047 | 3047 | ); |
3048 | - } |
|
3049 | - } |
|
3048 | + } |
|
3049 | + } |
|
3050 | 3050 | |
3051 | - foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
3052 | - unset($thematic_plan['id']); |
|
3051 | + foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
3052 | + unset($thematic_plan['id']); |
|
3053 | 3053 | unset($thematic_plan['iid']); |
3054 | - $thematic_plan['thematic_id'] = $last_id; |
|
3055 | - $thematic_plan['c_id'] = $this->destination_course_id; |
|
3056 | - $my_id = Database::insert($table_thematic_plan, $thematic_plan, false); |
|
3054 | + $thematic_plan['thematic_id'] = $last_id; |
|
3055 | + $thematic_plan['c_id'] = $this->destination_course_id; |
|
3056 | + $my_id = Database::insert($table_thematic_plan, $thematic_plan, false); |
|
3057 | 3057 | |
3058 | - if ($my_id) { |
|
3058 | + if ($my_id) { |
|
3059 | 3059 | |
3060 | 3060 | $sql = "UPDATE $table_thematic_plan SET id = iid WHERE iid = $my_id"; |
3061 | 3061 | Database::query($sql); |
@@ -3067,12 +3067,12 @@ discard block |
||
3067 | 3067 | 'ThematicPlanAdded', |
3068 | 3068 | api_get_user_id() |
3069 | 3069 | ); |
3070 | - } |
|
3071 | - } |
|
3072 | - } |
|
3073 | - } |
|
3074 | - } |
|
3075 | - } |
|
3070 | + } |
|
3071 | + } |
|
3072 | + } |
|
3073 | + } |
|
3074 | + } |
|
3075 | + } |
|
3076 | 3076 | |
3077 | 3077 | /** |
3078 | 3078 | * Restore Attendance |
@@ -3080,14 +3080,14 @@ discard block |
||
3080 | 3080 | */ |
3081 | 3081 | public function restore_attendance($session_id = 0) |
3082 | 3082 | { |
3083 | - if ($this->course->has_resources(RESOURCE_ATTENDANCE)) { |
|
3084 | - $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
3085 | - $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
3083 | + if ($this->course->has_resources(RESOURCE_ATTENDANCE)) { |
|
3084 | + $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
3085 | + $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
3086 | 3086 | |
3087 | - $resources = $this->course->resources; |
|
3088 | - foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) { |
|
3087 | + $resources = $this->course->resources; |
|
3088 | + foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) { |
|
3089 | 3089 | |
3090 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3090 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3091 | 3091 | $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
3092 | 3092 | $obj->params['description'], |
3093 | 3093 | $this->course->code, |
@@ -3099,11 +3099,11 @@ discard block |
||
3099 | 3099 | unset($obj->params['id']); |
3100 | 3100 | unset($obj->params['iid']); |
3101 | 3101 | |
3102 | - $obj->params['c_id'] = $this->destination_course_id; |
|
3102 | + $obj->params['c_id'] = $this->destination_course_id; |
|
3103 | 3103 | |
3104 | - $last_id = Database::insert($table_attendance, $obj->params); |
|
3104 | + $last_id = Database::insert($table_attendance, $obj->params); |
|
3105 | 3105 | |
3106 | - if (is_numeric($last_id)) { |
|
3106 | + if (is_numeric($last_id)) { |
|
3107 | 3107 | |
3108 | 3108 | $sql = "UPDATE $table_attendance SET id = iid WHERE iid = $last_id"; |
3109 | 3109 | Database::query($sql); |
@@ -3117,11 +3117,11 @@ discard block |
||
3117 | 3117 | ); |
3118 | 3118 | |
3119 | 3119 | foreach ($obj->attendance_calendar as $attendance_calendar) { |
3120 | - unset($attendance_calendar['id']); |
|
3120 | + unset($attendance_calendar['id']); |
|
3121 | 3121 | unset($attendance_calendar['iid']); |
3122 | 3122 | |
3123 | - $attendance_calendar['attendance_id'] = $last_id; |
|
3124 | - $attendance_calendar['c_id'] = $this->destination_course_id; |
|
3123 | + $attendance_calendar['attendance_id'] = $last_id; |
|
3124 | + $attendance_calendar['c_id'] = $this->destination_course_id; |
|
3125 | 3125 | $attendanceCalendarId = Database::insert( |
3126 | 3126 | $table_attendance_calendar, |
3127 | 3127 | $attendance_calendar |
@@ -3129,11 +3129,11 @@ discard block |
||
3129 | 3129 | |
3130 | 3130 | $sql = "UPDATE $table_attendance_calendar SET id = iid WHERE iid = $attendanceCalendarId"; |
3131 | 3131 | Database::query($sql); |
3132 | - } |
|
3133 | - } |
|
3134 | - } |
|
3135 | - } |
|
3136 | - } |
|
3132 | + } |
|
3133 | + } |
|
3134 | + } |
|
3135 | + } |
|
3136 | + } |
|
3137 | 3137 | |
3138 | 3138 | /** |
3139 | 3139 | * Restore Works |
@@ -3274,11 +3274,11 @@ discard block |
||
3274 | 3274 | */ |
3275 | 3275 | public function DBUTF8($str) |
3276 | 3276 | { |
3277 | - if (UTF8_CONVERT) { |
|
3277 | + if (UTF8_CONVERT) { |
|
3278 | 3278 | $str = utf8_encode($str); |
3279 | 3279 | } |
3280 | - return $str; |
|
3281 | - } |
|
3280 | + return $str; |
|
3281 | + } |
|
3282 | 3282 | |
3283 | 3283 | /** |
3284 | 3284 | * @param string $str |
@@ -3289,8 +3289,8 @@ discard block |
||
3289 | 3289 | if (UTF8_CONVERT) { |
3290 | 3290 | $str = utf8_encode($str); |
3291 | 3291 | } |
3292 | - return Database::escape_string($str); |
|
3293 | - } |
|
3292 | + return Database::escape_string($str); |
|
3293 | + } |
|
3294 | 3294 | |
3295 | 3295 | /** |
3296 | 3296 | * @param array $array |
@@ -372,13 +372,13 @@ discard block |
||
372 | 372 | $firstname = $userInfo['firstname']; |
373 | 373 | $lastname = $userInfo['lastname']; |
374 | 374 | |
375 | - if (api_is_western_name_order()) { |
|
376 | - $message = sprintf(get_lang('AttemptingToLoginAs'),$firstname, $lastname, $userId); |
|
377 | - } else { |
|
378 | - $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId); |
|
379 | - } |
|
375 | + if (api_is_western_name_order()) { |
|
376 | + $message = sprintf(get_lang('AttemptingToLoginAs'),$firstname, $lastname, $userId); |
|
377 | + } else { |
|
378 | + $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId); |
|
379 | + } |
|
380 | 380 | |
381 | - if ($userId) { |
|
381 | + if ($userId) { |
|
382 | 382 | |
383 | 383 | // Logout the current user |
384 | 384 | LoginDelete(api_get_user_id()); |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | }*/ |
454 | 454 | |
455 | 455 | if (!in_array($direction, array('ASC','DESC'))) { |
456 | - $direction = 'ASC'; |
|
456 | + $direction = 'ASC'; |
|
457 | 457 | } |
458 | 458 | $column = intval($column); |
459 | 459 | $from = intval($from); |
@@ -464,23 +464,23 @@ discard block |
||
464 | 464 | $sql .= " WHERE u.creator_id = ".api_get_user_id(); |
465 | 465 | } |
466 | 466 | |
467 | - $sql .= " ORDER BY col$column $direction "; |
|
468 | - $sql .= " LIMIT $from,$number_of_items"; |
|
467 | + $sql .= " ORDER BY col$column $direction "; |
|
468 | + $sql .= " LIMIT $from,$number_of_items"; |
|
469 | 469 | |
470 | - $res = Database::query($sql); |
|
470 | + $res = Database::query($sql); |
|
471 | 471 | |
472 | - $users = array (); |
|
472 | + $users = array (); |
|
473 | 473 | $t = time(); |
474 | - while ($user = Database::fetch_row($res)) { |
|
475 | - $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL); |
|
476 | - $photo = '<img src="'.$userPicture.'" width="22" height="22" alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" />'; |
|
474 | + while ($user = Database::fetch_row($res)) { |
|
475 | + $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL); |
|
476 | + $photo = '<img src="'.$userPicture.'" width="22" height="22" alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" />'; |
|
477 | 477 | |
478 | 478 | if ($user[7] == 1 && !empty($user[10])) { |
479 | 479 | // check expiration date |
480 | 480 | $expiration_time = convert_sql_date($user[10]); |
481 | 481 | // if expiration date is passed, store a special value for active field |
482 | 482 | if ($expiration_time < $t) { |
483 | - $user[7] = '-1'; |
|
483 | + $user[7] = '-1'; |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | */ |
511 | 511 | function email_filter($email) |
512 | 512 | { |
513 | - return Display :: encrypted_mailto_link($email, $email); |
|
513 | + return Display :: encrypted_mailto_link($email, $email); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | */ |
521 | 521 | function user_filter($name, $params, $row) |
522 | 522 | { |
523 | - return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>'; |
|
523 | + return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>'; |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | /** |
@@ -532,23 +532,23 @@ discard block |
||
532 | 532 | */ |
533 | 533 | function modify_filter($user_id, $url_params, $row) |
534 | 534 | { |
535 | - global $charset, $_admins_list; |
|
535 | + global $charset, $_admins_list; |
|
536 | 536 | $is_admin = in_array($user_id, $_admins_list); |
537 | 537 | $statusname = api_get_status_langvars(); |
538 | 538 | $user_is_anonymous = false; |
539 | 539 | $current_user_status_label = $row['7']; |
540 | 540 | |
541 | - if ($current_user_status_label == $statusname[ANONYMOUS]) { |
|
542 | - $user_is_anonymous = true; |
|
543 | - } |
|
544 | - $result = ''; |
|
545 | - if (!$user_is_anonymous) { |
|
541 | + if ($current_user_status_label == $statusname[ANONYMOUS]) { |
|
542 | + $user_is_anonymous = true; |
|
543 | + } |
|
544 | + $result = ''; |
|
545 | + if (!$user_is_anonymous) { |
|
546 | 546 | $icon = Display::return_icon( |
547 | 547 | 'course.png', |
548 | 548 | get_lang('Courses'), |
549 | 549 | array('onmouseout' => 'clear_course_list (\'div_'.$user_id.'\')') |
550 | 550 | ); |
551 | - $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" > |
|
551 | + $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" > |
|
552 | 552 | '.$icon.' |
553 | 553 | <div class="blackboard_hide" id="div_'.$user_id.'"> </div> |
554 | 554 | </a>'; |
@@ -558,14 +558,14 @@ discard block |
||
558 | 558 | get_lang('Sessions'), |
559 | 559 | array('onmouseout' => 'clear_session_list (\'div_s_'.$user_id.'\')') |
560 | 560 | ); |
561 | - $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" > |
|
561 | + $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" > |
|
562 | 562 | '.$icon.' |
563 | 563 | <div class="blackboard_hide" id="div_s_'.$user_id.'"> </div> |
564 | 564 | </a>'; |
565 | - } else { |
|
566 | - $result .= Display::return_icon('course_na.png',get_lang('Courses')).' '; |
|
567 | - $result .= Display::return_icon('course_na.png',get_lang('Sessions')).' '; |
|
568 | - } |
|
565 | + } else { |
|
566 | + $result .= Display::return_icon('course_na.png',get_lang('Courses')).' '; |
|
567 | + $result .= Display::return_icon('course_na.png',get_lang('Sessions')).' '; |
|
568 | + } |
|
569 | 569 | |
570 | 570 | if (api_is_platform_admin()) { |
571 | 571 | if (!$user_is_anonymous) { |
@@ -614,18 +614,18 @@ discard block |
||
614 | 614 | ); |
615 | 615 | } |
616 | 616 | |
617 | - if ($is_admin) { |
|
617 | + if ($is_admin) { |
|
618 | 618 | $result .= Display::return_icon( |
619 | 619 | 'admin_star.png', |
620 | 620 | get_lang('IsAdministrator'), |
621 | 621 | array('width' => ICON_SIZE_SMALL, 'heigth' => ICON_SIZE_SMALL) |
622 | 622 | ); |
623 | - } else { |
|
624 | - $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator')); |
|
625 | - } |
|
623 | + } else { |
|
624 | + $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator')); |
|
625 | + } |
|
626 | 626 | |
627 | - // actions for assigning sessions, courses or users |
|
628 | - if (!api_is_session_admin()) { |
|
627 | + // actions for assigning sessions, courses or users |
|
628 | + if (!api_is_session_admin()) { |
|
629 | 629 | if ($current_user_status_label == $statusname[SESSIONADMIN]) { |
630 | 630 | $result .= Display::url( |
631 | 631 | Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')), |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | ); |
656 | 656 | } |
657 | 657 | } |
658 | - } |
|
658 | + } |
|
659 | 659 | |
660 | 660 | if (api_is_platform_admin()) { |
661 | 661 | $result .= ' <a data-title="'.get_lang('FreeBusyCalendar').'" href="'.api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?a=get_user_agenda&user_id='.$user_id.'&modal_size=lg" class="agenda_opener ajax">'. |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | } |
675 | 675 | } |
676 | 676 | |
677 | - return $result; |
|
677 | + return $result; |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | /** |
@@ -706,16 +706,16 @@ discard block |
||
706 | 706 | if ($action === 'edit') { |
707 | 707 | $result = Display::return_icon($image.'.png', get_lang('AccountExpired'), array(), 16); |
708 | 708 | } elseif ($row['0'] <> $_user['user_id']) { |
709 | - // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore. |
|
709 | + // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore. |
|
710 | 710 | $result = Display::return_icon( |
711 | 711 | $image.'.png', |
712 | 712 | get_lang(ucfirst($action)), |
713 | 713 | array('onclick' => 'active_user(this);', 'id' => 'img_'.$row['0']), |
714 | 714 | 16 |
715 | 715 | ); |
716 | - } |
|
716 | + } |
|
717 | 717 | |
718 | - return $result; |
|
718 | + return $result; |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | /** |
@@ -728,8 +728,8 @@ discard block |
||
728 | 728 | * @author Patrick Cool <[email protected]>, Ghent University, Belgium |
729 | 729 | */ |
730 | 730 | function status_filter($status) { |
731 | - $statusname = api_get_status_langvars(); |
|
732 | - return $statusname[$status]; |
|
731 | + $statusname = api_get_status_langvars(); |
|
732 | + return $statusname[$status]; |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | if (isset($_GET['keyword']) || isset($_GET['keyword_firstname'])) { |
@@ -745,8 +745,8 @@ discard block |
||
745 | 745 | |
746 | 746 | if (!empty($action)) { |
747 | 747 | $check = Security::check_token('get'); |
748 | - if ($check) { |
|
749 | - switch ($action) { |
|
748 | + if ($check) { |
|
749 | + switch ($action) { |
|
750 | 750 | case 'add_user_to_my_url': |
751 | 751 | $user_id = $_REQUEST["user_id"]; |
752 | 752 | $result = UrlManager::add_user_to_url($user_id, $current_access_url_id); |
@@ -756,45 +756,45 @@ discard block |
||
756 | 756 | $message = Display::return_message($message, 'confirmation'); |
757 | 757 | } |
758 | 758 | break; |
759 | - case 'delete_user': |
|
760 | - if (api_is_platform_admin()) { |
|
759 | + case 'delete_user': |
|
760 | + if (api_is_platform_admin()) { |
|
761 | 761 | $user_to_delete = $_GET['user_id']; |
762 | 762 | $current_user_id = api_get_user_id(); |
763 | 763 | |
764 | - if ($deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) { |
|
765 | - if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) { |
|
766 | - $message = Display :: return_message(get_lang('UserDeleted'), 'confirmation'); |
|
767 | - } else { |
|
768 | - $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error'); |
|
769 | - } |
|
770 | - } else { |
|
771 | - $message = Display :: return_message(get_lang('CannotDeleteUser'),'error'); |
|
772 | - } |
|
773 | - } |
|
774 | - break; |
|
764 | + if ($deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) { |
|
765 | + if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) { |
|
766 | + $message = Display :: return_message(get_lang('UserDeleted'), 'confirmation'); |
|
767 | + } else { |
|
768 | + $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error'); |
|
769 | + } |
|
770 | + } else { |
|
771 | + $message = Display :: return_message(get_lang('CannotDeleteUser'),'error'); |
|
772 | + } |
|
773 | + } |
|
774 | + break; |
|
775 | 775 | case 'delete': |
776 | - if (api_is_platform_admin()) { |
|
777 | - $number_of_selected_users = count($_POST['id']); |
|
778 | - $number_of_deleted_users = 0; |
|
779 | - if (is_array($_POST['id'])) { |
|
780 | - foreach ($_POST['id'] as $index => $user_id) { |
|
781 | - if ($user_id != $_user['user_id']) { |
|
782 | - if (UserManager::delete_user($user_id)) { |
|
783 | - $number_of_deleted_users++; |
|
784 | - } |
|
785 | - } |
|
786 | - } |
|
787 | - } |
|
788 | - if ($number_of_selected_users == $number_of_deleted_users) { |
|
776 | + if (api_is_platform_admin()) { |
|
777 | + $number_of_selected_users = count($_POST['id']); |
|
778 | + $number_of_deleted_users = 0; |
|
779 | + if (is_array($_POST['id'])) { |
|
780 | + foreach ($_POST['id'] as $index => $user_id) { |
|
781 | + if ($user_id != $_user['user_id']) { |
|
782 | + if (UserManager::delete_user($user_id)) { |
|
783 | + $number_of_deleted_users++; |
|
784 | + } |
|
785 | + } |
|
786 | + } |
|
787 | + } |
|
788 | + if ($number_of_selected_users == $number_of_deleted_users) { |
|
789 | 789 | $message = Display :: return_message(get_lang('SelectedUsersDeleted'), 'confirmation'); |
790 | - } else { |
|
790 | + } else { |
|
791 | 791 | $message = Display :: return_message(get_lang('SomeUsersNotDeleted'), 'error'); |
792 | - } |
|
793 | - } |
|
794 | - break; |
|
795 | - } |
|
796 | - Security::clear_token(); |
|
797 | - } |
|
792 | + } |
|
793 | + } |
|
794 | + break; |
|
795 | + } |
|
796 | + Security::clear_token(); |
|
797 | + } |
|
798 | 798 | } |
799 | 799 | |
800 | 800 | // Create a search-box |
@@ -811,15 +811,15 @@ discard block |
||
811 | 811 | $actionsCenter = ''; |
812 | 812 | $actionsRight = ''; |
813 | 813 | if (api_is_platform_admin()) { |
814 | - $actionsRight .= '<a class="pull-right" href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'. |
|
815 | - Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
814 | + $actionsRight .= '<a class="pull-right" href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'. |
|
815 | + Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
816 | 816 | } |
817 | 817 | |
818 | 818 | $actionsLeft .= $form->returnForm(); |
819 | 819 | $actionsCenter .= $searchAdvanced; |
820 | 820 | |
821 | 821 | if (isset($_GET['keyword'])) { |
822 | - $parameters = array('keyword' => Security::remove_XSS($_GET['keyword'])); |
|
822 | + $parameters = array('keyword' => Security::remove_XSS($_GET['keyword'])); |
|
823 | 823 | } elseif (isset ($_GET['keyword_firstname'])) { |
824 | 824 | $parameters['keyword_firstname'] = Security::remove_XSS($_GET['keyword_firstname']); |
825 | 825 | $parameters['keyword_lastname'] = Security::remove_XSS($_GET['keyword_lastname']); |
@@ -893,11 +893,11 @@ discard block |
||
893 | 893 | $table->set_header(2, get_lang('OfficialCode')); |
894 | 894 | |
895 | 895 | if (api_is_western_name_order()) { |
896 | - $table->set_header(3, get_lang('FirstName')); |
|
897 | - $table->set_header(4, get_lang('LastName')); |
|
896 | + $table->set_header(3, get_lang('FirstName')); |
|
897 | + $table->set_header(4, get_lang('LastName')); |
|
898 | 898 | } else { |
899 | - $table->set_header(3, get_lang('LastName')); |
|
900 | - $table->set_header(4, get_lang('FirstName')); |
|
899 | + $table->set_header(3, get_lang('LastName')); |
|
900 | + $table->set_header(4, get_lang('FirstName')); |
|
901 | 901 | } |
902 | 902 | $table->set_header(5, get_lang('LoginName')); |
903 | 903 | $table->set_header(6, get_lang('Email')); |
@@ -433,7 +433,7 @@ |
||
433 | 433 | $form->addElement( |
434 | 434 | 'checkbox', |
435 | 435 | 'confirmation', |
436 | - null, |
|
436 | + null, |
|
437 | 437 | $plugin->get_lang('RequestConfirmation') |
438 | 438 | ); |
439 | 439 | } |
@@ -77,20 +77,20 @@ discard block |
||
77 | 77 | |
78 | 78 | function show_compose_reply_to_message($message_id, $receiver_id) |
79 | 79 | { |
80 | - $table_message = Database::get_main_table(TABLE_MESSAGE); |
|
81 | - $query = "SELECT user_sender_id |
|
80 | + $table_message = Database::get_main_table(TABLE_MESSAGE); |
|
81 | + $query = "SELECT user_sender_id |
|
82 | 82 | FROM $table_message |
83 | 83 | WHERE user_receiver_id = ".intval($receiver_id)." AND id='".intval($message_id)."';"; |
84 | - $result = Database::query($query); |
|
85 | - $row = Database::fetch_array($result,'ASSOC'); |
|
86 | - if (!isset($row['user_sender_id'])) { |
|
87 | - $html = get_lang('InvalidMessageId'); |
|
84 | + $result = Database::query($query); |
|
85 | + $row = Database::fetch_array($result,'ASSOC'); |
|
86 | + if (!isset($row['user_sender_id'])) { |
|
87 | + $html = get_lang('InvalidMessageId'); |
|
88 | 88 | |
89 | - return $html; |
|
90 | - } |
|
91 | - $userInfo = api_get_user_info($row['user_sender_id']); |
|
92 | - $default['users'] = array($row['user_sender_id']); |
|
93 | - $html = manage_form($default, null, $userInfo['complete_name']); |
|
89 | + return $html; |
|
90 | + } |
|
91 | + $userInfo = api_get_user_info($row['user_sender_id']); |
|
92 | + $default['users'] = array($row['user_sender_id']); |
|
93 | + $html = manage_form($default, null, $userInfo['complete_name']); |
|
94 | 94 | |
95 | 95 | return $html; |
96 | 96 | } |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | function show_compose_to_user ($receiver_id) |
99 | 99 | { |
100 | 100 | $userInfo = api_get_user_info($receiver_id); |
101 | - $html = get_lang('To').': <strong>'.$userInfo['complete_name'].'</strong>'; |
|
102 | - $default['title'] = api_xml_http_response_encode(get_lang('EnterTitle')); |
|
103 | - $default['users'] = array($receiver_id); |
|
104 | - $html .= manage_form($default); |
|
101 | + $html = get_lang('To').': <strong>'.$userInfo['complete_name'].'</strong>'; |
|
102 | + $default['title'] = api_xml_http_response_encode(get_lang('EnterTitle')); |
|
103 | + $default['users'] = array($receiver_id); |
|
104 | + $html .= manage_form($default); |
|
105 | 105 | |
106 | 106 | return $html; |
107 | 107 | } |
@@ -273,13 +273,13 @@ discard block |
||
273 | 273 | |
274 | 274 | /* MAIN SECTION */ |
275 | 275 | if ($socialToolIsActive) { |
276 | - $this_section = SECTION_SOCIAL; |
|
276 | + $this_section = SECTION_SOCIAL; |
|
277 | 277 | $interbreadcrumb[] = array( |
278 | 278 | 'url' => api_get_path(WEB_PATH).'main/social/home.php', |
279 | 279 | 'name' => get_lang('SocialNetwork') |
280 | 280 | ); |
281 | 281 | } else { |
282 | - $this_section = SECTION_MYPROFILE; |
|
282 | + $this_section = SECTION_MYPROFILE; |
|
283 | 283 | $interbreadcrumb[] = array( |
284 | 284 | 'url' => api_get_path(WEB_PATH).'main/auth/profile.php', |
285 | 285 | 'name' => get_lang('Profile') |
@@ -289,30 +289,30 @@ discard block |
||
289 | 289 | $group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null; |
290 | 290 | $social_right_content = null; |
291 | 291 | if ($group_id != 0) { |
292 | - $social_right_content .= '<div class=actions>'; |
|
293 | - $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/group_view.php?id='.$group_id.'">'. |
|
294 | - Display::return_icon('back.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>'; |
|
295 | - $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?group_id='.$group_id.'">'. |
|
296 | - Display::return_icon('message_new.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>'; |
|
297 | - $social_right_content .= '</div>'; |
|
292 | + $social_right_content .= '<div class=actions>'; |
|
293 | + $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/group_view.php?id='.$group_id.'">'. |
|
294 | + Display::return_icon('back.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>'; |
|
295 | + $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?group_id='.$group_id.'">'. |
|
296 | + Display::return_icon('message_new.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>'; |
|
297 | + $social_right_content .= '</div>'; |
|
298 | 298 | } else { |
299 | - if ($socialToolIsActive) { |
|
300 | - } else { |
|
301 | - $social_right_content .= '<div class=actions>'; |
|
302 | - if (api_get_setting('allow_social_tool') === 'true' && api_get_setting('allow_message_tool') === 'true') { |
|
303 | - $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'. |
|
299 | + if ($socialToolIsActive) { |
|
300 | + } else { |
|
301 | + $social_right_content .= '<div class=actions>'; |
|
302 | + if (api_get_setting('allow_social_tool') === 'true' && api_get_setting('allow_message_tool') === 'true') { |
|
303 | + $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'. |
|
304 | 304 | Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>'; |
305 | - } |
|
306 | - if (api_get_setting('allow_message_tool') === 'true') { |
|
307 | - $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'. |
|
305 | + } |
|
306 | + if (api_get_setting('allow_message_tool') === 'true') { |
|
307 | + $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'. |
|
308 | 308 | Display::return_icon('message_new.png',get_lang('ComposeMessage')).'</a>'; |
309 | - $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'. |
|
309 | + $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'. |
|
310 | 310 | Display::return_icon('inbox.png',get_lang('Inbox')).'</a>'; |
311 | 311 | $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'. |
312 | 312 | Display::return_icon('outbox.png',get_lang('Outbox')).'</a>'; |
313 | - } |
|
314 | - $social_right_content .= '</div>'; |
|
315 | - } |
|
313 | + } |
|
314 | + $social_right_content .= '</div>'; |
|
315 | + } |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | // LEFT COLUMN |