@@ 38-60 (lines=23) @@ | ||
35 | * @param $options |
|
36 | * @return array |
|
37 | */ |
|
38 | function b_XHP_completed_show($options) |
|
39 | { |
|
40 | global $xoopsDB, $xoopsUser, $xoopsConfig; |
|
41 | $myts = MyTextSanitizer::getInstance(); |
|
42 | $block = array(); |
|
43 | $mydirname = $options[3]; |
|
44 | $mymodpath = "modules/$mydirname"; |
|
45 | include "$mymodpath/module_prefix.php"; |
|
46 | $rsl = $xoopsDB->prefix($module_prefix . '_results'); |
|
47 | $usr = $xoopsDB->prefix('users'); |
|
48 | $sql = |
|
49 | "SELECT count(*) AS completed, $rsl.uid, $usr.uname FROM $rsl INNER JOIN $usr ON $rsl.uid=$usr.uid GROUP BY $rsl.uid HAVING completed >= $options[2] ORDER BY completed $options[0] LIMIT $options[1]"; |
|
50 | $result = $xoopsDB->query($sql); |
|
51 | while ($myrow = $xoopsDB->fetchArray($result)) { |
|
52 | $items = array(); |
|
53 | $items['completed'] = $myrow['completed']; |
|
54 | $items['uname'] = $myrow['uname']; |
|
55 | $items['uid'] = $myrow['uid']; |
|
56 | $block['items'][] = $items; |
|
57 | } |
|
58 | ||
59 | return $block; |
|
60 | } |
|
61 | ||
62 | /** |
|
63 | * @param $options |
@@ 38-60 (lines=23) @@ | ||
35 | * @param $options |
|
36 | * @return array |
|
37 | */ |
|
38 | function b_XHP_ranking_show($options) |
|
39 | { |
|
40 | global $xoopsDB, $xoopsUser, $xoopsConfig; |
|
41 | $myts = MyTextSanitizer::getInstance(); |
|
42 | $block = array(); |
|
43 | $mydirname = $options[3]; |
|
44 | $mymodpath = "modules/$mydirname"; |
|
45 | include "$mymodpath/module_prefix.php"; |
|
46 | $rsl = $xoopsDB->prefix($module_prefix . '_results'); |
|
47 | $usr = $xoopsDB->prefix('users'); |
|
48 | $sql = |
|
49 | "SELECT round(avg(score),2) AS average, $rsl.uid, $usr.uname FROM $rsl INNER JOIN $usr ON $rsl.uid=$usr.uid GROUP BY $rsl.uid HAVING average >= $options[2] ORDER BY average $options[0] LIMIT $options[1]"; |
|
50 | $result = $xoopsDB->query($sql); |
|
51 | while ($myrow = $xoopsDB->fetchArray($result)) { |
|
52 | $items = array(); |
|
53 | $items['average'] = $myrow['average']; |
|
54 | $items['uname'] = $myrow['uname']; |
|
55 | $items['uid'] = $myrow['uid']; |
|
56 | $block['items'][] = $items; |
|
57 | } |
|
58 | ||
59 | return $block; |
|
60 | } |
|
61 | ||
62 | /** |
|
63 | * @param $options |