46 Universitas Kristen Petra
4. IMPLEMENTASI SISTEM
Pada bab 4 ini, akan dijelaskan mengenai implementasi dari desain sistem yang telah dibuat pada bab 3. Penulis akan menjelaskan cara mengatur database web beserta menu pada web. Database yang digunakan adalah MySQL 5 dan untuk pembuatan web menggunakan web server Apache 2.2 dan bahasa pemrograman PHP versi 2.2.4.
4.1. Implementasi Database
Database yang digunakan dalam pembuatan web modul pembelajaran Bayesian Network adalah MySQL 5. Pengaturan database dapat dilakukan melalui phpMyAdmin. Database yang dibuat sesuai dengan desain sistem yang dibuat pada Bab 3, seperti terlihat pada Gambar 4.1.
Gambar 4.1. Tampilan phpMyAdmin
4.2. Setting Koneksi Database
Untuk menghubungkan database MySQL 5 dengan aplikasi web agar data
yang terdapat pada database dapat diakses menggunakan pemrograman PHP
dengan mengetikkan perintah berikut pada script PHP. Untuk koneksi database
terdapat dalam file connection.php seperti ditunjukkan oleh segment program 4.1.
47 Universitas Kristen Petra
Segment program 4.1. Koneksi PHP- Database
4.3. Implementasi Interface
Desain interface yang digunakan dalam aplikasi web terdiri dari header, menu, side-menu, dan footer. Penjelasan mengenai form-form yang digunakan pada aplikasi web dapat dilihat pada Tabel 4.1.
Tabel 4.1. Daftar dan Keterangan Form
User Nama Form Keterangan
Admin
Index.php Login
Tutorial.php Menambah topik baru Newtutorial.php Menambah sub topik baru New.php Mengedit sub topic Sound.php Menambah sound file Video.php Menambah movie file
Quiz.php Memilih topik untuk soal latihan Quizex.php Mengedit soal latihan
Newquiz.php Memilih soal latihan History.php Melihat history Viewhistory.php Melihat detail history Profile.php Mengedit isi profile
Deltemp.php Menghapus urutan soal latihan
Delquizex.php Menghapus topik exercise yang di view Logout.php Logout
Index.php Melihat halaman utama
<?php
$dbserver="localhost";
$dbuser="root";
$dbpass="";
$dbname="TA";
$con=mysql_connect($dbserver,$dbuser,$dbpass);
mysql_select_db($dbname);
?>
48 Universitas Kristen Petra
Tabel 4.1. Daftar dan Keterangan Form ( lanjutan )
User
Tutorial.php Memilih topik materi Newtutorial.php Melihat materi
Quiz.php Memilih topik untuk soal latihan Newquiz.php Melihat soal latihan
Signup.php Sign up
Profile.php Melihat profile
Pdf2.php Menampilkan data untuk diproses ke format pdf
4.4. Implementasi Program
Implementasi aplikasi web dirancang dengan menggunakan bahasa PHP.
Dalam aplikasi web ini terdapat dua macam user yang berbeda, yaitu admin dan user. Admin memiliki akses ke dalam semua halaman web, sedangkan user biasa dapat dibagi menjadi dua yaitu user yang sudah menjadi member selanjutnya ditulis member dan user yang belum menjadi member selanjutnya ditulis user.
Berikut adalah tabel perbandingan halaman yang dapat diakses oleh admin dan user seperti yang telah dilakukan pada bab 3.
Tabel 4.2. Tabel Perbandingan Akses Halaman Utama
Form Administrator User Member
Index √ √ √
Tutorial √ √ √
Member √ √ √
Profile √ √ √
Exercise √ √ √
49 Universitas Kristen Petra
Tabel 4.3. Tabel Perbandingan Akses Halaman Admin
Form Administrator User Member
Index √ - -
Tutorial √ - √
Member √ - -
Profile √ - -
Exercise √ - √
History √ - -
4.4.1. Form Index
Halaman ini adalah halaman utama dari aplikasi web ini, pada halaman ini terdapat menu-menu untuk masuk ke form lainnya dan dapat login untuk masuk ke halaman admin sesuai dengan hak akses user. Seperti terlihat pada Segmen Program 4.2.
Segmen program 4.2. Index
<html>
<head>
<title>Home</title>
<link rel=stylesheet type="text/css" href="style.css">
</head>
<body bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0"
topmargin="0" background="images/background.jpg">
<form method="POST">
<table width="780" height="0" cellpadding="0" cellspacing="0" border="0">
<tr >
<td >
<img src="templogotop.jpg" width="780" height="140" border="0" alt=""></td>
<tr ><td >
<div id="menu" >
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="tutorial.php">tutorial</a></li>
<li><a href="member.php">member</a></li>
<li><a href="profile.php">profile</a></li>
</ul>
</div>
</td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="175">
<table width="175" cellpadding="10" cellspacing="5" border="0"><tr valign="top"><td width="175">
<BR>
<a href="index.php">Home</a><BR>
<a href="tutorial.php">Tutorial</a><BR>
<a href="member.php">Member</a><BR>
<a href="profile.php">Profile</a><BR>
<!--<a href="">Logout</a><BR>-->
<br><p><font size="2">
Name <input type="text" name="nama" width="3">
Password<input type="password" name="pass">
<input type="submit" name="login" value="login">
50 Universitas Kristen Petra
Segmen program 4.2. Index ( lanjutan )
4.4.2. Form login
Halaman ini digunakan untuk melakukan autentikasi user, apakah user adalah admin atau member yang sedang melakukan proses login. Untuk melakukan login, user harus memasukkan username dan password pada text box yang tersedia. Seperti terlihat pada Segmen Program 4.3.
Segmen Program 4.3. login
</ul></div></td></tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td width="175">
<table width="175" cellpadding="10" cellspacing="5" border="0"><tr valign="top"><td width="175">
<BR>
<a href="index.php">Home</a><BR>
<a href="tutorial.php">Tutorial</a><BR>
<a href="member.php">Member</a><BR>
<a href="profile.php">Profile</a><BR>
<!--<a href="">Logout</a><BR>-->
<br><p><font size="2">
Name <input type="text" name="nama" width="3">
Password<input type="password" name="pass">
<input type="submit" name="login" value="login">
<p>Not a member yet?<a href="signup.php">sign up</a> now</p>
</font></p></td></tr></table></td>
<td width="1000">
<table width="710" cellpadding="5" cellspacing="5" border="0" >
<tr valign="top">
<td width="700">
<h3>Home</h3>
<?php
include("connection.php");
$sql="select content from tisi where page_name='index'";
$res=mysql_query($sql);
$id=mysql_result($res,0,0);
echo "$id";
?>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<center>This site is © Copyright Ivan 2008-2009, All Rights Reserved.</center>
<center>
</td></tr></table></td></tr></table> </form></body></html>
<?php session_start();
if(isset($_POST['login'])) {
include("connection.php");
$stat=0;
$login=$_POST['nama'];
$pw=$_POST['pass'];
$sql="select nama from tlogin";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
for($i=0;$i<$count;$i++) {
$id=mysql_result($res,$i,0);
if($login==$id) {
51 Universitas Kristen Petra
Segmen Program 4.3. login ( lanjutan )
4.4.3. Form Signup
Halaman ini digunakan oleh user untuk melakukan sign up sehingga dapat menjadi member. Seperti terlihat pada Segmen Program 4.4.
Segmen Program 4.4. Sign Up
$sql="select pass from tlogin ";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
for($j=0;$j<$count;$j++) {
$pass=mysql_result($res,$j,0);
if($pw==$pass) {
$stat=1;
setcookie("user",$_POST['nama'],time()+3600);
$_SESSION['name']=$_POST['nama'];
if($login=='admin')
header("location:admin/index.php");
else
header("location:admin/tutorial.php");
} }
} }
if($stat==0) echo"<script>alert('Wrong Name or Password,please try again!');</script>";
}
?>
<html>
<head>
<title>Sign Up</title>
<link rel=stylesheet type="text/css" href="style.css">
</head>
<body bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0"
topmargin="0" background="images/background.jpg">
<form method="POST">
<table width="780" height="0" cellpadding="0" cellspacing="0" border="0">
<tr >
<td >
<img src="templogotop.jpg" width="780" height="140" border="0" alt=""></td>
<tr ><td >
<div id="menu" >
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="tutorial.php">tutorial</a></li>
<li><a href="member.php">member</a></li>
<li><a href="profile.php">profile</a></li>
</ul>
</div>
</td></tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="175">
<table width="175" cellpadding="10" cellspacing="5" border="0"><tr valign="top"><td width="175">
<BR>
<a href="index.php">Home</a><BR>
<a href="tutorial.php">Tutorial</a><BR>
<a href="member.php">Member</a><BR>
<a href="profile.php">Profile</a><BR>
<br><p><font size="2">
Name <input type="text" name="nama" width="3">
Password<input type="password" name="pass">
<input type="submit" name="login" value="login">
<p>Not a member yet?<a href="signup.php">sign up</a> now</p>
</font></p>
</td></tr></table>
</td>
52 Universitas Kristen Petra
Segmen Program 4.4. Sign Up ( lanjutan )
<br><p><font size="2">
Name <input type="text" name="nama" width="3">
Password<input type="password" name="pass">
<input type="submit" name="login" value="login">
<p>Not a member yet?<a href="signup.php">sign up</a> now</p>
</font></p>
</td></tr></table>
</td> <td width="1000"> <table width="710" cellpadding="5" cellspacing="5" border="0" >
<tr valign="top"> <td width="700">
<h3>Sign Up</h3>
<table>
<?php
if(isset($_POST['signup']))
{ //signup user
include("connection.php");
$username=$_POST['snama'];
$pass1=$_POST['spassword1'];
$pass2=$_POST['spassword2'];
$namal=$_POST['namal'];
$email=$_POST['email'];
$country=$_POST['country'];
$city=$_POST['city'];
$occupation=$_POST['occupation'];
$companies=$_POST['companies'];
$degree=$_POST['degree'];
$sql="select nama from tlogin where nama='$nama'";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
if($count!=0)
echo "<font face=\"Arial\" size=\"-1\" color=\"#FF0000\">Please choose another username<br></font>";
else if($username=="" or $pass1=="" or $pass2=="" or $namal==""){
echo "<font face=\"Arial\" size=\"-1\" color=\"#FF0000\">Invalid input, * is required<br></font>";
} else if($pass1!=$pass2){
echo "<font face=\"Arial\" size=\"-1\" color=\"#FF0000\">Password does not match<br></font>";
} else{
$sql="insert into tlogin
values('$username','$pass1','$email','$namal','$country','$city','$occupation','$companies','$degree','1')";
$res=mysql_query($sql);
echo "<font face=\"Arial\" size=\"-1\" color=\"#FF0000\">Sign up is success<br></font>";
} }
?>
<tr><td>Username</td><td> <input type="text" name="snama" style="width:300px">*</td></tr>
<tr><td>Password</td><td> <input type="password" name="spassword1"
style="width:300px">*</td></tr>
<tr><td>Re-type password</td><td> <input type="password" name="spassword2"
style="width:300px">*</td></tr>
<tr><td>Nama</td><td> <input type="text" name="namal" style="width:300px">*</td></tr>
<tr><td>E-mail address</td><td> <input type="text" name="email" style="width:300px">*</td></tr>
<tr><td>Country</td><td> <input type="text" name="country" style="width:300px"></td></tr>
<tr><td>City</td><td> <input type="text" name="city" style="width:300px"></td></tr>
<tr><td>Occupation</td><td> <input type="text" name="occupation" style="width:300px"></td></tr>
<tr><td>Companies</td><td> <input type="text" name="companies" style="width:300px"></td></tr>
<tr><td>Degree</td><td> <input type="text" name="degree" style="width:300px"></td></tr>
</table>
<input type="submit" name="signup" value="sign up">
<BR><BR><BR><BR><BR><BR><BR><BR><BR>
<BR><BR><BR><BR><BR><BR><BR><BR><BR>
<center>This site is © Copyright Ivan 2008-2009, All Rights Reserved.</center>
<center> </td></tr> </table></td></tr>
</table>
</form>
</body>
</html>
53 Universitas Kristen Petra
4.4.4. Form Tutorial
Halaman ini digunakan untuk menampilkan materi yang terdapat pada web dan juga terdapat link untuk mengerjakan soal-soal latihan atau exercise. Seperti terlihat pada Segmen Program 4.5.
Segmen Program 4.5. Tutorial
Pada Segmen Program 4.5 menampilkan daftar materi yang terdapat pada web kemudian setelah memilih materi akan dialihkan pada newtutorial.php. Berikut adalah segment script pada newtutorial.php, seperti ditunjukkan pada Segmen Program 4.6.
<html>
<head>
<title>Tutorial</title>
<link rel=stylesheet type="text/css" href="style.css">
</head>
<body bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0"
topmargin="0" background="images/background.jpg">
<form method="POST">
<table width="780" height="0" cellpadding="0" cellspacing="0" border="0">
<tr >
<td >
<img src="templogotop.jpg" width="780" height="140" border="0" alt=""></td>
<tr ><td >
<div id="menu" >
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="tutorial.php">tutorial</a></li>
<li><a href="member.php">member</a></li>
<li><a href="profile.php">profile</a></li>
</ul>
</div>
</td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="175">
<table width="175" cellpadding="10" cellspacing="5" border="0"><tr valign="top"><td width="175">
<BR>
<a href="index.php">Home</a><BR>
<a href="tutorial.php">Tutorial</a><BR>
<?php
$sql="select id,topic_name from tlist";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
for($i=0;$i<$count;$i++){
$id=mysql_result($res,$i,0);
$tn=mysql_result($res,$i,1);
echo "<li><a href='newtutorial.php?q=$tn&id=$id'>$tn</a></li>";
}
?>
<a href="member.php">Member</a><BR>
<a href="profile.php">Profile</a><BR>
54 Universitas Kristen Petra
Segmen Program 4.6. View Tutorial
<html>
<head>
<script type="text/javascript" src="flowplayer/flowplayer-3.0.5.min.js"></script>
<title>Tutorial</title>
<script language="JavaScript" src="audio-player/audio-player/audio-player.js"></script>
<link rel=stylesheet type="text/css" href="style.css">
</head>
<body bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0"
topmargin="0" background="images/background.jpg">
<form method="POST">
<table width="780" height="0" cellpadding="0" cellspacing="0" border="0">
<tr >
<td >
<img src="templogotop.jpg" width="780" height="140" border="0" alt=""></td>
<tr ><td >
<div id="menu" >
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="tutorial.php">tutorial</a></li>
<li><a href="member.php">member</a></li>
<li><a href="profile.php">profile</a></li>
</ul>
</div>
</td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="175">
<table width="175" cellpadding="10" cellspacing="5" border="0"><tr valign="top"><td width="175">
<BR>
<a href="index.php">Home</a><BR>
<a href="tutorial.php">Tutorial</a><BR>
<?php
$sql="select id,topic_name from tlist";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
for($i=0;$i<$count;$i++){
$id=mysql_result($res,$i,0);
$tn=mysql_result($res,$i,1);
echo "<li><a href='newtutorial.php?q=$tn&id=$id'>$tn</a></li>";
}
?>
<a href="member.php">Member</a><BR>
<a href="profile.php">Profile</a><BR>
<br><p><font size="2">
Name <input type="text" name="nama" width="3">
Password<input type="password" name="pass">
<input type="submit" name="login" value="login">
<p>Not a member yet?<a href="signup.php">sign up</a> now</p>
</font></p>
</td></tr></table>
</td>
<td width="1000">
<table width="710" cellpadding="5" cellspacing="5" border="0" >
<tr valign="top">
<td width="700">
55 Universitas Kristen Petra
Segmen Program 4.6. View Tutorial ( lanjutan )
<?php
include("connection.php");
$sql="select topic_name from tlist where id='$c[1]'";
$res=mysql_query($sql);
$tn=mysql_result($res,0,0);
echo "<a href='exercise.php?q=$tn&id=$c[1]' target=\"_new\">exercise</a>";
echo "<br>Download PDF";
$sql="select page_name,content from tisi where id='$c[1]'";
$res=mysql_query($sql);
$id=mysql_result($res,0,0);
echo "<a name=\"0\"></a><h3>$c[1]."."$id</h3>";
$id=mysql_result($res,0,1);
echo $id;
echo "<br>";
$sql="select id,page_name,content from tisi where topic_id='$c[1]' order by id";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
echo "<table border=1 >";
echo "<tr><td bgcolor='#FAFFC4'>";
echo "<a href=\"#$count-1\">".$c[1];
$id=mysql_result($res,$count-1,1);
echo ". ".$id."</a><br>";
for($i=0;$i<$count-1;$i++){
$id=mysql_result($res,$i,0);
$length=strlen($id);
$length=$length/2;
for($j=0;$j<$length;$j++) echo " ";
echo "<a href=\"#$i\">".$c[1].$id;
$id=mysql_result($res,$i,1);
echo ". ".$id."</a><br>";
}
echo "</td></tr>";
echo "</table>";
echo "<br>";
$hid='true';
$x='a';
$y='a';
for($i=0;$i<$count-1;$i++){
$id=mysql_result($res,$i,0);
if($id=='1') {}
else{
echo "<a name=\"$i\"></a><b>".$c[1].$id.". ";
$id=mysql_result($res,$i,1);
echo $id."</b> <a href=\"#0\">Back to top</a>";
$id=mysql_result($res,$i,2);
echo "<br>";
$len=strlen($id);
for($j=0;$j<$len;$j++){
if($id[$j]=='^'){
//echo $x;
if($x=='a'){
$hid='false';
$a=explode('^',$id);
echo "title=".$a[1];
echo "<a href='admin/upload/$a[1]'
style='display:block;width:400px;height:300px' class='player'>
<img src='flowplayer/flow_eye.jpg'>
</a>";
$x='i';
}
elseif($x=='i') {$hid='true';$x='a';}
}
if($id[$j]=='`'){
if($y=='a'){
$hid='false';
$a=explode('`',$id);
echo "title=".$a[1];
echo "<object type=\"application/x-shockwave-flash\"
data=\"audio-player/audio-player/player.swf\" id=\"audioplayer1\" height=\"24\" width=\"290\">";
echo "<param name=\"movie\" value=\"audio-player/audio- player/player.swf\">";
echo "<param name=\"FlashVars\"
value=\"playerID=1&soundFile=admin/upload/$a[1]\">";
echo "<param name=\"quality\" value=\"high\">";
echo "<param name=\"menu\" value=\"false\">";
echo "<param name=\"wmode\" value=\"transparent\">";
56 Universitas Kristen Petra
Segmen Program 4.6. View Tutorial ( lanjutan )
4.4.5. Admin page
User yang telah melakukan proses login sebagai admin akan diarahkan pada halaman admin page, pada halaman ini admin tersebut dapat menggunakan semua fitur-fitur pada aplikasi web ini. Sedangkan ada beberapa halaman yang dapat diakses oleh member juga yaitu tutorial, exercise, add video, add sound clip.
4.4.5.1. Form Home
Halaman ini digunakan oleh admin untuk mengubah isi dari halaman utama pada web ini. Seperti terlihat pada Segmen Program 4.7.
$a=explode('`',$id);
echo "title=".$a[1];
echo "<object type=\"application/x-shockwave-flash\" data=\"audio- player/audio-player/player.swf\" id=\"audioplayer1\" height=\"24\" width=\"290\">";
echo "<param name=\"movie\" value=\"audio-player/audio- player/player.swf\">";
echo "<param name=\"FlashVars\"
value=\"playerID=1&soundFile=admin/upload/$a[1]\">";
echo "<param name=\"quality\" value=\"high\">";
echo "<param name=\"menu\" value=\"false\">";
echo "<param name=\"wmode\" value=\"transparent\">";
echo "</object>";
$y='i';
}
elseif($y=='i') {$hid='true';$y='a';}
}
elseif($hid=='false'){}
elseif($hid=='true') echo $id[$j];
} } }
echo"<br><br><br><br>";
echo "<a href='exercise.php?q=$tn&id=$c[1]' target=\"_new\">exercise</a>";
?>
<script>
$f("a.player", "flowplayer/flowplayer-3.0.5.swf", { // each clip comes from blip.tv
clip: { baseUrl: '' },
// disable controls from each player plugins: { controls:null }
})
</script>
<BR><BR><BR><BR><BR><BR><BR><BR><BR>
<center>This site is © Copyright Ivan 2008-2009, All Rights Reserved.</center>
</td></tr></table></td></tr>
</table>
</form>
</body>
</html>
57 Universitas Kristen Petra
Segmen Program 4.7. Home
<?php session_start();
if (!($_SESSION["name"])=='nama'){
header('Location: ../index.php');
}
else{
include("../connection.php");
include("../fckeditor/fckeditor.php");
include("deltemp.php");
$today = date("F j, Y. g:i a");
$login=$_COOKIE["user"];
if($_POST['input']) {
$isi=$_POST['FCKeditor1'];
$sql="update tisi set content='$isi' where page_name='index'";
$res=mysql_query($sql);
$sql2="insert into thistory values('','index','$today','$login','','$isi')";
$res=mysql_query($sql2);
echo "<script>alert('Input successful');</script>";
} }
?>
<html>
<head>
<title>Home</title>
<link rel=stylesheet type="text/css" href="style.css">
</head>
<body bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0"
topmargin="0" background="images/background.jpg">
<form method="POST">
<table width="800" height="0" cellpadding="0" cellspacing="0" border="0">
<tr ><td >
<img src="templogotop.jpg" width="780" height="140" border="0" alt=""></td>
<tr ><td >
<div id="menu" >
<ul>
<?php
if($login=='admin')
echo "<li><a href=\"index.php\">Home</a></li>";
?>
<li><a href="tutorial.php">tutorial</a></li>
<li><a href="quiz.php">exercise</a></li>
<?php
if($login=='admin'){
echo "<li><a href=\"member.php\">member</a></li>";
echo "<li><a href=\"profile.php\">profile</a></li>";
echo "<li><a href=\"history.php\">history</a></li>";
}
?>
<li><a href="logout.php" title="">logout</a></li>
</ul></div>
</td></tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="175">
<table width="175" cellpadding="10" cellspacing="5" border="0"><tr valign="top"><td width="175">
<BR>
<?php
if($login=='admin')
echo "<a href=\"index.php\">Home</a><br>";
?>
<a href="tutorial.php">Tutorial</a><BR>
<a href="quiz.php">Exercise</a><BR>
<?php
if($login=='admin'){
echo "<a href=\"member.php\">Member</a><br>";
echo "<a href=\"profile.php\">Profile</a><br>";
echo "<a href=\"history.php\">History</a><br><br>";
}
?>
<a href="logout.php">Logout</a><BR>
</font></p>
</td></tr></table>
</td>
<td width="1000">
<table width="710" cellpadding="5" cellspacing="5" border="0" >
<tr valign="top">
<td width="700">
<h3>Home Page</h3>
58 Universitas Kristen Petra
Segmen Program 4.7. Home ( lanjutan )
4.4.5.2. Form Add Tutorial
Halaman ini digunakan untuk menambah topik materi baru, memilih topik materi yang sudah ada dan mengubah isi halaman tutorial pada aplikasi web. Halaman ini dapat diakses juga oleh member setelah melakukan proses login. Seperti terlihat pada Segmen Program 4.8.
Segmen Program 4.8. Add Tutorial
if($id==""){
$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = $abasepath.'fckeditor/' ;
$oFCKeditor->Value ="Silahkan Isi Comming Issue";
$oFCKeditor->Height =400;
$oFCKeditor->Create() ; }
else{
$sql="select content from tisi where page_name='index'";
$res=mysql_query($sql);
$id=mysql_result($res,0,0);
$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = $abasepath.'fckeditor/' ;
$oFCKeditor->Value = $id;
$oFCKeditor->Height =400;
$oFCKeditor->Create() ; }
?>
<input type="submit" name="input" value="input">
<center>This site is © Copyright Ivan, All Rights Reserved.</center>
</td></tr>
</table>
</td></tr>
</table>
</form>
</body>
</html>
<?php
session_start();
if (!($_SESSION["name"])=='nama'){
header('Location: ../index.php');
}
else{
include("../connection.php");
include("../fckeditor/fckeditor.php");
include("deltemp.php");
$today = date("F j, Y. g:i a");
$login=$_COOKIE["user"];
if($_POST['addnew']){ //add new tutorial
$new=$_POST['newtopic'];
$sql="select * from tlist";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
$count=$count+1;
$boleh=1;
$sql="select topic_name from tlist";
$res=mysql_query($sql);
$count2=mysql_num_rows($res);
59 Universitas Kristen Petra
Segmen Program 4.8. Add Tutorial ( lanjutan )
for($i=0;$i<$count2;$i++){
$id=mysql_result($res,$i,0);
if($new==$id){
$boleh=0;
} }
if($boleh==0){
echo"<script>alert('Topic is already used')</script>";
} else{
$sql="insert into tlist values('$count','$new')";
$res=mysql_query($sql);
$sql="insert into tisi values('$new','$count','',0,'','$count','$login')";
$res=mysql_query($sql);
$sql="insert into thistory values('','$new','$today','$login','new topic','')";
$res=mysql_query($sql);
} }
if($_POST['input']) { //input isi tutorial
$isi=$_POST['FCKeditor1'];
$sql="insert into thistory values('','tutorial','$today','$login','','$isi')";
$res=mysql_query($sql);
$sql="update tisi set content='$isi' where page_name='tutorial'";
$res=mysql_query($sql);
echo "<script>alert('Input successful');</script>";
} }
?>
<html>
<head>
<title>Tutorial</title>
<link rel=stylesheet type="text/css" href="style.css">
</head>
<body bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0"
topmargin="0" background="images/background.jpg">
<form method="POST">
<table width="780" height="0" cellpadding="0" cellspacing="0" border="0">
<tr ><td >
<img src="templogotop.jpg" width="780" height="140" border="0" alt=""></td>
<tr ><td >
<div id="menu" >
<ul><?php
if($login=='admin')
echo "<li><a href=\"index.php\">Home</a></li>";
?>
<li><a href="tutorial.php">tutorial</a></li>
<li><a href="quiz.php">exercise</a></li>
<?php
if($login=='admin'){
echo "<li><a href=\"member.php\">member</a></li>";
echo "<li><a href=\"profile.php\">profile</a></li>";
echo "<li><a href=\"history.php\">history</a></li>";
}
?>
<li><a href="logout.php" title="">logout</a></li>
</ul></div>
</td></tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td width="175">
<table width="175" cellpadding="10" cellspacing="5" border="0"><tr valign="top"><td width="175">
<BR>
<?php
if($login=='admin')
echo "<a href=\"index.php\">Home</a><BR>";
?>
<a href="tutorial.php">Tutorial</a><BR>
60 Universitas Kristen Petra
Segmen Program 4.8. Add Tutorial ( lanjutan )
<?php
$sql="select id,topic_name from tlist";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
for($i=0;$i<$count;$i++){
$id=mysql_result($res,$i,0);
$tn=mysql_result($res,$i,1);
echo "<li><a href='newtutorial.php?q=$tn&id=$id'>$tn</a></li>";
}
echo "<a href=\"quiz.php\">Exercise</a><br>";
if($login=='admin'){
echo "<a href=\"member.php\">Member</a><br>";
echo "<a href=\"profile.php\">Profile</a><BR>";
echo "<a href=\"history.php\">History</a><br><br>";
}
?>
<a href="video.php">add video</a><br>
<a href="sound.php">add sound clip</a><br>
<br>
<a href="logout.php">Logout</a><BR>
</font></p>
</td></tr></table>
</td><td width="1000">
<table width="710" cellpadding="5" cellspacing="5" border="0" >
<tr valign="top">
<td width="700">
<h3>Tutorial Page</h3>
<?php
echo "Input new topic : <input type=\"text\" name=\"newtopic\" style=\"width:250px\">";
echo "<br><input type=\"submit\" name=\"addnew\" value=\"Add\">";
echo "<br><br>";
$sql="select content from tisi where page_name='tutorial'";
$res=mysql_query($sql);
$id=mysql_result($res,0,0);
if($id==""){
$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = $abasepath.'fckeditor/' ;
$oFCKeditor->Value ="Silahkan Isi Comming Issue";
$oFCKeditor->Height =400;
$oFCKeditor->Create() ; }
else{
$sql="select content from tisi where page_name='tutorial'";
$res=mysql_query($sql);
$id=mysql_result($res,0,0);
$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = $abasepath.'fckeditor/' ;
$oFCKeditor->Value = $id;
$oFCKeditor->Height =400;
$oFCKeditor->Create() ; }
?>
<input type="submit" name="input" value="input">
<center>This site is © Copyright Ivan, All Rights Reserved.</center>
</td></tr>
</table>
</td></tr>
</table>
</form>
</body>
</html>
61 Universitas Kristen Petra
4.4.5.3. Form Select Tutorial
Halaman ini digunakan untuk memilih subtopik dari topik yang sudah dipilih. Pada halaman ini menggunakan script AJAX untuk mengarahkan ke halaman subtopik yang dipilih oleh user. Berikut adalah segmen script AJAX, seperti ditunjukan pada Segment Srogram 4.9 dan Segmen Program 4.10 untuk segmen script program.
Segmen Program 4.9. Script AJAX
function chtopic(str) {
var xmlHttp;
try {
// Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest();
} catch (e) {
// Internet Explorer try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) { try {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert("Your browser does not support AJAX!");
return false;
} } }
xmlHttp.onreadystatechange=function() {
if(xmlHttp.readyState==4) {
document.getElementById("chtopic").innerHTML=xmlHttp.responseText }
}
var url="new.php"
url=url+"?chtopic="+str xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
62 Universitas Kristen Petra
Segmen Program 4.10. Select Tutorial
<?php
include("../connection.php");
include("../fckeditor/fckeditor.php");
$login=$_COOKIE["user"];
$id=$_SERVER['QUERY_STRING'];
$tp=$_GET['chtopic'];
$c=explode('chtopic=',$id);
$d=explode('+',$c[1]);
if($tp!=0){
echo "<br><br>";
if($d[1]==''){
$sql="select page_name from tisi where id='$d[0]' and topic_id='$d[0]'";
$res=mysql_query($sql);
$id=mysql_result($res,0,0);
} else{
$sql="select page_name from tisi where id='$d[0]' and topic_id='$d[1]'";
$res=mysql_query($sql);
$id=mysql_result($res,0,0);
}
echo "<input type=\"text\" style=\"width:250px\" name=\"text1\" value=\"$id\"> <input type=\"submit\"
name=\"edit\" value=\"Edit\">";
echo "<br>";
if($d[1]==''){
$sql="select content from tisi where id='$d[0]' and topic_id='$d[0]'";
$res=mysql_query($sql);
$id=mysql_result($res,0,0);
} else{
$sql="select content from tisi where id='$d[0]' and topic_id='$d[1]'";
$res=mysql_query($sql);
$id=mysql_result($res,0,0);
}
$oFCKeditor = new FCKeditor('FCKeditor2') ;
$oFCKeditor->BasePath = $abasepath.'fckeditor/' ;
$oFCKeditor->Value = $id;
$oFCKeditor->Height =300;
$oFCKeditor->Create() ; //textarea
echo "<br><br>Copy text pada textarea di bawah ini untuk ditampilkan di pdf";
$myfile="pdf/".$tp.".txt";
if(file_exists($myfile)){
if(filesize($myfile)!=0){
$fh=fopen($myfile,'r');
$data=fread($fh,filesize($myfile));
fclose($fh);
echo "<br><textarea name=\"ta\" style=\"width:700px;height:200px\" >$data</textarea>";
} else{
echo "<br><textarea name=\"ta\" style=\"width:700px;height:200px\" ></textarea>";
} }
else{
echo "<br><textarea name=\"ta\" style=\"width:700px;height:200px\" ></textarea>";
}
echo "<br><br>";
//comment history
$sql="select page_name from tisi where id='$d[0]' and topic_id='$d[1]'";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
if($count!="") $pagename=mysql_result($res,0,0);
$sql="select * from thistory where page_name='$pagename'";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
echo "<table width=\"70%\" border=\"1\" cellspacing=\"1\" cellpadding=\"1\"
bgcolor=\"#FFFFFF\">";
echo "<tr><td>Tanggal</td><td>Keterangan</td><td>Comment</td></tr>";
if($count!=""){
for($i=0;$i<$count;$i++){
echo "<tr>";
$his=mysql_result($res,$i,2);
echo "<td>$his</td>";
$his=mysql_result($res,$i,3);
echo "<td>last edited by $his</td>";
$his=mysql_result($res,$i,4);
63 Universitas Kristen Petra
Segmen Program 4.10. Select Tutorial ( lanjutan )
4.4.5.4. Form Add Video
Halaman ini digunakan untuk meng-upload video. Seperti pada Segmen Program 4.11.
Segmen Program 4.11. Form Add Video
echo "<tr><td>Tanggal</td><td>Keterangan</td><td>Comment</td></tr>";
if($count!=""){
for($i=0;$i<$count;$i++){
echo "<tr>";
$his=mysql_result($res,$i,2);
echo "<td>$his</td>";
$his=mysql_result($res,$i,3);
echo "<td>last edited by $his</td>";
$his=mysql_result($res,$i,4);
echo "<td>$his</td>";
echo "</tr>";
} }
echo "</table>";
echo "Comment<br>";
echo "<textarea name=\"com\" style=\"width:700px;height:50px\"></textarea>";
echo "<br><br><input type=\"submit\" name=\"save\" value=\"Save\">";
echo "<br><br><br>";
echo "Add sub page in this page <input type=\"submit\" name=\"addtp\" value=\"Add\">";
echo "<br>---";
if($d[1]==''){
$sql="select username from tisi where id='$d[0]' and topic_id='$d[0]'";
$res=mysql_query($sql);
$id=mysql_result($res,0,0);
} else{
$sql="select username from tisi where id='$d[0]' and topic_id='$d[1]'";
$res=mysql_query($sql);
$id=mysql_result($res,0,0);
}
if($login==$id or $login=='admin'){
echo "<br>Delete this page <input type=\"submit\" name=\"delete\"
value=\"Delete\">";
}
}
?>
<body bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0"
topmargin="0" background="images/background.jpg">
<form enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="15000000">
<table width="780" height="0" cellpadding="0" cellspacing="0" border="0">
<tr ><td >
<img src="templogotop.jpg" width="780" height="140" border="0" alt=""></td>
<tr ><td >
<div id="menu" >
<ul>
<?php
if($login=='admin')
echo "<li><a href=\"index.php\">Home</a></li>";
?>
64 Universitas Kristen Petra
Segmen Program 4.11. Form Add Video ( lanjutan )
<li><a href="tutorial.php">tutorial</a></li>
<li><a href="quiz.php">exercise</a></li>
<?php
if($login=='admin'){
echo "<li><a href=\"member.php\">member</a></li>";
echo "<li><a href=\"profile.php\">profile</a></li>";
echo "<li><a href=\"history.php\">history</a></li>";
}
?>
<li><a href="logout.php" title="">logout</a></li>
</ul>
</div>
</td></tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="175">
<table width="175" cellpadding="10" cellspacing="5" border="0"><tr valign="top"><td width="175">
<BR>
<?php
if($login=='admin')
echo "<a href=\"index.php\">Home</a><BR>";
?>
<a href="tutorial.php">Tutorial</a><BR>
<?php
$sql="select id,topic_name from tlist";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
for($i=0;$i<$count;$i++){
$id=mysql_result($res,$i,0);
$tn=mysql_result($res,$i,1);
echo "<li><a href='newtutorial.php?q=$tn&id=$id'>$tn</a></li>";
}
echo "<a href=\"quiz.php\">Exercise</a><br>";
if($login=='admin'){
echo "<a href=\"member.php\">Member</a><br>";
echo "<a href=\"profile.php\">Profile</a><BR>";
echo "<a href=\"history.php\">History</a><br><br>";
}
?>
<a href="video.php">add video</a><br>
<a href="sound.php">add sound clip</a><br>
<br>
<a href="logout.php">Logout</a><BR>
</font></p>
</td></tr></table></td>
<td width="100">
<table width="710" cellpadding="5" cellspacing="5" border="0" >
<tr valign="top">
<td width="700">
<h3>Video Page</h3>
<?php
echo "Please choose a file : <input type=\"file\" name=\"uploaded\"> <input type=\"submit\"
name=\"upload\" value=\"Upload\">";
echo "<br><br>";
echo "File has been uploaded : <br><br>";
$sql="select nama_file from tupload where jenis='movie'";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
$i=0;
for($j=0;$j<$count;$j++){
$id=mysql_result($res,$j,0);
$i=$i+1;
echo $i.". <input type=\"text\" style=\"width:600px\" value=\"^$id^\">
<sup>*</sup><br>";
echo "<input type=\"hidden\" name=\"id\" value=\"$i\">";
echo " <input type=\"submit\" name=\"delete\" value=\"Delete\"><br>";
}
echo "<br>*) ";
echo " <small>Copy script in the textbox to fckeditor</small>";
?>
<br><br><br><br><br>
<center>This site is © Copyright Ivan, All Rights Reserved.</center>
65 Universitas Kristen Petra
Segmen Program 4.11. Form Add Video ( lanjutan )
4.4.5.5. Form Add Sound Clip
Halaman ini digunakan untuk meng-upload video. Seperti pada Segmen Program 4.12.
Segmen Program 4.12. Form Sound Clip
echo "<input type=\"hidden\" name=\"id\" value=\"$i\">";
echo " <input type=\"submit\" name=\"delete\" value=\"Delete\"><br>";
}
echo "<br>*) ";
echo " <small>Copy script in the textbox to fckeditor</small>";
?>
<br><br><br><br><br>
<center>This site is © Copyright Ivan, All Rights Reserved.</center>
</td></tr>
</table>
</td></tr>
</table>
</form>
</body>
</html>
<html>
<head>
<title>Sound</title>
<link rel=stylesheet type="text/css" href="style.css">
</head>
<body bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0"
topmargin="0" background="images/background.jpg">
<form enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="15000000">
<table width="780" height="0" cellpadding="0" cellspacing="0" border="0">
<tr ><td >
<img src="templogotop.jpg" width="780" height="140" border="0" alt=""></td>
<tr ><td >
<div id="menu" >
<ul>
<?php
if($login=='admin')
echo "<li><a href=\"index.php\">Home</a></li>";
?>
<li><a href="tutorial.php">tutorial</a></li>
<li><a href="quiz.php">exercise</a></li>
<?php
if($login=='admin'){
echo "<li><a href=\"member.php\">member</a></li>";
echo "<li><a href=\"profile.php\">profile</a></li>";
echo "<li><a href=\"history.php\">history</a></li>";
}
?>
<li><a href="logout.php" title="">logout</a></li>
</ul>
</div></td></tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="175">
<table width="175" cellpadding="10" cellspacing="5" border="0"><tr valign="top"><td width="175">
<BR>
<?php
if($login=='admin')
echo "<a href=\"index.php\">Home</a><BR>";
?>
<a href="tutorial.php">Tutorial</a><BR>
<?php
$sql="select id,topic_name from tlist";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
66 Universitas Kristen Petra
Segmen Program 4.12. Form Sound Clip ( lanjutan )
Segmen Program 4.17. Form Sound Clip ( lanjutan )
<table width="175" cellpadding="10" cellspacing="5" border="0"><tr valign="top"><td width="175">
<BR>
<?php
if($login=='admin')
echo "<a href=\"index.php\">Home</a><BR>";
?>
<a href="tutorial.php">Tutorial</a><BR>
<?php
$sql="select id,topic_name from tlist";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
for($i=0;$i<$count;$i++){
$id=mysql_result($res,$i,0);
$tn=mysql_result($res,$i,1);
echo "<li><a href='newtutorial.php?q=$tn&id=$id'>$tn</a></li>";
}
echo "<a href=\"quiz.php\">Exercise</a><br>";
if($login=='admin'){
echo "<a href=\"member.php\">Member</a><br>";
echo "<a href=\"profile.php\">Profile</a><BR>";
echo "<a href=\"history.php\">History</a><br><br>";
}
?>
<a href="video.php">add video</a><br>
<a href="sound.php">add sound clip</a><br>
<br>
<a href="logout.php">Logout</a><BR>
</font></p>
</td></tr></table></td>
<td width="1000">
<table width="710" cellpadding="5" cellspacing="5" border="0" >
<tr valign="top">
<td width="700">
<h3>Sound Page</h3>
<tr valign="top">
<td width="700">
<h3>Sound Page</h3>
<?php
echo "Silahkan pilih file : <input type=\"file\" name=\"uploaded\"> <input type=\"submit\"
name=\"upload\" value=\"Upload\">";
echo "<br><br>";
echo "File yang sudah di upload : <br><br>";
$sql="select nama_file from tupload where jenis='sound'";
$res=mysql_query($sql);
$count=mysql_num_rows($res);
for($i=0;$i<$count;$i++){
$id=mysql_result($res,$i,0);
$i=$i+1;
echo $i.". <input type=\"text\" style=\"width:600px\" value=\"`$id`\">
<sup>*<sup><br>";
echo "<input type=\"hidden\" name=\"id\" value=\"$i\">";
echo " <input type=\"submit\" name=\"delete\" value=\"Delete\"><br>";
}
echo "<br>*) ";
echo " Copy script pada textbox atau tekan Ctrl+A kemudian paste script pada fckeditor";
?>
<br><br><br><br><br>
<center>This site is © Copyright Ivan, All Rights Reserved.</center>
</td></tr> </table> </td>
</tr>
</table>
</form>
</body></html>
67 Universitas Kristen Petra
4.4.5.6. Form Exercise
Halaman ini digunakan untuk menambah soal latihan, meng-edit, dan juga menghapus soal yang sudah ada. Pada form exercise ini nomor soal yang dimasukkan tidak dibatasi, apabila nomor yang dipilih sudah terdapat soal maka akan muncul soal yang sudah ada.
Seperti pada Segmen Program 4.13.
Segmen Program 4.13. Form Exercise
<?php
session_start();
if (!($_SESSION["name"])=='nama'){
header('Location: ../index.php');
}
else{
include("../connection.php");
include("../fckeditor/fckeditor.php");
include("deltemp.php");
$login=$_COOKIE["user"];
$today = date("F j, Y. g:i a");
$id=$_SERVER['QUERY_STRING'];
$c=explode('&id=',$id);
function delTquiz($topic,$jenis,$no,$login,$today){
if($jenis=="a"){
$sql="select * from tsa where topic_id='$topic' and no='$no'";
$res=mysql_query($sql);
$ti=mysql_result($res,0,0);
$no=mysql_result($res,0,1);
$q=mysql_result($res,0,2);
$a=mysql_result($res,0,3);
$e=mysql_result($res,0,4);
$stringdt="topic id : $ti no : $no
question : $q answer : $a explanation : $e";
$sql="insert into thistory values('','evaluation','$today','$login','evaluation is deleted','$stringdt')";
$res=mysql_query($sql);
$sql="delete from tsa where topic_id='$topic' and no='$no'";
$res=mysql_query($sql);
}
if($jenis=="b"){
$stringdt="";
$sql="select question,pil1,pil2,pil3,pil4,pil5,ans1,ans2,ans3,ans4,ans5,topic_id,no,explanation from tmc where topic_id='$topic' and no='$no'";
$res2=mysql_query($sql);
$id2=mysql_result($res2,0,6);
if($id2!=""){
$id2=mysql_result($res2,0,1);
$stringdt=$stringdt.$id2.' ';
}
$id2=mysql_result($res2,0,7);
if($id2!=""){
$id2=mysql_result($res2,0,2);
$stringdt=$stringdt.$id2.' ';
}
$id2=mysql_result($res2,0,8);
if($id2!=""){
$id2=mysql_result($res2,0,3);
$stringdt=$stringdt.$id2.' ';
}
$id2=mysql_result($res2,0,9);
if($id2!=""){
$id2=mysql_result($res2,0,4);
$stringdt=$stringdt.$id2.' ';
}
$id2=mysql_result($res2,0,10);
if($id2!=""){
$id2=mysql_result($res2,0,5);
$stringdt=$stringdt.$id2.' ';
}
$ti=mysql_result($res2,0,11);
$no=mysql_result($res2,0,12);
68 Universitas Kristen Petra
Segmen Program 4.13. Form Exercise ( lanjutan )
Segmen Program 4.18. Form Exercise ( lanjutan )
$id2=mysql_result($res2,0,9);
if($id2!=""){
$id2=mysql_result($res2,0,4);
$stringdt=$stringdt.$id2.' ';
}
$id2=mysql_result($res2,0,10);
if($id2!=""){
$id2=mysql_result($res2,0,5);
$stringdt=$stringdt.$id2.' ';
}
$ti=mysql_result($res2,0,11);
$no=mysql_result($res2,0,12);
$q=mysql_result($res2,0,0);
$e=mysql_result($res2,0,13);
$mc="";
for($j=1;$j<6;$j++){
$id2=mysql_result($res2,0,$j);
$mc=$mc.$id2.' ';
}
$string="Topic id : $ti no : $no
question : $q multiple choice : $mc answer : $stringdt explanation : $e";
$sql="insert into thistory values('','evaluation','$today','$login','evaluation is deleted','$string')";
$res=mysql_query($sql);
$sql="delete from tmc where topic_id='$topic' and no='$no'";
$res=mysql_query($sql);
}
if($jenis=="c"){
$sql="select
que1,que2,que3,que4,que5,ans1,ans2,ans3,ans4,ans5,topic_id,no,explanation from tdd where topic_id='$topic' and no='$no'";
$res2=mysql_query($sql);
$ti=mysql_result($res2,0,10);
$no=mysql_result($res2,0,11);
$e=mysql_result($res2,0,12);
$stringdt="";
for($j=0;$j<5;$j++){
$a=mysql_result($res2,0,$j);
$b=mysql_result($res2,0,$j+5);
$stringdt=$stringdt.$a.' '.$b;
}
$string="Topic id : $ti no : $no
drag and drop :
$stringdt explanation : $e";
$sql="insert into thistory values('','evaluation','$today','$login','evaluation is deleted','$string')";
$res=mysql_query($sql);
$sql="delete from tdd where topic_id='$topic' and no='$no'";
$res=mysql_query($sql);
}
if($jenis=="d"){
$sql="select * from ttf where topic_id='$topic' and no='$no'";
$res=mysql_query($sql);
$ti=mysql_result($res,0,0);
$no=mysql_result($res,0,1);
$q=mysql_result($res,0,2);
$ans=mysql_result($res,0,3);
$e=mysql_result($res,0,4);
$string="Topic id : $ti no : $no
question : $q true or false : $ans explanation : $e";
$sql="insert into thistory values('','evaluation','$today','$login','evaluation is deleted','$string')";
$res=mysql_query($sql);
$sql="delete from ttf where topic_id='$topic' and no='$no'";
$res=mysql_query($sql);
} if($_POST['delete']){
69 Universitas Kristen Petra
Segmen Program 4.13. Form Exercise ( lanjutan )
Segmen Program 4.18. Form Exercise ( lanjutan )
$res=mysql_query($sql);
}
if($_POST['delete']){ //delete topic
$idtp=$_POST['id_topic'];
$sql="select no from tquizex";
$res=mysql_query($sql);
$id=mysql_result($res,0,0);
$no=$id;
$sql="select jenis from tquiz where topic_name='$idtp' and no='$no'";
$res=mysql_query($sql);
$jen=mysql_result($res,0,0);
$sql="delete from tquiz where topic_name='$idtp' and no='$no'";
$res=mysql_query($sql);
delTquiz($idtp,$jen,$no,$login,$today);
}
if($_POST['savea']){ //edit topic
$idtp=$_POST['id_topic'];
$sql="select no from tquizex";
$res=mysql_query($sql);
$id=mysql_result($res,0,0);
$no=$id;
$sql="select jenis from tquiz where topic_name='$idtp' and no='$no'";
$res=mysql_query($sql);$jen=mysql_result($res,0,0);
$jen=mysql_result($res,0,0);
if($jen=="a"){
$ans=$_POST['ans'];
$que=$_POST['que'];
$exp=$_POST['exp'];
if($ans=="") echo "<script>alert('Inputan masih salah');</script>";
else{
$stringdt="topic id : $idtp no : $no
question : $que answer : $ans explanation : $exp";
$sql="insert into thistory values('','evaluation','$today','$login','evaluation is edited','$stringdt')";
$res=mysql_query($sql);
$sql="update tsa set
answer='$ans',question='$que',explanation='$exp' where topic_id='$idtp' and no='$no'";
$res=mysql_query($sql);
} }
if($jen=="b"){
$que=$_POST['que'];
$pil1=$_POST['pil1']; $ans1=$_POST['ans1'];
$pil2=$_POST['pil2']; $ans2=$_POST['ans2'];
$pil3=$_POST['pil3']; $ans3=$_POST['ans3'];
$pil4=$_POST['pil4']; $ans4=$_POST['ans4'];
$pil5=$_POST['pil5']; $ans5=$_POST['ans5'];
$exp=$_POST['exp'];
if($ans1=="" and $ans2=="" and $ans3=="" and $ans4=="" and
$ans5=="") echo "<script>alert('inputan masih salah')</script>";
else{
$mc=$pil1.' '.$pil2.' '.$pil3.' '.$pil4.' '.$pil5.' ';
$ans="";
if($ans1!="") $ans=$ans.$pil1.' ';
if($ans2!="") $ans=$ans.$pil2.' ';
if($ans3!="") $ans=$ans.$pil3.' ';
if($ans4!="") $ans=$ans.$pil4.' ';
if($ans5!="") $ans=$ans.$pil5.' ';
$stringdt="topic id : $idtp no : $no
multiple choice : $mc answer : $ans explanation : $exp";
$sql="insert into thistory values('','evaluation','$today','$login','evaluation is edited','$stringdt')";
$res=mysql_query($sql);
$sql="update tmc set
question='$que',pil1='$pil1',pil2='$pil2',pil3='$pil3',pil4='$pil4',pil5='$pil5',ans1='$ans1',ans2='$ans2',ans3
='$ans3',ans4='$ans4',ans5='$ans5',explanation='$exp' where topic_id='$idtp' and no='$no'";
$res=mysql_query($sql);
} }
70 Universitas Kristen Petra
Segmen Program 4.13. Form Exercise ( lanjutan )
Segmen Program 4.18. Form Exercise ( lanjutan )
if($jen=="a"){
$ans=$_POST['ans'];
$que=$_POST['que'];
$exp=$_POST['exp'];
if($ans=="") echo "<script>alert('Inputan masih salah');</script>";
else{
$stringdt="topic id : $idtp no : $no
question : $que answer : $ans explanation : $exp";
$sql="insert into thistory values('','evaluation','$today','$login','evaluation is edited','$stringdt')";
$res=mysql_query($sql);
$sql="update tsa set
answer='$ans',question='$que',explanation='$exp' where topic_id='$idtp' and no='$no'";
$res=mysql_query($sql);
} }
if($jen=="b"){
$que=$_POST['que'];
$pil1=$_POST['pil1']; $ans1=$_POST['ans1'];
$pil2=$_POST['pil2']; $ans2=$_POST['ans2'];
$pil3=$_POST['pil3']; $ans3=$_POST['ans3'];
$pil4=$_POST['pil4']; $ans4=$_POST['ans4'];
$pil5=$_POST['pil5']; $ans5=$_POST['ans5'];
$exp=$_POST['exp'];
if($ans1=="" and $ans2=="" and $ans3=="" and $ans4=="" and
$ans5=="") echo "<script>alert('inputan masih salah')</script>";
else{
$mc=$pil1.' '.$pil2.' '.$pil3.' '.$pil4.' '.$pil5.' ';
$ans="";
if($ans1!="") $ans=$ans.$pil1.' ';
if($ans2!="") $ans=$ans.$pil2.' ';
if($ans3!="") $ans=$ans.$pil3.' ';
if($ans4!="") $ans=$ans.$pil4.' ';
if($ans5!="") $ans=$ans.$pil5.' ';
$stringdt="topic id : $idtp no : $no
multiple choice : $mc answer : $ans explanation : $exp";
$sql="insert into thistory values('','evaluation','$today','$login','evaluation is edited','$stringdt')";
$res=mysql_query($sql);
$sql="update tmc set
question='$que',pil1='$pil1',pil2='$pil2',pil3='$pil3',pil4='$pil4',pil5='$pil5',ans1='$ans1',ans2='$ans2',ans3
='$ans3',ans4='$ans4',ans5='$ans5',explanation='$exp' where topic_id='$idtp' and no='$no'";
$res=mysql_query($sql);
} }
if($jen=="c"){
$que1=$_POST['que1'];
$que2=$_POST['que2'];
$que3=$_POST['que3'];
$que4=$_POST['que4'];
$que5=$_POST['que5'];
$ans1=$_POST['ans1'];
$ans2=$_POST['ans2'];
$ans3=$_POST['ans3'];
$ans4=$_POST['ans4'];
$ans5=$_POST['ans5'];
$exp=$_POST['exp'];
$bole=0;
if(($que1!="" and $ans1=="") or ($que1=="" and $ans1!="")) $bole=1;