当前位置: 首页>>代码示例>>Python>>正文


Python Question.gql方法代码示例

本文整理汇总了Python中models.Question.gql方法的典型用法代码示例。如果您正苦于以下问题:Python Question.gql方法的具体用法?Python Question.gql怎么用?Python Question.gql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Question的用法示例。


在下文中一共展示了Question.gql方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import gql [as 别名]
    def get(self):
        numADQuestions = Question.gql('WHERE product = :1', 'ADSync').count()
        numSPQuestions = Question.gql('WHERE product = :1', 'SharePoint Web Part').count()
        numSSOQuestions = Question.gql('WHERE product = :1', 'SSO').count()

        values = { 'numADQuestions': numADQuestions, 'numSPQuestions': numSPQuestions, 'numSSOQuestions': numSSOQuestions }
        self.response.out.write(template.render('templates/index.html', values))
开发者ID:nmccarthy,项目名称:Yammer-Integration-Questionnaire,代码行数:9,代码来源:questionnaire.py

示例2: home

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import gql [as 别名]
def home():
    questions = Question.gql( "WHERE aproved = 'yes'" ).fetch(limit=100)
    if (len(questions) != 0 and questions != None):
        random.shuffle(questions)
        top_yes = Question.gql( "WHERE aproved = 'yes' AND vote_yes !=0 ORDER BY vote_yes DESC" ).fetch(limit=3)
        top_no = Question.gql( "WHERE aproved = 'yes' AND vote_no!=0 ORDER BY vote_no DESC" ).fetch(limit=3)
    else:
        """
        Nothing in the database, let's fill it up with some stock questions.
        """
        stock_questions = (
                "have DVDs",
                "have desktop computers",
                "have optical media in the same size and shape as CDs and DVDs",
                "have free bags with a purchase from a store",
                "have cheap wine in bottles",
                "have large grocery stores that you make orders from",
                "have CDs",
                "have written signatures on credit card receipts",
                "have paper receipts for purchases",
                "have large grocery stores that you visit in person",
                "have IPv4",
                "have credit cards based upon magnetic strips",
                "have voice-only phone calls",
                "have IPv6",
                "have refridgerator magnets",
                "have corks actually made out of cork",
                "have broadcast television",
            )
        for question in stock_questions:
            q = Question(question=question, vote_yes=0, vote_no=0, total=0, aproved="yes")
            q.save()
            questions.append(q)
            top_yes = questions
            top_no = questions
    top_yes = [i for i in top_yes if i.vote_yes != 0]
    top_yes = [
                {
                'question': entry.question,
                'key': entry.key(),
                'total': entry.total,
                'style': "style-" + str(int(float(Decimal(str(float(1.0*entry.vote_yes/entry.total)*100)).quantize(TWOPLACES)))),
                'percent': float(Decimal(str(float(1.0*entry.vote_yes/entry.total)*100)).quantize(TWOPLACES))
                } for entry in top_yes if entry.total != 0]
    top_yes.sort(lambda x, y: cmp(x['percent'], y['percent']), reverse=True)
    top_no = [i for i in top_no if i.vote_no != 0]
    top_no = [
                {
                'question': entry.question,
                'key': entry.key(),
                'total': entry.total,
                'style': "style-" + str(100- int(float(Decimal(str(float(1.0*entry.vote_no/entry.total)*100)).quantize(TWOPLACES)))),
                'percent': 100.00 - float(Decimal(str(float(1.0*entry.vote_no/entry.total)*100)).quantize(TWOPLACES))
                } for entry in top_no if entry.total != 0]
    top_no.sort(lambda x, y: cmp(x['percent'], y['percent']))
    return render_template('index.html', questions=questions, top_yes=top_yes, top_no=top_no)
开发者ID:johl,项目名称:futureproof,代码行数:58,代码来源:views.py

示例3: get_rev_set_raw

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import gql [as 别名]
def get_rev_set_raw(rev):
    qs = []
    #first object to be the description of the revision
    lect_class = LectClass.get(rev.lect_class)
    rev_desc = {
                'lecturer':rev.user.name,
                'institution':rev.user.institution,
                'title':rev.title,
                'class':lect_class.name,
                'description':rev.description,
                'created':rev.created.strftime("%B %d, %Y")
                }
    qs.append(rev_desc)
    questions = Question.gql('WHERE revision = :1',rev).fetch(100) #how do we fetch all the Qs?
    for q in questions:
        answers = Answer.gql('WHERE question=:1',q)
        ans = []
        for a in answers:
            ans.append(a.answer)
        question = {
                    'question':q.question.replace("\n","").replace("\r",""),
                    'answers':ans
                    }
        qs.append(question)
    return qs
开发者ID:BeyondeLabs,项目名称:quizer,代码行数:27,代码来源:explore.py

示例4: post

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import gql [as 别名]
    def post(self):
        newUser = Responder(name = self.request.get('name'), email = self.request.get('email'), company = self.request.get('company'))
        newUser.put()

        set = ResponseSet(product = 'ADSync', responder = newUser)
        set.put()

        adQuestions = Question.gql('WHERE product = :1', 'ADSync')

        htmlBody = '<h2>Response to ADSync Questionnaire</h2><p><i>Submitted by ' + newUser.name +', ' + newUser.email + '</i></p>'

        for adQuestion in adQuestions:
            responseText = self.request.get('response' + str(adQuestion.key().id()))
            response = Response(text = responseText, question = adQuestion, responseSet = set)
            response.put()
            htmlBody += '<h3>' + adQuestion.text + '</h3>' + '<p>' + response.text + '</p>'

        #send email notification
        sender = '[email protected]'
        recipients = ['[email protected]', '[email protected]', '[email protected]']
        sub = newUser.name + ' from ' + newUser.company + ' responded to the ADSync Questionnaire'
        plainBody = 'Get response here: http://yammerie.appspot.com/responsesets?id=' + str(set.key().id())

        mail.send_mail(sender, recipients, sub, plainBody, html = htmlBody)

        self.redirect('/adsuccess')
开发者ID:nmccarthy,项目名称:Yammer-Integration-Questionnaire,代码行数:28,代码来源:questionnaire.py

示例5: random_question

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import gql [as 别名]
def random_question(qid=None):
    """Return a random question that isn't the one this was linked from"""
    questions = Question.gql( "WHERE aproved = 'yes'" ).fetch(limit=100)
    if (not questions == None):
        questions = [question for question in questions if question.key() != qid]
        random.shuffle(questions)
        question = questions.pop()
        return redirect("/question/%s/" % question.key())
开发者ID:johl,项目名称:futureproof,代码行数:10,代码来源:views.py

示例6: get_rev_set

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import gql [as 别名]
def get_rev_set(rev):
    questions = Question.gql('WHERE revision = :1',rev).fetch(100) #how do we fetch all the Qs?
    qs = []
    for q in questions:
        answers = Answer.gql('WHERE question=:1',q)
        comments = QuestionComment.gql('WHERE question=:1',q)
        comments_ = []
        for c in comments:
            c_ = {
                  'comment':c.comment,
                  'ckey':c.key().__str__(),
                  'user':QAUser.get(c.ukey)
                  }
            comments_.append(c_)

        question = {
                    'question':q,
                    'qkey':q.key().__str__(),
                    'answers':answers,
                    'comments':comments_,
                    'comment_count':comments.count()
                    }
        qs.append(question)
    return qs
开发者ID:BeyondeLabs,项目名称:quizer,代码行数:26,代码来源:explore.py


注:本文中的models.Question.gql方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。