Php script of upload notice

September 13,2016

Today i have worked on php script of upload notice.The whole  data of notice is stored in database.

<?php
$title=$_POST[‘Title’];
$type=$_POST[‘Type’];
$description=$_POST[‘Description’];
$url=$_POST[‘URL’];

$con=new mysqli(“localhost”,”root”,””,”login”);
if($con->connect_errno)
{
$response=”db_err”;
}
else
{
$query1=”INSERT into upload_notice VALUES (null,’$title’,’$type’,’$description’,’$url’,null)”;
$result=$con->query($query1);
if($result){
$response=’ok’;
}
else{
$response=’error’;
}
}
echo json_encode(array(‘result’=>$response));
$con->close();
?>

Upload Notices

September  12,2016

Today i have worked on my third activity i.e. upload a notice.

In this activity the teacher have to upload the notice.Teacher have to choose that what type of notice he/she have to upload i.e. the notice is of any branch or it is a general notice for all branches.For this there is a spinner to choose the branches.The notice must be a pdf file.

Teacher and Student Information

September 9,2016

Today i have done some more work on navigation activity.In navigation activity i m going to show some details of student or teacher.These details are shown on content navigation file.

In teacher navigation file there are two aspects to show:

  • Name of the teacher
  • Department of the teacher

In student navigation file there are following aspects to show:

  • Name of the student
  • Semester of the student
  • Rollno of the student
  • Branch of the student

Activity-2(Student Login)

September 8,2016

Today i have done the student navigation drawer .In this the items of menu is shown below:

  • Assignment
  • Notice
  • Attendance
  • General

In assignment the student can download the assignment which teacher had upload.

In Notice the student can check and download the notice

In Attendance the student can check their attendance of particular subject.

In genera the student can see the syllabus of their perspective year.

 

Activity-2(Teacher Navigation)

September 7,2016

Today i have worked on second activity i.e. Navigation Drawer.If teacher is login then the menu of navigation drawer is differ from student navigation.In teacher navigation drawer the menu contains following items:

  • Upload Assignment
  • Upload Notice
  • Upload Attendance
  • Check Attendance

In upload assignment the teacher can upload an assignment of a particular subject.

In upload Notice the teacher can upload a notice of a particular branch or general.

In mark attendance the teacher can mark attendance of students of particular subject.

In check attendance teacher can check the attendance of whole students.

Login page Coding

September 6,2016

Today i have worked on the coding of login page activity i.e. the main part.

void showDialog(){
    dia=new ProgressDialog(this);
    dia.setTitle("Loading");
    dia.show();
}
public void loginButton(View v){
     String usrnm=ed_usrnm.getText().toString();
     String pwd=ed_pwd.getText().toString();
     if(valid_pwd() && valid_usrnm()){
         FetchData f=new FetchData();
         f.execute(ed_usrnm.getText().toString(),ed_pwd.getText().toString());
     }

}
public boolean valid_usrnm(){
    if(ed_usrnm.equals(null)){
        ed_usrnm.setError("Enter username!!");
        return false;
    }
    else{
    return true;
    }
}
public boolean valid_pwd(){
    if(ed_pwd.length()==0){
        ed_pwd.setError("Enter Password!! ");
        return false;
    }
    else{
        return true;
    }
}

class FetchData extends AsyncTask<String,Integer,Boolean>{
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        showDialog();
    }

    @Override
    protected Boolean doInBackground(String... params) {
        ArrayList<NameValuePair> list= new ArrayList<>();
        list.add(new BasicNameValuePair("Username",params[0]));
        list.add(new BasicNameValuePair("Password",params[1]));
        try{
            HttpClient client=new DefaultHttpClient();
            HttpPost post=new HttpPost(getString(R.string.path)+"login.php");
            post.setEntity(new UrlEncodedFormEntity(list));
            HttpResponse r=client.execute(post);
            HttpEntity e=r.getEntity();
            InputStream is=e.getContent();
            BufferedReader bf=new BufferedReader(new InputStreamReader(is));
            StringBuilder b=new StringBuilder();
            String line;
            while ((line=bf.readLine())!=null){
                b.append(line);
            }
            String result=b.toString();
            Log.d("result",result);
            JSONObject jsonObject=new JSONObject(result);
            resp=jsonObject.getString("response");
            if(resp.equalsIgnoreCase("ok")) {
                Type = jsonObject.getString("type");
                if (Type.equalsIgnoreCase("Student")) {
                    Name = jsonObject.getString("name");
                    Rollno = jsonObject.getString("roll");
                    Stream=jsonObject.getString("stream");
                   Semester=jsonObject.getString("semester");
                } else {
                    Tchr_name = jsonObject.getString("tch_name");
                    Dept = jsonObject.getString("dept");
                }
                return true;
            }

        }
        catch(Exception e){
            e.printStackTrace();
        }

        return false;
    }

    @Override
    protected void onPostExecute(Boolean aBoolean) {
        if(aBoolean==true){
            SharedPreferences sh=getSharedPreferences("preference_ht", Context.MODE_PRIVATE);
            SharedPreferences.Editor editor=sh.edit();
            if(Type.equalsIgnoreCase("Student")){
                editor.putString("name_pref",Name);
                editor.putString("roll_pref",Rollno);
                editor.putString("stream_pref",Stream);
                editor.putString("sem_pref",Semester);
                editor.apply();
                Intent i=new Intent(Login.this,Navigation.class);
                startActivity(i);
            }
            else{
                editor.putString("tch_name_pref",Tchr_name);
                editor.putString("dept_pref",Dept);
                editor.apply();
                Intent i=new Intent(Login.this,TchrNav.class);
                startActivity(i);
            }
        }

        super.onPostExecute(aBoolean);
    }
}

 

Activity-1

September 5,2016

Today i continue with my first login activity.Today i have worked on php script used in  login activity.

<?php
$usrnm=$_POST[‘Username’];
$pwd=$_POST[‘Password’];
//$usrnm=’1001′;
//$pwd=’jaspreet123′;
$con=new mysqli(“localhost”,”root”,””,”login”);
if($con->connect_errno)
{
$response=”db_err”;
}
else
{
$loginquery=”select * from user_login where Username=’$usrnm’ and Password=’$pwd’ “;
$result_login=$con->query($loginquery);
if($result_login->num_rows>0)
{

while($sql_fetch_array=mysqli_fetch_array($result_login))
{
$type=$sql_fetch_array[‘Type’];
if($type==’Student’)
{
$query1=”select * from user_info where Username=’$usrnm'”;
$result1=$con->query($query1);
if($result1->num_rows>0)
{
while($sql_fetch_array=mysqli_fetch_array($result1))
{
$name=$sql_fetch_array[‘Name’];

$roll=$sql_fetch_array[‘Rollno’];

$stream=$sql_fetch_array[‘Stream’];

$sem=$sql_fetch_array[‘Semester’];

$response=’ok’;

echo json_encode(array(‘response’=>$response,’type’=>$type,’name’=>$name,’roll’=>$roll,’stream’=>$stream,’semester’=>$sem));
}
}
}
else
{
$query2=”select * from tchr_info where Username=’$usrnm'”;
$result2=$con->query($query2);
if($result2->num_rows>0)
{
while($sql_fetch_array=mysqli_fetch_array($result2))
{
$dept=$sql_fetch_array[‘Department’];

$tch_name=$sql_fetch_array[‘Name’];
$response=’ok’;
echo json_encode(array(‘response’=>$response,’type’=>$type,’dept’=>$dept,’tch_name’=>$tch_name));
}
}
}
}
$response=’ok’;
}
else
{
$response=’error’;
}
}

//echo json_encode(array(‘response’=>response));
$con->close();
?>

DataSharing-Activity 1

September 2,2016

Today i have started work on my first activity i.e. login page.

The login page of both student and teacher is same.The data of student and teacher is stored in database.The information related to teacher and student is also stored in database.Student or teacher whoever login,their username and password is checked with the database and then they will proceed to their work.

Project-DataSharing

September 1,2016

Today i have decided my android application i.e. DataSharing Project which is a project in which documents like any assignment,notices,syllabus etc. are shared between students and faculty. In this project faculty may upload any notice and assignment.Also they can upload the attendance of students of any particular subject.On the other hand student may download notices and assignments and also check their attendance of particular subjects.Teacher may also check the attendance of students.Both have one their work by using their login id and passwords which they have assign via campus.

Shared Preferences

August 29,2016

Shared Preferences

Shared Preferences allow you to save and retrieve data in the form of key,value pair. In order to use shared preferences, you have to call a method getSharedPreferences() that returns a SharedPreference instance pointing to the file that contains the values of preferences.

SharedPreferences sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);	

You can save something in the sharedpreferences by using SharedPreferences.Editor class. You will call the edit method of SharedPreference instance and will receive it in an editor object. Its syntax is −

Editor editor = sharedpreferences.edit();
editor.putString("key", "value");
editor.commit();

Apart from the putString method, there are methods available in the editor class that allows manipulation of data inside shared preferences. They are listed as follows −

Sr.No Mode & description
1 apply()

It is an abstract method. It will commit your changes back from editor to the sharedPreference object you are calling

2 clear()

It will remove all values from the editor

3 remove(String key)

It will remove the value whose key has been passed as a parameter

4 putLong(String key, long value)

It will save a long value in a preference editor

5 putInt(String key, int value)

It will save a integer value in a preference editor

6 putFloat(String key, float value)

It will save a float value in a preference editor