def access(self, exam_id, **kw):
        
        exam_collection = Exam()
        metric_preprocessor = MetricPreProcessor()
        client_preprocessor = ClientPreProcessor()
        db_pre_processor = DBPreProcessor()
        
        exam_doc = exam_collection.query_doc(exam_id)
        #print exam_data
        
        exam_dict = db_pre_processor.unicode_dict_from_DB_to_string(exam_doc)
        
        packet_to_metric = metric_preprocessor.produce_packet(exam_dict)
        
        #print "TEST\n", packet_to_metric

        """ Calculate the statistics information """
        statistics_info = after(packet_to_metric)

        print statistics_info
        
        """ Prepare information that will send to client """
        exam_doc['practices'] = client_preprocessor.dict_to_list(exam_doc['practices'])
        exam_doc['practices'] = client_preprocessor.sort_by_id(exam_doc['practices'])
        exam_doc['practices'] = client_preprocessor.add_key_from_list(exam_doc['practices'],'correct_rate',statistics_info['correct_rate'])
        exam_doc['practices'] = client_preprocessor.add_key_from_list(exam_doc['practices'],'real_difficulty',statistics_info['real_difficulty'])

        exam = {
            'exam_doc':exam_doc,
            'exam_statics':statistics_info
        }
        
        return exam
Exemplo n.º 2
0
 def access(self, exam_id, **kw):
     
     exam_collection = Exam()
     metric_preprocessor = MetricPreProcessor()
     db_pre_processor = DBPreProcessor()
     
     exam_doc = exam_collection.query_doc(exam_id)
     #print exam_data
     
     exam_dict = db_pre_processor.unicode_dict_from_DB_to_string(exam_doc)
     
     packet_to_metric = metric_preprocessor.produce_packet(exam_dict)
     
     #for key, val in packet_to_metric.iteritems():
         #print '\n{} : {}\n'.format(key,val)
     
     return packet_to_metric
Exemplo n.º 3
0
    def access(self, exam_id, **kw):

        exam_collection = Exam()
        metric_preprocessor = MetricPreProcessor()
        client_preprocessor = ClientPreProcessor()
        db_pre_processor = DBPreProcessor()

        exam_doc = exam_collection.query_doc(exam_id)
        # print exam_data

        exam_dict = db_pre_processor.unicode_dict_from_DB_to_string(exam_doc)

        packet_to_metric = metric_preprocessor.produce_packet(exam_dict)

        """ Calculate the statistics information """
        statistics_info = all(packet_to_metric)

        """ Prepare information that will send to client """
        exam_doc["practices"] = client_preprocessor.dict_to_list(exam_doc["practices"])
        exam_doc["practices"] = client_preprocessor.sort_by_id(exam_doc["practices"])

        exam = {"exam_doc": exam_doc, "exam_statics": statistics_info}

        return exam