/
QuestionTemplate.php
91 lines (80 loc) · 3.03 KB
/
QuestionTemplate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
if (!defined('BASEPATH'))
die('No direct script access allowed');
/*
* LimeSurvey
* Copyright (C) 2007-2011 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
*/
class QuestionTemplate extends CFormModel
{
/**
* Called from admin, to generate the template list for a given question type
*/
static public function getQuestionTemplateList($type)
{
$sUserQTemplateRootDir = Yii::app()->getConfig("userquestiontemplaterootdir");
$aQuestionTemplates = array();
$aQuestionTemplates['core'] = gT('Default');
$aTypeToFolder = self::getTypeToFolder($type);
$sFolderName = $aTypeToFolder[$type];
if ($sUserQTemplateRootDir && is_dir($sUserQTemplateRootDir) ){
$handle = opendir($sUserQTemplateRootDir);
while (false !== ($file = readdir($handle))){
// Maybe $file[0] != "." to hide Linux hidden directory
if (!is_file("$sUserQTemplateRootDir/$file") && $file != "." && $file != ".." && $file!=".svn"){
if (is_dir("$sUserQTemplateRootDir/$file/survey/questions/answer/$sFolderName")){
$templateName = $file;
$aQuestionTemplates[$file] = $templateName;
}
}
}
}
return $aQuestionTemplates;
}
/**
* Correspondance between question type and the view folder name
* Rem: should be in question model. We keep it here for easy access
*/
static public function getTypeToFolder()
{
return array(
"1" => 'arrays/dualscale',
"5" => '5pointchoice',
"A" => 'arrays/5point',
"B" => 'arrays/10point',
"C" => 'arrays/yesnouncertain',
"D" => 'date',
"E" => 'arrays/increasesamedecrease',
"F" => 'arrays/array',
"G" => 'gender',
"H" => 'arrays/column',
"I" => 'language',
"K" => 'multiplenumeric',
"L" => 'listradio',
"M" => 'multiplechoice',
"N" => 'numerical',
"O" => 'list_with_comment',
"P" => 'multiplechoice_with_comments',
"Q" => 'multipleshorttext',
"R" => 'ranking',
"S" => 'shortfreetext',
"T" => 'longfreetext',
"U" => 'longfreetext',
"X" => 'boilerplate',
"Y" => 'yesno',
"!" => 'list_dropdown',
":" => 'arrays/multiflexi',
";" => 'arrays/texts',
"|" => 'file_upload',
"*" => 'equation',
);
}
}