def post(self):
        from model import StudentActivity
        from updates import send_update_query

        self.load_search_party_context(user_type="student")

        if self.is_student and self.person.is_logged_in:
            student = self.person
            lesson = student.lesson
            teacher = lesson.teacher
            task_idx = int(self.request.get("task_idx", 0))
            query = self.request.get("query")
            url = self.request.get("url", default_value=None)
            ext = int(self.request.get("ext", 0))
            activity = StudentActivity(
                student=student, lesson=lesson, task_idx=task_idx, activity_type="search", search=query, link=url
            )
            activity.put()

            notifyStudent = ext == 1
            send_update_query(
                student=student, teacher=teacher, task_idx=task_idx, query=query, notifyStudent=notifyStudent
            )
            response_data = {"status": 1}

        else:
            response_data = {"status": 0, "msg": "Student not logged in"}

        import json

        self.response.headers.add_header("Content-Type", "application/json", charset="utf-8")
        self.response.out.write(json.dumps(response_data))
    def post(self):
        from helpers import log
        from updates import send_update_answer
        from model import StudentActivity

        self.load_search_party_context(user_type="student")
        
        if self.is_student and self.person.is_logged_in:
            student = self.person 
            lesson = student.lesson
            teacher = lesson.teacher
            task_idx = int(self.request.get("task_idx", 0))
            answer_text = self.request.get("answer_text")
            answer_explanation = self.request.get("answer_explanation")
            ext = int(self.request.get("ext", 0))

            activity = StudentActivity(
                student=student,
                lesson=lesson,
                task_idx=task_idx,
                activity_type=StudentActivity.ACTIVITY_TYPE_ANSWER,
                answer_text=answer_text,
                answer_explanation=answer_explanation
            )
            activity.put()
            
            log( "AnswerHandler:  task_idx=%r,  answer=%r, explanation=%r"%(task_idx, answer_text, answer_explanation) )
            notifyStudent = ext==1
            send_update_answer(student=student, teacher=teacher, task_idx=task_idx,
                answer_text=answer_text, answer_explanation=answer_explanation, notifyStudent=notifyStudent)
            response_data = activity.toDict();
            response_data['status'] = 1;
            
        else:
            response_data = { "status":0, "msg":"Student not logged in" }
         
        import json
        self.response.headers.add_header('Content-Type', 'application/json', charset='utf-8')
        self.response.out.write(json.dumps(response_data))
    def post(self):
        from model import StudentActivity, Student
        from updates import send_update_link_followed

        self.load_search_party_context(user_type="student")
        
        if self.is_student and self.person.is_logged_in:
            student = self.person 
            teacher = student.teacher
            task_idx = int(self.request.get("task_idx", 0))
            query = self.request.get("query")
            url = self.request.get("url")
            lesson_key = Student.lesson.get_value_for_datastore(student)
            title = self.request.get("title")
            ext = int(self.request.get("ext", 0))
            link = StudentActivity(
                student = student,
                lesson = lesson_key,
                task_idx = task_idx,
                activity_type = StudentActivity.ACTIVITY_TYPE_LINK,
                search = query,
                link = url,
                link_title = title
            )
            link.put()

            notifyStudent = ext==1
            send_update_link_followed(student=student, teacher=teacher, task_idx=task_idx, query=query, url=url, title=title, notifyStudent=notifyStudent)
            response_data = link.toDict();
            response_data['status'] = 1;
            
        else:
            response_data = { "status":0, "msg":"Student not logged in" }
         
        import json
        self.response.headers.add_header('Content-Type', 'application/json', charset='utf-8')
        self.response.out.write(json.dumps(response_data))
    def post(self):
        from model import StudentActivity, Student
        from updates import send_update_link_rated

        self.load_search_party_context(user_type="student")
        
        if self.is_student and self.person.is_logged_in:
            student = self.person
            teacher = student.teacher
            task_idx = int(self.request.get("task_idx", 0))
            url = self.request.get('url')
            title = self.request.get('title', None)
            lesson_key = Student.lesson.get_value_for_datastore(student)
            is_helpful = {"1":True, "0":False, None:None}[self.request.get("is_helpful")]
            ext = int(self.request.get("ext", 0))
            link = StudentActivity(
                student = student,
                lesson = lesson_key,
                task_idx = task_idx,
                activity_type = StudentActivity.ACTIVITY_TYPE_LINK_RATING,
                link = url,
                link_title = title,
                is_helpful = is_helpful
            )
            link.put()

            notifyStudent = ext==1
            send_update_link_rated(student=student, teacher=teacher, task_idx=task_idx, url=url, is_helpful=is_helpful, notifyStudent=notifyStudent)            
            response_data = link.toDict();
            response_data['status'] = 1;
            
        else:
            response_data = { "status":0, "msg":"Student not logged in" }
         
        import json
        self.response.headers.add_header('Content-Type', 'application/json', charset='utf-8')
        self.response.out.write(json.dumps(response_data))