Skip to content

Commit

Permalink
Evarisk#1927 [QuestionGroup] add: question group object
Browse files Browse the repository at this point in the history
  • Loading branch information
theodaviddd committed Dec 3, 2024
1 parent bf5ed14 commit 6160804
Show file tree
Hide file tree
Showing 18 changed files with 2,144 additions and 12 deletions.
5 changes: 5 additions & 0 deletions class/question.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,11 @@ public function selectQuestionList($selected = '', $htmlname = 'socid', $filter
$num = $this->db->num_rows($resql);
$i = 0;

if ($showempty)
{
if ($showempty === '1') $out .= '<option value="0"></option>';
else $out .= '<option value="0"></option>';
}
if ($num) {
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
Expand Down
578 changes: 578 additions & 0 deletions class/question_group.class.php

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions core/modules/digiquali/question_group/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
//Silence is golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/* Copyright (C) 2022 EVARISK <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* or see https://www.gnu.org/
*/

/**
* \file core/modules/digiquali/question/mod_question_standard.php
* \ingroup digiquali
* \brief File of class to manage question numbering rules standard.
*/

// Load Saturne libraries.
require_once __DIR__ . '/../../../../../saturne/core/modules/saturne/modules_saturne.php';

/**
* Class to manage question numbering rules standard.
*/
class mod_question_group_standard extends ModeleNumRefSaturne
{
/**
* @var string Numbering module ref prefix.
*/
public string $prefix = 'QG';

/**
* @var string Name.
*/
public string $name = 'Kari';
}
72 changes: 60 additions & 12 deletions core/modules/modDigiQuali.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function __construct($db)
$i++ => ['DIGIQUALI_SHEET_BACKWARD_COMPATIBILITY', 'integer', 0, '', 0, 'current'],

// CONST QUESTION
$i++ => ['DIGIQUALI_QUESTION_ADDON', 'chaine', 'mod_question_standard', '', 0, 'current'],
$i++ => ['DIGIQUALI_QUESTION_ADDON', 'chaine', 'mod_question_group_standard', '', 0, 'current'],
$i++ => ['DIGIQUALI_QUESTION_BACKWARD_COMPATIBILITY', 'integer', 1, '', 0, 'current'],

// CONST ANSWER
Expand Down Expand Up @@ -470,6 +470,23 @@ public function __construct($db)
$this->rights[$r][1] = $langs->transnoentities('DeleteObjects', dol_strtolower($langs->transnoentities('Surveys'))); // Permission label
$this->rights[$r][4] = 'survey'; // In php code, permission will be checked by test if ($user->rights->digiquali->level1->level2)
$this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->digiquali->level1->level2)
$r++;

/* QUESTION GROUP PERMISSIONS */
$this->rights[$r][0] = $this->numero . sprintf('%02d', $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = $langs->transnoentities('ReadObjects', dol_strtolower($langs->transnoentities('QuestionGroups'))); // Permission label
$this->rights[$r][4] = 'question_group'; // In php code, permission will be checked by test if ($user->rights->digiquali->level1->level2)
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->digiquali->level1->level2)
$r++;
$this->rights[$r][0] = $this->numero . sprintf('%02d', $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = $langs->transnoentities('CreateObjects', dol_strtolower($langs->transnoentities('QuestionGroups'))); // Permission label
$this->rights[$r][4] = 'question_group'; // In php code, permission will be checked by test if ($user->rights->digiquali->level1->level2)
$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->digiquali->level1->level2)
$r++;
$this->rights[$r][0] = $this->numero . sprintf('%02d', $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = $langs->transnoentities('DeleteObjects', dol_strtolower($langs->transnoentities('QuestionGroups'))); // Permission label
$this->rights[$r][4] = 'question_group'; // In php code, permission will be checked by test if ($user->rights->digiquali->level1->level2)
$this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->digiquali->level1->level2)
$r++;

/* ADMINPAGE PANEL ACCESS PERMISSIONS */
Expand Down Expand Up @@ -598,32 +615,63 @@ public function __construct($db)
];

$this->menu[$r++] = [
'fk_menu' => 'fk_mainmenu=digiquali',
'fk_menu' => 'fk_mainmenu=digiquali',
'type' => 'left',
'titre' => $langs->transnoentities('Survey'),
'prefix' => '<i class="fas fa-marker pictofixedwidth"></i>',
'mainmenu' => 'digiquali',
'leftmenu' => 'digiquali_survey',
'url' => '/digiquali/view/survey/survey_list.php',
'langs' => 'digiquali@digiquali',
'position' => 1000 + $r,
'enabled' => '$conf->digiquali->enabled && $user->rights->digiquali->survey->read',
'perms' => '$user->rights->digiquali->survey->read',
'target' => '',
'user' => 0,
];

$this->menu[$r++] = [
'fk_menu' => 'fk_mainmenu=digiquali,fk_leftmenu=digiquali_survey',
'type' => 'left',
'titre' => $langs->transnoentities('Survey'),
'prefix' => '<i class="fas fa-marker pictofixedwidth"></i>',
'titre' => '<i class="fas fa-tags pictofixedwidth" style="padding-right: 4px;"></i>' . $langs->transnoentities('Categories'),
'mainmenu' => 'digiquali',
'leftmenu' => 'digiquali_survey',
'url' => '/digiquali/view/survey/survey_list.php',
'leftmenu' => 'digiquali_surveytags',
'url' => '/categories/index.php?type=survey',
'langs' => 'digiquali@digiquali',
'position' => 1000 + $r,
'enabled' => '$conf->digiquali->enabled && $user->rights->digiquali->survey->read',
'enabled' => '$conf->digiquali->enabled && $conf->categorie->enabled && $user->rights->digiquali->survey->read',
'perms' => '$user->rights->digiquali->survey->read',
'target' => '',
'user' => 0,
];

$this->menu[$r++] = [
'fk_menu' => 'fk_mainmenu=digiquali,fk_leftmenu=digiquali_survey',
'fk_menu' => 'fk_mainmenu=digiquali',
'type' => 'left',
'titre' => $langs->transnoentities('QuestionGroup'),
'prefix' => '<i class="fas fa-group pictofixedwidth"></i>',
'mainmenu' => 'digiquali',
'leftmenu' => 'digiquali_question_group',
'url' => '/digiquali/view/question_group/question_group_list.php',
'langs' => 'digiquali@digiquali',
'position' => 1000 + $r,
'enabled' => '$conf->digiquali->enabled && $user->rights->digiquali->question_group->read',
'perms' => '$user->rights->digiquali->question_group->read',
'target' => '',
'user' => 0,
];

$this->menu[$r++] = [
'fk_menu' => 'fk_mainmenu=digiquali,fk_leftmenu=digiquali_question_group',
'type' => 'left',
'titre' => '<i class="fas fa-tags pictofixedwidth" style="padding-right: 4px;"></i>' . $langs->transnoentities('Categories'),
'mainmenu' => 'digiquali',
'leftmenu' => 'digiquali_surveytags',
'url' => '/categories/index.php?type=survey',
'leftmenu' => 'digiquali_question_groupytags',
'url' => '/categories/index.php?type=question_group',
'langs' => 'digiquali@digiquali',
'position' => 1000 + $r,
'enabled' => '$conf->digiquali->enabled && $conf->categorie->enabled && $user->rights->digiquali->survey->read',
'perms' => '$user->rights->digiquali->survey->read',
'enabled' => '$conf->digiquali->enabled && $conf->categorie->enabled && $user->rights->digiquali->question_group->read',
'perms' => '$user->rights->digiquali->question_group->read',
'target' => '',
'user' => 0,
];
Expand Down
102 changes: 102 additions & 0 deletions js/modules/question_group.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@

/**
* Initialise l'objet "questionGroup" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
* @since 1.1.0
* @version 1.1.0
*/
window.digiquali.questionGroup = {};

/**
* La méthode appelée automatiquement par la bibliothèque EoxiaJS.
*
* @since 1.1.0
* @version 1.1.0
*
* @return {void}
*/
window.digiquali.questionGroup.init = function() {
window.digiquali.questionGroup.event();
};

/**
* La méthode contenant tous les événements pour le questionGroup.
*
* @since 1.1.0
* @version 1.1.0
*
* @return {void}
*/
window.digiquali.questionGroup.event = function() {
$( document ).on( 'click', '.clicked-photo-preview', window.digiquali.questionGroup.previewPhoto );
$( document ).on( 'click', '.ui-dialog-titlebar-close', window.digiquali.questionGroup.closePreviewPhoto );
$( document ).on( 'click', '#show_photo', window.digiquali.questionGroup.showPhoto );
$( document ).on( 'click', '.answer-picto .item, .wpeo-table .item', window.digiquali.questionGroup.selectAnswerPicto );
};

/**
* Add border on preview photo.
*
* @since 1.1.0
* @version 1.1.0
*
* @param {MouseEvent} event Les attributs lors du clic.
* @return {void}
*/
window.digiquali.questionGroup.previewPhoto = function ( event ) {
if ($(this).hasClass('photo-ok')) {
$("#dialogforpopup").attr('style', 'border: 10px solid #47e58e')
} else if ($(this).hasClass('photo-ko')) {
$("#dialogforpopup").attr('style', 'border: 10px solid #e05353')
}
};

/**
* Close preview photo.
*
* @since 1.1.0
* @version 1.1.0
*
* @param {MouseEvent} event Les attributs lors du clic.
* @return {void}
*/
window.digiquali.questionGroup.closePreviewPhoto = function ( event ) {
$("#dialogforpopup").attr('style', 'border:')
};

/**
* Show photo for questionGroup.
*
* @since 1.3.0
* @version 1.3.0
*
* @return {void}
*/
window.digiquali.questionGroup.showPhoto = function() {
let photo = $(this).closest('.questionGroup-table').find('.linked-medias')

if (photo.hasClass('hidden')) {
photo.attr('style', '')
photo.removeClass('hidden')
} else {
photo.attr('style', 'display:none')
photo.addClass('hidden')
}
};

/**
* Lors du clic sur un picto de réponse, remplace le contenu du toggle et met l'image du picto sélectionné.
*
* @since 1.0.0
* @version 1.0.0
*
* @param {MouseEvent} event [description]
* @return {void}
*/
window.digiquali.questionGroup.selectAnswerPicto = function( event ) {
var element = $(this).closest('.wpeo-dropdown');
$(this).closest('.content').removeClass('active');
element.find('.dropdown-toggle span').hide();
element.find('.dropdown-toggle.button-picto').html($(this).closest('.wpeo-tooltip-event').html());
element.find('.input-hidden-picto').val($(this).data('label'));
};
14 changes: 14 additions & 0 deletions langs/fr_FR/digiquali.lang
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,20 @@ AutoSaveActionQuestionAnswer = Sauvegarde automatique des réponses a
AutoSaveActionQuestionAnswerDescription = Sauvegarde automatiquement les réponses aux questions lors du choix de la réponse
NoObjectLineAnswersPhoto = Pas de photos sur les réponses du %s



#
# Groupes de questions
#

# Data - Donnée
QuestionGroup = Groupe de questions
QuestionGroups = Groupes de questions
NewQuestionGroup = Nouveau groupe de questions
ModifyQuestionGroup = Modifier un groupe de questions



#
# ControlDocument - Fiche de Contrôle
#
Expand Down
37 changes: 37 additions & 0 deletions lib/digiquali_question_group.lib.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/* Copyright (C) 2022-2023 EVARISK <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* \file lib/digiquali_question_group.lib.php
* \ingroup digiquali
* \brief Library files with common functions for Question.
*/

// Load Saturne libraries.
require_once __DIR__ . '/../../saturne/lib/object.lib.php';

/**
* Prepare array of tabs for question group.
*
* @param QuestionGroup $object QuestionGroup object.
* @return array Array of tabs.
* @throws Exception
*/
function question_group_prepare_head(QuestionGroup $object): array
{
return saturne_object_prepare_head($object);
}
2 changes: 2 additions & 0 deletions sql/question_group/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
//Silence is golden
20 changes: 20 additions & 0 deletions sql/question_group/llx_categorie_question_group.key.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Copyright (C) 2022 EVARISK <[email protected]>
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/.

ALTER TABLE llx_categorie_question_group ADD PRIMARY KEY pk_categorie_question (fk_categorie, fk_question);
ALTER TABLE llx_categorie_question_group ADD INDEX idx_categorie_question_fk_categorie (fk_categorie);
ALTER TABLE llx_categorie_question_group ADD INDEX idx_categorie_question_fk_question (fk_question);
ALTER TABLE llx_categorie_question_group ADD CONSTRAINT fk_categorie_question_group_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid);
ALTER TABLE llx_categorie_question_group ADD CONSTRAINT fk_categorie_question_group_digiquali_question_group_rowid FOREIGN KEY (fk_question) REFERENCES llx_digiquali_question_group (rowid);
20 changes: 20 additions & 0 deletions sql/question_group/llx_categorie_question_group.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Copyright (C) 2022 EVARISK <[email protected]>
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/.

CREATE TABLE llx_categorie_question_group(
fk_categorie integer NOT NULL,
fk_question_group integer NOT NULL,
import_key varchar(14)
) ENGINE=innodb;
20 changes: 20 additions & 0 deletions sql/question_group/llx_digiquali_question_group.key.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Copyright (C) 2022 EVARISK <[email protected]>
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/.

ALTER TABLE llx_digiquali_question_group ADD INDEX idx_digiquali_question_group_rowid (rowid);
ALTER TABLE llx_digiquali_question_group ADD INDEX idx_digiquali_question_group_ref (ref);
ALTER TABLE llx_digiquali_question_group ADD INDEX idx_digiquali_question_group_status (status);
ALTER TABLE llx_digiquali_question_group ADD UNIQUE INDEX uk_digiquali_question_group_ref (ref, entity);
ALTER TABLE llx_digiquali_question_group ADD CONSTRAINT llx_digiquali_question_group_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid);
Loading

0 comments on commit 6160804

Please sign in to comment.