Scenario
You have been tasked to develop an application which manages student tasks. An instructor
should be a to add tasks for students. A task should have a taskID, taskName, dueDate, and
a module where the test is for. A module should have a moduleID, moduleName, and the
duration for the module. Modules should be added by an admin. Students should also be
added by the admin, and students should have a studentID, studentName, studentSurname,
and the Dob. Students and instructors should be able to sign into the system to access
different functionalities.
Functionality for students include:
• Access tasks created by the instructor.
• Indicate whether the tasks are completed or not.
Functionality for the instructor includes:
• Creating tasks for students.
Functionality for adminsinclude:
• Creating students’ records.
• Creating module records.
• Creating instructor records.
You are required to implement a login activity to control access between the different roles
(admin, instructor, and a student) and use a navigation activity to group the different activities
for a specific user role. Each functionality in the program should have its own activity.
The following is what i have done so far:
public class LoginActivity extends AppCompatActivity {
private EditText usernameEditText, passwordEditText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
usernameEditText = findViewById(R.id.usernameEditText);
passwordEditText = findViewById(R.id.passwordEditText);
Button loginButton = findViewById(R.id.loginButton);
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Perform authentication logic here
String username = usernameEditText.getText().toString();
String password = passwordEditText.getText().toString();
// Example authentication logic (replace with your own)
if (username.equals("admin") && password.equals("admin")) {
// Redirect to AdminActivity
startActivity(new Intent(LoginActivity.this, AdminActivity.class));
} else if (username.equals("instructor") && password.equals("instructor")) {
// Redirect to InstructorActivity
// startActivity(new Intent(LoginActivity.this, InstructorActivity.class));
Toast.makeText(LoginActivity.this, "Instructor login", Toast.LENGTH_SHORT).show();
} else if (username.equals("student") && password.equals("student")) {
// Redirect to StudentActivity
// startActivity(new Intent(LoginActivity.this, StudentActivity.class));
Toast.makeText(LoginActivity.this, "Student login", Toast.LENGTH_SHORT).show();
} else {
// Invalid credentials
Toast.makeText(LoginActivity.this, "Invalid username or password", Toast.LENGTH_SHORT).show();
}
}
});
}
}
1