コード例 #1
0
  public String commentPass() {
    /////// Session
    // Bean/////////////////////////////////////////////////////////////////////////////
    Users e = (Users) ActionContext.getContext().getSession().get("user");
    if (e == null) {
      return ERROR;
    }

    SessionBean session = new SessionBean();
    l1 = session.getLecture(lectureID);
    Comment comment = new Comment();
    comment.setUser(e);
    comment.setComment(this.userComment);
    comment.setLecture(l1);

    Comment = session.findCommentByLectureId(lectureID);
    Comment.add(comment);
    session.updateLecture(l1);
    session.saveComment(comment);

    return SUCCESS;
  }
コード例 #2
0
  public String execute() {

    /////// Session
    // Bean/////////////////////////////////////////////////////////////////////////////
    SessionBean session = new SessionBean();
    Users e = (Users) ActionContext.getContext().getSession().get("user");

    if (e == null) {
      return ERROR;
    }
    if (e.getRole().equals("instructor")) {
      role = "instructor";
    } else {

      role = "student";
    }

    String email = e.getEmail();
    l1 = session.getLecture(lectureID);
    this.description = l1.getLectureDescription();
    this.title = l1.getLectureTitle();
    media = l1.getMaterials();

    List<Media> allQ = new ArrayList<Media>();
    int j = 0;
    for (int i = 0; i < media.size(); i++) {
      j = 0;
      for (j = 0; j < allQ.size(); j++) {
        if (media.get(i).getPath().equals(allQ.get(j).getPath())
            || media.get(i).getType().equals("empty")) {
          break;
        }
      }

      if (j == allQ.size()) {
        allQ.add(media.get(i));
      }
    }

    media = allQ;
    downLoadFiles = new ArrayList<String>();

    for (int i = 0; i < media.size(); i++) {
      if (media.get(i).getType().equals("mp4")
          || media.get(i).getType().equals(".mp4")
          || media.get(i).getType().equals("mpeg")) {

        videoPath = media.get(i).getPath();
      } else {
        downLoadFiles.add(media.get(i).getPath());
      }
    }
    videoPath = mediaLocation + videoPath;

    Comment = session.findCommentByLectureId(lectureID);

    int length = downLoadFiles.size();
    if (length == 1) {
    } else {
      List<String> temp = new ArrayList<String>();
      for (int i = 1; i < length; i++) {
        temp.add(downLoadFiles.get(i));
      }
      downLoadFiles = temp;
    }

    if (role.equals("instructor")) {

      instructor = session.getInstructor(email);
      courses = session.findByInstructor(email);
      System.out.println(instructor.getFirstname() + " " + instructor.getLastname());
      role = "instructor";
      return "instructor";
    } else {

      student = session.getStudent(email);
      courses = session.findByStudent(email);
      otherCourses = session.findOtherCoursesByStudent(email);

      System.out.println(student.getFirstname() + " " + student.getLastname());
      role = "student";

      return "student";
    }
  }