示例#1
0
文件: Signup.py 项目: IssVader/TIPOO
 def post(self):
     user=self.get_user_type()
     errors={}        
     if user == user_type.visitor:            
         #email=escape(self.request.get('email',None))  
         email=self.request.get('email',None)
         email.lower()            
         email.strip()                      
         #pwd=input_field().encrypt_password(escape(self.request.get('pwd',None)))
         pwd=input_field().encrypt_password(self.request.get('pwd',None))
         pwd.lower()
         pwd.strip()                    
         #first = escape(self.request.get('user',None))
         first = self.request.get('user',None)            
         
         if student_management().add_basic_info(first,email, pwd):
             #email_confirmation().send_mail(email)
             self.session['success'] = '<h2>Registro exitoso bienvenido a TIPOO</h2>'
             self.redirect('/login#signup')
         else:                
             self.session['error3'] = '<span>El usuario registrado ya existe en el sistema</span>'
             self.redirect('/login#signup')
         return 0
          
     elif user == user_type.student:
         self.redirect('/')
         return 1
     
     elif user == user_type.tutor:
         self.redirect('/')
         return 2
     
     else:
         return 3
示例#2
0
	def post(self):	           
		user = self.get_user_type()                    
		if user == user_type.visitor: 
			self.redirect('/')                              
			return 0
		elif user == user_type.student:			
			user_id = self.session["user-id"]
			user_instance = student_management().find_key(user_id)							
			date_1 = self.request.get('date_1',None)
			date_2 = self.request.get('date_2',None)		
			event = self.request.get('event',None)
			content_url = self.request.get('content_url',None)
			information = self.request.get('information',None)
			site_url = self.request.get('site_url',None)
			
			if date_1 and date_2:
				list_sites_url = student_records_management().get_all_sites()
				list_events = student_records_management().get_all_events()
				list_events_site = student_records_management().get_average_student_records_site_url(user_instance.key())
				count_events = 0
				html=''										
				date_1 = str(date_1)
				date_2 = str(date_2)
				for site_url in list_sites_url:
					c=0
					if site_url == '/view_video' or site_url == '/explorer' or site_url == '/tracker':
						pass
					else:
						html+='<br /><hr /><span>'+site_url+'</span>'
						for i in range(len(list_events)):						
							html+='<br />Evento: '+str(list_events[i])
							#count_events = student_records_management().count_events(list_events[i],site_url)
							count_events = student_records_management().count_events_between_dates(date_1,date_2,list_events[i],site_url,user_instance.key())
							html+=', '+str(count_events)+' veces'
						c+=1
				#html+='</div><div>'	
				html+='<br /><hr /><span>Urls</span>'			
				list_content_urls = student_records_management().get_all_content_urls()
				for content_url in list_content_urls:
					if content_url:
						if str(content_url).find('view_video') >= 0:
							html+='<br />Url visitada: '+str(content_url)
							count_url = student_records_management().count_content_urls_between_dates(date_1,date_2,content_url,user_instance.key())
							html+=', '+str(count_url)+' veces'
				#html+='</div>'
				m = student_records_management().get_average_student_records(date_1,date_2,user_instance.key())				
				
				self.response.write(html)
			elif event and site_url:
				html=''
				user_id = int(self.session['user-id'])
				student_records_management().add(user_id,site_url,event,content_url,information)
			return 1
		elif user == user_type.tutor:			
			self.redirect('/home')
			return 2
		else:
			self.redirect('/home')	
		return 3
示例#3
0
 def find_user(self, user_email):
     login_user_type = [
         student_management().find_email(user_email),
         tutor_management().find_email(user_email),
         admin_management().find_email(user_email)
     ]
     for user_data in login_user_type:
         if user_data is not None:
             return user_data
示例#4
0
 def new_user_type(self, user_email):
     login_user_type = [
         student_management().find_email(user_email),
         tutor_management().find_email(user_email),
         admin_management().find_email(user_email)
     ]
     for index, user_data in enumerate(login_user_type):
         if user_data is not None:
             return user_type.Value[index + 1]
示例#5
0
文件: Exam.py 项目: IssVader/TIPOO
    def post(self):
        user = self.get_user_type()     
        if user == user_type.visitor:
            self.response.write('0')
            self.redirect('/')
            return 0
        elif user == user_type.student:
            
            exam_id = int(self.request.get('exam_id',None))
            exam_instance = exam_management().find_exam(exam_id)            
            list_answers = []           
            number_questions = len(exam_instance.questions)
            for i in range(number_questions):
                list_answers.append( int(self.request.get('r['+ str(i) +']')))
            time_init = self.request.get('time_init',None)
            
            

            time_end = dt.datetime.utcnow()
            time = elapsed_time().elapsed_time(time_init,time_end)
            
            session = self.get_user_id()
            student = student_management().find_key(session)            
            test_id = test_management().add(time.time(),student.key(),exam_instance.key(),list_answers)
            test_id = int(test_id.id())
            test = test_management().find_test(test_id)
            feedback_message = test_evaluation().feedback_message(test_id)
            #self.response.write(feedback_message)          
            test_score = test_evaluation().test_score(test_id)
            #self.response.write(test_score)
            count_correct_answers = test_evaluation().count_correct_answers(test_id)
            #self.response.write(count_correct_answers)
            count_questions = test_evaluation().count_question(test_id)
            #self.response.write(count_questions)
            if feedback_message != feedback_msg.insuficient:
                test.approved = True
                test.put()
                                                
            template_values = {
                "user":"******",
                "feedback_message":feedback_message,
                "test_score":test_score,
                "count_correct_answers":count_correct_answers,
                "count_questions":count_questions,
                
            }
            self.response.write(finished_template.render(template_values))
            return 1
        elif user == user_type.tutor:                               
            self.redirect('/home')             
            return 2
            
        else:
            
            self.redirect('/home')
            return 3
示例#6
0
    def post(self):
        user = self.get_user_type()
        if user == user_type.visitor:
            self.response.write('0')
            self.redirect('/')
            return 0
        elif user == user_type.student:

            exam_id = int(self.request.get('exam_id', None))
            exam_instance = exam_management().find_exam(exam_id)
            list_answers = []
            number_questions = len(exam_instance.questions)
            for i in range(number_questions):
                list_answers.append(int(self.request.get('r[' + str(i) + ']')))
            time_init = self.request.get('time_init', None)

            time_end = dt.datetime.utcnow()
            time = elapsed_time().elapsed_time(time_init, time_end)

            session = self.get_user_id()
            student = student_management().find_key(session)
            test_id = test_management().add(time.time(), student.key(),
                                            exam_instance.key(), list_answers)
            test_id = int(test_id.id())
            test = test_management().find_test(test_id)
            feedback_message = test_evaluation().feedback_message(test_id)
            #self.response.write(feedback_message)
            test_score = test_evaluation().test_score(test_id)
            #self.response.write(test_score)
            count_correct_answers = test_evaluation().count_correct_answers(
                test_id)
            #self.response.write(count_correct_answers)
            count_questions = test_evaluation().count_question(test_id)
            #self.response.write(count_questions)
            if feedback_message != feedback_msg.insuficient:
                test.approved = True
                test.put()

            template_values = {
                "user": "******",
                "feedback_message": feedback_message,
                "test_score": test_score,
                "count_correct_answers": count_correct_answers,
                "count_questions": count_questions,
            }
            self.response.write(finished_template.render(template_values))
            return 1
        elif user == user_type.tutor:
            self.redirect('/home')
            return 2

        else:

            self.redirect('/home')
            return 3
示例#7
0
    def get(self):
        user = self.get_user_type()                    
        if user == user_type.visitor:                    
            self.redirect('/')
            return 0
        elif user == user_type.student:
            '''
            user_id=self.get_user_id()
            self.response.write(user_id)
            self.response.write('<br>')
            '''
            
            s = session()
            student_id = self.session['user-id']
            user = student_management().get_student(student_id)
            
            
            s.user = user
            s.time_init = self.session['user-time']
            s.time_end = time.time()
            s.time_conected = s.time_end - self.session['user-time'] 
            s.put()
            
            
            user_session().close(self.session)
            
            '''
            #self.response.write(logout)
            #if str(user_id) == str(logout):
            #for s in self.session.keys():
            #    self.session[s]=None
                #self.response.write(self.session[s])
                #self.response.write('<br/>')
            #self.session['user']=None
            #self.session['user-id']=None
            '''
            
            self.redirect('/')


            return 1

        elif user == user_type.tutor:

            user_session().close(self.session)
    
            self.redirect('/')

            return 2        
示例#8
0
	def get(self):
		user = self.get_user_type()                    
		if user == user_type.visitor: 
			self.redirect('/')                   
			return 0
		elif user == user_type.student: 
			user_id = self.session["user-id"]
			user_instance = student_management().find_key(int(user_id))
								
			list_sites_url = student_records_management().get_all_sites()
			list_events = student_records_management().get_all_events()
			
			list_events_site = student_records_management().get_average_student_records_site_url(user_instance.key())
			
			count_events = 0			
			html = ''			
			html+= '<div id="tracker"><div id="content">'
			for site_url in list_sites_url:
				c=0
				if site_url == '/view_video' or site_url == '/explorer' or site_url == '/tracker':
					pass
				else:
					html+='<br /><hr /><span>'+site_url+'</span>'
					for i in range(len(list_events)):
						html+='<br />Evento: '+str(list_events[i])
						count_events = student_records_management().count_events(list_events[i],site_url,user_instance.key())
						html+=', '+str(count_events)+' veces'
					c+=1		
			html+='<br /><hr /><span>Urls</span>'		
								
			list_content_urls = student_records_management().get_all_content_urls()
			for content_url in list_content_urls:
				if content_url:
					if str(content_url).find('view_video') >= 0:
						html+='<br />Url visitada: '+str(content_url)
						count_url = student_records_management().count_content_urls(content_url,user_instance.key())
						html+=', '+str(count_url)+' veces'
			#html+='</div>'			
			template_values = {
				"html":html,
				"user":"******",					
				"student_name":user_instance.first
			}				
			self.response.write(tracker_template.render(template_values))
			#'''
		elif user == user_type.tutor:
			self.redirect('/home')
		else:
			self.redirect('/home')
示例#9
0
    def get(self):
        user = self.get_user_type()
        if user == user_type.visitor:
            self.redirect('/')
            return 0
        elif user == user_type.student:
            self.redirect('/')
            return 1
        elif user == user_type.tutor:
            template_values = {}
            list_data = session().get_all_sessions()

            data_sessions = {}
            list_data_sessions = []
            for l in list_data:
                student = student_management().get_student(l.user.key().id())
                data_sessions['name'] = student.first
                data_sessions['last'] = student.last
                data_sessions['email'] = student.email
                data_sessions['sex'] = student.sex
                data_sessions['bday'] = student.bday
                data_sessions['learning_style'] = student.learning_style
                data_sessions['time_init'] = datetime.datetime.fromtimestamp(
                    l.time_init).strftime('%Y-%m-%d %H:%M:%S')
                data_sessions['time_end'] = datetime.datetime.fromtimestamp(
                    l.time_end).strftime('%Y-%m-%d %H:%M:%S')
                data_sessions[
                    'time_conected'] = datetime.datetime.fromtimestamp(
                        l.time_conected).strftime('%H:%M:%S')
                data_sessions['number_clicks'] = action(
                ).count_events_between_dates(l.time_init, l.time_end, 'click',
                                             l.user)
                data_sessions['number_scrolls'] = action(
                ).count_events_between_dates(l.time_init, l.time_end, 'scroll',
                                             l.user)
                list_data_sessions.append(data_sessions.copy())

            template_values = {'list_data_sessions': list_data_sessions}
            self.response.write(
                students_records_template.render(template_values))

            return 2
        else:
            return 3
示例#10
0
    def get(self):
        user = self.get_user_type()                    
        if user == user_type.visitor:
        	self.redirect('/')
        	return 0
        elif user == user_type.student:
        	self.redirect('/')
        	return 1
        elif user == user_type.tutor:
            template_values = {}
            list_data = session().get_all_sessions()
            
            data_sessions = {}
            list_data_sessions = []
            for l  in list_data:
                student = student_management().get_student( l.user.key().id() )
                data_sessions['name'] = student.first
                data_sessions['last'] = student.last
                data_sessions['email'] = student.email
                data_sessions['sex'] = student.sex
                data_sessions['bday'] = student.bday
                data_sessions['learning_style'] = student.learning_style
                data_sessions['time_init'] = datetime.datetime.fromtimestamp(l.time_init).strftime('%Y-%m-%d %H:%M:%S')
                data_sessions['time_end'] = datetime.datetime.fromtimestamp(l.time_end).strftime('%Y-%m-%d %H:%M:%S')
                data_sessions['time_conected'] = datetime.datetime.fromtimestamp(l.time_conected).strftime('%H:%M:%S')
                data_sessions['number_clicks'] = action().count_events_between_dates(l.time_init,l.time_end,'click',l.user)
                data_sessions['number_scrolls'] = action().count_events_between_dates(l.time_init,l.time_end,'scroll',l.user)
                list_data_sessions.append(data_sessions.copy())

             
            
            
            template_values = {'list_data_sessions':list_data_sessions}
            self.response.write(students_records_template.render(template_values))
            
            return 2
        else:
        	return 3
示例#11
0
    def post(self):
        user = self.get_user_type()
        errors = {}
        if user == user_type.visitor:
            #email=escape(self.request.get('email',None))
            email = self.request.get('email', None)
            email.lower()
            email.strip()
            #pwd=input_field().encrypt_password(escape(self.request.get('pwd',None)))
            pwd = input_field().encrypt_password(self.request.get('pwd', None))
            pwd.lower()
            pwd.strip()
            #first = escape(self.request.get('user',None))
            first = self.request.get('user', None)

            if student_management().add_basic_info(first, email, pwd):
                #email_confirmation().send_mail(email)
                self.session[
                    'success'] = '<h2>Registro exitoso bienvenido a TIPOO</h2>'
                self.redirect('/login#signup')
            else:
                self.session[
                    'error3'] = '<span>El usuario registrado ya existe en el sistema</span>'
                self.redirect('/login#signup')
            return 0

        elif user == user_type.student:
            self.redirect('/')
            return 1

        elif user == user_type.tutor:
            self.redirect('/')
            return 2

        else:
            return 3
示例#12
0
    def get(self):
        user = self.get_user_type()                    
        if user == user_type.visitor:                    
            self.redirect('/')
            return 0
        elif user == user_type.student:                 
			student_instance = student_management().get_student(int(self.session['user-id']))
			tutor = tutor_management().get_all_tutors()[0]            
			subject = subject_management().get_subject_by_name('Programacion Orientada a Objetos')			
			unit_id = self.request.get('unit_id',None)
			if unit_id:
				unit_id = int(unit_id)
			else:
				##id de 1era unidad
				unit_id = 6348855016685568
			page = self.request.get('page',0)
			try:
				int(page)
				page = int(page)-1
			except ValueError:
				page = 0
			if page < 1:
				page = 0
			unit = unit_management().get_unit(unit_id)
			list_list_text_info = []            
			countent = {}
			list_counter = []   
			list_content = []
			listi = []
			list_all_videos = video_material_management().get_all_unit_available_videos(unit.key().id())
			for t in student_instance.tutors_list:
				listi.extend(video_material_management().get_all_videos_material(t,subject.key(),page))       
			self.list_list_vm = video_material_management().get_list_video_material_of_subject(tutor.key(),page)                        
			list_vm = video_material_management().get_unit_available_videos(unit.key().id(),page)     
			
			c=0
			list_videos = []
			total_text = 0
			if list_vm:
				for index in range(len(list_vm)):
					vm = list_vm[index]
					video_instance = video_material_management().get_video(vm)
					vinfo = {}        
					vinfo['id'] = vm.key().id()          
					vinfo['able'] = vm.available
					vinfo['tutor'] = (tutor_management().get_tutor(vm.tutor.key().id())).first
					vinfo['topic'] = (topic_management().get_topic(vm.topic.key().id())).name                    
					vinfo['content'] = video_instance.content                    
					vinfo['number_views'] = video_instance.number_views
					list_videos.append(vinfo)
					index = index + 1

			pages = int(ceil(len(list_all_videos)/10.))
			if pages < 1:
				pages = 1
			list_page = [None] * pages              
			
			html = ''
			template_values={
				"user":"******",
				"header_welcome":"",
				"header_tutor":"",
                "total_pages":len(list_page),
                "current_page":(page+1),
				"list_videos": list_videos,
				"unit_id": unit_id,                
				"pages":list_page,
				"Titulo":"Gestion de Videos",
				"counter":list_counter,
				"html":html,
				"subject":subject.name,
				"student_name": student_instance.first
			}  
			                  
			self.response.write(admin_video_template.render(template_values))  
        	
			return 1

        elif user == user_type.tutor:                                    
			list_list_texts = []
			tutor_id = self.session['user-id']
			tutor_key = tutor_management().get_tutor(tutor_id).key()
			tutor_instance = tutor_management().get_tutor(tutor_id)
			subject = subject_management().get_subject_by_name('Programacion Orientada a Objetos')
			page = self.request.get('page',0)
			try:
				int(page)
				page = int(page)-1
			except ValueError:
				page = 0
			if page < 1:
				page = 0
			index = 0
			list_list_text_info = []            
			countent = {}
			list_counter = []   
			list_content = []         
			#self.list_list_vm = text_material_management().get_list_text_material_of_subject(tutor_key,pages) 

			listi = video_material_management().get_all_videos_material(tutor_key,subject,page)     
			list_vm = video_material_management().get_list_video_material_of_one_subject(tutor_key,subject.key(),page)
			c=0
			list_videos = []
			total_text = 0
			if list_vm:
				for index in range(len(list_vm)):
					vm = list_vm[index]
					video_instance = video_material_management().get_video(vm)
					vinfo = {}        
					vinfo['id'] = vm.key().id()          
					vinfo['able'] = vm.available
					vinfo['tutor'] = (tutor_management().get_tutor(vm.tutor.key().id())).first
					vinfo['topic'] = (topic_management().get_topic(vm.topic.key().id())).name                    
					vinfo['content'] = video_instance.content                    
					vinfo['number_views'] = video_instance.number_views
					list_videos.append(vinfo)
					index = index + 1
			
			pages = int(ceil(len(listi)/10.))
		
			if pages < 1:
				pages = 1
			list_page = [None] * pages              
			
			template_values={
				"user":"******",
				"header_welcome":"",
				"header_tutor":"",
				"list_videos": list_videos,  
                "total_pages":len(list_page),
                "current_page":(page+1),
				"pages":list_page,
				"Titulo":"Gestion de Videos",
				"counter":list_counter,			
				"subject":subject.name,
				"tutor_name": tutor_instance.first
			}  
			                  
			self.response.write(admin_video_template.render(template_values))  
			return 2                    
        else:                        
            
            admi_text_template_values = {

            }
            self.response.write(admi_text_template.render(template_values))                        
            return 3
示例#13
0
    def get(self):
        user = self.get_user_type()
        if user == user_type.visitor:
            self.redirect('/')
            return 0
        elif user == user_type.student:
            tutor_id = self.session['user-id']
            student_instance = student_management().get_student(
                int(self.session['user-id']))
            tutor = tutor_management().get_tutor(5066549580791808)
            subject = subject_management().get_subject_by_name(
                'Programacion Orientada a Objetos')
            page = self.request.get('page', 0)
            unit_id = self.request.get('unit_id', None)
            if unit_id:
                unit_id = int(unit_id)
            else:
                ##id de 1era unidad
                unit_id = 5750892489867264
            page = self.request.get('page', 0)
            try:
                int(page)
                page = int(page) - 1
            except ValueError:
                page = 0
            if page < 1:
                page = 0
            index = 0
            unit = unit_management().get_unit(unit_id)
            list_list_text_info = []
            countent = {}
            list_counter = []
            list_content = []
            list_all_exams = exam_management().get_all_unit_available_exams(
                unit.key())
            list_em = exam_management().get_unit_available_exams(
                unit.key(), page)

            list_exams = []
            if list_em:
                #total_text = text_material_management().get_all_texts_material(tutor_key,self.list_list_tm[index][0].subject.key(),page)
                for index in range(len(list_em)):
                    em = list_em[index]
                    exam_instance = exam_management().find_exam(em.key().id())
                    einfo = {}
                    einfo['id'] = em.key().id()
                    einfo['able'] = em.available
                    einfo['tutor'] = (tutor_management().get_tutor(
                        em.user.key().id())).first
                    einfo['topic'] = em.topic
                    #einfo['content'] = exam_instance.content
                    #einfo['number_views'] = exam_instance.number_views
                    #einfo['description'] = 	exam_instance.description
                    list_exams.append(einfo)
                    index = index + 1
            html = ''
            pages = int(ceil(len(list_all_exams) / 10.))
            if pages < 1:
                pages = 1
            list_page = [None] * pages
            template_values = {
                "user": "******",
                "header_welcome": "",
                "header_tutor": "",
                "total_pages": len(list_page),
                "current_page": (page + 1),
                "list_exams": list_exams,
                "pages": list_page,
                #Agregado
                "unit_id": unit_id,
                "Titulo": "Gestion de Textos",
                "counter": list_counter,
                "html": html,
                "subject": subject.name,
                "student_name": student_instance.first
            }
            self.response.write(admin_exam_template.render(template_values))

            return 1

        elif user == user_type.tutor:
            tutor_id = self.session['user-id']
            tutor_key = tutor_management().get_tutor(tutor_id).key()
            tutor_instance = tutor_management().get_tutor(tutor_id)
            subject = subject_management().get_subject_by_name(
                'Programacion Orientada a Objetos')
            page = self.request.get('page', 0)
            try:
                int(page)
                page = int(page) - 1
            except ValueError:
                page = 0
            if page < 1:
                page = 0
            index = 0
            list_list_text_info = []
            countent = {}
            list_counter = []
            list_content = []
            listi = tutor_management().find_all_exams_subject(
                tutor_key, subject.key())
            #self.list_list_tm = text_material_management().get_list_text_material_of_subject(tutor_key,page)
            list_em = tutor_management().find_all_exams(
                tutor_key, subject.key(), page)

            c = 0
            list_exams = []
            total_em = 0
            if list_em:
                #total_text = text_material_management().get_all_texts_material(tutor_key,self.list_list_tm[index][0].subject.key(),page)
                for index in range(len(list_em)):
                    em = list_em[index]
                    exam_instance = exam_management().find_exam(em.key().id())
                    einfo = {}
                    einfo['id'] = em.key().id()
                    einfo['able'] = em.available
                    einfo['tutor'] = (tutor_management().get_tutor(
                        em.user.key().id())).first
                    einfo['topic'] = em.topic
                    '''
					einfo['content'] = exam_instance.content                    
					einfo['number_views'] = exam_instance.number_views
					einfo['description'] = 	exam_instance.description					
					'''
                    list_exams.append(einfo)
                    index = index + 1
            html = ''

            pages = int(ceil(len(listi) / 10.))
            if pages < 1:
                pages = 1
            list_page = [None] * pages
            template_values = {
                "user": "******",
                "header_welcome": "",
                "header_tutor": "",
                "total_pages": len(list_page),
                "current_page": (page + 1),
                "list_exams": list_exams,
                "subject": subject.name,
                "pages": list_page,
                "Titulo": "Gestion de Examenes",
                "counter": list_counter,
                "tutor_name": tutor_instance.first
            }

            self.response.write(admin_exam_template.render(template_values))

            return 2
        else:
            return 3
示例#14
0
    def get(self):
        user = self.get_user_type()
        if user == user_type.visitor:
            self.redirect('/')
        elif user == user_type.student:
            video_material_id = self.request.get('video_material_id',None)
            if not video_material_id:
                self.redirect('/explorer')
            video_instance = None        
            video_material_instance = None
            video_material_id = int(video_material_id)
            if video_material_id:                
                video_material_instance = video_material_management().get_video_material(video_material_id)
            if not video_material_instance:
                self.redirect('/explorer')                
            else:             
            	student_instance = student_management().find_key(self.session['user-id'])
                video_instance = video_material_management().get_video(video_material_instance)                        
                video_management().update_number_views(video_instance)
                list_tag_video_supported = ['mkv','mp4']
                list_tag_embedded_supported = ['wmv','mov','mpg','avi']
                #list_tag_object_supported = ['swf'] 
                vformat = video_instance.ext_format                
                vinfo = {}
                vinfo['format'] = vformat
                vinfo['tutor'] = (tutor_management().get_tutor(video_material_instance.tutor.key().id())).first
                vinfo['topic'] = (topic_management().get_topic(video_material_instance.topic.key().id())).name                    
                vinfo['content'] = video_instance.content
                vinfo['subject'] = (subject_management().get_subject(video_material_instance.subject.key().id())).name
                vinfo['description'] = video_instance.description
                vinfo['tags'] = video_material_instance.tags
                template_values={
                    "user":"******",   
                    "header_welcome":"",
                    "header_tutor":"",                
                    "vinfo":vinfo,            
                    'embbeded_supported':list_tag_embedded_supported,
                    'video_supported':list_tag_video_supported,
                    "student_name":student_instance.first
                    #"object_supported":list_tag_object_supported
                }                                           
                self.response.write(viewvideo_template.render(template_values))            
        elif user == user_type.tutor:
            video_material_id = int(self.request.get('video_material_id', None))
            video_instance = None        
            video_material_instance = None
            if video_material_id:                
                video_material_instance = video_material_management().get_video_material(video_material_id)
            if not video_material_instance:
                self.redirect('/home')                
            else:
				tutor_id = self.session['user-id']
				tutor_key = tutor_management().get_tutor(tutor_id).key()
				tutor_instance = tutor_management().get_tutor(tutor_id)
				video_instance = video_material_management().get_video(video_material_instance)                                                
				list_video_supported = ['mp4','wmv','mkv','ogg','webm']
				vformat = video_instance.ext_format            
				#list_tag_object_supported = ['swf']
				vinfo = {}
				vinfo['format'] = vformat
				vinfo['tutor'] = (tutor_management().get_tutor(video_material_instance.tutor.key().id())).first
				vinfo['topic'] = (topic_management().get_topic(video_material_instance.topic.key().id())).name                    
				vinfo['content'] = video_instance.content
				vinfo['subject'] = (subject_management().get_subject(video_material_instance.subject.key().id())).name
				vinfo['description'] = video_instance.description
				vinfo['tags'] = video_material_instance.tags
				#blob_info = BlobInfo.get(video_instance.content.key())
				template_values={
					"user":"******",   
					"header_welcome":"",
					"header_tutor":"",                
					"vinfo":vinfo,                                
					"tutor_name": tutor_instance.first,					
					#"object_supported":list_tag_object_supported
				}         
				#self.response.headers['Content-Type'] = 'video/avi'
				self.response.write(viewvideo_template.render(template_values))            
        else:
            self.redirect('/home')
示例#15
0
    def get(self):
        user = self.get_user_type()                    
        if user == user_type.visitor:                                    
			self.redirect('/')
			return 0
        elif user == user_type.student:                    	
			#self.response.headers['Content-Type'] = 'text/html'
			classification = self.request.get('classification',None)
			student_instance = student_management().find_key(self.session['user-id'])
			page = 1            
			list_list_texts = []
			index = 0
			list_list_text_info = []            
			list_list_counter = []
			countent = {}
			list_counter = []   
			list_content = []         
			i = 0
			list_list_tm = text_material_management().get_subjects_available_texts(page)
			for index in range(len(list_list_tm)):
				list_texts = []
				counter = {}                
				content = {}
				if list_list_tm[index]:	
					counter['tutorid'] = ''
					counter['class'] = 'subject'
					counter['title'] = (subject_management().get_subject(list_list_tm[index][0].subject.key().id())).name                    
					counter['total-text'] = text_material_management().get_all_subject_available_texts(list_list_tm[index][0].subject.key(),page)
					for subindex in range(len(list_list_tm[index])):                    
						tm = list_list_tm[index][subindex]
						text_instance = text_material_management().get_text(tm)
						tinfo = {}        
						tinfo['id'] = tm.key().id()          
						if tm.available == True:
							tinfo['able'] = 'Deshabilitar'
						else:
							tinfo['able'] = 'Habilitar'
						tinfo['tutor'] = (tutor_management().get_tutor(tm.tutor.key().id())).first
						tinfo['topic'] = (topic_management().get_topic(tm.topic.key().id())).name                    
						tinfo['content'] = text_instance.content                    
						tinfo['number_views'] = text_instance.number_views
						list_texts.append(tinfo)
					index = index + 1
					counter['index'] = index
					list_counter.append(copy.deepcopy(counter))
					list_list_text_info.append(list_texts)
			list_list_tm = text_material_management().get_tutors_available_texts(page)        		
			x = 2
			for index in range(len(list_list_tm)):
				list_texts = []
				counter = {}                
				content = {}
				if list_list_tm[index]:			
					counter['tutorid'] = list_list_tm[index][0].tutor.key().id()
					counter['class'] = 'tutor'		
					counter['title'] = (tutor_management().find_key(list_list_tm[index][0].tutor.key().id())).first                    
					counter['total-text'] = text_material_management().get_all_tutor_available_texts(list_list_tm[index][0].tutor.key(),page)
					for subindex in range(len(list_list_tm[index])):                    
						tm = list_list_tm[index][subindex]
						text_instance = text_material_management().get_text(tm)
						tinfo = {}        
						tinfo['id'] = tm.key().id()          
						if tm.available == True:
							tinfo['able'] = 'Deshabilitar'
						else:
							tinfo['able'] = 'Habilitar'
						tinfo['tutor'] = (tutor_management().get_tutor(tm.tutor.key().id())).first
						tinfo['topic'] = (topic_management().get_topic(tm.topic.key().id())).name                    
						tinfo['content'] = text_instance.content                    
						tinfo['number_views'] = text_instance.number_views
						list_texts.append(tinfo)
					index = index + 1
					counter['index'] = index
					list_counter.append(copy.deepcopy(counter))
					list_list_text_info.append(list_texts)				

			new_list_counter = []
			l = []
			c = 0
			for i in range(len(list_counter)):
				c = 0
				l = list_counter[i]['total-text']
				new_counter = {}
				for j in range(len(l)):
					if l[j].available:
						c+=1
				# for j in range(len(list_counter[i])):
				# 	if list_counter[i][j]['total-text'].available:
				# 		c += 1
				new_counter['num_texts'] = c
				new_list_counter.append(copy.deepcopy(new_counter))

			html = ''			
			for i in range(len(list_list_text_info)):                
				if  x==2:
					html += '<div class="block '+str(list_counter[i]['class'])+'" data-tutor-id="'+str(list_counter[i]['tutorid'])+'" id="num'+str(i)+'"><div class="head"><i class="fa fa-book"></i> <span class="subject">'+str(list_counter[i]['title'])+'</span><small> ('+str(new_list_counter[i]['num_texts'])+' texts)</small><span class="toggle"><i class="fa fa-caret-square-o-up"></i> Ocultar Materia</span></div>'
				else:
					html += '<div class="block '+str(list_counter[i]['class'])+'" id="num'+str(i)+'"><div class="head"><i class="fa fa-book"></i> <span class="subject">'+str(list_counter[i]['title'])+'</span><small> (# texts)</small><span class="toggle"><i class="fa fa-caret-square-o-up"></i> Ocultar Materia</span></div>'					
				for j in range(len(list_list_text_info[i])):
					html +='\
					<a class="textr" href="view_text?text_material_id='+str(list_list_text_info[i][j]['id'])+'" alt="'+str(list_list_text_info[i][j]['topic'])+'">\
					<div class="text" id="'+str(list_list_text_info[i][j]['id'])+'">\
					<div class="bimg" style="background:url(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS67YRkacb2A7x0mniuG1SUXllu22UOKOGYfJwARDWeZl8SyZQpfg);background-size:cover;background-position:center;">\
					<div class="views">\
					<i class="fa fa-eye"></i> '+str(list_list_text_info[i][j]['number_views'])+'\
					</div>\
					</div>\
					<div class="about">\
					<h2>'+str(list_list_text_info[i][j]['topic'])+'</h2>\
					<small>por '+str(list_list_text_info[i][j]['tutor'])+'</small>\
					</div>\
			 		</div>\
			 		</a>  '
			 	# if len(list_counter[i]['total-text']) > 6:
			 	if new_list_counter[i]['num_texts'] > 6:
			 		html += '<div class="more"><i class="fa fa-refresh"></i> Mostrar mas</div>'                    
			 	html += '</div>'           

			template_values={
				"user":"******",
				"header_welcome":"",
				"header_tutor":"",
				"list_list_texts": list_list_text_info,                
				"counter":list_counter,
				"html":html,
				"student_name":student_instance.first
			}
			self.response.write(explorer_template.render(template_values)) 
			return 1
        elif user == user_type.tutor:                      	        
			self.redirect('/home')            
			return 2                    
        else:          	        
			self.redirect('/home')                                         
			return 3
示例#16
0
	def post(self):
		user = self.get_user_type()		
		if user == user_type.visitor:
			self.response.write('0')
			self.redirect('/')
			return 0
		elif user == user_type.student:
			'''
			Retrieve the exam_id from the url and find that exam, 
			receive the start and end time of the exam, the student who 
			answered and the answers of this one.

			Save that instance and later calculate the score to get the 
			results, update the test to know if the student approved or not
			the test and show in the template the results
			'''
			exam_id = int(self.request.get('exam_id',None))
			exam_instance = exam_management().find_exam(exam_id)			
			list_answers = []			
			number_questions = len(exam_instance.questions)
			for index in range(number_questions):
				list_answers.append(int(self.request.get('r[{0}]'.format(index),0)))
			time_init = self.request.get('time_init',None)
			'''
			Cambiar por sesiones o cookies
			'''
			time_end = dt.datetime.utcnow()
			time = elapsed_time().elapsed_time(time_init,time_end)
			
			session = self.get_user_id()
			student = student_management().find_key(session)			
			test_id = test_management().add(time.time(),student.key(),exam_instance.key(),list_answers)
			test_id = int(test_id.id())
			test = test_management().find_test(test_id)
			feedback_message = test_evaluation().feedback_message(test_id)
			#self.response.write(feedback_message)			
			test_score = test_evaluation().test_score(test_id)
			#self.response.write(test_score)
			count_correct_answers = test_evaluation().count_correct_answers(test_id)
			#self.response.write(count_correct_answers)
			count_questions = test_evaluation().count_question(test_id)
			#self.response.write(count_questions)
			if feedback_message != feedback_msg.insuficient:
				test.approved = True
				test.put()
												
			template_values = {
				"user":"******",
				"feedback_message":feedback_message,
				"test_score":test_score,
				"count_correct_answers":count_correct_answers,
				"count_question":count_questions,
				"status":1
			}						
			self.response.write(template.render(template_values))
			return 1
		elif user == user_type.tutor:								
				
			'''
			This is use it to retrieve all the elements of an exam if
			exists one or show the form to create a new one

			delete and available came from a request of ajax and update 
			the exam

			otherwise it will create a new one and retrieve all the data
			from the form
			'''
			available = self.request.get('available',None)
			'''
			to be deleted
			'''
			delete = self.request.get('delete',None)
			if delete:								
				exam_id = int(self.request.get('exam_id',None))					
				exam_instance = exam_management().find_exam(exam_id)
				db.delete(exam_instance)
			if available:
				exam_id = int(self.request.get('exam_id',None))					
				exam_instance = exam_management().find_exam(exam_id)
				if exam_instance.available == True:
					exam_instance.available = False
				else:
					exam_instance.available = True
				exam_instance.put()
			else:
				'''
				This section it's for create the exam with the values that
				came from the server
				'''
				session = self.session['user-id']			
				user = tutor_management().find_key(session)						

				learning_style = self.request.get('learning_style',None)
				level = self.request.get('level',None)			
				unit = self.request.get('unit',None)
				subject = self.request.get('subject',None)
						
				number_questions = 0
				while self.request.get_all('q[{0}]'.format(number_questions),None):
					number_questions = number_questions + 1

				question = []
				question_value = []
				list_answer = []
				list_correct_answer = []						
				list_correct_answer_int = []
				list_list_correct_answer_int = []
				question_value_int = []
				list_list_str_answer = []
				list_str_question = []
				'''
				Retrieve all the inputs from the form and save it in lists
				'''
				for index in range(number_questions):				
					question.append(self.request.get('q[{0}]'.format(index),None))
					question_value.append(self.request.get('v[{0}]'.format(index),None))				
					list_answer.append(self.request.get_all('a[{0}]'.format(index),None))
					list_correct_answer.append(self.request.get_all('r[{0}]'.format(index),None))			

				for index in range(number_questions):
					sub_index = 0
					list_correct_answer_int = []
					while sub_index < len(list_correct_answer[index]):					
						list_correct_answer_int.append(int(list_correct_answer[index][sub_index]))
						sub_index = sub_index + 1
					list_list_correct_answer_int.append(list_correct_answer_int)
				
				for index in range(number_questions):
					question_value_int.append(int(question_value[index]))

				for index in range(number_questions):
					sub_index = 0
					list_str_answer = []
					while sub_index < len(list_answer[index]):
						list_str_answer.append(str(list_answer[index][sub_index]))
						sub_index = sub_index + 1
					list_list_str_answer.append(list_str_answer)

				for index in range(number_questions):							
					list_str_question.append(str(question[index]))
				self.response.write(list_list_correct_answer_int)			
				list_questions = []
				'''
				Put the list in a question model object to store in the database
				'''
				for index in range(number_questions):
					q = question_model()	
					q.text = list_str_question[index]
					q.answers = list_list_str_answer[index]
					q.correct_answers = list_list_correct_answer_int[index]
					q.value = question_value_int[index]				
					#list_questions[index]= q.put()
					list_questions.append(q.put())

				s = subject_model()
				s.name = str(subject)							
				exam_id = self.request.get('exam_id',None)
				'''
				If a exam_id it's retrieved from the url it means that this exam it's been
				modified, so it doesn't need to be created, otherwise it have to and put all
				the data need to store it in the database
				'''
				if exam_id:
					exam_id = int(exam_id)
					exam_instance = exam_management().modify(exam_id,user,int(learning_style),int(level),int(unit),s.put(),list_questions)
					self.redirect('/home')
					#self.response.write('<a href="/home">Home</a>')
					#desplegar mensaje que se ha modificado
				else:
					exam_key = exam_management().add(user,int(learning_style),int(level),int(unit),s.put(),list_questions)								
					self.redirect('/home')
					#self.response.write('<a href="/home">Home</a>')
					#desplegar mensaje que se ha creado
				#self.redirect('/home')			
			return 2
			
		else:
			self.response.write('3')
			self.redirect('/home')
			return 3
示例#17
0
 def get(self):
     user = self.get_user_type()
     if user == user_type.visitor:
         self.redirect('/')
     elif user == user_type.student:
         video_material_id = self.request.get('video_material_id', None)
         if not video_material_id:
             self.redirect('/explorer')
         video_instance = None
         video_material_instance = None
         video_material_id = int(video_material_id)
         if video_material_id:
             video_material_instance = video_material_management(
             ).get_video_material(video_material_id)
         if not video_material_instance:
             self.redirect('/explorer')
         else:
             student_instance = student_management().find_key(
                 self.session['user-id'])
             video_instance = video_material_management().get_video(
                 video_material_instance)
             video_management().update_number_views(video_instance)
             list_tag_video_supported = ['mkv', 'mp4']
             list_tag_embedded_supported = ['wmv', 'mov', 'mpg', 'avi']
             #list_tag_object_supported = ['swf']
             vformat = video_instance.ext_format
             vinfo = {}
             vinfo['format'] = vformat
             vinfo['tutor'] = (tutor_management().get_tutor(
                 video_material_instance.tutor.key().id())).first
             vinfo['topic'] = (topic_management().get_topic(
                 video_material_instance.topic.key().id())).name
             vinfo['content'] = video_instance.content
             vinfo['subject'] = (subject_management().get_subject(
                 video_material_instance.subject.key().id())).name
             vinfo['description'] = video_instance.description
             vinfo['tags'] = video_material_instance.tags
             template_values = {
                 "user": "******",
                 "header_welcome": "",
                 "header_tutor": "",
                 "vinfo": vinfo,
                 'embbeded_supported': list_tag_embedded_supported,
                 'video_supported': list_tag_video_supported,
                 "student_name": student_instance.first
                 #"object_supported":list_tag_object_supported
             }
             self.response.write(viewvideo_template.render(template_values))
     elif user == user_type.tutor:
         video_material_id = int(self.request.get('video_material_id',
                                                  None))
         video_instance = None
         video_material_instance = None
         if video_material_id:
             video_material_instance = video_material_management(
             ).get_video_material(video_material_id)
         if not video_material_instance:
             self.redirect('/home')
         else:
             tutor_id = self.session['user-id']
             tutor_key = tutor_management().get_tutor(tutor_id).key()
             tutor_instance = tutor_management().get_tutor(tutor_id)
             video_instance = video_material_management().get_video(
                 video_material_instance)
             list_video_supported = ['mp4', 'wmv', 'mkv', 'ogg', 'webm']
             vformat = video_instance.ext_format
             #list_tag_object_supported = ['swf']
             vinfo = {}
             vinfo['format'] = vformat
             vinfo['tutor'] = (tutor_management().get_tutor(
                 video_material_instance.tutor.key().id())).first
             vinfo['topic'] = (topic_management().get_topic(
                 video_material_instance.topic.key().id())).name
             vinfo['content'] = video_instance.content
             vinfo['subject'] = (subject_management().get_subject(
                 video_material_instance.subject.key().id())).name
             vinfo['description'] = video_instance.description
             vinfo['tags'] = video_material_instance.tags
             #blob_info = BlobInfo.get(video_instance.content.key())
             template_values = {
                 "user": "******",
                 "header_welcome": "",
                 "header_tutor": "",
                 "vinfo": vinfo,
                 "tutor_name": tutor_instance.first,
                 #"object_supported":list_tag_object_supported
             }
             #self.response.headers['Content-Type'] = 'video/avi'
             self.response.write(viewvideo_template.render(template_values))
     else:
         self.redirect('/home')
示例#18
0
 def get(self):
     user = self.get_user_type()
     if user == user_type.visitor:
         self.redirect('/')
     elif user == user_type.student:
         text_material_id = self.request.get('text_material_id', None)
         if not text_material_id:
             self.redirect('/explorer')
         text_instance = None
         text_material_instance = None
         text_material_id = int(text_material_id)
         if text_material_id:
             text_material_instance = text_material_management(
             ).get_text_material(text_material_id)
         if not text_material_instance:
             self.redirect('/explorer')
         else:
             student_instance = student_management().find_key(
                 self.session['user-id'])
             text_instance = text_material_management().get_text(
                 text_material_instance)
             text_management().update_number_views(text_instance)
             list_tag_text_supported = ['pdf']
             list_tag_embedded_supported = ['pdf']
             #list_tag_object_supported = ['swf']
             tformat = text_instance.ext_format
             tinfo = {}
             tinfo['format'] = tformat
             tinfo['tutor'] = (tutor_management().get_tutor(
                 text_material_instance.tutor.key().id())).first
             tinfo['topic'] = (topic_management().get_topic(
                 text_material_instance.topic.key().id())).name
             tinfo['content'] = text_instance.content
             tinfo['subject'] = (subject_management().get_subject(
                 text_material_instance.subject.key().id())).name
             tinfo['description'] = text_instance.description
             tinfo['tags'] = text_material_instance.tags
             template_values = {
                 "user": "******",
                 "header_welcome": "",
                 "header_tutor": "",
                 "tinfo": tinfo,
                 'embbeded_supported': list_tag_embedded_supported,
                 'text_supported': list_tag_text_supported,
                 "student_name": student_instance.first
                 #"object_supported":list_tag_object_supported
             }
             self.response.write(viewtext_template.render(template_values))
     elif user == user_type.tutor:
         text_material_id = int(self.request.get('text_material_id'))
         text_instance = None
         text_material_instance = None
         if text_material_id:
             text_material_instance = text_material_management(
             ).get_text_material(text_material_id)
         if not text_material_instance:
             self.redirect('/home')
         else:
             tutor_id = self.session['user-id']
             tutor_key = tutor_management().get_tutor(tutor_id).key()
             tutor_instance = tutor_management().get_tutor(tutor_id)
             text_instance = text_material_management().get_text(
                 text_material_instance)
             list_text_supported = ['pdf']
             tformat = text_instance.ext_format
             #list_tag_object_supported = ['swf']
             tinfo = {}
             tinfo['format'] = tformat
             tinfo['tutor'] = (tutor_management().get_tutor(
                 text_material_instance.tutor.key().id())).first
             tinfo['topic'] = (topic_management().get_topic(
                 text_material_instance.topic.key().id())).name
             tinfo['content'] = text_instance.content
             tinfo['subject'] = (subject_management().get_subject(
                 text_material_instance.subject.key().id())).name
             tinfo['description'] = text_instance.description
             tinfo['tags'] = text_material_instance.tags
             #blob_info = BlobInfo.get(text_instance.content.key())
             template_values = {
                 "user": "******",
                 "header_welcome": "",
                 "header_tutor": "",
                 "tinfo": tinfo,
                 "tutor_name": tutor_instance.first,
                 #"object_supported":list_tag_object_supported
             }
             #self.response.headers['Content-Type'] = 'video/avi'
             self.response.write(viewtext_template.render(template_values))
     else:
         self.redirect('/home')
示例#19
0
	def get(self):
		user = self.get_user_type()               
		if user == user_type.visitor:                    
			self.redirect('/')
			return 0
		elif user == user_type.student:
			tutor_id = self.session['user-id']
			student_instance = student_management().get_student(int(self.session['user-id']))
			tutor = tutor_management().get_tutor(5066549580791808)
			subject = subject_management().get_subject_by_name('Programacion Orientada a Objetos')
			page = self.request.get('page',0)   
			unit_id = self.request.get('unit_id',None)
			if unit_id:
				unit_id = int(unit_id)
			else:
				##id de 1era unidad
				unit_id = 5750892489867264
			page = self.request.get('page',0)
			try:
				int(page)
				page = int(page)-1
			except ValueError:
				page = 0
			if page < 1:
				page = 0
			index = 0
			unit = unit_management().get_unit(unit_id)
			list_list_text_info = []            
			countent = {}
			list_counter = []   
			list_content = []  
			list_all_exams = exam_management().get_all_unit_available_exams(unit.key())  
			list_em = exam_management().get_unit_available_exams(unit.key(),page)
			
			list_exams = []
			if list_em:				
				#total_text = text_material_management().get_all_texts_material(tutor_key,self.list_list_tm[index][0].subject.key(),page)
				for index in range(len(list_em)):
					em = list_em[index]
					exam_instance = exam_management().find_exam(em.key().id())
					einfo = {}        
					einfo['id'] = em.key().id()          
					einfo['able'] = em.available
					einfo['tutor'] = (tutor_management().get_tutor(em.user.key().id())).first
					einfo['topic'] = em.topic                    
					#einfo['content'] = exam_instance.content                    
					#einfo['number_views'] = exam_instance.number_views
					#einfo['description'] = 	exam_instance.description					
					list_exams.append(einfo)
					index = index + 1
			html = ''
			pages = int(ceil(len(list_all_exams)/10.))
			if pages < 1:
				pages = 1
			list_page = [None] * pages              
			template_values={
				"user":"******",
				"header_welcome":"",
				"header_tutor":"",
                "total_pages":len(list_page),
                "current_page":(page+1),
				"list_exams": list_exams,                
				"pages":list_page,
				#Agregado
				"unit_id":unit_id,
				"Titulo":"Gestion de Textos",
				"counter":list_counter,
				"html":html,
				"subject":subject.name,
				"student_name": student_instance.first
			} 	
			self.response.write(admin_exam_template.render(template_values))
			
			return 1		

		elif user == user_type.tutor:
			tutor_id = self.session['user-id']
			tutor_key = tutor_management().get_tutor(tutor_id).key()
			tutor_instance = tutor_management().get_tutor(tutor_id)
			subject = subject_management().get_subject_by_name('Programacion Orientada a Objetos')
			page = self.request.get('page',0)
			try:
				int(page)
				page = int(page)-1
			except ValueError:
				page = 0
			if page < 1:
				page = 0
			index = 0
			list_list_text_info = []            
			countent = {}
			list_counter = []   
			list_content = []  
			listi = tutor_management().find_all_exams_subject(tutor_key,subject.key())      
			#self.list_list_tm = text_material_management().get_list_text_material_of_subject(tutor_key,page)
			list_em = tutor_management().find_all_exams(tutor_key,subject.key(),page)
			
			c=0                        
			list_exams = []
			total_em = 0
			if list_em:				
				#total_text = text_material_management().get_all_texts_material(tutor_key,self.list_list_tm[index][0].subject.key(),page)
				for index in range(len(list_em)):
					em = list_em[index]
					exam_instance = exam_management().find_exam(em.key().id())
					einfo = {}        
					einfo['id'] = em.key().id()          
					einfo['able'] = em.available
					einfo['tutor'] = (tutor_management().get_tutor(em.user.key().id())).first
					einfo['topic'] = em.topic                    
					'''
					einfo['content'] = exam_instance.content                    
					einfo['number_views'] = exam_instance.number_views
					einfo['description'] = 	exam_instance.description					
					'''
					list_exams.append(einfo)
					index = index + 1								
			html = ''
			
			pages = int(ceil(len(listi)/10.))
			if pages < 1:
				pages = 1
			list_page = [None] * pages              
			template_values={
				"user":"******",
				"header_welcome":"",
				"header_tutor":"",
                "total_pages":len(list_page),
                "current_page":(page+1),
				"list_exams": list_exams,
				"subject":subject.name,
				"pages":list_page,
				"Titulo":"Gestion de Examenes",                
				"counter":list_counter,
				"tutor_name": tutor_instance.first
			}  
            
			self.response.write(admin_exam_template.render(template_values))
			
			return 2                                      
		else: 
			return 3
示例#20
0
    def get(self):
        user = self.get_user_type()
        if user == user_type.visitor:
            self.redirect('/')
            return 0
        elif user == user_type.student:
            #self.response.headers['Content-Type'] = 'text/html'
            classification = self.request.get('classification', None)
            student_instance = student_management().find_key(
                self.session['user-id'])
            page = 1
            list_list_texts = []
            index = 0
            list_list_text_info = []
            list_list_counter = []
            countent = {}
            list_counter = []
            list_content = []
            i = 0
            list_list_tm = text_material_management(
            ).get_subjects_available_texts(page)
            for index in range(len(list_list_tm)):
                list_texts = []
                counter = {}
                content = {}
                if list_list_tm[index]:
                    counter['tutorid'] = ''
                    counter['class'] = 'subject'
                    counter['title'] = (subject_management().get_subject(
                        list_list_tm[index][0].subject.key().id())).name
                    counter['total-text'] = text_material_management(
                    ).get_all_subject_available_texts(
                        list_list_tm[index][0].subject.key(), page)
                    for subindex in range(len(list_list_tm[index])):
                        tm = list_list_tm[index][subindex]
                        text_instance = text_material_management().get_text(tm)
                        tinfo = {}
                        tinfo['id'] = tm.key().id()
                        if tm.available == True:
                            tinfo['able'] = 'Deshabilitar'
                        else:
                            tinfo['able'] = 'Habilitar'
                        tinfo['tutor'] = (tutor_management().get_tutor(
                            tm.tutor.key().id())).first
                        tinfo['topic'] = (topic_management().get_topic(
                            tm.topic.key().id())).name
                        tinfo['content'] = text_instance.content
                        tinfo['number_views'] = text_instance.number_views
                        list_texts.append(tinfo)
                    index = index + 1
                    counter['index'] = index
                    list_counter.append(copy.deepcopy(counter))
                    list_list_text_info.append(list_texts)
            list_list_tm = text_material_management(
            ).get_tutors_available_texts(page)
            x = 2
            for index in range(len(list_list_tm)):
                list_texts = []
                counter = {}
                content = {}
                if list_list_tm[index]:
                    counter['tutorid'] = list_list_tm[index][0].tutor.key().id(
                    )
                    counter['class'] = 'tutor'
                    counter['title'] = (tutor_management().find_key(
                        list_list_tm[index][0].tutor.key().id())).first
                    counter['total-text'] = text_material_management(
                    ).get_all_tutor_available_texts(
                        list_list_tm[index][0].tutor.key(), page)
                    for subindex in range(len(list_list_tm[index])):
                        tm = list_list_tm[index][subindex]
                        text_instance = text_material_management().get_text(tm)
                        tinfo = {}
                        tinfo['id'] = tm.key().id()
                        if tm.available == True:
                            tinfo['able'] = 'Deshabilitar'
                        else:
                            tinfo['able'] = 'Habilitar'
                        tinfo['tutor'] = (tutor_management().get_tutor(
                            tm.tutor.key().id())).first
                        tinfo['topic'] = (topic_management().get_topic(
                            tm.topic.key().id())).name
                        tinfo['content'] = text_instance.content
                        tinfo['number_views'] = text_instance.number_views
                        list_texts.append(tinfo)
                    index = index + 1
                    counter['index'] = index
                    list_counter.append(copy.deepcopy(counter))
                    list_list_text_info.append(list_texts)

            new_list_counter = []
            l = []
            c = 0
            for i in range(len(list_counter)):
                c = 0
                l = list_counter[i]['total-text']
                new_counter = {}
                for j in range(len(l)):
                    if l[j].available:
                        c += 1
                # for j in range(len(list_counter[i])):
                # 	if list_counter[i][j]['total-text'].available:
                # 		c += 1
                new_counter['num_texts'] = c
                new_list_counter.append(copy.deepcopy(new_counter))

            html = ''
            for i in range(len(list_list_text_info)):
                if x == 2:
                    html += '<div class="block ' + str(
                        list_counter[i]['class']
                    ) + '" data-tutor-id="' + str(
                        list_counter[i]['tutorid']
                    ) + '" id="num' + str(
                        i
                    ) + '"><div class="head"><i class="fa fa-book"></i> <span class="subject">' + str(
                        list_counter[i]['title']
                    ) + '</span><small> (' + str(
                        new_list_counter[i]['num_texts']
                    ) + ' texts)</small><span class="toggle"><i class="fa fa-caret-square-o-up"></i> Ocultar Materia</span></div>'
                else:
                    html += '<div class="block ' + str(
                        list_counter[i]['class']
                    ) + '" id="num' + str(
                        i
                    ) + '"><div class="head"><i class="fa fa-book"></i> <span class="subject">' + str(
                        list_counter[i]['title']
                    ) + '</span><small> (# texts)</small><span class="toggle"><i class="fa fa-caret-square-o-up"></i> Ocultar Materia</span></div>'
                for j in range(len(list_list_text_info[i])):
                    html += '\
					<a class="textr" href="view_text?text_material_id=' + str(
                        list_list_text_info[i][j]['id']) + '" alt="' + str(
                            list_list_text_info[i][j]['topic']) + '">\
					<div class="text" id="' + str(list_list_text_info[i][j]['id']) + '">\
					<div class="bimg" style="background:url(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS67YRkacb2A7x0mniuG1SUXllu22UOKOGYfJwARDWeZl8SyZQpfg);background-size:cover;background-position:center;">\
					<div class="views">\
					<i class="fa fa-eye"></i> ' + str(
                                list_list_text_info[i][j]['number_views']) + '\
					</div>\
					</div>\
					<div class="about">\
					<h2>' + str(list_list_text_info[i][j]['topic']) + '</h2>\
					<small>por ' + str(list_list_text_info[i][j]['tutor']) + '</small>\
					</div>\
			 		</div>\
			 		</a>  '

            # if len(list_counter[i]['total-text']) > 6:
                if new_list_counter[i]['num_texts'] > 6:
                    html += '<div class="more"><i class="fa fa-refresh"></i> Mostrar mas</div>'
                html += '</div>'

            template_values = {
                "user": "******",
                "header_welcome": "",
                "header_tutor": "",
                "list_list_texts": list_list_text_info,
                "counter": list_counter,
                "html": html,
                "student_name": student_instance.first
            }
            self.response.write(explorer_template.render(template_values))
            return 1
        elif user == user_type.tutor:
            self.redirect('/home')
            return 2
        else:
            self.redirect('/home')
            return 3
示例#21
0
    def get(self):
        user = self.get_user_type()
        if user == user_type.visitor:
            self.redirect('/')
        elif user == user_type.student:
            text_material_id = self.request.get('text_material_id',None)
            if not text_material_id:
                self.redirect('/explorer')
            text_instance = None        
            text_material_instance = None
            text_material_id = int(text_material_id)
            if text_material_id:                
                text_material_instance = text_material_management().get_text_material(text_material_id)
            if not text_material_instance:
                self.redirect('/explorer')                
            else:             
            	student_instance = student_management().find_key(self.session['user-id'])
                text_instance = text_material_management().get_text(text_material_instance)                        
                text_management().update_number_views(text_instance)
                list_tag_text_supported = ['pdf']
                list_tag_embedded_supported = ['pdf']
                #list_tag_object_supported = ['swf'] 
                tformat = text_instance.ext_format                
                tinfo = {}
                tinfo['format'] = tformat
                tinfo['tutor'] = (tutor_management().get_tutor(text_material_instance.tutor.key().id())).first
                tinfo['topic'] = (topic_management().get_topic(text_material_instance.topic.key().id())).name                    
                tinfo['content'] = text_instance.content
                tinfo['subject'] = (subject_management().get_subject(text_material_instance.subject.key().id())).name
                tinfo['description'] = text_instance.description
                tinfo['tags'] = text_material_instance.tags
                template_values={
                    "user":"******",   
                    "header_welcome":"",
                    "header_tutor":"",                
                    "tinfo":tinfo,            
                    'embbeded_supported':list_tag_embedded_supported,
                    'text_supported':list_tag_text_supported,
                    "student_name":student_instance.first
                    #"object_supported":list_tag_object_supported
                }                                           
                self.response.write(viewtext_template.render(template_values))            
        elif user == user_type.tutor:
            text_material_id = int(self.request.get('text_material_id'))
            text_instance = None        
            text_material_instance = None
            if text_material_id:                
                text_material_instance = text_material_management().get_text_material(text_material_id)
            if not text_material_instance:
                self.redirect('/home')                
            else:
				tutor_id = self.session['user-id']
				tutor_key = tutor_management().get_tutor(tutor_id).key()
				tutor_instance = tutor_management().get_tutor(tutor_id)
				text_instance = text_material_management().get_text(text_material_instance)                                                
				list_text_supported = ['pdf']
				tformat = text_instance.ext_format            
				#list_tag_object_supported = ['swf']
				tinfo = {}
				tinfo['format'] = tformat
				tinfo['tutor'] = (tutor_management().get_tutor(text_material_instance.tutor.key().id())).first
				tinfo['topic'] = (topic_management().get_topic(text_material_instance.topic.key().id())).name                    
				tinfo['content'] = text_instance.content
				tinfo['subject'] = (subject_management().get_subject(text_material_instance.subject.key().id())).name
				tinfo['description'] = text_instance.description
				tinfo['tags'] = text_material_instance.tags
				#blob_info = BlobInfo.get(text_instance.content.key())
				template_values={
					"user":"******",   
					"header_welcome":"",
					"header_tutor":"",                
					"tinfo":tinfo,                                
					"tutor_name": tutor_instance.first,					
					#"object_supported":list_tag_object_supported
				}         
				#self.response.headers['Content-Type'] = 'video/avi'
				self.response.write(viewtext_template.render(template_values))            
        else:
            self.redirect('/home')
示例#22
0
文件: Home.py 项目: tonaclaudia/TIPOO
	def get(self):
		user = self.get_user_type()                    
		unit_exists = unit_management().get_unit_by_name("Introduccion a Java")
		'''
		subject = subject_management().get_subject_by_name('Programacion Orientada a Objetos')
		unit_management().add('Unidad 1 Introduccion a Java',subject.key(),1)
		unit_management().add('Unidad 2  Variables, objetos y clases',subject.key(),2)
		unit_management().add('Unidad 3 Codificacion de imágenes',subject.key(),3)
		unit_management().add('Unidad 4 Ambiente de ejecución y arreglos',subject.key(),4)
		unit_management().add('Unidad 5 Tópicos avanzados de java',subject.key(),5)
		unit_management().add('Unidad 6 Manejo de Excepciones',subject.key(),6)
		unit_management().add('Unidad 7 Recursos Escenciales de Java',subject.key(),7)
		unit_management().add('Unidad 8 Hilos',subject.key(),8)
		unit_management().add('Unidad 9 Manipulación de medios',subject.key(),9)
		'''
		if user == user_type.visitor:                    
			self.redirect('/')
			return 0
		elif user == user_type.student:       
			tutors = tutor_management().get_all_tutors()
			student = student_management().get_student(int(self.session['user-id']))
			list = []

			for t in tutors:
				if t.key() not in student.tutors_list:
					student.tutors_list.append(t)					
			template_values = {
				"total":len(student.tutors_list),
				"user": "******",
			}
			self.response.write(template.render(template_values))
			return 1

		elif user == user_type.tutor:     
			'''                     
			page = 1            
			list_list_videos = []
			tutor_id = self.session['user-id']
			tutor_key = tutor_management().get_tutor(tutor_id).key()
			tutor_instance = tutor_management().get_tutor(tutor_id)
			index = 0
			list_list_video_info = []            
			countent = {}
			list_counter = []   
			list_content = []         
			list_list_vm = video_material_management().get_list_video_material_of_subject(tutor_key,page)                        
			for index in range(len(list_list_vm)):
				list_videos = []
				counter = {}                
				content = {}
				if list_list_vm[index]:					
					counter['subject'] = (subject_management().get_subject(list_list_vm[index][0].subject.key().id())).name                    
					counter['total-video'] = video_material_management().get_all_videos_material(tutor_key,list_list_vm[index][0].subject.key(),page)
					for subindex in range(len(list_list_vm[index])):                    
						vm = list_list_vm[index][subindex]
						video_instance = video_material_management().get_video(vm)
						vinfo = {}        
						vinfo['id'] = vm.key().id()          
						if vm.available == True:
							vinfo['able'] = '<i class="fa fa-pencil-square-o"></i> Deshabilitar'
						else:
							vinfo['able'] = '<i class="fa fa-pencil-square-o"></i> Habilitar'
						vinfo['tutor'] = (tutor_management().get_tutor(vm.tutor.key().id())).first
						vinfo['topic'] = (topic_management().get_topic(vm.topic.key().id())).name                    
						vinfo['content'] = video_instance.content                    
						vinfo['number_views'] = video_instance.number_views
						list_videos.append(vinfo)
					index = index + 1
					counter['index'] = index
					list_counter.append(copy.deepcopy(counter))
					list_list_video_info.append(list_videos)
					self.response.write(list_list_vm[0])

			html = ''
			for i in range(len(list_list_video_info)):                
				html += '<div class="block" id="num'+str(i)+'"><div class="head"><i class="fa fa-book"></i> <span class="subject">'+str(list_counter[i]['subject'])+'</span><small> ('+str(len(list_counter[i]['total-video']))+' Videos)</small><span class="toggle"><i class="fa fa-caret-square-o-up"></i> Ocultar Materia</span></div>'
				for j in range(len(list_list_video_info[i])):
					html +='\
					\
					<a class="videor" href="view_video?video_material_id='+str(list_list_video_info[i][j]['id'])+'" alt="'+str(list_list_video_info[i][j]['topic'])+'">\
					<div class="video" id="'+str(list_list_video_info[i][j]['id'])+'">\
					<div class="bimg" style="background:url(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS67YRkacb2A7x0mniuG1SUXllu22UOKOGYfJwARDWeZl8SyZQpfg);background-size:cover;background-position:center;">\
					<div class="remove" id="'+str(list_list_video_info[i][j]['id'])+'">'+str(list_list_video_info[i][j]['able'])+'</div>\
					<div class="views">\
					<i class="fa fa-eye"></i> '+str(list_list_video_info[i][j]['number_views'])+'\
					</div>\
					</div>\
					<div class="about">\
					<h2>'+str(list_list_video_info[i][j]['topic'])+'</h2>\
					<small>por '+str(list_list_video_info[i][j]['tutor'])+'</small>\
					</div>\
					</div>\
					</a>  '
				#if len(list_counter[i]['total-video']) > 6:
					#html += '<div class="more"><i class="fa fa-refresh"></i> Mostrar mas</div>'                    
				html += '</div>' 

				pages =  len(list_counter[i]['total-video'])/6
				if pages < 1:
					pages = 1
				html += '\
				<nav> \
					<ul class="pagination">'
				for p in range(1, pages+1):
					html += '<li><a href="#">' + str(p) + '</a></li>'
				html += '\
				</ul>\
					</nav\>'
			'''
			template_values={					
				"user":"******",
				"header_welcome":"",
				"header_tutor":"",				
			}  
			                 
			self.response.write(template.render(template_values))  
			return 2                    
		else:                                    
			template_values = {

			}
			self.response.write(template.render(template_values))                        
			return 3