def get(self):
        """Handles GET requests."""
        models.MemcacheManager.begin_readonly()
        try:
            user = self.personalize_page_and_get_user()
            if user is None:
                student = TRANSIENT_STUDENT
            else:
                student = Student.get_enrolled_student_by_user(user)
                profile = StudentProfileDAO.get_profile_by_user(user)
                self.template_value['has_global_profile'] = profile is not None
                if not student:
                    student = TRANSIENT_STUDENT

            if (student.is_transient and
                not self.app_context.get_environ()['course']['browsable']):
                self.redirect('/preview')
                return

            # If we are on this page due to visiting the course base URL
            # (and not base url plus "/course"), redirect registered students
            # to the last page they were looking at.
            last_location = self.get_redirect_location(student)
            if last_location:
                self.redirect(last_location)
                return

            tracker = self.get_progress_tracker()
            units = self.get_track_matching_student(student)
            units = filter_assessments_used_within_units(units)
            self.template_value['units'] = units
            self.template_value['show_registration_page'] = True

            if student and not student.is_transient:
                augment_assessment_units(self.get_course(), student)
                self.template_value['course_progress'] = (
                    tracker.get_course_progress(student))
            elif user:
                profile = StudentProfileDAO.get_profile_by_user_id(
                    user.user_id())
                additional_registration_fields = self.app_context.get_environ(
                    )['reg_form']['additional_registration_fields']
                if profile is not None and not additional_registration_fields:
                    self.template_value['show_registration_page'] = False
                    self.template_value['register_xsrf_token'] = (
                        XsrfTokenManager.create_xsrf_token('register-post'))

            self.template_value['transient_student'] = student.is_transient
            self.template_value['progress'] = tracker.get_unit_progress(student)
            course = self.app_context.get_environ()['course']
            set_image_or_video_exists(self.template_value, course)

            self.template_value['is_progress_recorded'] = is_progress_recorded(
                self, student)
            self.template_value['navbar'] = {'course': True}
        finally:
            models.MemcacheManager.end_readonly()
        self.render('course.html')
Exemple #2
0
    def get(self):
        """Handles GET requests."""
        user = self.personalize_page_and_get_user()
        if user is None:
            student = TRANSIENT_STUDENT
        else:
            student = Student.get_enrolled_student_by_email(user.email())
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            self.template_value['has_global_profile'] = profile is not None
            if not student:
                student = TRANSIENT_STUDENT

        if (student.is_transient and
            not self.app_context.get_environ()['course']['browsable']):
            self.redirect('/preview')
            return

        self.template_value['units'] = self.get_units()
        self.template_value['show_registration_page'] = True

        if student and not student.is_transient:
            self.augment_assessment_units(student)
        elif user:
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            additional_registration_fields = self.app_context.get_environ(
                )['reg_form']['additional_registration_fields']
            if profile is not None and not additional_registration_fields:
                self.template_value['show_registration_page'] = False
                self.template_value['register_xsrf_token'] = (
                    XsrfTokenManager.create_xsrf_token('register-post'))

        self.template_value['transient_student'] = student.is_transient
        self.template_value['progress'] = (
            self.get_progress_tracker().get_unit_progress(student))

        #progress bar
        total_progress = (self.get_progress_tracker().get_overall_progress_score(student))
        self.template_value['progress_value'] = total_progress.get('progress_score', 0)
        self.template_value['complete_value'] = total_progress.get('completed_score', 0)
        self.template_value['percentage'] = total_progress.get('percentage', '')

        self.template_value['progress'] = (self.get_progress_tracker().get_unit_progress(student))

        course = self.app_context.get_environ()['course']
        self.template_value['video_exists'] = bool(
            'main_video' in course and
            'url' in course['main_video'] and
            course['main_video']['url'])
        self.template_value['image_exists'] = bool(
            'main_image' in course and
            'url' in course['main_image'] and
            course['main_image']['url'])

        self.template_value['is_progress_recorded'] = (
            CAN_PERSIST_ACTIVITY_EVENTS.value)
        self.template_value['navbar'] = {'course': True}
        self.render('home.html')
Exemple #3
0
    def get(self):
        """Handles GET requests."""
        user = self.personalize_page_and_get_user()
        if user is None:
            student = TRANSIENT_STUDENT
        else:
            student = Student.get_enrolled_student_by_email(user.email())
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            self.template_value['has_global_profile'] = profile is not None
            if not student:
                student = TRANSIENT_STUDENT

        if (student.is_transient and
            not self.app_context.get_environ()['course']['browsable']):
            self.redirect('/preview')
            return

        self.template_value['units'] = self.get_units()
        self.template_value['show_registration_page'] = True

        if student and not student.is_transient:
            self.augment_assessment_units(student)
        elif user:
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            additional_registration_fields = self.app_context.get_environ(
                )['reg_form']['additional_registration_fields']
            if profile is not None and not additional_registration_fields:
                self.template_value['show_registration_page'] = False
                self.template_value['register_xsrf_token'] = (
                    XsrfTokenManager.create_xsrf_token('register-post'))

        self.template_value['transient_student'] = student.is_transient
        self.template_value['progress'] = (
            self.get_progress_tracker().get_unit_progress(student))

        course = self.app_context.get_environ()['course']
        self.template_value['video_exists'] = bool(
            'main_video' in course and
            'url' in course['main_video'] and
            course['main_video']['url'])
        self.template_value['image_exists'] = bool(
            'main_image' in course and
            'url' in course['main_image'] and
            course['main_image']['url'])

        self.template_value['is_progress_recorded'] = (
            CAN_PERSIST_ACTIVITY_EVENTS.value)
        self.template_value['navbar'] = {'course': True}

            
        self.template_value['units_progress'] = self.get_course().get_units_progress()
        
        self.render('course.html')
    def get(self):
        """Handles GET requests."""
        if not course_explorer.GCB_ENABLE_COURSE_EXPLORER_PAGE.value:
            self.error(404)
            return

        user = self.initialize_page_and_get_user()
        if not user:
            self.redirect('/explorer')
            return

        courses = self.get_public_courses()
        self.template_values['student'] = (
            StudentProfileDAO.get_profile_by_user_id(user.user_id()))
        self.template_values['navbar'] = {'profile': True}
        self.template_values['courses'] = self.get_enrolled_courses(courses)
        self.template_values['student_edit_xsrf_token'] = (
            XsrfTokenManager.create_xsrf_token(
                STUDENT_RENAME_GLOBAL_XSRF_TOKEN_ID))
        self.template_values['html_hooks'] = NullHtmlHooks()
        self.template_values['student_preferences'] = {}

        template = jinja_utils.get_template(
            '/modules/course_explorer/views/profile.html', DIR)
        self.response.write(template.render(self.template_values))
Exemple #5
0
    def get(self):
        """Handles GET requests."""
        if not course_explorer.GCB_ENABLE_COURSE_EXPLORER_PAGE.value:
            self.error(404)
            return

        user = self.initialize_page_and_get_user()
        if not user:
            self.redirect('/explorer')
            return

        courses = self.get_public_courses()
        self.template_values['student'] = (
            StudentProfileDAO.get_profile_by_user_id(user.user_id()))
        self.template_values['navbar'] = {'profile': True}
        self.template_values['courses'] = self.get_enrolled_courses(courses)
        self.template_values['student_edit_xsrf_token'] = (
            XsrfTokenManager.create_xsrf_token(
                STUDENT_RENAME_GLOBAL_XSRF_TOKEN_ID))
        self.template_values['html_hooks'] = NullHtmlHooks()
        self.template_values['student_preferences'] = {}

        template = jinja_utils.get_template(
            '/modules/course_explorer/views/profile.html', DIR)
        self.response.write(template.render(self.template_values))
Exemple #6
0
    def post(self):
        """Handles POST requests."""
        user = self.personalize_page_and_get_user()
        if not user:
            self.redirect(users.create_login_url(self.request.uri), normalize=False)
            return

        if not self.assert_xsrf_token_or_fail(self.request, "register-post"):
            return

        can_register = self.app_context.get_environ()["reg_form"]["can_register"]
        if not can_register:
            self.redirect("/course#registration_closed")
            return

        if "name_from_profile" in self.request.POST.keys():
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            name = profile.nick_name
        else:
            name = self.request.get("form01")

        Student.add_new_student_for_current_user(name, transforms.dumps(self.request.POST.items()))

        course = sites.get_course_for_current_request()
        if course.get_slug().split("_")[-1] == "DFR":
            self.redirect("/gDefier/register")
        else:
            self.redirect("/course#registration_confirmation")
    def get(self):
        """Handles GET request."""
        user = self.personalize_page_and_get_user()
        if not user:
            self.redirect(
                users.create_login_url(self.request.uri), normalize=False)
            return

        student = Student.get_enrolled_student_by_email(user.email())
        if student:
            self.redirect('/course')
            return

        can_register = self.app_context.get_environ(
            )['reg_form']['can_register']
        if not can_register:
            self.redirect('/course#registration_closed')
            return

        # pre-fill nick name from the profile if available
        self.template_value['current_name'] = ''
        profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
        if profile and profile.nick_name:
            self.template_value['current_name'] = profile.nick_name

        self.template_value['navbar'] = {}
        self.template_value['transient_student'] = True
        self.template_value['register_xsrf_token'] = (
            XsrfTokenManager.create_xsrf_token('register-post'))

        self.render('register.html')
    def post(self):
        """Handles POST requests."""
        user = self.personalize_page_and_get_user()
        if not user:
            self.redirect(
                users.create_login_url(self.request.uri), normalize=False)
            return

        if not self.assert_xsrf_token_or_fail(self.request, 'register-post'):
            return

        can_register = self.app_context.get_environ(
            )['reg_form']['can_register']
        if not can_register:
            self.redirect('/course#registration_closed')
            return

        if 'name_from_profile' in self.request.POST.keys():
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            name = profile.nick_name
        else:
            name = self.request.get('form01')

        Student.add_new_student_for_current_user(
            name, transforms.dumps(self.request.POST.items()))
        # Render registration confirmation page
        self.redirect('/course#registration_confirmation')
Exemple #9
0
    def get(self):
        """Handles GET request."""
        user = self.personalize_page_and_get_user()
        if not user:
            self.redirect(
                users.create_login_url(self.request.uri), normalize=False)
            return

        student = Student.get_enrolled_student_by_email(user.email())
        if student:
            self.redirect('/course')
            return

        can_register = self.app_context.get_environ(
            )['reg_form']['can_register']
        if not can_register:
            self.redirect('/course#registration_closed')
            return

        # pre-fill nick name from the profile if available
        self.template_value['current_name'] = ''
        profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
        if profile and profile.nick_name:
            self.template_value['current_name'] = profile.nick_name

        self.template_value['navbar'] = {}
        self.template_value['transient_student'] = True
        self.template_value['register_xsrf_token'] = (
            XsrfTokenManager.create_xsrf_token('register-post'))

        self.render('register.html')
Exemple #10
0
    def post(self):
        """Handles POST requests."""
        user = self.personalize_page_and_get_user()
        if not user:
            self.redirect(
                users.create_login_url(self.request.uri), normalize=False)
            return

        if not self.assert_xsrf_token_or_fail(self.request, 'register-post'):
            return

        can_register = self.app_context.get_environ(
            )['reg_form']['can_register']
        if not can_register:
            self.redirect('/course#registration_closed')
            return

        if 'name_from_profile' in self.request.POST.keys():
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            name = profile.nick_name
        else:
            name = self.request.get('form01')

        Student.add_new_student_for_current_user(
            name, transforms.dumps(self.request.POST.items()))
        # Render registration confirmation page
        self.redirect('/course#registration_confirmation')
Exemple #11
0
    def get(self):
        """Handles GET request."""
        user = self.personalize_page_and_get_user()
        if not user:
            self.redirect(users.create_login_url(self.request.uri), normalize=False)
            return

        student = Student.get_enrolled_student_by_user(user)
        if student:
            self.redirect("/course")
            return

        can_register = self.app_context.get_environ()["reg_form"]["can_register"]
        if not can_register:
            self.redirect("/course#registration_closed")
            return

        # pre-fill nick name from the profile if available
        self.template_value["current_name"] = ""
        profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
        if profile and profile.nick_name:
            self.template_value["current_name"] = profile.nick_name

        self.template_value["navbar"] = {}
        self.template_value["transient_student"] = True
        self.template_value["register_xsrf_token"] = XsrfTokenManager.create_xsrf_token("register-post")

        alternate_content = []
        for hook in self.PREVENT_REGISTRATION_HOOKS:
            alternate_content.extend(hook(self.app_context, user.user_id()))
        self.template_value["alternate_content"] = alternate_content

        self.render("register.html")
 def initialize(cls, template_values):
     template_values.update(
         {'show_course_explorer_tab': GCB_ENABLE_COURSE_EXPLORER_PAGE.value})
     user = users.get_current_user()
     if user:
         profile = StudentProfileDAO.get_profile_by_user_id(
             users.get_current_user().user_id())
         template_values.update({'has_global_profile': profile is not None})
Exemple #13
0
 def initialize(cls, template_values):
     template_values.update(
         {'show_course_explorer_tab': GCB_ENABLE_COURSE_EXPLORER_PAGE.value})
     user = users.get_current_user()
     if user:
         profile = StudentProfileDAO.get_profile_by_user_id(
             users.get_current_user().user_id())
         template_values.update({'has_global_profile': profile is not None})
Exemple #14
0
 def get_mentors_with_no_local_chapter(cls, ignore_ids=None):
     mentor_list = Mentor.query(cls.local_chapter == False).fetch(None)
     mentor_id_list = [
         mentor.user_id for mentor in mentor_list
         if mentor.user_id not in ignore_ids
     ]
     mentor_profile_list = StudentProfileDAO.bulk_get_student_profile_by_id(
         mentor_id_list)
     return mentor_profile_list
    def get(self):
        """Handles GET requests."""
        user = self.personalize_page_and_get_user()
        if user is None:
            student = TRANSIENT_STUDENT
        else:
            student = Student.get_enrolled_student_by_email(user.email())
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            self.template_value["has_global_profile"] = profile is not None
            if not student:
                student = TRANSIENT_STUDENT

        if student.is_transient and not self.app_context.get_environ()["course"]["browsable"]:
            self.redirect("/preview")
            return

        self.template_value["units"] = self.get_units()
        self.template_value["show_registration_page"] = True

        if student and not student.is_transient:
            self.augment_assessment_units(student)
        elif user:
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            additional_registration_fields = self.app_context.get_environ()["reg_form"][
                "additional_registration_fields"
            ]
            if profile is not None and not additional_registration_fields:
                self.template_value["show_registration_page"] = False
                self.template_value["register_xsrf_token"] = XsrfTokenManager.create_xsrf_token("register-post")

        self.template_value["transient_student"] = student.is_transient
        self.template_value["progress"] = self.get_progress_tracker().get_unit_progress(student)

        course = self.app_context.get_environ()["course"]
        self.template_value["video_exists"] = bool(
            "main_video" in course and "url" in course["main_video"] and course["main_video"]["url"]
        )
        self.template_value["image_exists"] = bool(
            "main_image" in course and "url" in course["main_image"] and course["main_image"]["url"]
        )

        self.template_value["is_progress_recorded"] = CAN_PERSIST_ACTIVITY_EVENTS.value
        self.template_value["navbar"] = {"course": True}
        self.render("course.html")
Exemple #16
0
    def post(self):
        """Handles POST requests."""
        user = self.personalize_page_and_get_user()
        if not user:
            self.redirect(
                users.create_login_url(self.request.uri), normalize=False)
            return

        if not self.assert_xsrf_token_or_fail(self.request, 'register-post'):
            return

        can_register = self.app_context.get_environ(
            )['reg_form']['can_register']
        if not can_register:
            self.redirect('/course#registration_closed')
            return

        if 'name_from_profile' in self.request.POST.keys():
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            name = profile.nick_name
        else:
            name = self.request.get('form01')

        Student.add_new_student_for_current_user(
            name, transforms.dumps(self.request.POST.items()))

        # CGL-MOOC-Builder: Get user's Google App email and
        # course title, email body from course setting page.
        course = self.app_context.get_environ()['course']
        if 'google_app_email' in course:
            sender_email = course['google_app_email']
        else:
            sender_email = ''

        if 'title' in course:
            course_title = course['title']
        else:
            course_title = ''

        if 'email_body' in course and course['email_body'] != '':
            email_body = course['email_body']
        else:
            email_body = "<div style='background-color: #999999; color: #ffffff; padding: 0px 20px 20px 20px; font-family: 'Verdana', sans-serif;'> <div style='width: 500px; margin: 0 auto;'> <p style='background-color: #093359; height: 100px; margin: 0px; padding: 0px;'> <img src='http://cloudmooc.pti.indiana.edu:8080/assets/img/Logo.png'></img> </p> <div style='background-color: #CCC; color: black; padding: 15px;'> <p>Welcome " + name + ",</p> <p>Thank you for enrolling in this.</p> </div> <p style='background-color: #012256; height: 50px; margin: 0px; padding: 0px;'></p></div></div>"

        # CGL-MOOC-Builder starts:
        # Send an notification email after registration
        sender_address = course_title + " <"+sender_email+">"
        user_address = name + " <" + user.email() + ">"
        subject = "Welcome "+name+" to "+course_title
        body = "Welcome!"
        html = email_body
        mail.send_mail(sender_address, user_address, subject, body, html=html)
        # CGL-MOOC-Builder ends

        # Render registration confirmation page
        self.redirect('/course#registration_confirmation')
    def post(self):
        """Handles post requests."""
        if not self.is_valid_xsrf_token(STUDENT_RENAME_GLOBAL_XSRF_TOKEN_ID):
            self.error(403)
            return

        user = self.initialize_page_and_get_user()
        if not user:
            self.redirect('/explorer')
            return

        new_name = self.request.get('name')
        if not (new_name and self._storable_in_string_property(new_name)):
            self.error(400)
            return

        StudentProfileDAO.update(
            user.user_id(), None, nick_name=new_name, profile_only=True)
        self.redirect('/explorer/profile')
    def post(self):
        """Handles post requests."""
        user = self.initialize_page_and_get_user()
        if not user:
            self.error(403)
            return

        if not self.is_valid_xsrf_token(STUDENT_RENAME_GLOBAL_XSRF_TOKEN_ID):
            self.error(403)
            return

        new_name = self.request.get('name')
        if not (new_name and self._storable_in_string_property(new_name)):
            self.error(400)
            return

        StudentProfileDAO.update(
            user.user_id(), None, nick_name=new_name, profile_only=True)
        self.redirect('/explorer/profile')
Exemple #19
0
 def get_mentors_for_local_chapter(cls, local_chapter_id, ignore_ids=None):
     mentor_list = Mentor.query(
         cls.local_chapter == True,
         cls.college_id == local_chapter_id).fetch(None)
     mentor_id_list = [
         mentor.user_id for mentor in mentor_list
         if mentor.user_id not in ignore_ids
     ]
     mentor_profile_list = StudentProfileDAO.bulk_get_student_profile_by_id(
         mentor_id_list)
     return mentor_profile_list
Exemple #20
0
    def get(self):
        """Handles GET requests."""
        user = self.personalize_page_and_get_user()
        if user is None:
            student = TRANSIENT_STUDENT
        else:
            student = Student.get_enrolled_student_by_email(user.email())
            if not student:
                student = TRANSIENT_STUDENT

        # If the course is browsable, or the student is logged in and
        # registered, redirect to the main course page.
        if ((student and not student.is_transient) or
            self.app_context.get_environ()['course']['browsable']):
            self.redirect('/course')
            return
        units = self.get_units()
        self.template_value['transient_student'] = True
        self.template_value['can_register'] = self.app_context.get_environ(
            )['reg_form']['can_register']
        self.template_value['navbar'] = {'course': True}
        self.template_value['units'] = units
        self.template_value['show_registration_page'] = True
        course = self.app_context.get_environ()['course']
        self.template_value['video_exists'] = bool(
            'main_video' in course and
            'url' in course['main_video'] and
            course['main_video']['url'])
        self.template_value['image_exists'] = bool(
            'main_image' in course and
            'url' in course['main_image'] and
            course['main_image']['url'])

        #get all lessons info
        all_lessons = {}
        for u in units:
            if u.type == 'U':
                all_lessons[u.unit_id] = get_all_lesson(self, u.unit_id)

        self.template_value['all_lessons'] = all_lessons

        if user:
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            additional_registration_fields = self.app_context.get_environ(
                )['reg_form']['additional_registration_fields']
            if profile is not None and not additional_registration_fields:
                self.template_value['show_registration_page'] = False
                self.template_value['register_xsrf_token'] = (
                    XsrfTokenManager.create_xsrf_token('register-post'))
        self.render('preview.html')
Exemple #21
0
    def get(self):
        """Handles GET requests."""
        user = self.initialize_page_and_get_user()
        courses = self.get_public_courses()
        self.template_values['student'] = (
            StudentProfileDAO.get_profile_by_user_id(user.user_id()))
        self.template_values['navbar'] = {'profile': True}
        self.template_values['courses'] = self.get_enrolled_courses(courses)
        self.template_values['student_edit_xsrf_token'] = (
            XsrfTokenManager.create_xsrf_token(
                STUDENT_RENAME_GLOBAL_XSRF_TOKEN_ID))

        template = jinja_utils.get_template(
            '/modules/course_explorer/views/profile.html', DIR, LOCALE)
        self.response.write(template.render(self.template_values))
Exemple #22
0
    def get(self):
        """Handles GET requests."""
        user = self.initialize_page_and_get_user()
        courses = self.get_public_courses()
        self.template_values['student'] = (
            StudentProfileDAO.get_profile_by_user_id(user.user_id()))
        self.template_values['navbar'] = {'profile': True}
        self.template_values['courses'] = self.get_enrolled_courses(courses)
        self.template_values['student_edit_xsrf_token'] = (
            XsrfTokenManager.create_xsrf_token(
                STUDENT_RENAME_GLOBAL_XSRF_TOKEN_ID))

        template = jinja_utils.get_template(
            '/modules/course_explorer/views/profile.html', DIR, LOCALE)
        self.response.write(template.render(self.template_values))
Exemple #23
0
    def post(self):
        """Handles POST requests."""
        user = self.personalize_page_and_get_user()
        if not user:
            self.redirect(users.create_login_url(self.request.uri),
                          normalize=False)
            return

        if not self.assert_xsrf_token_or_fail(self.request, 'register-post'):
            return

        can_register = self.app_context.get_environ(
        )['reg_form']['can_register']
        if not can_register:
            self.redirect('/course#registration_closed')
            return

        if 'name_from_profile' in self.request.POST.keys():
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            name = profile.nick_name
        else:
            name = self.request.get('form01')
        age = self.request.get('age')  #Age
        city = self.request.get('city')  #City
        state = self.request.get('state')  #State
        country = self.request.get('country')  #Country
        education = self.request.get('education')  #Education
        profession = self.request.get('profession')  #Profession
        organization = self.request.get('organization')  #Organization
        motivation = self.request.get('motivation')  #Motivation
        referral = self.request.get('referral')  #Referral
        privacy = self.request.get('privacy')  #Privacy

        Student.add_new_student_for_current_user(
            name, age, city, state, country, education, profession,
            organization, motivation, referral, privacy,
            transforms.dumps(self.request.POST.items()))

        # send a notification email
        sender_address = "MOOCbuilder <*****@*****.**>"
        user_address = name + " <" + user.email() + ">"
        subject = "Welcome to the Big Data Applications and Analytics MOOC"
        body = "Dear " + name + ", Example HTML content"
        html = "<div style='background-color: #666666; color: #ffffff; padding: 0px 20px 20px 20px; font-family: 'Verdana', sans-serif;'> <div style='width: 500px; margin: 0 auto;'> <p style='background-color: #012256; height: 100px; margin: 0px; padding: 0px;'><img src='http://cloudmooc.pti.indiana.edu:8080/assets/img/Logo.png'></img></p> <div style='background-color: #CCC; color: black; padding: 15px;'> <p>Welcome " + name + ",</p> <p>Thank you for enrolling in <a href='https://bigdatacourse.appspot.com' title='Big Data Applications and Analytics MOOC' target='_blank' style='color: #003366; '>Big Data Applications and Analytics MOOC</a>. This MOOC will take you on a journey to learn great things about Big Data and its case studies.</p> <p>This course is open for everyone, so watch a unit or two whenever you get time. You can also review homework assignments of your peers and view your feedback!</p><p>You can download the entire <a href='http://tinyurl.com/bigdatasyllabus' title='Big Data MOOC Course Syllabus' target='_blank'>syllabus</a>, <a href='https://www.dropbox.com/s/2p2zj9jbywcb76u/Course_Slides.pdf' title='Big Data MOOC Course Slides' target='_blank'>slides</a>, and the entire <a href='https://www.dropbox.com/s/htvr0l9d6g2gl71/Big_Data_Course_Material.zip' title='Big Data MOOC Course Material Zip File' target='_blank'>course material</a> directly.</p><p>Get Ready!<br> Geoffrey Fox and the Big Data MOOC Team</p> <p>Go to the <a href='https://bigdatacourse.appspot.com' title='Big Data Applications and Analytics MOOC' target='_blank' style='color: #003366;'>Course</a></p> <p>Share this MOOC with your friends!</p> </div> <p style='background-color: #012256; height: 50px; margin: 0px; padding: 0px;'></p> </div> </div>"
        mail.send_mail(sender_address, user_address, subject, body, html=html)

        # Render registration confirmation page
        self.redirect('/course#registration_confirmation')
Exemple #24
0
    def get(self):
        """Handles GET requests."""
        user = self.personalize_page_and_get_user()
        if user is None:
            student = TRANSIENT_STUDENT
        else:
            student = Student.get_enrolled_student_by_email(user.email())
            if not student:
                student = TRANSIENT_STUDENT

        # If the course is browsable, or the student is logged in and
        # registered, redirect to the main course page.
        if ((student and not student.is_transient)
                or self.app_context.get_environ()['course']['browsable']):
            self.redirect('/course')
            return
        units = self.get_units()
        self.template_value['transient_student'] = True
        self.template_value['can_register'] = self.app_context.get_environ(
        )['reg_form']['can_register']
        self.template_value['navbar'] = {'course': True}
        self.template_value['units'] = units
        self.template_value['show_registration_page'] = True
        course = self.app_context.get_environ()['course']
        self.template_value['video_exists'] = bool(
            'main_video' in course and 'url' in course['main_video']
            and course['main_video']['url'])
        self.template_value['image_exists'] = bool(
            'main_image' in course and 'url' in course['main_image']
            and course['main_image']['url'])

        #get all lessons info
        all_lessons = {}
        for u in units:
            if u.type == 'U':
                all_lessons[u.unit_id] = get_all_lesson(self, u.unit_id)

        self.template_value['all_lessons'] = all_lessons

        if user:
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            additional_registration_fields = self.app_context.get_environ(
            )['reg_form']['additional_registration_fields']
            if profile is not None and not additional_registration_fields:
                self.template_value['show_registration_page'] = False
                self.template_value['register_xsrf_token'] = (
                    XsrfTokenManager.create_xsrf_token('register-post'))
        self.render('preview.html')
Exemple #25
0
    def post(self):
        """Handles POST requests."""
        user = self.personalize_page_and_get_user()
        if not user:
            self.redirect(
                users.create_login_url(self.request.uri), normalize=False)
            return

        if not self.assert_xsrf_token_or_fail(self.request, 'register-post'):
            return

        can_register = self.app_context.get_environ(
            )['reg_form']['can_register']
        if not can_register:
            self.redirect('/course#registration_closed')
            return

        if 'name_from_profile' in self.request.POST.keys():
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            name = profile.nick_name
        else:
            name = self.request.get('form01')
        age = self.request.get('age')                   #Age
        city = self.request.get('city')                 #City
        state = self.request.get('state')               #State
        country = self.request.get('country')           #Country
        education = self.request.get('education')       #Education
        profession = self.request.get('profession')     #Profession
        organization = self.request.get('organization') #Organization
        motivation = self.request.get('motivation')     #Motivation
        privacy = self.request.get('privacy')           #Privacy
        reference = self.request.get('reference')       #Reference

        Student.add_new_student_for_current_user(
            name, age, city, state, country, education, profession, organization, motivation, privacy, reference, transforms.dumps(self.request.POST.items()))

        # send a notification email
        sender_address = "X-Informatics <*****@*****.**>"
        user_address = name + " <" + user.email() + ">"
        subject = "Welcome to the Big Data Applications and Analytics MOOC"
        body = "Dear " + name + ", Example HTML content"
        html = "<div style='background-color: #999999; color: #ffffff; padding: 0px 20px 20px 20px; font-family: 'Verdana', sans-serif;'> <div style='width: 500px; margin: 0 auto;'> <p style='background-color: #093359; height: 100px; margin: 0px; padding: 0px;'> <img src='http://cloudmooc.pti.indiana.edu:8080/assets/img/Logo.png'></img> </p> <div style='background-color: #CCC; color: black; padding: 15px;'> <p>Welcome " + name + ",</p> <p>Thank you for enrolling in <a href='https://bigdatacourse.appspot.com' title='Big Data Applications and Analytics MOOC' target='_blank' style='color: #003366; '>Big Data Applications and Analytics MOOC</a>. This MOOC will take you on a journey to learn great things about Big Data and its case studies.</p> <p>This course is open for everyone, so watch a unit or two whenever you get time. You can also review homework assignments of your peers and view your feedback!</p><p>You can download the entire <a href='http://tinyurl.com/bigdatasyllabus' title='Big Data MOOC Course Syllabus' target='_blank'>syllabus</a>, <a href='https://www.dropbox.com/s/2p2zj9jbywcb76u/Course_Slides.pdf' title='Big Data MOOC Course Slides' target='_blank'>slides</a>, and the entire <a href='https://www.dropbox.com/s/htvr0l9d6g2gl71/Big_Data_Course_Material.zip' title='Big Data MOOC Course Material Zip File' target='_blank'>course material</a> directly.</p><p>Get Ready!<br> Geoffrey Fox and the Big Data MOOC Team</p> <p>Go to the <a href='https://bigdatacourse.appspot.com' title='Big Data Applications and Analytics MOOC' target='_blank' style='color: #093359;'>Course</a></p> <p>Share this MOOC with your friends!</p> </div> <p style='background-color: #012256; height: 50px; margin: 0px; padding: 0px;'></p></div></div>"
        mail.send_mail(sender_address, user_address, subject, body, html=html)

        # Render registration confirmation page
        self.redirect('/course#registration_confirmation')
Exemple #26
0
    def initialize_student_state(self):
        """Initialize course information related to student."""
        PageInitializerService.get().initialize(self.template_values)
        self.enrolled_courses_dict = {}
        self.courses_progress_dict = {}
        user = users.get_current_user()
        if not user:
            return

        profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
        if not profile:
            return

        self.template_values['register_xsrf_token'] = (
            XsrfTokenManager.create_xsrf_token('register-post'))

        self.enrolled_courses_dict = transforms.loads(profile.enrollment_info)
        if self.enrolled_courses_dict:
            self.template_values['has_enrolled_courses'] = True

        if profile.course_info:
            self.courses_progress_dict = transforms.loads(profile.course_info)
    def initialize_student_state(self):
        """Initialize course information related to student."""
        PageInitializerService.get().initialize(self.template_values)
        self.enrolled_courses_dict = {}
        self.courses_progress_dict = {}
        user = users.get_current_user()
        if not user:
            return

        profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
        if not profile:
            return

        self.template_values['register_xsrf_token'] = (
            XsrfTokenManager.create_xsrf_token('register-post'))

        self.enrolled_courses_dict = transforms.loads(profile.enrollment_info)
        if self.enrolled_courses_dict:
            self.template_values['has_enrolled_courses'] = True

        if profile.course_info:
            self.courses_progress_dict = transforms.loads(profile.course_info)
Exemple #28
0
    def get(self):
        """Handles GET requests."""
        user = self.personalize_page_and_get_user()
        if user is None:
            student = TRANSIENT_STUDENT
        else:
            student = Student.get_enrolled_student_by_email(user.email())
            if not student:
                student = TRANSIENT_STUDENT

        # If the course is browsable, or the student is logged in and
        # registered, redirect to the main course page.
        if (student and not student.is_transient) or self.app_context.get_environ()["course"]["browsable"]:
            self.redirect("/course")
            return

        self.template_value["transient_student"] = True
        self.template_value["can_register"] = self.app_context.get_environ()["reg_form"]["can_register"]
        self.template_value["navbar"] = {"course": True}
        self.template_value["units"] = self.get_units()
        self.template_value["show_registration_page"] = True

        course = self.app_context.get_environ()["course"]
        self.template_value["video_exists"] = bool(
            "main_video" in course and "url" in course["main_video"] and course["main_video"]["url"]
        )
        self.template_value["image_exists"] = bool(
            "main_image" in course and "url" in course["main_image"] and course["main_image"]["url"]
        )

        if user:
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            additional_registration_fields = self.app_context.get_environ()["reg_form"][
                "additional_registration_fields"
            ]
            if profile is not None and not additional_registration_fields:
                self.template_value["show_registration_page"] = False
                self.template_value["register_xsrf_token"] = XsrfTokenManager.create_xsrf_token("register-post")
        self.render("preview.html")
Exemple #29
0
 def _get_mentor_profile(cls, mentor_id):
     return StudentProfileDAO.get_profile_by_user_id(mentor_id)
Exemple #30
0
 def get_mentor_for_student(cls, student_id):
     mentor = cls._get_mentor_for_student(student_id)
     if mentor:
         return StudentProfileDAO.get_profile_by_user_id(mentor.user_id)
     return None
Exemple #31
0
    def get(self):
        """Handles GET requests."""
        user = self.personalize_page_and_get_user()
        if user is None:
            student = TRANSIENT_STUDENT
        else:
            student = Student.get_enrolled_student_by_email(user.email())
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            self.template_value['has_global_profile'] = profile is not None
            if not student:
                student = TRANSIENT_STUDENT

        if (student.is_transient and
            not self.app_context.get_environ()['course']['browsable']):
            self.redirect('/preview')
            return
        # CGL-MOOC-Builder:
        self.template_value['units'] = self.get_units()
        self.template_value['sorted_units'] = self.get_units_groupby_section()
        self.template_value['show_registration_page'] = True

        if student and not student.is_transient:
            self.augment_assessment_units(student)
        elif user:
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            additional_registration_fields = self.app_context.get_environ(
                )['reg_form']['additional_registration_fields']
            if profile is not None and not additional_registration_fields:
                self.template_value['show_registration_page'] = False
                self.template_value['register_xsrf_token'] = (
                    XsrfTokenManager.create_xsrf_token('register-post'))

        self.template_value['transient_student'] = student.is_transient
        self.template_value['progress'] = (
            self.get_progress_tracker().get_unit_progress(student))

        course = self.app_context.get_environ()['course']
        self.template_value['video_exists'] = bool(
            'main_video' in course and
            'url' in course['main_video'] and
            course['main_video']['url'])
        self.template_value['image_exists'] = bool(
            'main_image' in course and
            'url' in course['main_image'] and
            course['main_image']['url'])

        # CGL-MOOC-Builder: Set template values for instructor_details and main_video
        if 'instructor_details' in course:
            self.template_value['instructor_details'] = course['instructor_details']
        else:
            self.template_value['instructor_details'] = ''

        if self.template_value['video_exists']:
            self.template_value['main_video'] = course['main_video']['url']
        else: 
            self.template_value['main_video'] = ''

        # CGL-MOOC-Builder: Set template value for instructor image and alt text.
        self.set_instructor_image_and_alt()

        # CGL-MOOC-Builder: Set template value for Google Community ID
        self.set_google_community_template_value()

        self.template_value['is_progress_recorded'] = (
            CAN_PERSIST_ACTIVITY_EVENTS.value)
        self.template_value['navbar'] = {'course': True}

        # CGL-MOOC-Builder starts:
        # Set template value for students progress bar that shows on the top navigation(header.html)
        total_progress = (self.get_progress_tracker().get_overall_progress_score(student))
        self.template_value['progress_value'] = total_progress.get('progress_score', 0)
        self.template_value['complete_value'] = total_progress.get('completed_score', 0)
        self.template_value['percentage'] = total_progress.get('percentage', '')
        # Set template value for all lesson information in course_structure.html
        all_lessons = {}
        for u in self.template_value['units']:
            if u.type == 'U':
                all_lessons[u.unit_id] = get_all_lesson(self, u.unit_id)
        self.template_value['all_lessons'] = all_lessons
        # CGL-MOOC-Builder ends

        self.render('home.html')
Exemple #32
0
    def post(self):
        """Handles POST requests."""
        user = self.personalize_page_and_get_user()
        if not user:
            self.redirect(
                users.create_login_url(self.request.uri), normalize=False)
            return

        if not self.assert_xsrf_token_or_fail(self.request, 'register-post'):
            return

        can_register = self.app_context.get_environ(
            )['reg_form']['can_register']
        if not can_register:
            self.redirect('/course#registration_closed')
            return

        if 'name_from_profile' in self.request.POST.keys():
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            name = profile.nick_name
        else:
            name = self.request.get('form01')
        age = self.request.get('age')                   #Age
        city = self.request.get('city')                 #City
        state = self.request.get('state')               #State
        country = self.request.get('country')           #Country
        education = self.request.get('education')       #Education
        profession = self.request.get('profession')     #Profession
        organization = self.request.get('organization') #Organization
        motivation = self.request.get('motivation')     #Motivation
        privacy = self.request.get('privacy')           #Privacy

        Student.add_new_student_for_current_user(
            name, age, city, state, country, education, profession, organization, motivation, privacy, transforms.dumps(self.request.POST.items()))

        sender_address = "X-Informatics <*****@*****.**>"
        user_address = name + " <" + user.email() + ">"
        subject = "Welcome to X-Informatics"
        body = "Dear " + name + ", Example HTML content"
        html = "<p>Dear " + name + ",</p><p>Example HTML content</p>"
        mail.send_mail(sender_address, user_address, subject, body, html=html)
        # send a confirmation email
        #mandrill_key = "mfU0WroOFAer1a6iN3XfgQ"
        #mandrill_url = "https://mandrillapp.com/api/1.0/messages/send.json"
        #my_payload = {
        #    "key": mandrill_key,
        #    "message": {
        #        "html": "<p>Dear "+name+",</p><p>Example HTML content</p>",
        #        "subject": "testing email using Mandrill",
        #        "from_email": "*****@*****.**",
        #        "from_name": "X-Informatics",
        #        "to": [
        #            {
        #                "email": user.email(),
        #            }
        #        ]
        #    }
        #}
        #content = urlfetch.fetch(mandrill_url, method=urlfetch.POST, headers={'Content-Type': 'application/json'}, payload=json.dumps(my_payload))

        # Render registration confirmation page
        self.redirect('/course#registration_confirmation')
Exemple #33
0
    def get(self):
        """Handles GET requests."""
        user = self.personalize_page_and_get_user()
        if user is None:
            student = TRANSIENT_STUDENT
        else:
            student = Student.get_enrolled_student_by_email(user.email())
            if not student:
                student = TRANSIENT_STUDENT

        # If the course is browsable, or the student is logged in and
        # registered, redirect to the main course page.
        if ((student and not student.is_transient) or
            self.app_context.get_environ()['course']['browsable']):
            self.redirect('/course')
            return

        self.template_value['transient_student'] = True
        self.template_value['can_register'] = self.app_context.get_environ(
            )['reg_form']['can_register']
        self.template_value['navbar'] = {'course': True}
        self.template_value['units'] = sorted(self.get_units(), key = lambda x: int(x.section_id or 999))
        self.template_value['show_registration_page'] = True

        course = self.app_context.get_environ()['course']
        self.template_value['video_exists'] = bool(
            'main_video' in course and
            'url' in course['main_video'] and
            course['main_video']['url'])
        self.template_value['image_exists'] = bool(
            'main_image' in course and
            'url' in course['main_image'] and
            course['main_image']['url'])


        # CGL-MOOC-Builder starts:
        # Set template values for instructor_details, main_video and
        # Google Community ID.
        if 'instructor_details' in course:
            self.template_value['instructor_details'] = course['instructor_details']
        else:
            self.template_value['instructor_details'] = ''

        if self.template_value['video_exists']:
            self.template_value['main_video'] = course['main_video']['url']
        else:
            self.template_value['main_video'] = ''

        # Set template value for instructor image and alt text
        self.set_instructor_image_and_alt()

        # Set template value for Google Community ID
        self.set_google_community_template_value()

        #if 'google_community_id' in course:
        #    self.template_value['google_community_id'] = course['google_community_id']
        #else:
        #    self.template_value['google_communit_id'] = ''
        # CGL-MOOC-Builder ends

        # CGL-MOOC-Builder starts:
        # Set template value for all lessons in course_structure_preview.html
        all_lessons = {}
        for u in self.template_value['units']:
            if u.type == 'U':
                all_lessons[u.unit_id] = self.get_all_lesson(u.unit_id)
        self.template_value['all_lessons'] = all_lessons
        # CGL-MOOC-Builder ends

        if user:
            profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
            additional_registration_fields = self.app_context.get_environ(
                )['reg_form']['additional_registration_fields']
            if profile is not None and not additional_registration_fields:
                self.template_value['show_registration_page'] = False
                self.template_value['register_xsrf_token'] = (
                    XsrfTokenManager.create_xsrf_token('register-post'))
        self.render('preview.html')