// Getters
 // Getting specific assignment
 public Assignment getAssignment(int aid) {
   Log.d("Went into getAssignment", "yes: " + Integer.toString(aid));
   String selectQuery = "SELECT * FROM Assignment " + " WHERE aid = " + aid;
   Log.d("selectQuery: ", selectQuery);
   SQLiteDatabase db = this.getWritableDatabase();
   Cursor cursor = db.rawQuery(selectQuery, null);
   cursor.moveToFirst();
   Log.d("getAssignment cursor size: ", Integer.toString(cursor.getCount()));
   Log.d("getAssignment cursor 1st entry: ", cursor.getString(0));
   Assignment assignment = new Assignment();
   assignment.setaid(Integer.parseInt(cursor.getString(0)));
   assignment.settitle(cursor.getString(1));
   assignment.settype(cursor.getString(2));
   assignment.setmonth(Integer.parseInt(cursor.getString(3)));
   assignment.setday(Integer.parseInt(cursor.getString(4)));
   assignment.setyear(Integer.parseInt(cursor.getString(5)));
   assignment.setpriority(Integer.parseInt(cursor.getString(6)));
   Log.d("Got priority", cursor.getString(6));
   Log.d("Course = ", cursor.getString(7));
   if (cursor.getInt(7) > 0)
     assignment.setCourse(getCourse(Integer.parseInt(cursor.getString(7))));
   else assignment.setCourse(null);
   if (cursor.getInt(8) > 0)
     assignment.setInstructor(getInstructor(Integer.parseInt(cursor.getString(8))));
   else assignment.setInstructor(null);
   assignment.setPartner(getPartners(assignment.getaid()));
   assignment.setnotes(cursor.getString(9));
   assignment.setCompleted(cursor.getInt(10));
   if (cursor.getInt(10) == 1) {
     assignment.setGrade(getGrade(assignment.getaid()));
   }
   Log.d("Got everything successfully", "yes");
   return assignment;
 }
Exemplo n.º 2
0
 public Message EditAssignmentGrade(Message m) {
   Message rm = null;
   int sessID = (int) m.msg[m.msg.length - 1];
   String userName = network.getUserName(sessID);
   Person grader = LoginManager.get(userName); // get id of person doing the adding
   int asid = (Integer) m.msg[0];
   String gradeUserName = (String) m.msg[3];
   double newgrade = Double.parseDouble((String) m.msg[1]);
   String newcomments = (String) m.msg[2];
   int cid = ((Course) m.msg[4]).getCID(); // cid of course
   Course c = LoginManager.getCourse(cid);
   Person beingGraded = LoginManager.get((gradeUserName));
   Assignment gradeassign = c.getAssignment(asid);
   HashMap<Integer, Person> TAs = c.getTAs();
   if (gradeassign == null) {
     rm = new Message(Message.Type.EditAssignmentGradeResponse, false);
   } else {
     gradeassign.setGrade(grader, beingGraded, newgrade, newcomments);
     rm = new Message(Message.Type.EditAssignmentGradeResponse, true);
   }
   enc = LoginManager.save(enc);
   network.sendMessage(rm, sessID);
   return rm;
 }