-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathQuizStatusLabelHelper.php
More file actions
77 lines (72 loc) · 1.95 KB
/
QuizStatusLabelHelper.php
File metadata and controls
77 lines (72 loc) · 1.95 KB
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
<?php
/**
* Quizzes App Helper
*
* @author Allcreator Co., Ltd. <info@allcreator.net>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
App::uses('AppHelper', 'View/Helper');
/**
* Quizzes Status Label Helper
*
* @author Allcreator Co., Ltd. <info@allcreator.net>
* @package NetCommons\Quizzes\View\Helper
*/
class QuizStatusLabelHelper extends AppHelper {
/**
* Status label
*
* @param array $quiz quiz
* @return string
*/
public function statusLabel($quiz) {
$status = $quiz['Quiz']['status'];
//初期値セット
$lblColor = 'danger';
$lblMsg = __d('quizzes', 'Undefined');
if ($status == WorkflowComponent::STATUS_IN_DRAFT) {
//一時保存中
$lblColor = 'info';
$lblMsg = __d('net_commons', 'Temporary');
} elseif ($status == WorkflowComponent::STATUS_APPROVAL_WAITING) {
//承認待ち
$lblColor = 'warning';
$lblMsg = __d('net_commons', 'Approving');
} elseif ($status == WorkflowComponent::STATUS_DISAPPROVED) {
//差し戻し
$lblColor = 'danger';
$lblMsg = __d('net_commons', 'Disapproving');
} else {
if ($quiz['Quiz']['period_range_stat'] == QuizzesComponent::QUIZ_PERIOD_STAT_BEFORE) {
//未実施
$lblColor = 'default';
$lblMsg = __d('quizzes', 'Before public');
} elseif ($quiz['Quiz']['period_range_stat'] == QuizzesComponent::QUIZ_PERIOD_STAT_END) {
//終了
$lblColor = 'default';
$lblMsg = __d('quizzes', 'End');
} else {
$lblMsg = '';
}
}
if ($lblMsg) {
return '<span class="label label-' . $lblColor . '">' . $lblMsg . '</span>';
}
return '';
}
/**
* Status label for management widget
*
* @param array $quiz quiz data
* @return string
*/
public function statusLabelManagementWidget($quiz) {
$label = $this->statusLabel($quiz);
if ($label == '') {
$label = __d('net_commons', 'Published');
}
return $label;
}
}