Example #1
0
__author__ = "Benjamin"

import ExerciseHandler

ExerciseHandler.setCsvPath("./exercises.csv")
ExerciseHandler.readCsv()
for ex in ExerciseHandler.exercises:
    print str(ex.id) + " " + ex.exerciseText
    for corAnswer in ex.correctAnswers:
        print corAnswer
    for wrongAnswer in ex.wrongAnswers:
        print wrongAnswer
Example #2
0
                for answeredExercise in user.questionAnswerMap:
                    if answeredExercise['id'] == exercise.id:
                        answeredCounter += 1
                        if answeredExercise['isCorrect'] == True:
                            answeredCorrectlyCounter += 1
                        answers.append({'user': user.userName, 'answer': answeredExercise['answer'],
                                        'isCorrect': answeredExercise['isCorrect']})

            question = {'exercise': exercise.exerciseText, 'correctAnswers': exercise.correctAnswers,
                        'answeredCorrectlyCounter': answeredCorrectlyCounter, 'answeredCounter': answeredCounter,
                        'answers': answers}
            questions.append(question)

        self.wfile.write(json.dumps(questions))


if __name__ == '__main__':
    exercisesPath = "./exercises.csv"
    ExerciseHandler.setCsvPath(exercisesPath)
    ExerciseHandler.readCsv()
    print "Read exercises from " + exercisesPath

    httpServer = BaseHTTPServer.HTTPServer
    myServer = httpServer((HOST_NAME, PORT), MyHandler)
    print time.asctime(), "Server Starts - %s:%s" % (HOST_NAME, PORT)
    try:
        myServer.serve_forever()
    except KeyboardInterrupt:
        pass
    myServer.server_close()
    print time.asctime(), "Server Stops - %s:%s" % (HOST_NAME, PORT)
Example #3
0
                            'isCorrect':
                            answeredExercise['isCorrect']
                        })

            question = {
                'exercise': exercise.exerciseText,
                'correctAnswers': exercise.correctAnswers,
                'answeredCorrectlyCounter': answeredCorrectlyCounter,
                'answeredCounter': answeredCounter,
                'answers': answers
            }
            questions.append(question)

        self.wfile.write(json.dumps(questions))


if __name__ == '__main__':
    exercisesPath = "./exercises.csv"
    ExerciseHandler.setCsvPath(exercisesPath)
    ExerciseHandler.readCsv()
    print "Read exercises from " + exercisesPath

    httpServer = BaseHTTPServer.HTTPServer
    myServer = httpServer((HOST_NAME, PORT), MyHandler)
    print time.asctime(), "Server Starts - %s:%s" % (HOST_NAME, PORT)
    try:
        myServer.serve_forever()
    except KeyboardInterrupt:
        pass
    myServer.server_close()
    print time.asctime(), "Server Stops - %s:%s" % (HOST_NAME, PORT)
Example #4
0
__author__ = 'Benjamin'

import ExerciseHandler

ExerciseHandler.setCsvPath("./exercises.csv")
ExerciseHandler.readCsv()
for ex in ExerciseHandler.exercises:
    print str(ex.id) + " " + ex.exerciseText
    for corAnswer in ex.correctAnswers:
        print corAnswer
    for wrongAnswer in ex.wrongAnswers:
        print wrongAnswer