-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpersonal.php
146 lines (129 loc) · 6.25 KB
/
personal.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
// This file is part of the achievement plugin for Moodle
// This plugin 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 plugin 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 plugin. If not, see <http://www.gnu.org/licenses/>.
/**
*
* @package achievement
* @copyright 2012 Andil
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require(dirname(__FILE__).'/../../config.php');
require('achievement.php');
$PAGE->set_url('/blocks/achievement/personal.php');
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
$user = $USER; //TODO handle $_GET['id'] to display other user achievement
$navlinks[] = array('name' => get_string('blockname', 'block_achievement'),
'link' => '',
'type' => 'title');
$navlinks[] = array('name' => fullname($user),
'link' => '',
'type' => 'title');
$navigation = build_navigation($navlinks);
print_header_simple(get_string('modulename', 'block_achievement'), '', $navigation);
$tableheadtitle = get_string('tablehead_title', 'block_achievement');
$tableheaddesc = get_string('tablehead_desc', 'block_achievement');
$tableheaddate = get_string('tablehead_date', 'block_achievement');
$tableheadpercent = get_string('tablehead_accomplishmentpercent', 'block_achievement');
$currenttab = 'personaltab';
require('tabs.php');
?>
<script type="text/javascript" src="<?php echo $CFG->wwwroot; ?>/blocks/achievement/js/detail.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $CFG->wwwroot; ?>/blocks/achievement/css/achievement.css" />
<?php
$nbuser = $DB->count_records('user', array('deleted' => false));
$table->head = array($tableheadtitle, $tableheaddesc, $tableheaddate, $tableheadpercent);
$achievementprocessor = new achievement();
$achievementprocessor->load_achievementlist();
$achievementlist = $achievementprocessor->get_achievementlist();
$orderachievementlist = array('done' => array(), 'todo' => array());
foreach ($achievementlist as $currentachievement) {
$tmp = array('achievement' => $currentachievement->id);
$params = preg_split('/\|/', $currentachievement->compute_function_parameters);
if (($tmp['hassub'] = ($params[0] > 1)) === true) {
//compute progression
$tmp['progress'] = $achievementprocessor->achievementdone_search($user->achievementdone, $currentachievement) ?
1 : $achievementprocessor->get_progress_achievement_for_user($currentachievement, $user);
}
else {
$tmp['progress'] = $achievementprocessor->achievementdone_search($user->achievementdone, $currentachievement) ?
1 : 0;
}
if (($tmp['hassub'] && ($tmp['progress'] >= 1)) ||
($achievementprocessor->achievementdone_search($user->achievementdone, $currentachievement))
) {
$achuserdata = $achievementprocessor->get_achievementdone($currentachievement, $user);
$tmp['date'] = userdate($achuserdata->timecreated);
$orderachievementlist['done'][] = $tmp;
}
else {
$orderachievementlist['todo'][] = $tmp;
}
}
$achievementprocessor->aasort($orderachievementlist['todo'], 'progress');
$orderachievementlist['todo'] = array_reverse($orderachievementlist['todo']);
foreach ($orderachievementlist as $key => $value) {
echo $OUTPUT->heading(get_string($key, 'block_achievement'));
$attr = array('class' => ($key == 'done') ? 'achievementDone' : 'achievementTodo');
foreach ($value as $data) {
$currentachievement = $achievementlist[$data['achievement']];
?>
<div id="<?php echo $achievementprocessor->build_achievement_shortname($currentachievement); ?>" class="achievementEntry <?php echo $attr['class'];?>">
<div class="achieveTxtHolder">
<div class="achieveImgHolder">
<div class="pix">
<img
src="<?php echo $CFG->wwwroot . '/blocks/achievement/pix/' .$achievementprocessor->get_achievement_pix($currentachievement); ?>"
alt="<?php echo $achievementprocessor->get_achievement_string($currentachievement); ?>"/></div>
</div>
<div class="achieveTxt">
<h3><?php echo $achievementprocessor->get_achievement_string($currentachievement); ?></h3>
<h5><?php echo $achievementprocessor->get_achievement_string($currentachievement, '_desc'); ?></h5>
<?php
if(isset($data['hassub']) && $data['hassub']) {
?>
<img
src="<?php echo $CFG->wwwroot.'/blocks/achievement/pix/expand.png';?>"
alt="<?php echo get_string('seeprogression', 'block_achievement') ;?>"
title="<?php echo get_string('seeprogression', 'block_achievement') ;?>"
class="expand_icon">
<div class="progressbar">
<div class="bar" style="width:<?php echo $data['progress'] * 100-0.2;?>%; display:block;"></div>
<div class="progressbar-right"></div>
<div class="status"><?php
$nb = $achievementprocessor->get_donetime_achievement_for_user($currentachievement, $user);
$params = preg_split('/\|/', $currentachievement->compute_function_parameters);
if($nb > $params[0]) $nb = $params[0];
echo $nb.' / '.$params[0].' ('. ($data['progress'] * 100) . '%)';
?></div>
</div>
<?php
}
?>
</div>
<?php
if($key == 'done'){
?>
<div class="achieveDate">
<?php echo $data['date'];?>
</div>
<?php
}
?>
</div>
</div>
<?php
}
}
$OUTPUT->footer();
?>