@Post @Options public String getResetInfo(Representation entity) { // do not treat Options requests if (this.getRequest().getMethod() == Method.OPTIONS) return ""; Form request = new Form(this.getRequestEntity()); JSONObject info = JSONObject.fromObject(request.getValues("info")); int schoolId = info.getInt("schoolId"); String email = info.getString("email"); String database = ConfigurationSettings.getSchoolDatabaseName(schoolId); DBConnection dbConnection = DBConnectionManager.getConnection(schoolId, database); JSONObject resetInfo = DBUtils.getResetInfo(dbConnection, email); return resetInfo.toString(); }
@Post @Options public String getHomeworkNameAndGrade(Representation entity) { // do not treat Options requests if (this.getRequest().getMethod() == Method.OPTIONS) return ""; Form request = new Form(this.getRequestEntity()); JSONObject info = JSONObject.fromObject(request.getValues("info")); int schoolId = info.getInt("schoolId"); int homeworkId = info.getInt("homeworkId"); int graded = info.getInt("graded"); int grade = info.getInt("grade"); String feedback = info.getString("feedback"); String database = ConfigurationSettings.getSchoolDatabaseName(schoolId); DBConnection dbConnection = DBConnectionManager.getConnection(schoolId, database); int rows = DBUtils.rateHomework(dbConnection, homeworkId, graded, grade, feedback); return rows + ""; }