use of ca.dal.cs.softeng.database.Course in project CSCI3130 by T-Caines.
the class HasLabTest method setup.
@Before
public void setup() {
courseWithLab = new Course();
courseWithLab.hasLab = true;
courseWithoutLab = new Course();
courseWithoutLab.hasLab = false;
}
use of ca.dal.cs.softeng.database.Course in project CSCI3130 by T-Caines.
the class CourseAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = null;
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
v = inflater.inflate(R.layout.list_view, parent, false);
} else {
v = convertView;
}
Course model = items.get(position);
TextView seats = (TextView) v.findViewById(R.id.seats);
seats.setText(String.format("%s/%s", model.enrollment, model.seatsAvailable));
TextView code = (TextView) v.findViewById(R.id.code);
code.setText(model.faculty + model.courseID);
TextView courseName = (TextView) v.findViewById(R.id.name);
courseName.setText(model.courseName);
TextView timeEnd = (TextView) v.findViewById(R.id.end);
timeEnd.setText("" + model.timeEnd);
TextView timeStart = (TextView) v.findViewById(R.id.start);
timeStart.setText("" + model.timeStart);
TextView days = (TextView) v.findViewById(R.id.days);
// TODO: Right method to convert binary 10101 -> MWF
days.setText("" + model.days);
return v;
}
use of ca.dal.cs.softeng.database.Course in project CSCI3130 by T-Caines.
the class CourseManager method isConflicting.
/**
* Checks if the given course has a time conflict with any of the currently
* registered courses for the current term.
*
* @param course Course to be compared
* @return TRUE if conflicting; FALSE if not.
*/
public boolean isConflicting(Course course) {
ArrayList<Integer> startTime = new ArrayList<Integer>();
ArrayList<Integer> endTime = new ArrayList<Integer>();
for (int i = 0; i < registeredCRNs.get(ApplicationData.term.getTerm()).size(); i++) {
Course c = getCourse(registeredCRNs.get(ApplicationData.term.getTerm()).get(i));
startTime.add(c.timeStart);
endTime.add(c.timeEnd);
}
int timeStart = course.timeStart, timeStart2;
int timeEnd = course.timeEnd, timeEnd2;
for (int i = 0; i < startTime.size(); i++) {
timeStart2 = startTime.get(i);
timeEnd2 = endTime.get(i);
if (timeStart2 >= timeStart && timeStart2 <= timeEnd)
return true;
if (timeEnd2 >= timeStart && timeEnd2 <= timeEnd)
return true;
}
return false;
}
use of ca.dal.cs.softeng.database.Course in project CSCI3130 by T-Caines.
the class SearchActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search_activity);
searchButton = findViewById(R.id.searchButton);
startTimeSpinner = findViewById(R.id.startSpinner);
endTimeSpinner = findViewById(R.id.endSpinner);
searchBar = findViewById(R.id.searchBar);
user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
String uid = user.getUid();
mDatabase = FirebaseDatabase.getInstance().getReference().child("USERDATA").child(uid);
}
firebaseAdapter = new FirebaseListAdapter<Course>(this, Course.class, R.layout.list_view, FirebaseDatabase.getInstance().getReference("COURSE").child(ApplicationData.term.getTerm())) {
@Override
protected void populateView(View v, Course model, int position) {
TextView seats = (TextView) v.findViewById(R.id.seats);
seats.setText(String.format("%s/%s", model.enrollment, model.seatsAvailable));
TextView code = (TextView) v.findViewById(R.id.code);
code.setText(model.faculty + model.courseID);
TextView courseName = (TextView) v.findViewById(R.id.name);
courseName.setText(model.courseName);
TextView timeEnd = (TextView) v.findViewById(R.id.end);
timeEnd.setText("" + model.timeEnd);
TextView timeStart = (TextView) v.findViewById(R.id.start);
timeStart.setText("" + model.timeStart);
TextView days = (TextView) v.findViewById(R.id.days);
// TODO: Right method to convert binary 10101 -> MWF
days.setText("" + model.days);
}
};
// Create list view
listView = findViewById(R.id.list_view);
listView.setAdapter(firebaseAdapter);
switch(ApplicationData.term) {
case FALL:
RadioButton fallRB = findViewById(R.id.fall);
fallRB.setChecked(true);
break;
case WINTER:
RadioButton winterRB = findViewById(R.id.winter);
winterRB.setChecked(true);
break;
case SUMMER:
RadioButton summerRB = findViewById(R.id.summer);
summerRB.setChecked(true);
break;
}
// Set what happens when a list view item is clicked
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Grab selected item from firebase
selectedCourse = firebaseAdapter.getItem(position);
// If there is an item already selected, un-highlight
if (previousSelectedView != null) {
previousSelectedView.setBackgroundColor(getColor(R.color.defaultBackground));
}
// Used to unselect a course. Happens when you select the selected item.
if (previousSelectedView == view) {
previousSelectedView = null;
selectedCourse = null;
return;
}
// Highlight this item
view.setBackgroundColor(getColor(R.color.colorBalanced));
previousSelectedView = view;
}
});
Button addButton = findViewById(R.id.addbutton);
addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (selectedCourse == null)
return;
if (!courseManager.capReached(selectedCourse, v)) {
System.out.println("Adding failed");
}
}
});
}
use of ca.dal.cs.softeng.database.Course in project CSCI3130 by T-Caines.
the class AddDropCourseActivityTest method addButton.
@Test
public void addButton() throws Exception {
main.getActivity();
dbAuth = FirebaseAuth.getInstance();
dbAuth.signInWithEmailAndPassword("test@test.ca", "password");
onView(withId(R.id.summer)).perform(click());
onView(withText("Comm Skills: Oral/Written")).perform(click());
onView(withId(R.id.addbutton)).perform(click());
String term = ApplicationData.term.getTerm();
Course firstCourse = cm.getUserInfo().get(0);
onView(withId(R.id.dropbutton)).perform(click());
onView(withText("Yes")).perform(click());
onView(withId(R.id.addbutton)).perform(click());
Course newCourse = cm.getUserInfo().get(0);
// assertEquals(firstCourse.enrollmentSummer,newCourse.enrollmentSummer);
}
Aggregations