L A M P I R A N
Universitas Sumatera Utara
LISTING PROGRAM
Login.java
package portal.akademik;
import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.widget.EditText; import android.widget.Toast; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.view.View.OnClickListener; import android.widget.Button;
import java.util.ArrayList;
import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair;
import portal.akademik.CustomHttpClient;
public class Login extends Activity{
EditText nim, pass; Button masuk, keluar;
/** Called when the activity is first created. */ @Override
Universitas Sumatera Utara
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main);
nim = (EditText) findViewById(R.id.login_nim); pass = (EditText) findViewById(R.id.login_pass);
masuk = (Button) findViewById(R.id.masuk); keluar = (Button) findViewById(R.id.keluar);
//daftarkan event onClick pada (Button) masuk masuk.setOnClickListener(new View.OnClickListener(){
@Override public void onClick(View v) {
ArrayList
postParameters
=
new
ArrayList(); postParameters.add(new BasicNameValuePair("nim", nim.getText().toString())); postParameters.add(new BasicNameValuePair("pass", pass.getText().toString()));
String response = null;
try { response
=
CustomHttpClient.executeHttpPost("http://10.0.2.2/ta/Login_portal.php", postParameters); String res = response.toString(); res = res.trim(); res = res.replaceAll("\\s+","");
Universitas Sumatera Utara
if(res.equals("1")) { Toast.makeText(getBaseContext(),
"Berhasil
Login.",
Toast.LENGTH_SHORT).show(); //tampilkan
Intent intent = null; intent = new Intent(Login.this, Khs.class); startActivity(intent);
//menyimpan value nim pada method setNim di kelas SessionLogin SessionLogin.setNim(nim.getText().toString());
}else {
Toast.makeText(getBaseContext(),
"Gagal
Login.
Coba
Lagi.",
Toast.LENGTH_SHORT).show();//gagal } }catch (Exception e){ e.printStackTrace(); } } });
keluar.setOnClickListener(new OnClickListener(){ public void onClick(View v){ nim.setText(""); pass.setText(""); } });
} }
Universitas Sumatera Utara
Khs.java
package portal.akademik;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.Spinner;
public class Khs extends Activity{
public Spinner spinSemester; public RadioButton ganjil, genap; public Button tampil;
public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE);
Universitas Sumatera Utara
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.showdata);
// SPINNER UNTUK TAHUN AKADEMIK spinSemester = (Spinner) findViewById(R.id.spinner1);
List<String> spinner = new ArrayList<String>();
spinner.add("2011"); spinner.add("2012"); spinner.add("2013"); spinner.add("2014");
ArrayAdapter<String>
spinSem
=
new
ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, spinner);
spinSem.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_it em); spinSemester.setAdapter(spinSem);
spinSemester.setOnItemSelectedListener(new OnItemSelectedListener(){
@Override public void onItemSelected(AdapterView> parent, View view, int position, long id) {
Semester.setTahun(spinSemester.getSelectedItem().toString()); }
@Override public void onNothingSelected(AdapterView> arg0) { // DO NOTHING
Universitas Sumatera Utara
} });
// RADIOBUTTON UNTUK SEMESTER ganjil = (RadioButton) findViewById(R.id.ganjil); genap = (RadioButton) findViewById(R.id.genap);
ganjil.setOnClickListener(new RadioGroup.OnClickListener(){ public void onClick(View v) { Semester.setSemester(ganjil.getText().toString());
} });
genap.setOnClickListener(new RadioGroup.OnClickListener(){ public void onClick(View v) { Semester.setSemester(genap.getText().toString());
} });
tampil = (Button) findViewById(R.id.tampilkan); tampil.setOnClickListener(new View.OnClickListener(){
@Override public void onClick(View v) { Intent intent = null; intent = new Intent(Khs.this, InformasiHasilStudi.class); startActivity(intent); }
}); }
Universitas Sumatera Utara
}
InformasiHasilStudi.java package portal.akademik;
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList;
import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject;
import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.Window; import android.view.WindowManager; import android.widget.TextView; import android.widget.Toast;
Universitas Sumatera Utara
public class InformasiHasilStudi extends Activity{ String nimAndroid = SessionLogin.getNim(); String semAndroid = Semester.getSemester(); String thnAndroid = Semester.getTahun();
TextView kode, nm_mk, sks, nilai, nim, totalsks, ip, ipk;
TextView sem, thn;
public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.tampil_nilai2);
nim = (TextView) findViewById(R.id.nimAndroid); sem = (TextView) findViewById(R.id.semester); thn = (TextView) findViewById(R.id.tahun);
kode = (TextView) findViewById(R.id.kode); nm_mk = (TextView) findViewById(R.id.nm_mk); sks = (TextView) findViewById(R.id.sks); nilai = (TextView) findViewById(R.id.nilai);
totalsks = (TextView) findViewById(R.id.totalsks); ip = (TextView) findViewById(R.id.ip);
tampil(); }
private void tampil(){
Universitas Sumatera Utara
nim.setText(nimAndroid); sem.setText(semAndroid); thn.setText(thnAndroid);
String
url
=
"http://10.0.2.2/ta/tampil_nilai.php?nim="+nimAndroid.toString()+"&thnakademik="+thnAn droid.toString()+"&semester="+semAndroid.toString();
HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url.trim());
ArrayList param = new ArrayList();
try{ httpPost.setEntity(new UrlEncodedFormEntity(param));
HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity();
InputStream in = httpEntity.getContent(); BufferedReader read = new BufferedReader(new InputStreamReader(in));
String content = ""; String line = "";
while((line = read.readLine())!=null){ content += line; }
Log.d("ADBUG", "content: " + content);
//JSON if(!content.equals(" ")){
Universitas Sumatera Utara
//ingat inisialisasi //double totalNilai = 0;
int totalsSks = 0; double bobot = 0; double skor; double totalSkor = 0; double IP = 0;
try { JSONArray jArr = new JSONArray(content);
String KODE = ""; String NM_MK = ""; String SKS = ""; String NILAI = "";
for(int i=0;i<jArr.length();i++){ JSONObject jObj = jArr.getJSONObject(i);
//Mengambil value dari setiap field tabel di database String Kode = jObj.getString("kodemk"); String Nm_Mk = jObj.getString("namamk"); String Sks = jObj.getString("sks"); String Nilai = jObj.getString("nilai");
if(jObj.getString("nilai").equals("A")) { bobot=4; }
else if(jObj.getString("nilai").equals("B"))
Universitas Sumatera Utara
{ bobot=3; } else if(jObj.getString("nilai").equals("B+")) { bobot=3.5; } else if(jObj.getString("nilai").equals("C")) { bobot=2; } else if(jObj.getString("nilai").equals("C+")) { bobot=2.5; } else if(jObj.getString("nilai").equals("D")) { bobot=1; } else if(jObj.getString("nilai").equals("E")) { bobot=0; }
//Menghitung jumlah nilai skor = bobot * Integer.parseInt(jObj.getString("sks"));
//Menghitung jumlah sks //Jumlahkan sks, ambil dari string, kemudian konversi ke integer totalsSks = totalsSks + Integer.parseInt(jObj.getString("sks"));
//Menghitung jumlah nilai setelah dikalikan dengan bobot dan sks totalSkor = totalSkor + skor;
Universitas Sumatera Utara
//Menghitung IP IP = totalSkor/ totalsSks;
KODE += Kode+"\n"; NM_MK += Nm_Mk+"\n"; SKS += Sks+"\n"; NILAI += Nilai+"\n";
}
//Menampilkan hasil parsing data dari mysql kode.setText(KODE.toString()); nm_mk.setText(NM_MK.toString()); sks.setText(SKS.toString()); nilai.setText(NILAI.toString());
//menampilkan totalsks, ip, dan ipk totalsks.setText(String.valueOf(totalsSks)); ip.setText(String.valueOf(IP));
} catch (JSONException e) { e.printStackTrace(); } }else{ Toast.makeText(this, "Error" , Toast.LENGTH_LONG).show(); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }
Universitas Sumatera Utara
} }
SessionLogin.java package portal.akademik;
public class SessionLogin {
static String nim; static String pass;
public static String getPassword() { return pass; }
public static void setPassword(String p) { pass = p; }
public static String getNim() { return nim; }
public static void setNim(String u) { nim = u; } } Semester.java package portal.akademik;
public class Semester {
Universitas Sumatera Utara
static String semester; static String tahun;
public static String getSemester(){ return semester; } public static void setSemester(String s){ semester = s; } public static String getTahun(){ return tahun; } public static void setTahun(String t){ tahun = t; } }
ClientToServer.java
package portal.akademik;
import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URI; import java.util.ArrayList;
import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpGet;
Universitas Sumatera Utara
import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.params.ConnManagerParams; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams;
public class ClientToServer { public static final int HTTP_TIMEOUT = 30 * 1000; private static HttpClient client;
private static HttpClient getHttpClient() { if (client == null) { client = new DefaultHttpClient(); final HttpParams parameterHttp = client.getParams(); HttpConnectionParams.setConnectionTimeout(parameterHttp, HTTP_TIMEOUT); ConnManagerParams.setTimeout(parameterHttp, HTTP_TIMEOUT); } return client; }
public static String eksekusiHttpPost(String url, ArrayList postParameter) throws Exception { BufferedReader in = null; try { HttpClient klien = getHttpClient(); HttpPost req = new HttpPost(url); UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity( postParameter); req.setEntity(formEntity); HttpResponse jawaban = klien.execute(req); in = new BufferedReader(new InputStreamReader(jawaban.getEntity() .getContent()));
Universitas Sumatera Utara
StringBuffer sb = new StringBuffer(""); String line = ""; String NL = System.getProperty("line.separator"); while ((line = in.readLine()) != null) { sb.append(line + NL); } in.close(); String hasil = sb.toString(); return hasil; } finally { if (in != null) { in.close(); } } }
public static String eksekusiHttpGet(String url) throws Exception { BufferedReader in = null; try { HttpClient hc = getHttpClient(); HttpGet req = new HttpGet(); req.setURI(new URI(url)); HttpResponse resp = hc.execute(req); in = new BufferedReader(new InputStreamReader(resp.getEntity() .getContent())); StringBuffer sb = new StringBuffer(""); String line = ""; String NL = System.getProperty("line.separator"); while ((line = in.readLine()) != null) { sb.append(line + NL); } in.close(); String hasil = sb.toString();
Universitas Sumatera Utara
return hasil; } finally { if (in != null) { in.close(); } } } }
CustomHttpClient.java
package portal.akademik;
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URI; import java.util.ArrayList;
import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.params.ConnManagerParams; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams;
Universitas Sumatera Utara
public class CustomHttpClient {
/** The time it takes for our client to timeout */
public static final int HTTP_TIMEOUT = 30 * 1000 ; // milliseconds
/** Single instance of our HttpClient */ private static HttpClient mHttpClient;
/** * Get our single instance of our HttpClient object. * @return an HttpClient object with connection parameters set */
private static HttpClient getHttpClient() { if (mHttpClient == null) { mHttpClient = new DefaultHttpClient(); final HttpParams params = mHttpClient.getParams(); HttpConnectionParams.setConnectionTimeout(params, HTTP_TIMEOUT); HttpConnectionParams.setSoTimeout(params, HTTP_TIMEOUT); ConnManagerParams.setTimeout(params, HTTP_TIMEOUT); } return mHttpClient; } /** * Performs an HTTP Post request to the specified url with the * specified parameters. * * @param url The web address to post the request to * @param postParameters The parameters to send via the request * @return The result of the request * @throws Exception */
Universitas Sumatera Utara
public
static
String
executeHttpPost(String
url,
ArrayList
postParameters) throws Exception { BufferedReader in = null; try { HttpClient client = getHttpClient(); HttpPost request = new HttpPost(url); UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(postParameters); request.setEntity(formEntity); HttpResponse response = client.execute(request); in
=
new
BufferedReader(new
InputStreamReader(response.getEntity().getContent()));
StringBuffer sb = new StringBuffer(""); String line = ""; String NL = System.getProperty("line.separator"); while ((line = in.readLine()) != null) { sb.append(line + NL); } in.close(); String result = sb.toString(); return result; } finally { if (in != null) { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } } } /** * Performs an HTTP GET request to the specified url.
Universitas Sumatera Utara
* @param url The web address to post the request to * @return The result of the request * @throws Exception */
public static String executeHttpGet(String url) throws Exception { BufferedReader in = null; try { HttpClient client = getHttpClient(); HttpGet request = new HttpGet(); request.setURI(new URI(url)); HttpResponse response = client.execute(request); in
=
new
BufferedReader(new
InputStreamReader(response.getEntity().getContent()));
StringBuffer sb = new StringBuffer(""); String line = ""; String NL = System.getProperty("line.separator"); while ((line = in.readLine()) != null) { sb.append(line + NL); } in.close();
String result = sb.toString(); return result; } finally { if (in != null) { try { in.close(); } catch (IOException e) { e.printStackTrace(); }
Universitas Sumatera Utara
} } } }
main.xml (Login.java)
Universitas Sumatera Utara
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<EditText android:id="@+id/login_nim" android:layout_height="wrap_content" android:layout_width="fill_parent">
Universitas Sumatera Utara
android:layout_width="wrap_content" android:layout_height="wrap_content">
<EditText android:id="@+id/login_pass" android:layout_height="wrap_content" android:layout_width="fill_parent" android:inputType="textPassword">
<Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="LOGIN" android:textStyle="bold" android:id="@+id/masuk" android:onClick="loginHandler" android:layout_gravity="center"/>
<Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="RESET" android:textStyle="bold" android:id="@+id/keluar" android:onClick="exitHandler" android:layout_gravity="center"/>
Universitas Sumatera Utara
showdata.xml (Khs.java)
<Spinner android:id="@+id/spinner1" android:text="Tahun:"
Universitas Sumatera Utara
android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginTop="2dp"/>
<Button android:text="Tampilkan" android:id="@+id/tampilkan" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
tampil_nilai.xml (InformasiHasilStudi.java)
Universitas Sumatera Utara
android:layout_width="fill_parent" android:layout_gravity="center" android:paddingLeft="20dip" android:paddingRight="20dip">
Universitas Sumatera Utara
android:text="MATAKULIAH" android:textSize="14sp" android:textStyle="bold" android:gravity="center"/>
Universitas Sumatera Utara
login_portal.php
mysql_connect("localhost","root",""); mysql_select_db("portal");
$query = "SELECT * FROM login WHERE nim = '$nim' AND pass = $pass'"; $result = mysql_query($query) or die("Unable to verify user because : " . mysql_error());
if(mysql_num_rows($result) == 1){ echo 1;
}
Universitas Sumatera Utara
else { // print status message echo 0; } ?>
tampil_nilai.php
$nimAndroid = $_GET['nim']; $semAndroid = $_GET['semester']; $thnAndroid = $_GET['thnakademik'];
$sqlString = "SELECT data_ip2.kodemk, data_ip2.namamk, data_ip2.sks, data_ip2.nilai FROM data_ip2 WHERE data_ip2.thnakademik ='$thnAndroid' AND data_ip2.semester = '" . $semAndroid . "' AND data_ip2.nim ='$nimAndroid'";
$rs = mysql_query($sqlString);
if($rs){ while($objRs = mysql_fetch_assoc($rs)){ $output[] = $objRs; } echo json_encode($output); } mysql_close(); ?>
Universitas Sumatera Utara
KEMENTERIAN PENDIDIKAN NASIONAL
UNIVERSITAS SUMATERA UTARA FAKULTAS MATEMATIKA DAN ILMU PENGETAHUAN ALAM (FMIPA) JL. BIOTEKNOLOGI NO. 1 KAMPUS USU Telp. (061) 8214290
MEDAN – 20155, EMAIL : [email protected]
KARTU BIMBINGAN TUGAS AKHIR MAHASISWA Nama Mahasiswa Nomor Stambuk Judul Tugas Akhir Dosen Pembimbing 1 Tanggal Mulai Bimbingan Tanggal Selesai Bimbingan
No
TANGGAL ASSISTEN BIMBINGAN
: Evalyna Christie S : 092406170 : Aplikasi Portal Akademik Mobile Berbasis Android : Partano Siagian M.Sc : :
PEMBAHASAN PADA ASSISTEN MENGENAI PADA BAB
1 2 3 4 5 6 7
PARAF DOSEN PEMBIMBING
KETERANGAN
ACC PROPOSAL ACC BAB 1 ACC BAB 2 ACC BAB 3 ACC BAB 4 ACC BAB 5 UJI PROGRAM Kartu ini harap dikembalikan kejurusan Matematika Bila Bimbingan Mahasiswa telah Selesai
Diketahui Ketua Jurusan Matematika
Disetujui Pembimbing Utama/ Penanggung Jawab
Prof. Dr. Tulus, M.Si NIP. 19620901198803100
Partano Siagian M.Sc Nip.130877994
Universitas Sumatera Utara
SURAT KETERANGAN Hasil Uji Program Tugas Akhir
Yang bertanda tangan dibawah ini, menerangkan bahwa Tugas Akhir Mahasiswa Program D-III Teknik Informatika :
Nama Nomor Induk Mahasiswa Program Studi Judul Tugas Akhir
: : : :
EVALYNA CHRISTIE S 092406170 D-III TEKNIK INFORMATIKA APLIKASI PORTAL AKADEMIK MOBILE BERBASIS ANDROID
Telah melaksanakan tes program Tugas Akhir dari mahasiswa tersebut yang dilaksanakan pada tanggal 01 Juni 2012.
Dengan Hasil : Sukses / Gagal
Demikian diterangkan untuk digunakan melengkapi syarat pendaftaran Ujian Meja Hijau Tugas Akhir Mahasiswa yang bersangkutan di Departemen Matematika FMIPA USU Medan.
Medan, 01 Juni 2012 Dosen Pembimbing
Partano Siagian M.Sc NIP. 130877994
Universitas Sumatera Utara