-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprograms.php
119 lines (116 loc) · 3.11 KB
/
programs.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
<?php
$prgindx=12348;
include_once("includes/config.php");
$stdid=$loginfo->getUserId();
if(!$loginfo->isLoggedIn())
{
redirect("index.php");
}
function mysql_2_php_date($str)
{
$str=trim($str);
//'2012-05-14 10:19:30';
list($day,$time)=explode(" ", $str);
list($hour,$minute,$second)=explode(":", $time);
list($year,$month,$day)=explode("-", $day);
return mktime($hour,$minute,$second,$month,$day,$year);
}
function isallowed($progid,$studid)
{
//echo $progid.",".$studid;
$sql="select prog_start_date, prog_expire_date from es_prog where prog_id=$progid";
$res=mysql_query($sql);
$prog_start_date=0;
$prog_exp_date=0;
if($row=mysql_fetch_array($res))
{
$prog_start_date=mysql_2_php_date($row[0]);
$prog_exp_date=mysql_2_php_date($row[1]);
if($prog_start_date > time() || $prog_exp_date < time())
{
//echo "gdfc";
return false;
}
}
else{
//echo "gdf";
return false;
}
$sql="select max(sp_test_start_time) from es_std_prog where sp_std_id=$studid and sp_prog_id=$progid";// and sp_status='over'";
$res=mysql_query($sql);
if($row=mysql_fetch_array($res))
{
//var_dump($row);
if($row[0]==NULL || $row[0]==""){
//echo "da";
return true;
}
$lasttime=mysql_2_php_date($row[0]);
//echo $lasttime." \n<br\>";
if($prog_start_date > $lasttime)
{
//echo "asd";
return true;
}
return false;
}
return true;
}
$error="";
if(isset($_SESSION['prgerror']))
{
$error=$_SESSION['prgerror'];
unset($_SESSION['prgerror']);
}
?>
<?php include('includes/upper.php'); ?>
<!-- js or css here -->
<script>
$(function() {
$( "#accordion" ).accordion({
autoHeight: false,
navigation: true
});
$("a.taketest").css("cursor","pointer")
.css("text-decoration","underline")
.click(function(){window.open("question.php?prgid="+$(this).attr("prgid"),"_self")})
$("a.viewporg").css("cursor","pointer")
.css("text-decoration","underline")
.click(function(){alert("Not Implemented")})
});
</script>
<?php include('includes/middle.php'); ?>
<?php //include('includes/content_program.php'); ?>
<div class="demo">
<div class="prgpad ui-widget-header ui-corner-all">Programs</div>
<?php if($error!="") echo'<div style="padding: 0pt 0.7em;" class="ui-state-error ui-corner-all">'.$error.'</div>'; ?>
<div id="accordion">
<?php
//echo $stdid;
$sql="select * from es_prog where prog_deleted=0";
$res = mysql_query($sql);
while ($row = mysql_fetch_array($res)) {
?>
<h3><a href="#"><?php echo $row['prog_name']; ?></a></h3>
<div>
<p>
<div><?php echo htmlentities ( $row['prog_short_desc']) ?></div>
<div>
Started on: <span style="color:blue"><?php echo date("l, jS \of F Y h:i A",strtotime($row[7]));?></span>,
Expired on: <span style="color:blue"><?php echo date("l, jS \of F Y h:i A",strtotime($row[6]));?></span>
</div>
<div>
<a class="viewporg" prgid="<?php echo ($prgindx+$row[0]);?>">View Details</a>
<?php if( isallowed($row[0],$loginfo->getUserId())) { ?>
<a class="taketest" prgid="<?php echo ($prgindx+$row[0]);?>">Take Test</a>
<?php } ?>
</div>
</p>
</div>
<?php
}
mysql_free_result($res);
?>
</div>
</div>
<?php include('includes/lower.php'); ?>