示例#1
0
    @Override
    public void load(final Runnable onSuccess, final ICallback<Pair<String, Throwable>> onFailure) {
      String paramName = PageObjectParamNameMap.getInstance().get(Problem.class);
      final Integer problemId = pageParams.getInt(paramName);
      if (problemId == null) {
        onFailure.call(new Pair<String, Throwable>("No problem id specified", null));
      } else {
        CourseSelection courseSelection = session.get(CourseSelection.class);
        RPC.getCoursesAndProblemsService.getProblems(
            courseSelection.getCourse(),
            new AsyncCallback<Problem[]>() {
              @Override
              public void onFailure(Throwable caught) {
                onFailure.call(new Pair<String, Throwable>("Could not get problem", caught));
              }

              public void onSuccess(Problem[] result) {
                Problem problem = null;
                for (Problem p : result) {
                  if (p.getProblemId().equals(problemId)) {
                    problem = p;
                    break;
                  }
                }
                if (problem == null) {
                  onFailure.call(new Pair<String, Throwable>("No such problem", null));
                } else {
                  // Add the Problem to the session and continue
                  session.add(problem);
                  onSuccess.run();
                }
              }
            });
      }
    }
示例#2
0
 /**
  * Check whether logged-in user is an instructor in the selected course.
  *
  * @param courseSelection the selected course
  * @param courseRegList course registrations for logged-in user
  * @return true if the logged-in user is an instructor in the selected course, false otherwise
  */
 private static boolean isInstructor(
     CourseSelection courseSelection, CourseAndCourseRegistration[] courseRegList) {
   boolean isInstructor = false;
   for (CourseAndCourseRegistration reg : courseRegList) {
     if (reg.getCourse().getId() == courseSelection.getCourse().getId()) {
       isInstructor = reg.getCourseRegistration().getRegistrationType().isInstructor();
       break;
     }
   }
   return isInstructor;
 }
示例#3
0
    @Override
    public void activate(final Session session, final SubscriptionRegistrar subscriptionRegistrar) {

      UserSelection selectedUser = session.get(UserSelection.class);
      CourseSelection courseSelection = session.get(CourseSelection.class);

      // activate views
      statusMessageView.activate(session, subscriptionRegistrar);
      userProgressView.activate(session, subscriptionRegistrar);

      // Display top label (username and course)
      StringBuilder buf = new StringBuilder();
      buf.append("Progress for ");
      buf.append(selectedUser.getUser().getUsername());
      buf.append(" in ");
      buf.append(courseSelection.getCourse().getName());
      topLabel.setText(buf.toString());

      // Add back/logout handlers
      pageNavPanel.setLogoutHandler(new LogoutHandler(session));
      pageNavPanel.setBackHandler(new PageBackHandler(session));
    }
示例#4
0
 public void loadProblemsForCourse(final CourseSelection courseSelection) {
   GWT.log(
       "Loading problems and submission receipts for course "
           + courseSelection.getCourse().getNameAndTitle());
   SessionUtil.loadProblemAndSubmissionReceiptsInCourse(page, courseSelection, page.getSession());
 }