コード例 #1
0
 /** {@inheritDoc} */
 public boolean canViewModelAnswer(Assignment a, AssignmentSubmission s) {
   if (a != null) {
     AssignmentModelAnswerItem m = getModelAnswer(a.getId());
     if (m != null) {
       if (m_assignmentService.allowGradeSubmission(a.getReference())) {
         // model answer is viewable to all graders
         return true;
       } else {
         int show = m.getShowTo();
         if (show == AssignmentConstants.MODEL_ANSWER_SHOW_TO_STUDENT_BEFORE_STARTS) {
           return true;
         } else if (show == AssignmentConstants.MODEL_ANSWER_SHOW_TO_STUDENT_AFTER_SUBMIT
             && s != null
             && s.getSubmitted()) {
           return true;
         } else if (show == AssignmentConstants.MODEL_ANSWER_SHOW_TO_STUDENT_AFTER_GRADE_RETURN
             && s != null
             && s.getGradeReleased()) {
           return true;
         } else if (show == AssignmentConstants.MODEL_ANSWER_SHOW_TO_STUDENT_AFTER_ACCEPT_UTIL
             && (a.getCloseTime().before(TimeService.newTime()))) {
           return true;
         }
       }
     }
   }
   return false;
 }
コード例 #2
0
 /** {@inheritDoc}} */
 public boolean saveModelAnswer(AssignmentModelAnswerItem mItem) {
   try {
     getHibernateTemplate().saveOrUpdate(mItem);
     return true;
   } catch (DataAccessException e) {
     e.printStackTrace();
     Log.warn(
         this
             + ".saveModelAnswerQuestion() Hibernate could not save model answer for assignment "
             + mItem.getAssignmentId());
     return false;
   }
 }