use of com.remswork.project.alice.model.Class in project classify-system by anverliedoit.
the class ClassServiceImpl method updateClassById.
@Override
public Class updateClassById(long id, Class newClass, long teacherId, long subjectId, long sectionId) throws ClassException {
try {
StringBuilder uri = new StringBuilder();
uri.append(targetProperties.getDomain());
uri.append("/");
uri.append(targetProperties.getBaseUri());
uri.append("/");
uri.append(payload);
uri.append("/");
uri.append(id);
Client client = ClientBuilder.newClient();
WebTarget target = client.target(uri.toString());
Builder builder = target.queryParam("teacherId", teacherId).queryParam("subjectId", subjectId).queryParam("sectionId", sectionId).request();
builder.accept("application/json");
Response response = builder.put(Entity.json(newClass));
if (response.getStatus() == 200) {
return (Class) response.readEntity(Class.class);
} else if (response.getStatus() == 400) {
Message message = (Message) response.readEntity(Message.class);
throw new ClassServiceException(message.getMessage());
} else
throw new ClassServiceException("The request might invalid or server is down");
} catch (ClassServiceException e) {
throw new ClassException(e.getMessage());
}
}
use of com.remswork.project.alice.model.Class in project classify-system by anverliedoit.
the class ActivityGradeActivity method load.
public void load() {
try {
final FormulaService formulaService = new FormulaServiceImpl();
final GradeService gradeService = new GradeServiceImpl();
final long termId = getIntent().getExtras().getLong("termId");
final long classId = getIntent().getExtras().getLong("classId");
final Class _class = classService.getClassById(classId);
final long subjectId = _class.getSubject() != null ? _class.getSubject().getId() : 0;
final long teacherId = _class.getTeacher() != null ? _class.getTeacher().getId() : 0;
final Formula formula = formulaService.getFormulaBySubjectAndTeacherId(subjectId, teacherId, termId);
Log.i("SOMETHINGGG", "CLASSID" + classId + " FORMULAID" + formula.getId());
for (final Student student : classService.getStudentList(classId)) {
final Student cStudent = student;
Log.i("SOMETHINGGG", "Student" + student.getId());
Log.i("FORMULA", formula.getId() + "");
new Thread(new Runnable() {
@Override
public void run() {
try {
long studentId = cStudent.getId();
List<Grade> temp = gradeService.getGradeListByClass(classId, studentId, termId);
Grade grade = temp.size() > 0 ? temp.get(0) : new Grade();
Log.i("GRADE", grade.getId() + "");
double totalScore = ((double) formula.getActivityPercentage() / 100) * grade.getActivityScore();
grade.setTotalScore(totalScore);
grade.setStudent(student);
Log.i("SOMETHINGGG", "totalScore" + formula.getActivityPercentage());
gradeList.add(grade);
notifyChange();
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.remswork.project.alice.model.Class in project classify-system by anverliedoit.
the class ActivityGradeAssignment method load.
public void load() {
try {
final FormulaService formulaService = new FormulaServiceImpl();
final GradeService gradeService = new GradeServiceImpl();
final long termId = getIntent().getExtras().getLong("termId");
final long classId = getIntent().getExtras().getLong("classId");
final Class _class = classService.getClassById(classId);
final long subjectId = _class.getSubject() != null ? _class.getSubject().getId() : 0;
final long teacherId = _class.getTeacher() != null ? _class.getTeacher().getId() : 0;
final Formula formula = formulaService.getFormulaBySubjectAndTeacherId(subjectId, teacherId, termId);
Log.i("SOMETHINGGG", "CLASSID" + classId + " FORMULAID" + formula.getId());
for (final Student student : classService.getStudentList(classId)) {
final Student cStudent = student;
Log.i("SOMETHINGGG", "Student" + student.getId());
Log.i("FORMULA", formula.getId() + "");
new Thread(new Runnable() {
@Override
public void run() {
try {
long studentId = cStudent.getId();
List<Grade> temp = gradeService.getGradeListByClass(classId, studentId, termId);
Grade grade = temp.size() > 0 ? temp.get(0) : new Grade();
Log.i("GRADE", grade.getId() + "");
double totalScore = ((double) formula.getAssignmentPercentage() / 100) * grade.getAssignmentScore();
grade.setTotalScore(totalScore);
grade.setStudent(student);
Log.i("SOMETHINGGG", "totalScore" + formula.getAssignmentPercentage());
gradeList.add(grade);
notifyChange();
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.remswork.project.alice.model.Class in project classify-system by anverliedoit.
the class ActivityGradeQuiz method load.
public void load() {
try {
final FormulaService formulaService = new FormulaServiceImpl();
final GradeService gradeService = new GradeServiceImpl();
final long termId = getIntent().getExtras().getLong("termId");
final long classId = getIntent().getExtras().getLong("classId");
final Class _class = classService.getClassById(classId);
final long subjectId = _class.getSubject() != null ? _class.getSubject().getId() : 0;
final long teacherId = _class.getTeacher() != null ? _class.getTeacher().getId() : 0;
final Formula formula = formulaService.getFormulaBySubjectAndTeacherId(subjectId, teacherId, termId);
Log.i("SOMETHINGGG", "CLASSID" + classId + " FORMULAID" + formula.getId());
for (final Student student : classService.getStudentList(classId)) {
final Student cStudent = student;
Log.i("SOMETHINGGG", "Student" + student.getId());
Log.i("FORMULA", formula.getId() + "");
new Thread(new Runnable() {
@Override
public void run() {
try {
long studentId = cStudent.getId();
List<Grade> temp = gradeService.getGradeListByClass(classId, studentId, termId);
Grade grade = temp.size() > 0 ? temp.get(0) : new Grade();
Log.i("GRADE", grade.getId() + "");
double totalScore = ((double) formula.getQuizPercentage() / 100) * grade.getQuizScore();
grade.setTotalScore(totalScore);
grade.setStudent(student);
Log.i("SOMETHINGGG", "totalScore" + formula.getQuizPercentage());
gradeList.add(grade);
notifyChange();
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.remswork.project.alice.model.Class in project classify-system by anverliedoit.
the class ActivityDaoImpl method addActivity.
@Override
public Activity addActivity(Activity activity, long classId) throws GradingFactorException {
Session session = sessionFactory.openSession();
session.beginTransaction();
try {
Class _class = session.get(Class.class, classId);
if (activity == null)
throw new GradingFactorDaoException("You tried to add class with a null value");
if (classId == 0)
throw new GradingFactorDaoException("Query param : classId is required");
if (_class == null)
throw new GradingFactorDaoException("Activity's class with id : " + classId + " does not exist");
if (activity.getTitle() == null)
throw new GradingFactorDaoException("Activity's title is required");
if (activity.getTitle().trim().equals(""))
throw new GradingFactorDaoException("Activity can't have an empty title");
if (activity.getDate() == null)
throw new GradingFactorDaoException("Activity's date is required");
if (activity.getDate().trim().equals(""))
throw new GradingFactorDaoException("Activity can't have an empty date");
if (activity.getItemTotal() < 0)
throw new GradingFactorDaoException("Activity's itemTotal is invalid");
activity.set_class(_class);
session.persist(activity);
session.getTransaction().commit();
session.close();
return activity;
} catch (GradingFactorDaoException e) {
session.close();
throw new GradingFactorException(e.getMessage());
}
}
Aggregations