From 19dc4bd9d9137c0b7e40517bdfe94b5feef457ed Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Mon, 27 Apr 2015 09:57:31 -0500 Subject: [PATCH 01/22] Add question Matching Draggable type - refs 7611 --- main/exercice/MatchingDraggable.php | 263 ++++++++++++++++++++++++++++ main/exercice/question.class.php | 3 +- main/inc/lib/api.lib.php | 1 + 3 files changed, 266 insertions(+), 1 deletion(-) create mode 100644 main/exercice/MatchingDraggable.php diff --git a/main/exercice/MatchingDraggable.php b/main/exercice/MatchingDraggable.php new file mode 100644 index 0000000000..a8ed038979 --- /dev/null +++ b/main/exercice/MatchingDraggable.php @@ -0,0 +1,263 @@ + + */ +class MatchingDraggable extends Question +{ + + public static $typePicture = 'matching.png'; + static $explanationLangVar = 'MatchingDrag'; + + /** + * Class constructor + */ + public function __construct() + { + parent::__construct(); + + $this->type = MATCHING_DRAGGABLE; + $this->isContent = $this->getIsContent(); + } + + /** + * Creates the form to create / edit the answers of the question + * @param FormValidator $form + */ + public function createAnswersForm($form) + { + $defaults = $matches = []; + $nb_matches = $nb_options = 2; + + $answer = null; + + if ($form->isSubmitted()) { + $nb_matches = $form->getSubmitValue('nb_matches'); + $nb_options = $form->getSubmitValue('nb_options'); + + if (isset($_POST['lessMatches'])) { + $nb_matches--; + } + + if (isset($_POST['moreMatches'])) { + $nb_matches++; + } + + if (isset($_POST['lessOptions'])) { + $nb_options--; + } + + if (isset($_POST['moreOptions'])) { + $nb_options++; + } + } else if (!empty($this->id)) { + $answer = new Answer($this->id); + $answer->read(); + + if (count($answer->nbrAnswers) > 0) { + $nb_matches = $nb_options = 0; + + for ($i = 1; $i <= $answer->nbrAnswers; $i++) { + if ($answer->isCorrect($i)) { + $nb_matches++; + $defaults['answer[' . $nb_matches . ']'] = $answer->selectAnswer($i); + $defaults['weighting[' . $nb_matches . ']'] = float_format($answer->selectWeighting($i), 1); + $defaults['matches[' . $nb_matches . ']'] = $answer->correct[$i]; + } else { + $nb_options++; + $defaults['option[' . $nb_options . ']'] = $answer->selectAnswer($i); + } + } + } + } else { + $defaults['answer[1]'] = get_lang('DefaultMakeCorrespond1'); + $defaults['answer[2]'] = get_lang('DefaultMakeCorrespond2'); + $defaults['matches[2]'] = '2'; + $defaults['option[1]'] = get_lang('DefaultMatchingOptA'); + $defaults['option[2]'] = get_lang('DefaultMatchingOptB'); + } + + for ($i = 1; $i <= $nb_options; ++$i) { + // fill the array with A, B, C..... + $matches[$i] = chr(64 + $i); + } + + $form->addElement('hidden', 'nb_matches', $nb_matches); + $form->addElement('hidden', 'nb_options', $nb_options); + + // DISPLAY MATCHES + $html = ' + + + + + + + + + '; + + $form->addHeader(get_lang('MakeCorrespond')); + $form->addHtml($html); + + if ($nb_matches < 1) { + $nb_matches = 1; + Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer')); + } + + for ($i = 1; $i <= $nb_matches; ++$i) { + $renderer = &$form->defaultRenderer(); + + $renderer->setElementTemplate( + '', + "answer[$i]" + ); + $renderer->setElementTemplate( + '', + "matches[$i]" + ); + $renderer->setElementTemplate( + '', + "weighting[$i]" + ); + + $form->addHtml(''); + $form->addHtml(""); + $form->addText("answer[$i]", null); + $form->addSelect("matches[$i]", null, $matches); + $form->addText("weighting[$i]", null, true, ['value' => 10]); + $form->addHtml(''); + } + + $form->addHtml('
' . get_lang('Number') . '' . get_lang('Answer') . '' . get_lang('MatchesTo') . '' . get_lang('Weighting') . '
{error}{element}{error}{element}{error}{element}
$i
'); + $group = array(); + + $renderer->setElementTemplate('
{element}', 'lessMatches'); + $renderer->setElementTemplate('{element}
', 'moreMatches'); + + $group[] = $form->addButtonDelete(get_lang('DelElem'), 'lessMatches', true); + $group[] = $form->addButtonCreate(get_lang('AddElem'), 'moreMatches', true); + + $form->addGroup($group); + + // DISPLAY OPTIONS + $html = ' + + + + + + + '; + + $form->addHtml($html); + + if ($nb_options < 1) { + $nb_options = 1; + Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer')); + } + + for ($i = 1; $i <= $nb_options; ++$i) { + $renderer = &$form->defaultRenderer(); + + $renderer->setElementTemplate( + '', + "option[$i]" + ); + + $form->addHtml(''); + + $form->addHtml(''); + $form->addText("option[$i]", null); + + $form->addHtml(''); + } + + $form->addHtml('
' . get_lang('Number') . '' . get_lang('Answer') . '
{error}{element}
' . chr(64 + $i) . '
'); + + global $text; + + // setting the save button here and not in the question class.php + $group = []; + $group[] = $form->addButtonDelete(get_lang('DelElem'), 'lessOptions', true); + $group[] = $form->addButtonCreate(get_lang('AddElem'), 'moreOptions', true); + $group[] = $form->addButtonSave($text, 'submitQuestion', true); + + $form->addGroup($group); + + if (!empty($this->id)) { + $form->setDefaults($defaults); + } elseif ($this->isContent == 1) { + $form->setDefaults($defaults); + } + + $form->setConstants( + [ + 'nb_matches' => $nb_matches, + 'nb_options' => $nb_options + ] + ); + } + + /** + * + * @param type $form + */ + public function processAnswersCreation($form) + { + $nb_matches = $form->getSubmitValue('nb_matches'); + $nb_options = $form->getSubmitValue('nb_options'); + $this->weighting = 0; + $position = 0; + + $objAnswer = new Answer($this->id); + + // Insert the options + for ($i = 1; $i <= $nb_options; ++$i) { + $position++; + $option = $form->getSubmitValue("option[$i]"); + $objAnswer->createAnswer($option, 0, '', 0, $position); + } + + // Insert the answers + for ($i = 1; $i <= $nb_matches; ++$i) { + $position++; + + $answer = $form->getSubmitValue("answer[$i]"); + $matches = $form->getSubmitValue("matches[$i]"); + $weighting = $form->getSubmitValue("weighting[$i]"); + + $this->weighting += $weighting; + + $objAnswer->createAnswer($answer, $matches, '', $weighting, $position); + } + + $objAnswer->save(); + $this->save(); + } + + /** + * Shows question title an description + * @param string $feedback_type + * @param int $counter + * @param float $score + * @return string The header HTML code + */ + public function return_header($feedback_type = null, $counter = null, $score = null) + { + $header = parent::return_header($feedback_type, $counter, $score); + $header .= ' + + + + +
' . get_lang('ElementList') . '' . get_lang('CorrespondsTo') . '
'; + + return $header; + } + +} diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php index fa55d43668..fdadddfcc4 100755 --- a/main/exercice/question.class.php +++ b/main/exercice/question.class.php @@ -50,7 +50,8 @@ abstract class Question GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php' , 'GlobalMultipleAnswer'), CALCULATED_ANSWER => array('calculated_answer.class.php' , 'CalculatedAnswer'), UNIQUE_ANSWER_IMAGE => ['UniqueAnswerImage.php', 'UniqueAnswerImage'], - DRAGGABLE => ['Draggable.php', 'Draggable'] + DRAGGABLE => ['Draggable.php', 'Draggable'], + MATCHING_DRAGGABLE => ['MatchingDraggable.php', 'MatchingDraggable'] //MEDIA_QUESTION => array('media_question.class.php' , 'MediaQuestion') ); diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index e08b1c0ea0..e1a13584a6 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -474,6 +474,7 @@ define('MEDIA_QUESTION', 15); define('CALCULATED_ANSWER', 16); define('UNIQUE_ANSWER_IMAGE', 17); define('DRAGGABLE', 18); +define('MATCHING_DRAGGABLE', 19); //Some alias used in the QTI exports define('MCUA', 1); From e100653b33dd324634834a74f16af450f4141c55 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Mon, 27 Apr 2015 10:07:25 -0500 Subject: [PATCH 02/22] Allow restore Matching Draggable question - refs #7611 --- main/coursecopy/classes/CourseRestorer.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main/coursecopy/classes/CourseRestorer.class.php b/main/coursecopy/classes/CourseRestorer.class.php index 3e68a7eab1..59aee9e36e 100755 --- a/main/coursecopy/classes/CourseRestorer.class.php +++ b/main/coursecopy/classes/CourseRestorer.class.php @@ -1578,8 +1578,7 @@ class CourseRestorer } } } - - if ($question->quiz_type == MATCHING) { + if (in_array($question->quiz_type, [MATCHING, MATCHING_DRAGGABLE])) { $temp = array(); foreach ($question->answers as $index => $answer) { $temp[$answer['position']] = $answer; From 47bd70b243ffe27f8b062a469dbf810b2a0da6a0 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Mon, 27 Apr 2015 10:18:18 -0500 Subject: [PATCH 03/22] Manage Matching Draggable answer - refs #7611 --- main/exercice/answer_admin.inc.php | 8 ++++---- main/exercice/exercise.class.php | 13 +++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/main/exercice/answer_admin.inc.php b/main/exercice/answer_admin.inc.php index a97bf266bb..98e7c5d869 100755 --- a/main/exercice/answer_admin.inc.php +++ b/main/exercice/answer_admin.inc.php @@ -62,7 +62,7 @@ if ($modifyIn) { $reponse = unserialize($reponse); $comment = unserialize($comment); $weighting = unserialize($weighting); - } elseif ($answerType == MATCHING) { + } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) { $option = unserialize($option); $match = unserialize($match); $sel = unserialize($sel); @@ -368,7 +368,7 @@ if ($submitAnswers || $buttonBack) { } else { unset($setWeighting); } - } elseif ($answerType == MATCHING) { + } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) { if ($debug > 0) { echo str_repeat(' ', 2) . '$answerType is MATCHING' . "
\n"; } @@ -621,7 +621,7 @@ if ($modifyAnswers) { $weighting = unserialize($weighting); } } - } elseif ($answerType == MATCHING) { + } elseif(in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) { if ($debug > 0) { echo str_repeat(' ', 2) . '$answerType is MATCHING' . "
\n"; } @@ -1066,7 +1066,7 @@ if ($modifyAnswers) {

diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 304e8e462e..38131c70a8 100755 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -2774,6 +2774,8 @@ class Exercise break; case DRAGGABLE: //no break + case MATCHING_DRAGGABLE: + //no break case MATCHING: if ($from_database) { $sql = 'SELECT id, answer, id_auto @@ -2851,7 +2853,8 @@ class Exercise echo ''; echo '' . $s_answer_label . ''; echo '' . $user_answer; - if ($answerType == MATCHING) { + + if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) { if (isset($real_list[$i_answer_correct_answer])) { echo Display::span( $real_list[$i_answer_correct_answer], @@ -2977,7 +2980,7 @@ class Exercise if ( !in_array( $answerType, - [MATCHING, DRAGGABLE] + [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE] ) || $answerCorrect ) { @@ -3245,7 +3248,7 @@ class Exercise error_log(__LINE__.' first',0); } } - } elseif($answerType == MATCHING) { + } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) { echo ''; echo Display::tag('td', $answerMatching[$answerId]); echo Display::tag( @@ -3571,6 +3574,8 @@ class Exercise break; case DRAGGABLE: //no break + case MATCHING_DRAGGABLE: + //no break case MATCHING: echo ''; echo Display::tag('td', $answerMatching[$answerId]); @@ -3883,7 +3888,7 @@ class Exercise } else { Event::saveQuestionAttempt($questionScore, 0, $quesId, $exeId, 0, $this->id); } - } elseif (in_array($answerType, [MATCHING, DRAGGABLE])) { + } elseif (in_array($answerType, [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE])) { if (isset($matching)) { foreach ($matching as $j => $val) { Event::saveQuestionAttempt($questionScore, $val, $quesId, $exeId, $j, $this->id); From 074419ba70b30ece9fa00eee8dd6a74d34938e05 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Mon, 27 Apr 2015 12:33:12 -0500 Subject: [PATCH 04/22] Vendor - Add jsPlumb - refs #7611 --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6552d58b35..76968e35c0 100755 --- a/composer.json +++ b/composer.json @@ -70,7 +70,8 @@ "bower-asset/mediaelement": "@stable", "bower-asset/modernizr": "2.8.*", "bower-asset/jqueryui-timepicker-addon": "@stable", - "bower-asset/imageMap-resizer": "0.5.3" + "bower-asset/imageMap-resizer": "0.5.3", + "bower-asset/jsPlumb" : "1.7.5" }, "require-dev": { "behat/behat": "2.5.*@stable", From 13b274cf2dca3079e00611d66811b7d572ab5b72 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 28 Apr 2015 08:28:39 -0500 Subject: [PATCH 05/22] Vendor - Add XColor - refs #7611 --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 76968e35c0..aa7246a40c 100755 --- a/composer.json +++ b/composer.json @@ -71,7 +71,8 @@ "bower-asset/modernizr": "2.8.*", "bower-asset/jqueryui-timepicker-addon": "@stable", "bower-asset/imageMap-resizer": "0.5.3", - "bower-asset/jsPlumb" : "1.7.5" + "bower-asset/jsPlumb" : "1.7.5", + "bower-asset/xcolor": "1.8.0" }, "require-dev": { "behat/behat": "2.5.*@stable", From 4ed3f9e330f3f54416a227ef0d72a2e085679d39 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 28 Apr 2015 08:43:29 -0500 Subject: [PATCH 06/22] Allow export Matching Dragable questions - refs #7611 --- main/exercice/export/qti2/qti2_classes.php | 2 ++ main/exercice/export/scorm/scorm_classes.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/main/exercice/export/qti2/qti2_classes.php b/main/exercice/export/qti2/qti2_classes.php index e8d23f72b8..b771475694 100755 --- a/main/exercice/export/qti2/qti2_classes.php +++ b/main/exercice/export/qti2/qti2_classes.php @@ -32,6 +32,8 @@ class Ims2Question extends Question return $answer; case MATCHING: + //no break + case MATCHING_DRAGGABLE: $answer = new ImsAnswerMatching($this->id); return $answer; diff --git a/main/exercice/export/scorm/scorm_classes.php b/main/exercice/export/scorm/scorm_classes.php index dbeb3494e4..ec548d13f4 100755 --- a/main/exercice/export/scorm/scorm_classes.php +++ b/main/exercice/export/scorm/scorm_classes.php @@ -43,6 +43,8 @@ class ScormQuestion extends Question $this->answer->questionJSId = $this->js_id; break; case MATCHING : + //no break + case MATCHING_DRAGGABLE: $this->answer = new ScormAnswerMatching($this->id); $this->answer->questionJSId = $this->js_id; break; From 108e61917d2163ef1757f6b19dd111fed36133b9 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 28 Apr 2015 08:46:24 -0500 Subject: [PATCH 07/22] Show question in exercise resport - refs #7611 --- main/exercice/stats.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main/exercice/stats.php b/main/exercice/stats.php index 4e11e5d590..5d1302354c 100755 --- a/main/exercice/stats.php +++ b/main/exercice/stats.php @@ -169,6 +169,8 @@ if (!empty($question_list)) { } break; case MATCHING: + //no break + case MATCHING_DRAGGABLE: if ($is_correct == 0) { if ($answer_id == 1) { $data[$id]['name'] = cut($question_obj->question, 100); From 09c5864de7ef302845bf8ab568f68f9310d9e574 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 28 Apr 2015 10:03:15 -0500 Subject: [PATCH 08/22] Allow solve Matching Draggable answer - refs #7611 --- main/css/base.css | 24 +++ main/exercice/answer.class.php | 16 ++ main/exercice/exercise_show.php | 2 +- main/exercice/exercise_submit.php | 7 + main/inc/lib/display.lib.php | 6 +- main/inc/lib/exercise.lib.php | 137 ++++++++++++++++- main/template/default/exercise/submit.js.tpl | 148 +++++++++++++++++++ 7 files changed, 328 insertions(+), 12 deletions(-) diff --git a/main/css/base.css b/main/css/base.css index 06e9f9e523..3d56ed0bc7 100755 --- a/main/css/base.css +++ b/main/css/base.css @@ -5930,3 +5930,27 @@ ul.exercise-draggable-answer li { .question_options .droppable .gallery .exercise-draggable-answer-option { margin-bottom: 15px; } + +/*** Matching Draggable answer ***/ +.drag_question { + float: left; + min-height: 4em; + width: 100%; +} +.drag_question .window{ + box-shadow: 2px 2px 19px #AAA; + cursor: pointer; + min-height: 65px; + padding-top: 25px; +} +.window_left_question { + padding: 10px 25px 10px 10px; + text-align: right; +} +.window_right_question { + padding: 10px 10px 10px 25px; +} + +._jsPlumb_endpoint { + z-index: 50; +} \ No newline at end of file diff --git a/main/exercice/answer.class.php b/main/exercice/answer.class.php index b62f8c2a24..7777e2595f 100755 --- a/main/exercice/answer.class.php +++ b/main/exercice/answer.class.php @@ -759,4 +759,20 @@ class Answer } } } + + /** + * Get the necessary JavaScript for some ansers + * @return string + */ + public function getJs() { + //if ($this->questionId == 2) + return ""; + } + } diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php index 52bdc1ee9c..649d7f40de 100755 --- a/main/exercice/exercise_show.php +++ b/main/exercice/exercise_show.php @@ -343,7 +343,7 @@ foreach ($questionList as $questionId) { $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); $questionScore = $question_result['score']; $totalScore += $question_result['score']; - } elseif (in_array($answerType, [MATCHING, DRAGGABLE])) { + } elseif (in_array($answerType, [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE])) { $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); $questionScore = $question_result['score']; $totalScore += $question_result['score']; diff --git a/main/exercice/exercise_submit.php b/main/exercice/exercise_submit.php index f85b84fa92..a5b7e354bf 100755 --- a/main/exercice/exercise_submit.php +++ b/main/exercice/exercise_submit.php @@ -50,6 +50,13 @@ if ($showGlossary) { $htmlHeadXtra[] = api_get_js('jquery.highlight.js'); } +$htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; + //This library is necessary for the time control feature $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/stylesheet/jquery.epiclock.css'); $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/renderers/minute/epiclock.minute.css'); diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php index eb3e99b495..300db8a1a4 100755 --- a/main/inc/lib/display.lib.php +++ b/main/inc/lib/display.lib.php @@ -954,7 +954,7 @@ class Display if ($key == 'id') { $default_id = ''; } - $extra .= $key.'="'.$parameter.'"'; + $extra .= $key.'="'.$parameter.'" '; } $html .= ''; + $html .= ''; From 957775bfd072bb5100432db6bc947f10daf3f854 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Thu, 30 Apr 2015 12:04:47 -0500 Subject: [PATCH 17/22] Fix language variable name - refs #7611 --- main/exercice/MatchingDraggable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/exercice/MatchingDraggable.php b/main/exercice/MatchingDraggable.php index 91f9e0afd8..9311ede7e5 100644 --- a/main/exercice/MatchingDraggable.php +++ b/main/exercice/MatchingDraggable.php @@ -11,7 +11,7 @@ class MatchingDraggable extends Question { public static $typePicture = 'matching.png'; - static $explanationLangVar = 'MatchingDrag'; + static $explanationLangVar = 'MatchingDraggable'; /** * Class constructor From 3fdaf5dbdb593976ffbf4a0dd13c09538b5f8a31 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Thu, 30 Apr 2015 12:05:03 -0500 Subject: [PATCH 18/22] Update languages file - refs #7611 --- main/lang/english/trad4all.inc.php | 7 +++++++ main/lang/spanish/trad4all.inc.php | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/main/lang/english/trad4all.inc.php b/main/lang/english/trad4all.inc.php index 0764b4f9f8..d69a404fd4 100644 --- a/main/lang/english/trad4all.inc.php +++ b/main/lang/english/trad4all.inc.php @@ -7231,4 +7231,11 @@ $RequestSubmitted = "Your request has been submitted."; $RequestFailed = "We are not able to fulfill your request at this time. Please contact your administrator."; $InternalLogin = "Internal login"; $AlreadyLoggedIn = "You are already logged in"; +$Draggable = "Draggable"; +$Incorrect = "Incorrect"; +$YouNotYetAchievedCertificates = "You not yet achieved certificates"; +$SearchCertificates = "Search certificates"; +$TheUserXNotYetAchievedCertificates = "The user %s not yet achieved certificates"; +$CertificatesNotPublic = "Certificates not public"; +$MatchingDraggable = "Matching Draggable"; ?> \ No newline at end of file diff --git a/main/lang/spanish/trad4all.inc.php b/main/lang/spanish/trad4all.inc.php index 7a5271dac8..783813940b 100644 --- a/main/lang/spanish/trad4all.inc.php +++ b/main/lang/spanish/trad4all.inc.php @@ -7235,4 +7235,11 @@ $SaveBadge = "Guardar insignia"; $BadgeMeasuresXPixelsInPNG = "Medidas de la insignia 200x200 píxeles en formato PNG"; $SetTutor = "Hacer tutor"; $UniqueAnswerImage = "Respuesta de imagen única"; +$Draggable = "Arrastrable"; +$Incorrect = "Incorrecto"; +$YouNotYetAchievedCertificates = "Aún no ha logrado certificados"; +$SearchCertificates = "Buscar certificados"; +$TheUserXNotYetAchievedCertificates = "El usuario %s aún no ha logrado certificados"; +$CertificatesNotPublic = "Los certificados no son públicos"; +$MatchingDraggable = "Coincidencia arrastrable"; ?> \ No newline at end of file From 7fb83a5252ff8a530a2ed56b89da43a8f5f3b953 Mon Sep 17 00:00:00 2001 From: Imanol Losada Date: Thu, 30 Apr 2015 15:31:11 -0500 Subject: [PATCH 19/22] Fix queries - refs #7639 --- main/inc/lib/hook/HookManagement.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main/inc/lib/hook/HookManagement.php b/main/inc/lib/hook/HookManagement.php index 794940f027..e07fcb0bc4 100644 --- a/main/inc/lib/hook/HookManagement.php +++ b/main/inc/lib/hook/HookManagement.php @@ -145,8 +145,8 @@ class HookManagement implements HookManagementInterface public function listHookObservers($eventName) { $array = array(); - $joinTable = $this->tables[TABLE_HOOK_CALL] . 'hc ' . - ' INNER JOIN ' . $this->tables[TABLE_HOOK_EVENT] . 'he ' . + $joinTable = $this->tables[TABLE_HOOK_CALL] . ' hc' . + ' INNER JOIN ' . $this->tables[TABLE_HOOK_EVENT] . ' he' . ' ON hc.hook_event_id = he.id ' . ' INNER JOIN ' . $this->tables[TABLE_HOOK_OBSERVER] . ' ho ' . ' ON hc.hook_observer_id = ho.id '; @@ -202,8 +202,8 @@ class HookManagement implements HookManagementInterface public function listAllHookCalls() { $array = array(); - $joinTable = $this->tables[TABLE_HOOK_CALL] . 'hc ' . - ' INNER JOIN ' . $this->tables[TABLE_HOOK_EVENT] . 'he ' . + $joinTable = $this->tables[TABLE_HOOK_CALL] . ' hc' . + ' INNER JOIN ' . $this->tables[TABLE_HOOK_EVENT] . ' he' . ' ON hc.hook_event_id = he.id ' . ' INNER JOIN ' . $this->tables[TABLE_HOOK_OBSERVER] . ' ho ' . ' ON hc.hook_observer_id = ho.id '; @@ -338,8 +338,8 @@ class HookManagement implements HookManagementInterface $eventName = Database::escape_string($eventName); $observerClassName($observerClassName); $type = Database::escape_string($type); - $joinTable = $this->tables[TABLE_HOOK_CALL] . 'hc ' . - ' INNER JOIN ' . $this->tables[TABLE_HOOK_EVENT] . 'he ' . + $joinTable = $this->tables[TABLE_HOOK_CALL] . ' hc' . + ' INNER JOIN ' . $this->tables[TABLE_HOOK_EVENT] . ' he' . ' ON hc.hook_event_id = he.id ' . ' INNER JOIN ' . $this->tables[TABLE_HOOK_OBSERVER] . ' ho ' . ' ON hc.hook_observer_id = ho.id '; From 0052386b168a1ea4a6274220c74da0c8630a8366 Mon Sep 17 00:00:00 2001 From: Imanol Losada Date: Thu, 30 Apr 2015 15:31:25 -0500 Subject: [PATCH 20/22] Fix extra field creation - refs #7639 --- plugin/skype/src/Skype.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin/skype/src/Skype.php b/plugin/skype/src/Skype.php index b06d8b557b..c49ae8d895 100644 --- a/plugin/skype/src/Skype.php +++ b/plugin/skype/src/Skype.php @@ -48,8 +48,10 @@ class Skype extends Plugin implements HookPluginInterface ) ); if (empty($result)) { + require_once api_get_path(LIBRARY_PATH).'extra_field.lib.php'; $extraField = new Extrafield('user'); $extraField->save(array( + 'field_type' => UserManager::USER_FIELD_TYPE_TEXT, 'field_variable' => 'skype', 'field_display_text' => 'Skype', 'field_visible' => 1, From a5de6f1e75b93c30b478952b7c179dff57b6ff94 Mon Sep 17 00:00:00 2001 From: Imanol Losada Date: Thu, 30 Apr 2015 11:53:55 -0500 Subject: [PATCH 21/22] Remove notices and warning messages - refs #7670 --- plugin/ticket/src/myticket.php | 40 +++++++++++++++++++++++----- plugin/ticket/src/new_ticket.php | 5 +++- plugin/ticket/src/ticket.class.php | 18 ++++++++----- plugin/ticket/src/ticket_details.php | 12 +++++---- 4 files changed, 56 insertions(+), 19 deletions(-) diff --git a/plugin/ticket/src/myticket.php b/plugin/ticket/src/myticket.php index a0e79494e4..5fbda89c8b 100755 --- a/plugin/ticket/src/myticket.php +++ b/plugin/ticket/src/myticket.php @@ -199,9 +199,35 @@ $isAdmin = api_is_platform_admin(); Display::display_header($plugin->get_lang('MyTickets')); if ($isAdmin) { - $get_parameter = '&keyword=' . Security::remove_XSS($_GET['keyword']) . '&keyword_status=' . Security::remove_XSS($_GET['keyword_status']) . '&keyword_category=' .Security::remove_XSS($_GET['keyword_category']). '&keyword_request_user=' . Security::remove_XSS($_GET['keyword_request_user']); - $get_parameter .= '&keyword_admin=' . Security::remove_XSS($_GET['keyword_admin']) . '&keyword_start_date=' . Security::remove_XSS($_GET['keyword_start_date']) . '&keyword_unread=' . Security::remove_XSS($_GET['keyword_unread']); - $get_parameter2 = '&Tickets_per_page=' . Security::remove_XSS($_GET['Tickets_per_page']) . '&Tickets_column=' . Security::remove_XSS($_GET['Tickets_column']); + $getParameters = [ + 'keyword', + 'keyword_status', + 'keyword_category', + 'keyword_request_user', + 'keyword_admin', + 'keyword_start_date', + 'keyword_unread', + 'Tickets_per_page', + 'Tickets_column' + ]; + $get_parameter = ''; + foreach ($getParameters as $getParameter) { + if (isset($_GET[$getParameter])) { + $get_parameter .= "&$getParameter=".Security::remove_XSS($_GET[$getParameter]); + } + } + + $getParameters = [ + 'Tickets_per_page', + 'Tickets_column' + ]; + $get_parameter2 = ''; + foreach ($getParameters as $getParameter) { + if (isset($_GET[$getParameter])) { + $get_parameter2 .= "&$getParameter=".Security::remove_XSS($_GET[$getParameter]); + } + } + if (isset($_GET['submit_advanced'])) { $get_parameter .= "&submit_advanced="; } @@ -209,7 +235,7 @@ if ($isAdmin) { $get_parameter .= "&submit_simple="; } //select categories - $select_types .= ''; $select_types .= ''; $types = TicketManager::get_all_tickets_categories(); foreach ($types as $type) { @@ -217,7 +243,7 @@ if ($isAdmin) { } $select_types .= ""; //select admins - $select_admins .= ''; $select_admins .= ''; $select_admins .= ''; $admins = UserManager::get_user_list_like(array("status" => "1"), array("username"), true); @@ -226,7 +252,7 @@ if ($isAdmin) { } $select_admins .= ""; //select status - $select_status .= ''; $select_status .= ''; $status = TicketManager::get_all_tickets_status(); foreach ($status as $stat) { @@ -234,7 +260,7 @@ if ($isAdmin) { } $select_status .= ""; //select priority - $select_priority .= ''; $select_priority .= ''; $select_priority .= ''; $select_priority .= ''; diff --git a/plugin/ticket/src/new_ticket.php b/plugin/ticket/src/new_ticket.php index 8c29143fff..8fdd6187f3 100755 --- a/plugin/ticket/src/new_ticket.php +++ b/plugin/ticket/src/new_ticket.php @@ -411,8 +411,11 @@ function show_form_send_ticket() 'button', 'compose', get_lang('SendMessage'), + null, + null, + null, + 'save', array( - 'class' => 'save', 'id' => 'btnsubmit' ) ); diff --git a/plugin/ticket/src/ticket.class.php b/plugin/ticket/src/ticket.class.php index f5dece4692..056cc64023 100755 --- a/plugin/ticket/src/ticket.class.php +++ b/plugin/ticket/src/ticket.class.php @@ -504,9 +504,12 @@ class TicketManager if (!$isAdmin) { $sql .= " AND request_user = '$user_id' "; } - $keyword_unread = Database::escape_string( - trim($_GET['keyword_unread']) - ); + $keyword_unread = ''; + if (isset($_GET['keyword_unread'])) { + $keyword_unread = Database::escape_string( + trim($_GET['keyword_unread']) + ); + } //Search simple if (isset($_GET['submit_simple'])) { if ($_GET['keyword'] != '') { @@ -812,9 +815,12 @@ class TicketManager OR user.username LIKE '%$keyword%') "; } } - $keyword_unread = Database::escape_string( - trim($_GET['keyword_unread']) - ); + $keyword_unread = ''; + if (isset($_GET['keyword_unread'])) { + $keyword_unread = Database::escape_string( + trim($_GET['keyword_unread']) + ); + } //Search advanced if (isset($_GET['submit_advanced'])) { $keyword_category = Database::escape_string( diff --git a/plugin/ticket/src/ticket_details.php b/plugin/ticket/src/ticket_details.php index 2998ca740e..4b154d55c5 100755 --- a/plugin/ticket/src/ticket_details.php +++ b/plugin/ticket/src/ticket_details.php @@ -247,13 +247,14 @@ if (!isset($_POST['compose'])) { } } $titulo = '

Ticket #' . $ticket['ticket']['ticket_code'] . '

'; + $img_assing = ''; if ($isAdmin && $ticket['ticket']['status_id'] != 'CLS' && $ticket['ticket']['status_id'] != 'REE') { if ($ticket['ticket']['assigned_last_user'] != 0 && $ticket['ticket']['assigned_last_user'] == $user_id) { $img_assing = ' '; } else { - $img_assing .= ''; + $img_assing = ''; } } $bold = ''; @@ -306,7 +307,7 @@ if (!isset($_POST['compose'])) { '; } //select admins - $select_admins .= ''; $admins = UserManager::get_user_list_like(array("status" => "1"), array("username"), true); foreach ($admins as $admin) { @@ -450,9 +451,10 @@ function show_form_send_message() 'button', 'compose', get_lang('SendMessage'), - array( - 'class' => 'save' - ) + null, + null, + null, + 'save' ); $form->display(); From 785fbdaf5b9db205e18fa064b0e22a7f7024d8af Mon Sep 17 00:00:00 2001 From: Imanol Losada Date: Thu, 30 Apr 2015 11:55:45 -0500 Subject: [PATCH 22/22] Show content of tickets in the right way - refs #7670 --- plugin/ticket/src/ticket.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugin/ticket/src/ticket.class.php b/plugin/ticket/src/ticket.class.php index 056cc64023..4c0b954dc3 100755 --- a/plugin/ticket/src/ticket.class.php +++ b/plugin/ticket/src/ticket.class.php @@ -94,6 +94,14 @@ class TicketManager $category_id = intval($category_id); $project_id = intval($project_id); $subject = Database::escape_string($subject); + // Remove html tags + $content = strip_tags($content); + // Remove   + $content = str_replace(" ", '', $content); + // Remove \r\n\t\s... from ticket's beginning and end + $content = trim($content); + // Replace server newlines with html + $content = str_replace("\r\n", '
', $content); $content = Database::escape_string($content); $personalEmail = Database::escape_string($personalEmail); $status = Database::escape_string($status); @@ -717,7 +725,7 @@ class TicketManager $row['col7'], $row['col8'], $actions, - eregi_replace("[\n|\r|\n\r|\r\n]", ' ', strip_tags($row['col9'])) + $row['col9'] ); } else { $actions = "";