Changed grade_item so that its grademax is count(scale_items) and grademin is 1,...
[moodle-pu.git] / lib / bennu / bennu.class.php
blob40435c7006ebefae575c7597c18c968106718721
1 <?php // $Id$
3 /**
4 * BENNU - PHP iCalendar library
5 * (c) 2005-2006 Ioannis Papaioannou (pj@moodle.org). All rights reserved.
7 * Released under the LGPL.
9 * See http://bennu.sourceforge.net/ for more information and downloads.
11 * @author Ioannis Papaioannou
12 * @version $Id$
13 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
16 class Bennu {
17 function timestamp_to_datetime($t = NULL) {
18 if($t === NULL) {
19 $t = time();
21 return gmstrftime('%Y%m%dT%H%M%SZ', $t);
24 function generate_guid() {
25 // Implemented as per the Network Working Group draft on UUIDs and GUIDs
27 // These two octets get special treatment
28 $time_hi_and_version = sprintf('%02x', (1 << 6) + mt_rand(0, 15)); // 0100 plus 4 random bits
29 $clock_seq_hi_and_reserved = sprintf('%02x', (1 << 7) + mt_rand(0, 63)); // 10 plus 6 random bits
31 // Need another 14 random octects
32 $pool = '';
33 for($i = 0; $i < 7; ++$i) {
34 $pool .= sprintf('%04x', mt_rand(0, 65535));
37 // time_low = 4 octets
38 $random = substr($pool, 0, 8).'-';
40 // time_mid = 2 octets
41 $random .= substr($pool, 8, 4).'-';
43 // time_high_and_version = 2 octets
44 $random .= $time_hi_and_version.substr($pool, 12, 2).'-';
46 // clock_seq_high_and_reserved = 1 octet
47 $random .= $clock_seq_hi_and_reserved;
49 // clock_seq_low = 1 octet
50 $random .= substr($pool, 13, 2).'-';
52 // node = 6 octets
53 $random .= substr($pool, 14, 12);
55 return $random;