-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathQuizGradeLinkHelper.php
More file actions
78 lines (73 loc) · 1.81 KB
/
QuizGradeLinkHelper.php
File metadata and controls
78 lines (73 loc) · 1.81 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
78
<?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 QuizGradeLinkHelper extends AppHelper {
/**
* Other helpers used by FormHelper
*
* @var array
*/
public $helpers = array(
'Workflow.Workflow',
'NetCommons.NetCommonsForm',
'NetCommons.NetCommonsHtml',
'Form'
);
/**
* Goto Grade Page Link
*
* @param array $quiz quiz
* @return string
*/
public function getGradePageLink($quiz) {
if ($this->canGrade($quiz)) {
$gradingUrl = NetCommonsUrl::actionUrl(array(
'controller' => 'quiz_result',
'action' => 'index',
Current::read('Block.id'),
$quiz['Quiz']['key'],
'frame_id' => Current::read('Frame.id'),
));
} else {
$ownAnswere = $this->_View->viewVars['ownAnswerdSummaryMap'];
$gradingUrl = NetCommonsUrl::actionUrl(array(
'controller' => 'quiz_result',
'action' => 'view',
Current::read('Block.id'),
$quiz['Quiz']['key'],
$ownAnswere[$quiz['Quiz']['key']],
'frame_id' => Current::read('Frame.id'),
));
}
// ※未採点のデータがあります
$text = '<span class="text-danger">' .
__d('quizzes', '! There is a non-scoring of data') .
'</span>';
$ret = $this->NetCommonsHtml->link($text, $gradingUrl, array('escape' => false));
return $ret;
}
/**
* canGrade
*
* 採点できるかどうか
*
* @param array $quiz 対象となる小テスト
* @return bool
*/
public function canGrade($quiz) {
return Current::permission('block_editable');
}
}