- Beranda
- Komunitas
- Tech
- Programmer Forum
[Ask/Help]Timer pada sistem informasi ujian online


TS
nimod
[Ask/Help]Timer pada sistem informasi ujian online
Pagi para master,
ane mau minta tolong...
ane mau buat waktu mundur buat Web ujian online gan,
nah scriptnya kyk gini.
nah waktunya ini ane jalanin sendiri uda berjalan dengan normal gan...
yang jadi masalah, pada saat ane pasang di halaman soal.php
kodingnya seperti ini
nah yang muncul diatas soal ujian hanya "Waktu Anda:.."
waktu mundurnya tdk berjalan...
itu apanya kira2 yang salah gan.
mohon pencerahanya para master...
ane mau minta tolong...
ane mau buat waktu mundur buat Web ujian online gan,
nah scriptnya kyk gini.
Spoiler for waktu mundur:
[removed]
var waktunya = 70;
var waktu;
var jalan = 0;
var habis = 0;
function init(){
checkCookie()
mulai();
}
function keluar(){
if(habis==0){
setCookie('waktux',waktu,365);
}else{
setCookie('waktux',0,-1);
}
}
function mulai(){
jam = Math.floor(waktu/3600);
sisa = waktu%3600;
menit = Math.floor(sisa/60);
sisa2 = sisa%60
detik = sisa2%60;
if(detik<10){
detikx = "0"+detik;
}else{
detikx = detik;
}
if(menit<10){
menitx = "0"+menit;
}else{
menitx = menit;
}
if(jam<10){
jamx = "0"+jam;
}else{
jamx = jam;
}
document.getElementById("divwaktu")[removed] = jamx+":"+menitx+":"+detikx+" --> "+waktu;
waktu --;
if(waktu>0){
t = setTimeout("mulai()",1000);
jalan = 1;
}else{
if(jalan==1){
clearTimeout(t);
}
habis = 1;
document.getElementById("formulir").submit();
}
}
function selesai(){
document.getElementById("formulir").submit();
}
function getCookie(c_name){
if ([removed].length>0){
c_start=[removed].indexOf(c_name + "=");
if (c_start!=-1){
c_start=c_start + c_name.length+1;
c_end=[removed].indexOf(";",c_start);
if (c_end==-1) c_end=[removed].length;
return unescape([removed].substring(c_start,c_end));
}
}
return "";
}
function setCookie(c_name,value,expiredays){
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
[removed]=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function checkCookie(){
waktuy=getCookie('waktux');
if (waktuy!=null && waktuy!=""){
waktu = waktuy;
}else{
waktu = waktunya;
setCookie('waktux',waktunya,7);
}
}
[removed]
</header>
<body>
<p>
Waktu anda : <div id=divwaktu></div>
<form action=isinilai.php method=post id=formulir>
<ol>
var waktunya = 70;
var waktu;
var jalan = 0;
var habis = 0;
function init(){
checkCookie()
mulai();
}
function keluar(){
if(habis==0){
setCookie('waktux',waktu,365);
}else{
setCookie('waktux',0,-1);
}
}
function mulai(){
jam = Math.floor(waktu/3600);
sisa = waktu%3600;
menit = Math.floor(sisa/60);
sisa2 = sisa%60
detik = sisa2%60;
if(detik<10){
detikx = "0"+detik;
}else{
detikx = detik;
}
if(menit<10){
menitx = "0"+menit;
}else{
menitx = menit;
}
if(jam<10){
jamx = "0"+jam;
}else{
jamx = jam;
}
document.getElementById("divwaktu")[removed] = jamx+":"+menitx+":"+detikx+" --> "+waktu;
waktu --;
if(waktu>0){
t = setTimeout("mulai()",1000);
jalan = 1;
}else{
if(jalan==1){
clearTimeout(t);
}
habis = 1;
document.getElementById("formulir").submit();
}
}
function selesai(){
document.getElementById("formulir").submit();
}
function getCookie(c_name){
if ([removed].length>0){
c_start=[removed].indexOf(c_name + "=");
if (c_start!=-1){
c_start=c_start + c_name.length+1;
c_end=[removed].indexOf(";",c_start);
if (c_end==-1) c_end=[removed].length;
return unescape([removed].substring(c_start,c_end));
}
}
return "";
}
function setCookie(c_name,value,expiredays){
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
[removed]=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function checkCookie(){
waktuy=getCookie('waktux');
if (waktuy!=null && waktuy!=""){
waktu = waktuy;
}else{
waktu = waktunya;
setCookie('waktux',waktunya,7);
}
}
[removed]
</header>
<body>
<p>
Waktu anda : <div id=divwaktu></div>
<form action=isinilai.php method=post id=formulir>
<ol>
nah waktunya ini ane jalanin sendiri uda berjalan dengan normal gan...
yang jadi masalah, pada saat ane pasang di halaman soal.php
kodingnya seperti ini
Spoiler for soal.php:
<div>
<?php
if(isset($_SESSION['id_user'])){
?>
<h1>Ujian <?php echo ucwords($_SESSION['username']);?></h1>
[removed]
var waktunya = 70;
var waktu;
var jalan = 0;
var habis = 0;
function init(){
checkCookie()
mulai();
}
function keluar(){
if(habis==0){
setCookie('waktux',waktu,365);
}else{
setCookie('waktux',0,-1);
}
}
function mulai(){
jam = Math.floor(waktu/3600);
sisa = waktu%3600;
menit = Math.floor(sisa/60);
sisa2 = sisa%60
detik = sisa2%60;
if(detik<10){
detikx = "0"+detik;
}else{
detikx = detik;
}
if(menit<10){
menitx = "0"+menit;
}else{
menitx = menit;
}
if(jam<10){
jamx = "0"+jam;
}else{
jamx = jam;
}
document.getElementById("divwaktu")[removed] = jamx+":"+menitx+":"+detikx+" --> "+waktu;
waktu --;
if(waktu>0){
t = setTimeout("mulai()",1000);
jalan = 1;
}else{
if(jalan==1){
clearTimeout(t);
}
habis = 1;
document.getElementById("formulir").submit();
}
}
function selesai(){
document.getElementById("formulir").submit();
}
function getCookie(c_name){
if ([removed].length>0){
c_start=[removed].indexOf(c_name + "=");
if (c_start!=-1){
c_start=c_start + c_name.length+1;
c_end=[removed].indexOf(";",c_start);
if (c_end==-1) c_end=[removed].length;
return unescape([removed].substring(c_start,c_end));
}
}
return "";
}
function setCookie(c_name,value,expiredays){
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
[removed]=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function checkCookie(){
waktuy=getCookie('waktux');
if (waktuy!=null && waktuy!=""){
waktu = waktuy;
}else{
waktu = waktunya;
setCookie('waktux',waktunya,7);
}
}
[removed]
</header>
<body>
<p>
Waktu anda : <div id=divwaktu></div>
<form action=isinilai.php method=post id=formulir>
<ol>
</ol>
</form>
</body>
</html>
<p>
<?php
$hasil=mysql_query("select * from tabel_soal where publish='yes'");
$jumlah=mysql_num_rows($hasil);
$urut=0;
while($row =mysql_fetch_array($hasil))
{
$id=$row["id_soal"];
$pertanyaan=$row["pertanyaan"];
$pilihan_a=$row["pilihan_a"];
$pilihan_b=$row["pilihan_b"];
$pilihan_c=$row["pilihan_c"];
$pilihan_d=$row["pilihan_d"];
?>
<form name="form1" method="post" action="?page=jawaban">
<input type="hidden" name="id[]" value=<?php echo $id; ?>>
<input type="hidden" name="jumlah" value=<?php echo $jumlah; ?>>
<table width="457" border="0">
<tr>
<td width="17"><font color="#FFFFFF"><?php echo $urut=$urut+1; ?></font></td>
<td width="430"><font color="#FFFFFF"><?php echo "$pertanyaan"; ?></font></td>
</tr>
<tr>
<td height="21"> </td>
<td><input name="pilihan[<?php echo $id; ?>]" type="radio" value="A"> <font color="#FFFFFF"><?php echo "$pilihan_a";?></font> </td>
</tr>
<tr>
<td> </td>
<td><input name="pilihan[<?php echo $id; ?>]" type="radio" value="B"> <font color="#FFFFFF"><?php echo "$pilihan_b";?></font> </td>
</tr>
<tr>
<td> </td>
<td><input name="pilihan[<?php echo $id; ?>]" type="radio" value="C"> <font color="#FFFFFF"><?php echo "$pilihan_c";?></font> </td>
</tr>
<tr>
<td> </td>
<td><input name="pilihan[<?php echo $id; ?>]" type="radio" value="D"> <font color="#FFFFFF"><?php echo "$pilihan_d";?></font> </td>
</tr>
</table>
<?php
}
?>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Jawab"></td>
</tr>
</form>
</p>
<?php
}else{
?><p>Anda belum login. silahkan <a href="index.php">Login</a></p><?php
}
?>
</div>
<?php
if(isset($_SESSION['id_user'])){
?>
<h1>Ujian <?php echo ucwords($_SESSION['username']);?></h1>
[removed]
var waktunya = 70;
var waktu;
var jalan = 0;
var habis = 0;
function init(){
checkCookie()
mulai();
}
function keluar(){
if(habis==0){
setCookie('waktux',waktu,365);
}else{
setCookie('waktux',0,-1);
}
}
function mulai(){
jam = Math.floor(waktu/3600);
sisa = waktu%3600;
menit = Math.floor(sisa/60);
sisa2 = sisa%60
detik = sisa2%60;
if(detik<10){
detikx = "0"+detik;
}else{
detikx = detik;
}
if(menit<10){
menitx = "0"+menit;
}else{
menitx = menit;
}
if(jam<10){
jamx = "0"+jam;
}else{
jamx = jam;
}
document.getElementById("divwaktu")[removed] = jamx+":"+menitx+":"+detikx+" --> "+waktu;
waktu --;
if(waktu>0){
t = setTimeout("mulai()",1000);
jalan = 1;
}else{
if(jalan==1){
clearTimeout(t);
}
habis = 1;
document.getElementById("formulir").submit();
}
}
function selesai(){
document.getElementById("formulir").submit();
}
function getCookie(c_name){
if ([removed].length>0){
c_start=[removed].indexOf(c_name + "=");
if (c_start!=-1){
c_start=c_start + c_name.length+1;
c_end=[removed].indexOf(";",c_start);
if (c_end==-1) c_end=[removed].length;
return unescape([removed].substring(c_start,c_end));
}
}
return "";
}
function setCookie(c_name,value,expiredays){
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
[removed]=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function checkCookie(){
waktuy=getCookie('waktux');
if (waktuy!=null && waktuy!=""){
waktu = waktuy;
}else{
waktu = waktunya;
setCookie('waktux',waktunya,7);
}
}
[removed]
</header>
<body>
<p>
Waktu anda : <div id=divwaktu></div>
<form action=isinilai.php method=post id=formulir>
<ol>
</ol>
</form>
</body>
</html>
<p>
<?php
$hasil=mysql_query("select * from tabel_soal where publish='yes'");
$jumlah=mysql_num_rows($hasil);
$urut=0;
while($row =mysql_fetch_array($hasil))
{
$id=$row["id_soal"];
$pertanyaan=$row["pertanyaan"];
$pilihan_a=$row["pilihan_a"];
$pilihan_b=$row["pilihan_b"];
$pilihan_c=$row["pilihan_c"];
$pilihan_d=$row["pilihan_d"];
?>
<form name="form1" method="post" action="?page=jawaban">
<input type="hidden" name="id[]" value=<?php echo $id; ?>>
<input type="hidden" name="jumlah" value=<?php echo $jumlah; ?>>
<table width="457" border="0">
<tr>
<td width="17"><font color="#FFFFFF"><?php echo $urut=$urut+1; ?></font></td>
<td width="430"><font color="#FFFFFF"><?php echo "$pertanyaan"; ?></font></td>
</tr>
<tr>
<td height="21"> </td>
<td><input name="pilihan[<?php echo $id; ?>]" type="radio" value="A"> <font color="#FFFFFF"><?php echo "$pilihan_a";?></font> </td>
</tr>
<tr>
<td> </td>
<td><input name="pilihan[<?php echo $id; ?>]" type="radio" value="B"> <font color="#FFFFFF"><?php echo "$pilihan_b";?></font> </td>
</tr>
<tr>
<td> </td>
<td><input name="pilihan[<?php echo $id; ?>]" type="radio" value="C"> <font color="#FFFFFF"><?php echo "$pilihan_c";?></font> </td>
</tr>
<tr>
<td> </td>
<td><input name="pilihan[<?php echo $id; ?>]" type="radio" value="D"> <font color="#FFFFFF"><?php echo "$pilihan_d";?></font> </td>
</tr>
</table>
<?php
}
?>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Jawab"></td>
</tr>
</form>
</p>
<?php
}else{
?><p>Anda belum login. silahkan <a href="index.php">Login</a></p><?php
}
?>
</div>
nah yang muncul diatas soal ujian hanya "Waktu Anda:.."
waktu mundurnya tdk berjalan...
itu apanya kira2 yang salah gan.
mohon pencerahanya para master...

Diubah oleh nimod 12-05-2013 06:27
1
4.9K
Kutip
5
Balasan


Komentar yang asik ya
Urutan
Terbaru
Terlama


Komentar yang asik ya
Komunitas Pilihan