Exemple #1
0
    def get(self):
        user = self.get_user_type()
        if user == user_type.visitor:
            self.redirect('/')
            return 0
        elif user == user_type.student:
            unit_id = int(self.request.get('unit_id', None))
            unit = unit_management().get_unit(unit_id)
            exams = exam_management().get_exams_by_unit(unit)
            len_exams = len(exams)

            if (len_exams > 0):
                exam_selected = random.randint(0, len_exams - 1)
                exam = exams[exam_selected]
                template_values = {'exam_id': exam.key().id()}
                self.response.write(template.render(template_values))
            else:
                self.response.write('There i no exams')
            return 1

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

            return 3
Exemple #2
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('/home')
            return 1

        elif user == user_type.tutor:
            subject = subject_management().get_subject_by_name(
                'Programacion Orientada a Objetos')
            list_units = unit_management().get_all_units_of_subject(
                subject.key())

            template_values = {
                'list_units': list_units,
                'upload_url': blobstore.create_upload_url('/upload_exam')
            }
            self.response.write(template.render(template_values))

            return 2
        else:
            self.redirect('/')
            return 3
Exemple #3
0
    def get(self):
        user = self.get_user_type()                    
        if user == user_type.visitor:                    
            self.redirect('/')
            return 0
        elif user == user_type.student:       
            unit_id = int(self.request.get('unit_id',None))
            unit = unit_management().get_unit(unit_id)
            exams = exam_management().get_exams_by_unit(unit)
            len_exams = len(exams)
            
            if(len_exams>0):
                exam_selected  = random.randint(0,len_exams - 1)
                exam = exams[exam_selected]
                template_values={'exam_id':exam.key().id()}
                self.response.write(template.render(template_values))
            else:
                self.response.write('There i no exams')
            return 1

        elif user == user_type.tutor:                          
			self.redirect('/home')  
			return 2                    
        else:                        
            self.redirect('/')  
                                   
            return 3
Exemple #4
0
    def get(self):

        user = self.get_user_type()
        if user == user_type.visitor:
            return 0
        elif user == user_type.student:
            type = self.request.get('type', None)
            subject = subject_management().get_subject_by_name(
                'Programacion Orientada a Objetos')
            subject_units = unit_management().get_all_units_of_subject(
                subject.key())
            list_units = []
            for unit in subject_units:
                uinfo = {}
                uinfo['name'] = unit.name
                uinfo['id'] = unit.key().id()
                list_units.append(uinfo)
            template_values = {
                "list_units": list_units,
                "type": type,
                "subject": subject.name,
                "user": "******"
            }
            self.response.write(
                subject_content_template.render(template_values))
            return 1
        elif user == user_type.tutor:

            return 2
        else:
            return 3
Exemple #5
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('/home')
            return 1

        elif user == user_type.tutor:
            id_exam = int(self.request.get('exam_id',None))
            exam = exam_management().find_exam(id_exam)
            
            name = exam.name
            level = exam.level
            learning_type = exam.learning_type
            unit = exam.unit
            topic = exam.topic

            subject = subject_management().get_subject_by_name('Programacion Orientada a Objetos')
            list_units = unit_management().get_all_units_of_subject(subject.key())
            

            
            
            
            list_questions = [] 
            
            for q in exam.questions:
                q=exam_management().find_question(q.id())
                list_questions.append(q)

            
            len_questions = len(list_questions)

            template_values={'name':name,
                             'level':level,
                             'learning_type':learning_type,
                             'unit':unit,
                             'topic':topic,
                             'list_questions':list_questions,
                             'len_questions':len_questions,
                             'id_exam':id_exam,
                             'list_units':list_units,
                             'upload_url':blobstore.create_upload_url('/upload_exam')
                             }
            
            self.response.write(template.render(template_values))
            return 2                    
        else:                        
            self.redirect('/')  
            return 3
Exemple #6
0
	def get(self):
		user=self.get_user_type()
		if user == user_type.visitor:  
			
			self.session['errort'] = ''							
			self.session['successt'] = ''							
			self.session['error1'] = ''	
			self.session['error2'] = ''			
			self.session['error3'] = ''								
			self.session['success'] = ''
			self.session['errort'] = ''		
			self.session['successt'] = ''
			template_values={            
			}
			
			#if not student_management().find_email("*****@*****.**"):
				
			
			if not tutor_management().find_email("*****@*****.**"):
				tutor=Tutor.Tutor()
				tutor.activate=True
				tutor.bday=datetime.datetime.strptime("1991-09-22","%Y-%m-%d").date()
				tutor.sex="male"
				tutor.password="******"
				salt = 'iSG716Pcu#'
				m = hashlib.md5()
				m.update(salt+tutor.password)
				tutor.password=m.hexdigest()
				tutor.email="*****@*****.**"
				tutor.first="tutor"
				tutor.last="prueba"
				tutor.put()

				user=Student.Student()
				user.activate=True
				user.first="alumno"
				user.last="prueba"
				user.bday=datetime.datetime.strptime("1991-09-22","%Y-%m-%d").date()
				user.email="*****@*****.**"
				user.sex="male"
				user.password="******"
				user.tutors_list.append(tutor.key())
				salt = 'iSG716Pcu#'
				m = hashlib.md5()
				m.update(salt+user.password)
				user.password=m.hexdigest()
				user.put()



			if not subject_management().find_name('Programacion Orientada a Objetos'):
				s1 = Subject()
				s1.name = 'Programacion Orientada a Objetos'
				s1.put()
			if not subject_management().find_name('IA'):
				s2 = Subject()
				s2.name = 'IA'
				s2.put()
			if not subject_management().find_name('Programacion Orientada a Objetos Avanzada'):
				s3 = Subject()
				s3.name = 'Programacion Orientada a Objetos Avanzada'
				s3.put()
			if not subject_management().find_name('Algoritmos'):
				s4 = Subject()
				s4.name = 'Algoritmos'
				s4.put()
			if not subject_management().find_name('Circuitos Digitales'):
				s5 = Subject()
				s5.name = 'Circuitos Digitales'
				s5.put()
			if not unit_management().get_unit_by_name('Introduccion a Java'):
				subject = subject_management().find_name('Programacion Orientada a Objetos')
				unit_management().add('Introduccion a Java',subject.key(),1)
				sleep(0.1)
				unit_management().add('Variables, objetos y clases',subject.key(),2)
				sleep(0.1)
				unit_management().add('Codificacion de imagenes',subject.key(),3)
				sleep(0.1)
				unit_management().add('Ambiente de ejecucion y arreglos',subject.key(),4)
				sleep(0.1)
				unit_management().add('Topicos avanzados de java',subject.key(),5)
				sleep(0.1)
				unit_management().add('Manejo de Excepciones',subject.key(),6)
				sleep(0.1)
				unit_management().add('Recursos Escenciales de Java',subject.key(),7)
				sleep(0.1)
				unit_management().add('Hilos',subject.key(),8)
				sleep(0.1)
				unit_management().add('Manipulacion de medios',subject.key(),9)
				sleep(0.1)
			# Action().deleteall()
			# StudentRecords().deleteall()
			self.response.write(index_template.render(template_values))
			
			return 0			
		elif user == user_type.student:
			self.redirect('/explorer')
			return 1
		else:
			self.redirect('/home')
			return 2
Exemple #7
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
Exemple #8
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
	def get_list_video_material_of_one_subject_unit(self,tutor,subject,unit,page):
		s = subject_management().get_subject(subject.id())
		u = unit_management().get_unit(unit.id())
		return self.get_list_video_material_unit(tutor,s.key(),u.key(),page)
Exemple #10
0
 def get_list_video_material_of_one_subject_unit(self, tutor, subject, unit,
                                                 page):
     s = subject_management().get_subject(subject.id())
     u = unit_management().get_unit(unit.id())
     return self.get_list_video_material_unit(tutor, s.key(), u.key(), page)
Exemple #11
0
    def get(self):
        user = self.get_user_type()
        if user == user_type.visitor:

            self.session['errort'] = ''
            self.session['successt'] = ''
            self.session['error1'] = ''
            self.session['error2'] = ''
            self.session['error3'] = ''
            self.session['success'] = ''
            self.session['errort'] = ''
            self.session['successt'] = ''
            template_values = {}

            #if not student_management().find_email("*****@*****.**"):

            if not tutor_management().find_email("*****@*****.**"):
                tutor = Tutor.Tutor()
                tutor.activate = True
                tutor.bday = datetime.datetime.strptime(
                    "1991-09-22", "%Y-%m-%d").date()
                tutor.sex = "male"
                tutor.password = "******"
                salt = 'iSG716Pcu#'
                m = hashlib.md5()
                m.update(salt + tutor.password)
                tutor.password = m.hexdigest()
                tutor.email = "*****@*****.**"
                tutor.first = "tutor"
                tutor.last = "prueba"
                tutor.put()

                user = Student.Student()
                user.activate = True
                user.first = "alumno"
                user.last = "prueba"
                user.bday = datetime.datetime.strptime("1991-09-22",
                                                       "%Y-%m-%d").date()
                user.email = "*****@*****.**"
                user.sex = "male"
                user.password = "******"
                user.tutors_list.append(tutor.key())
                salt = 'iSG716Pcu#'
                m = hashlib.md5()
                m.update(salt + user.password)
                user.password = m.hexdigest()
                user.put()

            if not subject_management().find_name(
                    'Programacion Orientada a Objetos'):
                s1 = Subject()
                s1.name = 'Programacion Orientada a Objetos'
                s1.put()
            if not subject_management().find_name('IA'):
                s2 = Subject()
                s2.name = 'IA'
                s2.put()
            if not subject_management().find_name(
                    'Programacion Orientada a Objetos Avanzada'):
                s3 = Subject()
                s3.name = 'Programacion Orientada a Objetos Avanzada'
                s3.put()
            if not subject_management().find_name('Algoritmos'):
                s4 = Subject()
                s4.name = 'Algoritmos'
                s4.put()
            if not subject_management().find_name('Circuitos Digitales'):
                s5 = Subject()
                s5.name = 'Circuitos Digitales'
                s5.put()
            if not unit_management().get_unit_by_name('Introduccion a Java'):
                subject = subject_management().find_name(
                    'Programacion Orientada a Objetos')
                unit_management().add('Introduccion a Java', subject.key(), 1)
                sleep(0.1)
                unit_management().add('Variables, objetos y clases',
                                      subject.key(), 2)
                sleep(0.1)
                unit_management().add('Codificacion de imagenes',
                                      subject.key(), 3)
                sleep(0.1)
                unit_management().add('Ambiente de ejecucion y arreglos',
                                      subject.key(), 4)
                sleep(0.1)
                unit_management().add('Topicos avanzados de java',
                                      subject.key(), 5)
                sleep(0.1)
                unit_management().add('Manejo de Excepciones', subject.key(),
                                      6)
                sleep(0.1)
                unit_management().add('Recursos Escenciales de Java',
                                      subject.key(), 7)
                sleep(0.1)
                unit_management().add('Hilos', subject.key(), 8)
                sleep(0.1)
                unit_management().add('Manipulacion de medios', subject.key(),
                                      9)
                sleep(0.1)
            # Action().deleteall()
            # StudentRecords().deleteall()
            self.response.write(index_template.render(template_values))

            return 0
        elif user == user_type.student:
            self.redirect('/explorer')
            return 1
        else:
            self.redirect('/home')
            return 2
Exemple #12
0
	def get(self):
		user = self.get_user_type()
		if user == user_type.visitor:
			self.redirect('/')
		elif user == user_type.student:			
			if not 'video-id' in self.session:
				self.session['video-id'] = None
			video_content = ''
			if self.session['video-id'] == None:
				self.redirect('/home')

			try:
				video_id = int(self.session['video-id'])				
				video_instance = video_management().get_video(video_id)
				video_content = video_instance.content
			except ValueError:									
				video_content = ''		
			except TypeError:
				video_id = 0	

			template_values={
			    "user":"******",   
			    "header_welcome":"",
			    "header_user":"",
                "edit":False,
			    "video_content":video_content			    
			}
			self.response.write(datavideo_template.render(template_values))  			
		elif user == user_type.tutor:			
			video_material_id = self.request.get('video_material_id',None)
			if not 'video-id' in self.session:
				self.session['video-id'] = None
			if not 'name_file' in self.session:
				self.session['name_file'] = None	
			if not 'extension' in self.session:
				self.session['extension'] = None		

			if self.session['video-id'] == None and self.session['name_file'] == None and video_material_id is None:
				self.redirect('/home')
											
			video_format_allowed = ['mp4','wmv','mkv','ogg','webm']
			if not self.session['extension'] in video_format_allowed and video_material_id is None:
				self.redirect('/upload_video')

			tutor_id = self.session['user-id']
			tutor_key = tutor_management().get_tutor(tutor_id).key()
			tutor_instance = tutor_management().get_tutor(tutor_id)
				
			if video_material_id:			
				video_material_id = int(video_material_id)	
				video_material_instance = video_material_management().get_video_material(video_material_id)
				video_instance = video_material_management().get_video(video_material_instance)									
				vinfo = {}                                
				vinfo['topic'] = video_material_instance.topic
				vinfo['description'] = video_instance.description
				vinfo['level'] = video_material_instance.level
				vinfo['tags'] = video_material_instance.tags
				video_content = video_instance.content
				l_u=[]
				sub = subject_management().get_subject_by_name('Programacion Orientada a Objetos')
				list_unit = unit_management().get_all_units_of_subject(sub.key())		
				
				for u in list_unit:
					_u = {}
					_u['name'] = u.name
					_u['id'] = u.key().id()
					l_u.append(_u)			
				template_values = {
					"user":"******",
					"vinfo":vinfo,
					"video_content":video_content,
					"list_unit":l_u,
					"name_file":self.session['name_file'],
                    "edit":True,
					"tutor_name": tutor_instance.first,
					"video_material_id":video_material_id
				}
			else:
				video_content = ''
				l_s = []
				l_u=[]
				try:
					video_id = int(self.session['video-id'])				
					video_instance = video_management().get_video(video_id)
					video_content = video_instance.content
				except ValueError:									
					video_content = ''		
				except TypeError:
					video_id = 0
				sub = subject_management().get_subject_by_name('Programacion Orientada a Objetos')
				list_unit = unit_management().get_all_units_of_subject(sub.key())		
				
				for u in list_unit:
					_u = {}
					_u['name'] = u.name
					_u['id'] = u.key().id()
					l_u.append(_u)

				template_values={
					"user":"******",   
					"header_welcome":"",
					"header_tutor":"",
					"video_content":video_content,
					"list_unit":l_u,
					"name_file":self.session['name_file'],
					"tutor_name": tutor_instance.first,
					"video_material_id":"",
				}        
			self.response.write(datavideo_template.render(template_values))			
		else:
			self.redirect('/')
Exemple #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
Exemple #14
0
    def post(self):
        user = self.get_user_type()
        if user == user_type.visitor:
            self.redirect('/')
            return 0
        elif user == user_type.student:
            self.redirect('/home')
            return 1

        elif user == user_type.tutor:

            id_exam = self.request.get('id_exam', None)

            list_questions_aux = []
            if (id_exam):
                id_exam = int(id_exam)
                exam = exam_management().find_exam(id_exam)
                for q in exam.questions:
                    q = exam_management().find_question(q.id())
                    list_questions_aux.append(q)

            self.response.write(len(list_questions_aux))

            tutor_id = self.session['user-id']
            tutor_key = tutor_management().get_tutor(tutor_id)

            id_unit = int(self.request.get('unit_exam', None))
            unit = unit_management().get_unit(id_unit)

            name_exam = self.request.get('name_exam', None)
            topic_exam = self.request.get('topic_exam', None)

            learning_type = int(self.request.get('learning_type', None))
            level = int(self.request.get('level', None))

            subject = subject_management().get_subject_by_name(
                'Programacion Orientada a Objetos')

            count_questions = int(self.request.get('count_questions', None))

            answers = []
            list_questions = []
            correct_answers = []
            cout_images = 0

            for i in range(count_questions):
                q = Question()
                q.text = self.request.get('Q_' + str(i + 1), None)
                q.value = int(self.request.get('PossPtsQ_' + str(i + 1), None))

                answers.append(
                    self.request.get('Q_' + str(i + 1) + '_A_' + '1', None))
                answers.append(
                    self.request.get('Q_' + str(i + 1) + '_A_' + '2', None))
                answers.append(
                    self.request.get('Q_' + str(i + 1) + '_A_' + '3', None))
                answers.append(
                    self.request.get('Q_' + str(i + 1) + '_A_' + '4', None))
                q.answers = answers

                if (self.request.get('Q_' + str(i + 1) + '_ChkBox_' + '1')):
                    correct_answers.append(1)
                if (self.request.get('Q_' + str(i + 1) + '_ChkBox_' + '2')):
                    correct_answers.append(2)
                if (self.request.get('Q_' + str(i + 1) + '_ChkBox_' + '3')):
                    correct_answers.append(3)
                if (self.request.get('Q_' + str(i + 1) + '_ChkBox_' + '4')):
                    correct_answers.append(4)
                q.correct_answers = correct_answers

                if (id_exam and i < len(list_questions_aux)):
                    q.image = list_questions_aux[i].image

                if (self.request.get('Q_I' + str(i + 1))):
                    q.image = self.get_uploads()[cout_images]
                    cout_images = cout_images + 1

                q = q.put()

                list_questions.append(q)

            if (id_exam):
                exam.delete()
            exam_management().add(name_exam, tutor_key, learning_type, level,
                                  unit, topic_exam, list_questions, subject)
            self.redirect('/admin_exam')

            return 2
        else:
            self.redirect('/')

            return 3
Exemple #15
0
	def get(self):
		user = self.get_user_type()
		if user == user_type.visitor:
			self.redirect('/')
		elif user == user_type.student:			
			if not 'text-id' in self.session:
				self.session['text-id'] = None
			text_content = ''
			if self.session['text-id'] == None:
				self.redirect('/home')

			try:
				text_id = int(self.session['text-id'])				
				text_instance = text_management().get_text(text_id)
				text_content = text_instance.content
			except ValueError:									
				text_content = ''		
			except TypeError:
				text_id = 0	

			template_values={
			    "user":"******",   
			    "header_welcome":"",
			    "header_user":"",
			    "text_content":text_content			    
			}
			self.response.write(data_text_template.render(template_values))  			
		elif user == user_type.tutor:			
			text_material_id = self.request.get('text_material_id',None)
			if not 'text-id' in self.session:
				self.session['text-id'] = None
			if not 'name_file' in self.session:
				self.session['name_file'] = None	
			if not 'name_file' in self.session:
				self.session['extension'] = None		
			
			if self.session['text-id'] == None and self.session['name_file'] == None and text_material_id is None:
				self.redirect('/home')
											
			text_format_allowed = ['pdf']

			tutor_id = self.session['user-id']
			tutor_key = tutor_management().get_tutor(tutor_id).key()
			tutor_instance = tutor_management().get_tutor(tutor_id)
				
			if text_material_id:				
				text_material_id = int(text_material_id)
				text_material_instance = text_material_management().get_text_material(text_material_id)
				text_instance = text_material_management().get_text(text_material_instance)
				tinfo = {}                                
				tinfo['topic'] = text_material_instance.topic
				tinfo['description'] = text_instance.description
				tinfo['level'] = text_material_instance.level
				tinfo['tags'] = text_material_instance.tags
				text_content = text_instance.content
				subject = subject_management().get_subject_by_name('Programacion Orientada a Objetos')
				subject_units = unit_management().get_all_units_of_subject(subject.key())
				list_units = []
				for unit in subject_units:
					uinfo = {}
					uinfo['name'] = unit.name
					uinfo['id'] = unit.key().id()
					list_units.append(uinfo)				
				template_values = {
					"user":"******",
					"tinfo":tinfo,
					"edit":True,
					"text_content":text_content,
					"list_units":list_units,
					"name_file":self.session['name_file'],
					"tutor_name": tutor_instance.first,
					"text_material_id":text_material_id
				}				
			else:
				text_content = ''
				try:
					text_id = int(self.session['text-id'])				
					text_instance = text_management().get_text(text_id)
					text_content = text_instance.content
				except ValueError:									
					text_content = ''		
				except TypeError:
					text_id = 0
				subject = subject_management().get_subject_by_name('Programacion Orientada a Objetos')
				subject_units = unit_management().get_all_units_of_subject(subject.key())
				list_units = []
				for unit in subject_units:
					uinfo = {}
					uinfo['name'] = unit.name
					uinfo['id'] = unit.key().id()
					list_units.append(uinfo)
				template_values={
					"user":"******",   
					"header_welcome":"",
					"edit":False,
					"header_tutor":"",
					"text_content":text_content,
					"list_units":list_units,
					"name_file":self.session['name_file'],
					"tutor_name": tutor_instance.first,
					"text_material_id":""
				}        
			self.response.write(data_text_template.render(template_values))			
		else:
			self.redirect('/')
Exemple #16
0
	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