Example #1
0
    def has_new_question(self):
        questions = AnswerModel.get_active_questions(g.lti.get_user_id(),
                                                    g.lti.get_course_id())

        if len(questions) == 0:
            return json.dumps({'has_new': False})
        
        output = { 'has_new': True, 'len': len(questions) } 
        array = []        
        
        for question in questions:        
            time_remaining = question.get_time_left()
            
            answer_text = ''
            if AnswerModel.check_answer_exists(g.lti.get_user_id(), question.id) == 1:
                answer_text = AnswerModel.by_id(AnswerModel.get_answer_id(g.lti.get_user_id(), question.id)).text
            
            object = {'question_id': question.id,
                      'question_text': question.question,
                      'time_remaining': time_remaining,
                      'question_time': question.time,
                      'answer':answer_text}        
                      
            array.append(object)
       
        output['questions'] = array
        
        return json.dumps(output)
Example #2
0
 def calc_new_trust(self):
     winner    = AnswerModel.get_by_answer_id(self.best_answer_id)
     loser     = AnswerModel.get_by_answer_id(self.other_answer_id)
     new_trust = UserModel.newTrust(winner.userID, loser.userID)
     UserModel.setTrust(winner.userID,new_trust[0])
     UserModel.setTrust(loser.userID,new_trust[1])
     
 def test_3savereview(self):
     AnswerModel.savereview(999,9999,'TEST',1)
     obj = None
     try:
         obj = session.query(AnswerModel).filter_by(questionID=999,userID=9999).one()
     except:
         pass
     self.assertTrue(obj is not None)
 def test_2save(self):
     AnswerModel.save(101,1234,'TEST')
     obj = None
     try:
         obj = session.query(AnswerModel).filter_by(questionID=101,userID=1234).one()
     except:
         pass
     self.assertTrue(obj is not None)
Example #5
0
 def test_4remove_by_id(self):
     AnswerModel.remove_by_id(1)
     obj = None
     try:
         obj = session.query(AnswerModel).filter_by(id=1).one()
     except:
         pass
     self.assertTrue(obj is None)
Example #6
0
 def test_1get_all(self):
     AnswerModel.save(100,1234,'TEST')
     obj = None
     try:
         obj = AnswerModel().get_all()
     except:
         pass
     self.assertTrue(obj is not None)
 def test_4updateAnswer(self):
     AnswerModel.updateAnswer(1,'NEW')
     obj = None
     try:
         obj = session.query(AnswerModel).filter_by(id=1,text="NEW").one()
     except:
         pass
     self.assertTrue(obj is not None)
Example #8
0
 def test_3by_ids(self):
     AnswerModel.save(101,1234,'TEST')
     ids = [1, 2]
     obj = None
     try:
         obj = AnswerModel().by_ids(ids)
     except:
         pass
     self.assertTrue(obj is not None)
Example #9
0
    def toggle_options(args):
            try:
                type = args['type']
            except KeyError:
                return

            question = Question.by_id(args['id'])
            if question is None:
                return

            if not g.lti.is_instructor() and type != 'Reviewable':
                return

            if question.state == 'Answerable' and (type == 'Inactive' or type == 'Reviewable' or type == 'Archived'):
                AnswerModel.update_q_history(args['id'])

            rv = None
            if type == 'Inactive':
                rv = question.inactive = True
                question.answerable = question.reviewable = question.closed = False
                question.state = 'Inactive'

            if type == 'Answerable':
                rv = question.answerable = True
                question.activate_time = datetime.now()
                question.inactive = question.reviewable = question.closed = False
                question.state = 'Answerable'

            elif type == 'Reviewable':
                if not question.reviewable:
                    Scheduler(args['id'])
                    question.reviewable = True
                rv = question.reviewable
                question.inactive = question.answerable = question.closed = False
                question.state = 'Reviewable'

            elif type == 'Closed':
                rv = question.closed = True
                question.inactive = question.answerable = question.reviewable = False
                question.state = 'Closed'

            elif type == 'comments':
                rv = question.comment = not question.comment

            elif type == 'tags':
                rv = question.tags = not question.tags

            elif type == 'rating':
                rv = question.rating = not question.rating

            session.commit()
            return json.dumps({"toggle": rv, "check": True})
Example #10
0
    def save():
        try:
            questionid = int(request.values['questionid'])
            question = Question.by_id(questionid)
            text = request.values['text']
            userid = g.lti.get_user_id()
        except:
            return abort(404)

        if AnswerModel.question_valid(questionid) and text != "":
            AnswerModel.save(questionid, userid, text)

        return redirect('/index_student')
 def calc_new_trust(self):
     print "GET HERE "
     winner    = AnswerModel.get_by_answer_id(self.best_answer_id)
     loser     = AnswerModel.get_by_answer_id(self.other_answer_id)
     winner_h  = UserHistoryModel.get_by_user_id(winner.userID)
     loser_h   = UserHistoryModel.get_by_user_id(loser.userID)
     new_trust = UserModel.newTrust(winner.userID, loser.userID)
     #UserHistoryModel(winner.userID, new_trust[0], winner_h.answered, winner_h.asked)
     #UserHistoryModel(loser.userID, new_trust[1], loser_h.answered, loser_h.asked) 
     session.add(UserHistoryModel(winner.userID, new_trust[0], 17, 22))
     session.commit()
     session.add(UserHistoryModel(loser.userID, new_trust[1], 17, 25))
     session.commit()
     
 def test_5getAnswerID(self):
     id = None
     try:
         id = AnswerModel.getAnswerID(1234,101)
     except:
         pass
     self.assertTrue(id is not None)
 def test_6checkAnswerExist(self):
     bool = None
     try:
         bool = AnswerModel.checkAnswerExist(1234,101)
     except:
         pass
     self.assertTrue(bool is 1)
 def test_7get_unanswered_questions(self):
     obj = None
     try:
         obj = AnswerModel.get_unanswered_questions(1,1)
     except:
         pass
     self.assertTrue(obj is not None)        
 def test_8getTimeStamp(self):
     date = None
     try:
         date = AnswerModel.getTimeStamp(1)
     except:
         pass
     self.assertTrue(date is not None)       
Example #16
0
 def __init__(self, question_id):
     schedule_list = []
     user_list = []
     scores = []
     
     answers = AnswerModel.get_question_answers(question_id)
     for a in answers:
         uid = a.userID
         scores.append((UserModel.getTrust(uid), a))
         user_list.append(a.userID)
         
     scores.sort(key=lambda tup: tup[0])
     
     # TODO: possibly change fixed percentage to variable
     # IMPORTANT: users that did not give an answer should be able to rate,
     # not sure if that will happen right now
     #
     # initial scheduler
     shift_count = len(scores) - max(1, int(len(scores) * 0.2))
     user_list = user_list[shift_count:] + user_list[0:shift_count]
     
     for x in xrange(0, len(scores)):
         a_id = scores[x][1].id
         u_id = user_list[x]
         schedule_list.append((a_id, u_id))
     
     Schedule.add_list(schedule_list)
         
Example #17
0
    def __init__(self, answer_id):
        self.answer_id = answer_id
        self.answer = AnswerModel.by_id(answer_id)
        if self.answer == None:
            self.answer = "Error, Answer not found"

        fsession['assigntag'] = str(answer_id)
Example #18
0
    def get_answer(user_id):
        answer_id = session.query(Schedule.answer_id).filter(
            Schedule.user_id == user_id).first()

        if answer_id is not None:
            return AnswerModel.by_id(answer_id[0])
        
        return None
Example #19
0
    def get_filtered(self,limit=None,offset=None):
        args = self.get_args_for_filter()

        if len(args) > 0:
            if offset is None or limit is None:
                return answer.AnswerModel.get_filtered(**args)
            else:
                return answer.AnswerModel.get_filtered_offset(limit,
                                                              offset,
                                                              orderby='created',
                                                              **args)
        else:
            if offset is None or limit is None:
                return AnswerModel.get_filtered()
            else:
                return AnswerModel.get_filtered_offset(limit,
                                                       offset,
                                                       orderby='created')
Example #20
0
 def export_course(course_id, export_answers=True):
     questions = Question.by_course_id(course_id)
     ret = []
     for question in questions:
         q = {'question': question.question}
         if export_answers:
             answers = AnswerModel.get_filtered(questionID=question.id)
             q['answers'] = []
             for x in answers:
                 q['answers'].append(x.text)
         ret.append(q)
     return ret
Example #21
0
    def delete_question(qid):
        '''removes the question with the provided id from the database'''
        question = Question.by_id(int(qid))
        if g.lti.is_instructor():
            session.delete(question)
            #Delete answers
            quid = {"questionID": int(qid)}
            answers = AnswerModel.get_filtered(**quid)
            for x in answers:
                session.delete(x)
            session.commit()

        return json.dumps({'deleted': g.lti.is_instructor()})
Example #22
0
 def render(self):
     try:
         questionid = int(request.values['questionid'])
         answerid1 = int(request.values['answerid1'])
         answerid2 = int(request.values['answerid2'])
     except:
         return abort(404)
         
     try:
         question = Question.by_id(questionid)
         answer1 = AnswerModel.by_id(answerid1)
         answer2 = AnswerModel.by_id(answerid2)
     except:
         return abort(404)
         
     if AnswerModel.question_valid(questionid):
         return render_template('choice.html',
                                question = question,
                                answer1 = answer1,
                                answer2 = answer2)
     else:
         return redirect('/choicelobby?question_id=' + questionid)
Example #23
0
 def getotheranswers(userID,questionID):
     allanswers = (AnswerModel.get_all())
     allanswerchoices = (AnswerChoiceModel.get_all())
     validAnswers = []
     for currentanswer in allanswers:
         # if relevant answer and not submitted by the current user
         if currentanswer.userID != userID and currentanswer.questionID == questionID:
             shouldadd = True
             for currentanswerchoice in allanswerchoices:
                 # if answer was not rated before by the current user
                 if (currentanswerchoice.best_answer_id == currentanswer.id or currentanswerchoice.other_answer_id == currentanswer.id) and currentanswerchoice.user_id == userID:
                     break
             else: validAnswers.append(currentanswer.id)
         
     return validAnswers
Example #24
0
 def viewAnswer(self):
     aid = int(request.form['id'])
     return render_template('editanswer.html', answer=AnswerModel.by_id(aid))
Example #25
0
    def put(self):
        request_data = Answer.parser.parse_args()

        try:
            answer = AnswerModel.find_by_id(request_data['answer_id'])

            if not answer:
                answer = AnswerModel(request_data['answer_id'],
                                     request_data['quiz_id'],
                                     request_data['body'],
                                     request_data['is_correct'],
                                     request_data['path_to_attachment'],
                                     request_data['is_selected'])
            else:  # if 'answer' is defined, this means there's an existing record under this ID, so update it with the values we have

                if request_data['answer_id'] != None:
                    answer.answer_id = request_data['answer_id']

                if request_data['quiz_id'] != None:
                    answer.quiz_id = request_data['quiz_id']

                if request_data['body'] != None:
                    answer.body = request_data['body']

                if request_data['is_correct'] != None:
                    answer.is_correct = request_data['is_correct']

                if request_data['path_to_attachment'] != None:
                    answer.path_to_attachment = request_data[
                        'path_to_attachment']

                if request_data['is_selected'] != None:
                    answer.is_selected = request_data['is_selected']
        except:
            return {
                'message':
                'An error occurred while reading the answer ID from the database'
            }, 500

        try:
            answer.save_to_database()
            return answer.json()
        except:
            return {
                'message':
                'An error occurred while updating the answer in the database'
            }, 500
Example #26
0
 def calcNewRating(self):
     newRating = AnswerModel.newRating(self.best_answer_id, self.other_answer_id)
     AnswerModel.setRanking(self.best_answer_id, newRating[0])
     AnswerModel.setRanking(self.other_answer_id, newRating[1])
Example #27
0
def test_db():
    from models.user import UserModel, RoleModel

    student = RoleModel('student')
    instructor = RoleModel('instructor')
    db.session.add_all([student, instructor])
    db.session.commit()
    bart = UserModel('bart',
                     'bart',
                     'bart',
                     'student',
                     firstname=None,
                     lastname=None,
                     picture=None)
    lisa = UserModel('lisa',
                     'lisa',
                     'lisa',
                     'student',
                     firstname=None,
                     lastname=None,
                     picture=None)
    millhouse = UserModel('millhouse',
                          'millhouse',
                          'millhouse',
                          'student',
                          firstname=None,
                          lastname=None,
                          picture=None)
    edna = UserModel('edna',
                     'edna',
                     'edna',
                     'instructor',
                     firstname=None,
                     lastname=None,
                     picture=None)
    simour = UserModel('simour',
                       'simour',
                       'simour',
                       'instructor',
                       firstname=None,
                       lastname=None,
                       picture=None)
    db.session.add_all([bart, lisa, millhouse, edna, simour])
    db.session.commit()
    print('::: test roles and users ::: ok')
    ###################
    print('students')
    for student in student.users:
        print('>>> {}'.format(student.username))
    print('instructors')
    for instructor in instructor.users:
        print('>>> {}'.format(instructor.username))
    ###################

    from models.course import CourseModel
    from models.category import CategoryModel

    maths = CategoryModel('maths', fr_label=None, en_label=None, picture=None)
    english = CategoryModel('english',
                            fr_label=None,
                            en_label=None,
                            picture=None)
    db.session.add_all([maths, english])
    db.session.commit()
    math_course = CourseModel('mathematics',
                              'basic operations',
                              simour.id,
                              maths.id,
                              picture=None)
    english_course = CourseModel('english',
                                 'grammar',
                                 edna.id,
                                 english.id,
                                 picture=None)
    db.session.add_all([math_course, english_course])
    db.session.commit()
    math_course.register_student(bart.id)
    math_course.register_student(lisa.id)
    english_course.register_student(lisa.id)
    english_course.register_student(millhouse.id)
    db.session.commit()
    print('::: test categories and courses ::: ok')
    ###################
    print('students enrolled in math')
    for student in math_course.students:
        print('>>> {}'.format(student.username))
    print('author of math_course')
    print('>>> {}'.format(math_course.author.username))
    print('edna published courses')
    for course in edna.published_courses:
        print('>>> {} - {}'.format(course.title, course.category.name))
    ###################

    from models.chapter import ChapterModel
    from models.quiz import QuizModel
    from models.question import QuestionModel
    from models.answer import AnswerModel

    chapter1 = ChapterModel('adds', '2 + 2 = 4', 1, math_course.id)
    chapter2 = ChapterModel('subs', '2 - 2 = 0', 2, math_course.id)
    db.session.add_all([chapter1, chapter2])
    db.session.commit()
    quiz1 = QuizModel('first grade', 1, math_course.id)
    quiz2 = QuizModel('second grade', 2, math_course.id)
    db.session.add(quiz1)
    db.session.add(quiz2)
    db.session.commit()
    question1 = QuestionModel('1 + 1?', 1, 2, quiz1.id)
    db.session.add(question1)
    db.session.commit()
    answer1 = AnswerModel('0', 1, question1.id)
    db.session.add(answer1)
    answer2 = AnswerModel('2', 2, question1.id)
    db.session.add(answer2)
    question2 = QuestionModel('3 - 1?', 2, 1, quiz1.id)
    db.session.add(question2)
    answer3 = AnswerModel('2', 1, question2.id)
    db.session.add(answer3)
    answer4 = AnswerModel('4', 2, question2.id)
    db.session.add(answer4)
    db.session.commit()
    print('::: test chapters and quizzes and questions and answers ::: ok')
    ###################
    print('chapters in math_course')
    for chapter in math_course.chapters:
        print('>>> {}'.format(chapter.title))
    print('quizzes in math_course')
    for quiz in math_course.quizzes:
        print('>>> {}'.format(quiz.title))
    print('questions in quiz1')
    for question in quiz1.questions:
        print('>>> {}'.format(question.question))
    print('answers in question1')
    for answer in question1.answers:
        print('>>> {}'.format(answer.answer))
    print('for question1 the good answer is number {}'.format(
        question1.good_answer))
    current_question = question1.question
    good_answer = AnswerModel.query.filter_by(
        number=question1.good_answer).first()
    print('question: {} | response: {}'.format(current_question,
                                               good_answer.answer))
    ###################

    from models.comment import CommentModel
    from models.rating import RatingModel

    comment1 = CommentModel('hay caramba', 'hay caramba', math_course.id,
                            bart.id)
    comment2 = CommentModel('retention', 'retention', math_course.id,
                            simour.id)
    comment3 = CommentModel('eat my short', 'eat my short', math_course.id,
                            bart.id)
    db.session.add_all([comment1, comment2, comment3])
    db.session.commit()
    rate1 = RatingModel(5, english_course.id, lisa.id)
    rate2 = RatingModel(3, english_course.id, millhouse.id)
    db.session.add_all([rate1, rate2])
    db.session.commit()
    print('::: test comments and ratings ::: ok')
    ###################
    print('comments in math_course')
    for comment in math_course.comments:
        print('>>> {} by {}'.format(comment.title, comment.author.username))
    print('ratings in english_course')
    for rate in english_course.ratings:
        print('>>> {}/5 by {}'.format(rate.rate, rate.author.username))
    ###################

    from models.badge import BadgeModel
    from models.score import ScoreModel

    score = ScoreModel(2, 2, lisa.id, quiz1.id)
    db.session.add(score)
    db.session.commit()
    badge = BadgeModel('honor', math_course.id, lisa.id)
    db.session.add(badge)
    db.session.commit()
    print('::: test scores and badges ::: ok')
    ###################
    print('badges earned by lisa')
    for badge in lisa.badges:
        print('>>> {}'.format(badge.name))
    print('scores in quiz1')
    for score in quiz1.scores:
        print('>>> {} by {}'.format(score.score, score.student.username))
 def calc_new_rating(self):
     K = UserModel.getTrust(self.user_id) / 20.0
     new_rating = AnswerModel.new_rating(self.best_answer_id, self.other_answer_id, K)
     AnswerModel.set_ranking(self.best_answer_id, new_rating[0])
     AnswerModel.set_ranking(self.other_answer_id, new_rating[1])
Example #29
0
def insert_test_data(): # these are queries used only for inserting test data, this should not be needed once the form to make quizzes is implemented
    # Topic 1 - Child Protection Policy
    TopicModel(1, 1, 'Child Protection Policy', 100).save_to_database()
    # Test 1
    TestModel(1, 1, 1, 30, 1, 0, 15, None, 'This test will cover the introduction to Child Protection Policy.', 1, 1).save_to_database()
    # Quiz 1
    QuizModel(1, 1, 1, 10, 0, 'multiple_choice', 'What should be avoided except in emergencies?', None, 'Question 1', 'To complete this quiz please select an answer and then click next. You can, however, come to the question later and change your answer.').save_to_database()
    AnswerModel(1, 1, 'Spending time alone with children away from others', 1, None, 0).save_to_database()
    AnswerModel(2, 1, 'Making sport fun and enjoyable', 0, None, 0).save_to_database()
    AnswerModel(3, 1, 'Promoting fair play', 0, None, 0).save_to_database()
    # Quiz 2
    QuizModel(2, 1, 2, 10, 0, 'multiple_choice', 'Choose the most appropriate from the following options that best describes the aim of the Child Protection Policy:', None, 'Question 2', 'To complete this quiz please select an answer and then click next').save_to_database()
    AnswerModel(4, 2, 'Children should be safely protected with appropriate gear, so that we can minimize injuries to happen', 0, None, 0).save_to_database()
    AnswerModel(5, 2, 'Make sure that every young person can integrate with each other, in a safe and positive environment', 0, None, 0).save_to_database()
    AnswerModel(6, 2, 'Promoting good practice by providing young people with appropriate safety and protection, whilst in care of Slum Soccer', 1, None, 0).save_to_database()
    # Quiz 3 - Info Page
    QuizModel(3, 1, 3, 0, 0, 'info', 'Any  suspicion  that  a  child  has  been  abused  by  either a  member of  staff  or a  volunteer should  be reported  to  the  Slum  Soccer  Child  Protection  Officer, who  will take  such  steps  as considered necessary  to  ensure  the  safety  of  the  child  in  question  and  any  other child  who  may  be  at  risk. The  Slum  Soccer  Child  Protection  Officer will  refer the  allegation  to  the  social services department  who  may  involve  the  police. The  parents  or carers  of  the  child  will be  contacted  as soon  as possible  following  advice  from the  social services  department. The  Slum  Soccer  Child  Protection  Officer should  also  notify  the  relevant  Sport  Governing Body  officer who  in  turn  will inform  the  Sport  Governing  Body  Child  Protection  Officer who  will deal with  any  media  enquiries. If  the  Slum  Soccer  Child  Protection  Officer is the  subject  of  the  suspicion/allegation,  the  report must  be  made  to  the  appropriate  Manager or  in  his/her absence  the  Sport Governing Body  Child  Protection  Officer who  will  refer  the  allegation  to  Social  Services. ', 'cps.jpg', 'Reporting  concerns about  suspected abuse ', 'Read carefully the text and when you are ensure you understand everything, click next. You won t be able to return to this page when you leave it, so read carefully.').save_to_database()
    # Quiz 4
    QuizModel(4, 1, 4, 10, 0, 'multiple_choice', 'If there is suspicion that a child has been abused by either a member of staff or a volunteer, what is the order of people/roles to be appointed and the steps as considered necessary to be undertaken?', None, 'Question 4', 'To complete this quiz please select an answer and then click next').save_to_database()
    AnswerModel(10, 4, 'It should be reported to the appropriate Manager who will refer to the Slum Soccer Child Protection Officer who will contact the police or any social services department', 0, None, 0).save_to_database()
    AnswerModel(11, 4, 'It should be reported to the Slum Soccer Child Protection Officer, who will refer to the social services department. He should also notify the relevant Sport Governing body office',1, None, 0).save_to_database()
    AnswerModel(12, 4, 'It should be reported to the police that after their investigations, will contact the Slum Soccer Child Protection Officer, who will inform the Sport Governing Body Child Protection Officer', 0, None, 0).save_to_database()

    # Test 2
    TestModel(2, 1, 1, 40, 2, 0, 20, None, 'This test tests you on the aim of the Child Protection Policy. You have only one attempt for this test.', 0, 1).save_to_database()
    # Quiz 1 - Info Page
    QuizModel(5, 2, 1, 0, 0, 'info', 'Slum Soccer has a duty of care to safeguard all children involved in Slum Soccer from harm. All children have a right to protection, and the needs of disabled children and others who may be particularly vulnerable must be taken into account. Slum Soccer will ensure the safety and protection of all children involved in Slum Soccer through adherence to the Child Protection guidelines adopted by Slum Soccer. A child is defined as a person under the age of 18.', None, 'Aim of the Child Protection Policy', 'After leaving this page you won t be able to return. Read carefully.').save_to_database()
    # Quiz 2
    QuizModel(6, 2, 2, 10, 0, 'multiple_choice', 'What children does Slum Soccer ensures safety and protection to?', None, 'Question 1', 'Select your answer and click on continue...').save_to_database()
    AnswerModel(13, 6, 'All children around the globe', 0, None, 0).save_to_database()
    AnswerModel(14, 6, 'All children involved in Slum Soccer', 1, None, 0).save_to_database()
    AnswerModel(16, 6, 'All children involved in Slum Soccer who have a signature from their parents', 0, None, 0).save_to_database()
    # Quiz 3
    QuizModel(7, 2, 3, 10, 0, 'multiple_choice', 'What is the correct statement from the choices bellow?', None, 'Question 2', 'Select one answer from the answers provided. Only one of them is correct. When you feel ready click continue to continue with the test.').save_to_database()
    AnswerModel(17, 7, 'A child is defined as a person between 5 and 18 years of age.', 0, None, 0).save_to_database()
    AnswerModel(18, 7, 'Disabled children don t need to be taken into account as all children should be treated equally.', 0, None, 0).save_to_database()
    AnswerModel(19, 7, 'Slum Soccer has a duty of care to safeguard all children involved in Slum Soccer from Slum Soccer enemies.', 0, None, 0).save_to_database()
    AnswerModel(20, 7, 'Adherance to the Child Protection guidelines ensures the safety and protection of children in Slum Soccer.', 1, None, 0).save_to_database()
    # Quiz 4 - Info Page
    QuizModel(8, 2, 4, 0, 0, 'info', 'The aim of the Slum Soccer Child Protection Policy is to promote good practice by: Firstly, providing children and young people with appropriate safety and protection whilst in the care of Slum Soccer. Sceondly, allow all staff/volunteers to make informed and confident responses to specific child protection issues.', None, 'Policy Aims', 'After leaving this page you won t be able to return. Read carefully.').save_to_database()
    # Quiz 5
    QuizModel(9, 2, 5, 10, 0, 'multiple_choice', 'What is the aim of Slum Soccer Child Protectiion Policy?', None, 'Question 3', 'Select one answer from the answers bellow. Only one of them answers the question correctly. When you feel ready click continue.').save_to_database()
    AnswerModel(21, 9, 'Spread the awaraness of endangerment of human children.', 0, None, 0).save_to_database()
    AnswerModel(22, 9, 'Promote good practice.', 1, None, 0).save_to_database()
    AnswerModel(23, 9, 'Advertise Slum Soccer practices.', 0, None, 0).save_to_database()
    # Quiz 6
    QuizModel(10, 2, 6, 10, 0, 'multiple_choice', 'What doesn t belong among the aims of the Slum Soccer Child Protection Policy?', None, 'Question 4', 'Only one of them answers is incorrect. Select your answer and when you feel ready click continue.').save_to_database()
    AnswerModel(24, 10, 'Allow all staff /volunteers to make informed and confident responses to specific child protection issues.', 0, None, 0).save_to_database()
    AnswerModel(25, 10, 'Providing children and young people with appropriate safety and protection whilst in the care of Slum Soccer.', 0, None, 0).save_to_database()
    AnswerModel(26, 10, 'Find the most gifted children withing the Slum Soccer and train them to join Slum Soccer Professional Children League.', 1, None, 0).save_to_database()

    # Test 3 - empty an locked
    TestModel(3, 1, 0, 50, 3, 0, 25, None, 'This test might looked locked as of now. It is because it is locked and you cannot access it right now.', 1, 1).save_to_database()
    # Test 4 - empty an locked
    TestModel(4, 1, 0, 50, 4, 0, 25, None, 'Can t you believe this? This is locked too. What a nightmare... Maybe you should work harder to unlock it. Or maybe this is just an empty test to show how an unlocked test looks like, since it s quite difficult to create a new test.', 0, 1).save_to_database()
    
    # Topic 2 - Another Topic
    TopicModel(2, 1, 'Another Topic', 120).save_to_database()
    # Test 1
    TestModel(5, 2, 1, 50, 1, 0, 25, None, 'This is a practice test teaching you about colours. IT s not official so you can take it as often as you wish.', 1, 0).save_to_database()
    # Quiz 1 - Info page
    QuizModel(11, 5, 1, 0, 0, 'info', 'The ability of the human eye to distinguish colors is based upon the varying sensitivity of different cells in the retina to light of different wavelengths. Humans are trichromatic—the retina contains three types of color receptor cells, or cones. One quiz_type, relatively distinct from the other two, is most responsive to light that is perceived as blue or blue-violet, with wavelengths around 450 nm; cones of this quiz_type are sometimes called short-wavelength cones or S cones (or misleadingly, blue cones). The other two types are closely related genetically and chemically: middle-wavelength cones, M cones, or green cones are most sensitive to light perceived as green, with wavelengths around 540 nm, while the long-wavelength cones, L cones, or red cones, are most sensitive to light that is perceived as greenish yellow, with wavelengths around 570 nm. Light, no matter how complex its composition of wavelengths, is reduced to three color components by the eye. Each cone quiz_type adheres to the principle of univariance, which is that each cone s output is determined by the amount of light that falls on it over all wavelengths. For each location in the visual field, the three types of cones yield three signals based on the extent to which each is stimulated. These amounts of stimulation are sometimes called tristimulus values. The response curve as a function of wavelength varies for each quiz_type of cone. Because the curves overlap, some tristimulus values do not occur for any incoming light combination. For example, it is not possible to stimulate only the mid-wavelength so-called green cones; the other cones will inevitably be stimulated to some degree at the same time. The set of all possible tristimulus values determines the human color space. It has been estimated that humans can distinguish roughly 10 million different colors. The other quiz_type of light-sensitive cell in the eye, the rod, has a different response curve. In normal situations, when light is bright enough to strongly stimulate the cones, rods play virtually no role in vision at all.[12] On the other hand, in dim light, the cones are understimulated leaving only the signal from the rods, resulting in a colorless response. Furthermore, the rods are barely sensitive to light in the red range. In certain conditions of intermediate illumination, the rod response and a weak cone response can together result in color discriminations not accounted for by cone responses alone. These effects, combined, are summarized also in the Kruithof curve, that describes the change of color perception and pleasingness of light as function of temperature and intensity. SOURCE: https://en.wikipedia.org/wiki/Color', 'eye.jpg', 'Colours in the eye', 'This is an info page... read carefully. PICTURE SOURCE: https://en.wikipedia.org/wiki/Human_eye').save_to_database()
    # Quiz 2
    QuizModel(12, 5, 2, 10, 0, 'multiple_choice', 'What is the opposite colour of blue?', None, 'Question 1', 'Only one of them answers is correct. Select your answer and when you feel ready click continue.').save_to_database()
    AnswerModel(27, 12, 'Red', 0, None, 0).save_to_database()
    AnswerModel(28, 12, 'Yellow', 1, None, 0).save_to_database()
    AnswerModel(29, 12, 'Purple', 0, None, 0).save_to_database()
    # Quiz 3
    QuizModel(13, 5, 3, 10, 0, 'multiple_choice', 'What colour is on the picture?', 'red.jpg', 'Question 2', 'Only one of them answers is correct. Select your answer and when you feel ready click continue. PICTURE SOURCE: https://colourlex.com/project/chrome-red/').save_to_database()
    AnswerModel(30, 13, 'Red', 1, None, 0).save_to_database()
    AnswerModel(31, 13, 'Blue', 0, None, 0).save_to_database()
    # Quiz 4
    QuizModel(14, 5, 4, 10, 0, 'multiple_choice', 'What color reflects all colours?', None, 'Question 3', 'Only one of them answers is correct. Select your answer and when you feel ready click continue.').save_to_database()
    AnswerModel(32, 14, 'Yellow', 0, None, 0).save_to_database()
    AnswerModel(33, 14, 'Red', 0, None, 0).save_to_database()
    AnswerModel(34, 14, 'Black', 0, None, 0).save_to_database()
    AnswerModel(35, 14, 'White', 1, None, 0).save_to_database()
    AnswerModel(36, 14, 'Green', 0, None, 0).save_to_database()
    # Quiz 5 - Info page
    QuizModel(15, 5, 5, 0, 0, 'info', 'While the mechanisms of color vision at the level of the retina are well-described in terms of tristimulus values, color processing after that point is organized differently. A dominant theory of color vision proposes that color information is transmitted out of the eye by three opponent processes, or opponent channels, each constructed from the raw output of the cones: a red–green channel, a blue–yellow channel, and a black–white luminance channel. This theory has been supported by neurobiology, and accounts for the structure of our subjective color experience. Specifically, it explains why humans cannot perceive a reddish green or yellowish blue, and it predicts the color wheel: it is the collection of colors for which at least one of the two color channels measures a value at one of its extremes. The exact nature of color perception beyond the processing already described, and indeed the status of color as a feature of the perceived world or rather as a feature of our perception of the world—a quiz_type of qualia—is a matter of complex and continuing philosophical dispute. https://en.wikipedia.org/wiki/Color', 'brain.jpg', 'Colour in the brain', 'This information should be read carefully. You might not be able to see this page again. PICTURE SOURCE: https://slate.com/technology/2016/03/how-big-is-the-brain-who-knows-even-our-best-efforts-to-calculate-its-capacity-are-flawed-and-meaningless.html').save_to_database()
    # Quiz 6
    QuizModel(16, 5, 6, 10, 0, 'multiple_choice', 'How many hemispheres does human brain have?', None, 'Question 4', 'Only one of them answers is correct. Select your answer and when you feel ready click continue.').save_to_database()
    AnswerModel(37, 16, 'Two', 1, None, 0).save_to_database()
    AnswerModel(38, 16, 'None', 0, None, 0).save_to_database()
    # Quiz 7
    QuizModel(17, 5, 7, 10, 0, 'multiple_choice', 'Do all animals see the same colours?', None, 'Question 5', 'Only one of them answers is correct. Select your answer and when you feel ready click continue.').save_to_database()
    AnswerModel(39, 17, 'No', 1, None, 0).save_to_database()
    AnswerModel(40, 17, 'Yes', 0, None, 0).save_to_database()
    
    # Test 2
    TestModel(6, 2, 1, 20, 2, 0, 10, None, 'Koalas.. just koalas', 1, 1).save_to_database()
    # Quiz 1 - Info page
    QuizModel(18, 6, 1, 0, 0, 'info', 'This is a video about koalas, watch it.', 'https://www.youtube.com/embed/oI3ADcDH0Uc', 'Koalas', 'Watch it carefully and as many times as you want. However when you leave this page you cannot return. VIDEO SOURCE: https://www.youtube.com/watch?v=oI3ADcDH0Uc').save_to_database()
    # Quiz 2
    QuizModel(19, 6, 2, 10, 0, 'multiple_choice', 'How many species of Eucalypt do koalas prefer?', None, 'Question 1', 'Only one of them answers is correct. Select your answer and when you feel ready click continue.').save_to_database()
    AnswerModel(41, 19, '3', 0, None, 0).save_to_database()
    AnswerModel(42, 19, '30', 1, None, 0).save_to_database()
    AnswerModel(43, 19, '65', 0, None, 0).save_to_database()
    AnswerModel(44, 19, '6', 0, None, 0).save_to_database()
    AnswerModel(45, 19, '650', 0, None, 0).save_to_database()
    # Quiz 3
    QuizModel(20, 6, 3, 10, 0, 'multiple_choice', 'How many hours a day do koalas sleep?', 'https://www.youtube.com/embed/NnRcxHreJFM', 'Question 2', 'Only one of them answers is correct. Select your answer and when you feel ready click continue. VIDEO SOURCE: https://www.youtube.com/watch?v=NnRcxHreJFM').save_to_database()
    AnswerModel(46, 20, 'They can sleep for days.', 0, None, 0).save_to_database()
    AnswerModel(47, 20, 'Around 12 hours a day', 0, None, 0).save_to_database()
    AnswerModel(48, 20, 'Up to 20 hours a day.', 0, None, 0).save_to_database()
    AnswerModel(49, 20, 'Up to 22 hours a day.', 1, None, 0).save_to_database()
    

    # Test 3 - locked and empty
    TestModel(7, 2, 0, 20, 3, 0, 10, None, 'Just another empty test that you cannot see being empty.', 1, 1).save_to_database()
    # Test 4 - locked and empty
    TestModel(8, 2, 0, 20, 4, 0, 10, None, 'Empty as well...', 0, 0).save_to_database()
    # Test 5 - locked and empty
    TestModel(9, 2, 0, 20, 5, 0, 10, None, 'Nothing to see here', 0, 1).save_to_database()
    # Test 6 - locked and empty
    TestModel(10, 2, 0, 20, 6, 0, 10, None, 'Empty, lonely just incomplete...', 1, 0).save_to_database()

    # FA 1 - not started
    FormativeAssessmentModel(1, 2, 1, 1, 40, 0, None, 20, 'Write an essay of 2000 words comparing the life of koalas in captivity and in wilderness. You can gain maximum of 40 credits. For passing the module you need 20 credits. IMG SOURCE: https://en.wikipedia.org/wiki/Koala', 'Compare the life of koalas in captivity and in wilderness', 'koala.png', '1/6/2021', None, 0).save_to_database()
    # FA 2 - answered
    FormativeAssessmentModel(2, 2, 1, 2, 20, 0, 'my_colour_essay.docx', 10, 'Write an essay of 1500 words about the colour perception through a human eye. You can gain maximum of 20 credits. For passing the module you need 10 credits.', 'Colours through the eye', None, '20/4/2021', None, 0).save_to_database()
    # FA 3 - reviewed
    FormativeAssessmentModel(3, 2, 1, 3, 30, 16, 'self_reflection.docx', 15, 'Write a self reflection about your progress and improvements during this topic. It can be maximum 1000 words. You can gain maximum of 30 credits. For passing the module you need 15 credits. VIDEO SOURCE: https://www.youtube.com/watch?v=avHRLqVPYwg', 'Self reflection', 'https://www.youtube.com/embed/avHRLqVPYwg', '1/3/2021', 'Good job. But there is a lack of detail in the progress section. Be more specific about how you have improved.', 1). save_to_database()


    # Topic 3 - Yet One More Topic Here
    TopicModel(3, 0, 'Yet One More Topic Here', 250).save_to_database()
    # Test 1 - locked and empty
    TestModel(11, 3, 0, 100, 1, 0, 50, None, 'Very small locked test', 1, 0).save_to_database()
    # Test 2 - locked and empty
    TestModel(12, 3, 0, 100, 2, 0, 50, None, 'Sad test full of emptyness.', 1, 1).save_to_database()
    # Test 3 - locked and empty
    TestModel(13, 3, 0, 100, 3, 0, 50, None, 'The secrets you shall never see.', 1, 1).save_to_database()
    # Test 4 - locked and empty
    TestModel(14, 3, 0, 100, 4, 0, 50, None, 'Empty too...', 0, 0).save_to_database()
    # Test 5 - locked and empty
    TestModel(15, 3, 0, 100, 5, 0, 50, None, 'I was once unlocked I have hread..', 0, 1).save_to_database()

    # Topic 4 - Topic
    TopicModel(4, 0, 'Topic', 60).save_to_database()
    # Test 1 - locked and empty
    TestModel(16, 4, 0, 50, 1, 0, 25, None, 'Nothin..', 1, 0).save_to_database()
    # Test 2 - locked and empty
    TestModel(17, 4, 0, 50, 2, 0, 25, None, 'Empty', 1, 1).save_to_database()
    # FA 1
    FormativeAssessmentModel(4, 4, 1, 1, 20, 0, None, 10, 'Write an essay of 2000 words. You can gain maximum of 40 credits. For passing the module you need 20 credits.', 'Some title', None, '5/6/2021', None, 0).save_to_database()
    # FA 2
    FormativeAssessmentModel(5, 4, 1, 2, 20, 0, None, 10, 'Write an essay of 5000 words. You can gain maximum of 40 credits. For passing the module you need 20 credits.', 'Some title 2', None, '17/6/2021', None, 0).save_to_database()


    # Topic 5 - Topicnic
    TopicModel(5, 0, 'Topicnic', 12).save_to_database()
    # Test 1 - locked and empty
    TestModel(18, 5, 0, 5, 1, 0, 3, None, 'Locked test', 1, 0).save_to_database()
    # Test 2 - locked and empty
    TestModel(19, 5, 0, 5, 2, 0, 3, None, 'Test of emptyness.', 1, 1).save_to_database()
    # Test 3 - locked and empty
    TestModel(20, 5, 0, 5, 3, 0, 3, None, 'The secrets...', 1, 1).save_to_database()
    # Test 4 - locked and empty
    TestModel(21, 5, 0, 5, 4, 0, 3, None, 'Empty2', 0, 0).save_to_database()

    # Topic 6 - Topic of all the topics
    TopicModel(6, 0, 'Topic of all the topics', 5).save_to_database()
    # Test 1 - locked and empty
    TestModel(22, 6, 0, 10, 1, 0, 5, None, 'ONLY ONE TEST BUT IT S HARD', 1, 0).save_to_database()

    # Topic 7 - Topic as well
    TopicModel(7, 0, 'Topic as well', 500).save_to_database()
    # Test 1 - locked and empty
    TestModel(23, 7, 0, 333, 1, 0, 150, None, 'Smallest Test', 1, 0).save_to_database()
    # Test 2 - locked and empty
    TestModel(24, 7, 0, 333, 2, 0, 200, None, 'Smaller Test', 1, 1).save_to_database()
    # Test 3 - locked and empty
    TestModel(25, 7, 0, 334, 3, 0, 250, None, 'Small Test', 1, 1).save_to_database()

    # Topic 8 - Incomplete topic
    TopicModel(8, 0, 'Incomplete topic', 25).save_to_database()
    # Test 1 - locked and empty
    TestModel(26, 8, 0, 10, 1, 0, 5, None, 'Very small locked test', 1, 0).save_to_database()
    # Test 2 - locked and empty
    TestModel(27, 8, 0, 10, 2, 0, 5, None, 'VERY LOCKED.', 1, 1).save_to_database()
    # Test 3 - locked and empty
    TestModel(28, 8, 0, 10, 3, 0, 5, None, 'Nothing to see here in this world.', 1, 1).save_to_database()
    # Test 4 - locked and empty
    TestModel(29, 8, 0, 10, 4, 0, 5, None, 'Sorry, empty', 0, 0).save_to_database()
    # Test 5 - locked and empty
    TestModel(30, 8, 0, 10, 5, 0, 5, None, 'I am empty', 0, 1).save_to_database()
    # FA 1
    FormativeAssessmentModel(6, 8, 1, 1, 20, 0, None, 10, 'Write an essay of 5000 words. You can gain maximum of 40 credits. For passing the module you need 20 credits.', 'Some great title', None, '30/6/2021', None, 0).save_to_database()


    # Topic 9 - Very old topic
    TopicModel(9, 0, 'Very old topic', 75).save_to_database()
    # Test 1 - locked and empty
    TestModel(31, 9, 0,70, 1, 0, 35, None, 'I am first but locked.', 1, 0).save_to_database()
    # Test 2 - locked and empty
    TestModel(32, 9, 0, 70, 2, 0, 35, None, 'I am second but locked.', 1, 1).save_to_database()
Example #30
0
 def get(self, answer_id):
     answer = AnswerModel.find_by_id(answer_id)
     if answer:
         return answer.json()
     return {'message': 'Answer not found'}, 404
Example #31
0
 def get(self):
     return {'answeres': AnswerModel.query_all()}
Example #32
0
 def delete(self):
     AnswerModel.delete_all()
     return {'message': 'All answeres deleted'}
Example #33
0
 def render_results(self):
     qid = request.values["questionid"]
     answers = AnswerModel.get_answers_ordered_by_rank(qid)
     return render_template('rankresults.html', answers=answers)
Example #34
0
 def studenthistory_result(self):
     return render_template('studenthistory_result.html',
             studid=AnswerModel.get_answers_by_userid(request.values['sid']))