def create_review_question(self): self.review_question = ReviewQuestion( challenge=self.challenge, order=1, text= "Can you find any additional material not included in this submission?" ) self.review_question.save()
def create_review_question(self): self.review_question = ReviewQuestion( challenge=self.challenge, order=1, text="Can you find any additional material not included in this submission?" ) self.review_question.save()
def init_data(): CommentsConfig.setup() number_of_users = 3 users = [] dummy_users = [] tutors = [] for i in range(number_of_users): print("adding student %s of %s" % (i, number_of_users)) username = "******" % i user = AuroraUser(username=username) user.email = '*****@*****.**' % username user.first_name = 'Firstname_%s' % username user.last_name = 'Lastname_%s' % username user.nickname = 'Nickname_%s' % username user.matriculation_number = "{0:0=2d}".format(i) + ''.join( ["%s" % random.randint(0, 9) for num in range(0, 5)]) user.is_staff = False user.is_superuser = False password = username user.set_password(password) user.save() users.append(user) s0 = users[0] # create the three dummy users for jumpstarting the peer review process for i in range(4): print("adding dummy user %s of %s" % (i, 4)) username = "******" % i dummy_user = AuroraUser(username=username) dummy_user.email = '*****@*****.**' % username dummy_user.first_name = 'Firstname_%s' % username dummy_user.last_name = 'Lastname_%s' % username dummy_user.nickname = 'Nickname_%s' % username dummy_user.is_staff = False dummy_user.is_superuser = False password = username dummy_user.set_password(password) dummy_user.save() dummy_users.append(dummy_user) d1 = dummy_users[0] d2 = dummy_users[1] d3 = dummy_users[2] d4 = dummy_users[3] # create an admin user with password amanaman print('adding superuser') username = "******" amanaman = AuroraUser(username=username) amanaman.first_name = 'Firstname_%s' % username amanaman.last_name = 'Lastname_%s' % username amanaman.nickname = 'Nickname_%s' % username amanaman.set_password(username) amanaman.is_staff = True amanaman.is_superuser = True amanaman.save() # create courses "GSI" and "HCI" if Course.objects.filter(short_title='gsi').exists(): gsi = Course.objects.get(short_title='gsi') else: print('adding course gsi') gsi = Course( title='Gesellschaftliche Spannungsfelder der Informatik', short_title='gsi', description='GSI Description', course_number='187.237', ) gsi.save() if Course.objects.filter(short_title='bhci').exists(): hci = Course.objects.get(short_title='bhci') elif Course.objects.filter(short_title='hci').exists(): hci = Course.objects.get(short_title='hci') else: print('adding course hci') hci = Course( title='Human Computer Interaction', short_title='hci', description='HCI Description', course_number='187.A21', ) hci.save() for user in users: CourseUserRelation(course=gsi, user=user).save() CourseUserRelation(course=hci, user=user).save() # create course-user relations print('adding course-user relations for dummy users') CourseUserRelation(course=gsi, user=d1).save() CourseUserRelation(course=hci, user=d1).save() CourseUserRelation(course=gsi, user=d2).save() CourseUserRelation(course=hci, user=d2).save() CourseUserRelation(course=gsi, user=d3).save() CourseUserRelation(course=hci, user=d3).save() CourseUserRelation(course=gsi, user=d4).save() CourseUserRelation(course=hci, user=d4).save() # create challenges print('adding challenges') challenge_1 = Challenge( id=1, title='Personalisieren', subtitle='Personalisieren', description= 'Setzen sie in ihrem Profil ein Avatar-Bild, das ein anderes ist als der Default. Achten sie dabei bitte darauf, dass die Abbildungen' ' weder rassistisch noch sexistisch sind. Es muss allerdings auch kein Foto von ihnen sein. Machen sie dann einen Screenshot, auf dem' ' ihr Avatar-Bild gut zu sehen ist, laden sie ihn hoch und geben sie das für diesen Task ab. Achten sie bitte darauf, dass ausser ihrem' ' Nickname keine anderen persönlichen Daten zu sehen sind.<br/><br/>' 'Anmerkung: so ein Screenshot muss nicht ihren ganzen Bildschirm zeigen. Es genügt, wenn man den für den Task jeweils wesentlichen ' 'Ausschnitt sieht.', accepted_files='image/*', course=gsi, ) challenge_1.image.save( '1.png', File(open(os.path.join(STATIC_ROOT, 'img', '1.png'), 'rb'))) challenge_1.save() ReviewQuestion(challenge=challenge_1, order=1, text="Wurde die Aufgabe im wesentlichen erfüllt?", boolean_answer=True).save() ReviewQuestion( challenge=challenge_1, order=2, text= "Falls nein: Beschreiben sie, warum die Aufgabe nicht erfüllt wurde!" ).save() ReviewQuestion(challenge=challenge_1, order=3, text="Finden sie den Avatar nett?", boolean_answer=True).save() challenge_2 = Challenge( id=2, title='Kommentieren', subtitle='Kommentieren', prerequisite=challenge_1, description= 'Posten sie einen Kommentar zu den Folien der ersten Vorlesung. Dieser soll entweder einen inhaltlichen Bezug zum Inhalt einer Folie' ' bzw. des entsprechenden Vorlesungsteils haben, oder auf den Kommentar einer Kollegin oder eines Kollegen antworten.<br/>' 'Achten sie auch hier darauf, dass ihre Äusserungen nicht rassistisch oder sexistisch sind, und streben sie ein dem universitären ' 'Umfeld entsprechendes Anspruchsniveau an. Auch wenn Diskussionen hitzig und/oder emotional sind, sollten gewisse Grenzen (Beleidigung, ' 'Herabwürdigung, Beschimpfung etc.) nicht überschritten werden.<br/><br/>' 'Machen sie dann einen Screenshot ihres Kommentars, laden sieh ihn für diesen Task hoch und geben sie ihn ab. Geben sie ausserdem ' 'den Titel der Folie an, zu der sie den Kommentar gepostet haben.', accepted_files='image/*', course=gsi, ) challenge_2.image.save( '2.png', File(open(os.path.join(STATIC_ROOT, 'img', '2.png'), 'rb'))) challenge_2.save() ReviewQuestion(challenge=challenge_2, order=1, text="Wurde die Aufgabe im wesentlichen erfüllt?", boolean_answer=True).save() ReviewQuestion( challenge=challenge_2, order=2, text= "Falls nein: Beschreiben sie, warum die Aufgabe nicht erfüllt wurde!" ).save() ReviewQuestion( challenge=challenge_2, order=3, text= "Gibt es inzwischen Antworten auf den Kommentar? Gehen sie dazu zu der angegebenen Folie, und schauen sie, ob der Kommentar zum Zeitpunkt ihres Reviews" " schon eine Antwort bekommen hat.", boolean_answer=True).save() challenge_3 = Challenge( id=3, title='Markieren', subtitle='Markieren', prerequisite=challenge_2, description= 'Markieren Sie Folien! Im Bereich »Slides« gibt es bei jeder Folie rechts oben drei »Lesezeichen«-Symbole, mit denen sie verwirrende ' 'Folien [??], wichtige Folien [!] und Folien, die ihnen gefallen [*], markieren können.<br/><br/>' 'Markieren sie aus der ersten Vorlesung jeweils mindestens eine Folie als [??], [!] und [*]. Öffnen sie dann die drei ' '»Lesezeichen«-Seiten (direkt im Slides-Bereich, zweite Zeile) und machen sie drei Screenshots, die die so markierten Folien zeigen.<br/>' 'Geben sie diese drei Screenshots ab.', accepted_files='image/*', course=gsi, ) challenge_3.image.save( '3.png', File(open(os.path.join(STATIC_ROOT, 'img', '3.png'), 'rb'))) challenge_3.save() ReviewQuestion(challenge=challenge_3, order=1, text="Wurde die Aufgabe im wesentlichen erfüllt?", boolean_answer=True).save() ReviewQuestion( challenge=challenge_3, order=2, text= "Falls nein: Beschreiben sie, warum die Aufgabe nicht erfüllt wurde!" ).save() challenge_4 = Challenge( id=4, title='Bewerten', subtitle='Bewerten', prerequisite=challenge_3, description= 'Bewerten sie einen oder mehrere Kommentare in den Slides mit Hilfe der Bewertungspfeile rechts oben im Kommentar. ' 'Setzen sie diese Funktion ein, um auszudrücken, ob sie den Kommentar inhaltlich lesenswert finden - oder eben nicht.<br/><br/>' 'Machen sie einen Screenshot von einem Kommentar, den sie bewertet haben, und geben sie diesen ab.', accepted_files='image/*', course=gsi, ) challenge_4.image.save( '4.png', File(open(os.path.join(STATIC_ROOT, 'img', '4.png'), 'rb'))) challenge_4.save() ReviewQuestion(challenge=challenge_4, order=1, text="Wurde die Aufgabe im wesentlichen erfüllt?", boolean_answer=True).save() ReviewQuestion( challenge=challenge_4, order=2, text= "Falls nein: Beschreiben sie, warum die Aufgabe nicht erfüllt wurde!" ).save() challenge_5 = Challenge( id=5, title='Vormerken', subtitle='Vormerken', prerequisite=challenge_4, description= 'Markieren sie Kommentare! Möchten sie einen Kommentar vormerken, zB. weil er wichtige Informationen enthält, oder weil' ' sie ihn weiter verfolgen möchten? Markieren sie mindestens einen Kommentar (im Newsfeed, in den Kommentaren, oder überall,' ' wo es Kommentare gibt) mit Hilfe der »BOOKMARK«-Funktion links unter dem Kommentar.<br/><br/>' 'Öffnen sie dann die »Bookmarks«-Seite (Hauptnavigation), und machen sie einen Screenshot von der Sammlung vorgemerkter ' 'Kommentare. Geben sie diesen Screenshot ab.', accepted_files='image/*', course=gsi, ) challenge_5.image.save( '5.png', File(open(os.path.join(STATIC_ROOT, 'img', '5.png'), 'rb'))) challenge_5.save() ReviewQuestion(challenge=challenge_5, order=1, text="Wurde die Aufgabe im wesentlichen erfüllt?", boolean_answer=True).save() ReviewQuestion( challenge=challenge_5, order=2, text= "Falls nein: Beschreiben sie, warum die Aufgabe nicht erfüllt wurde!" ).save() ReviewQuestion( challenge=challenge_5, order=3, text="Schätzen sie: wurden hier sinnvolle Kommentare markiert?", boolean_answer=True).save() challenge_6 = Challenge( id=6, title='Erwarten', subtitle='Erwarten', prerequisite=challenge_5, description= 'Was erwarten Sie sich von dieser Lehrveranstaltung? Was, meinen sie, werden sie hier lernen? Schreiben sie etwa einen Absatz' ' Text über ihre <b>inhaltlichen</b> Erwartungen an diese LVA. Schreiben sie als Abschluss einen Satz zu anderen Erwartungen' ' zu dieser Lehrveranstaltung (Organisation, Experience, Unterhaltungswert, etc.).', accepted_files='', course=gsi, ) challenge_6.image.save( '6.png', File(open(os.path.join(STATIC_ROOT, 'img', '6.png'), 'rb'))) challenge_6.save() challenge_7 = Challenge( id=7, title='Personalisieren', subtitle='Personalisieren', description= 'Setzen sie in ihrem Profil ein Avatar-Bild, das ein anderes ist als der Default. Achten sie dabei bitte darauf, dass die Abbildungen' ' weder rassistisch noch sexistisch sind. Es muss allerdings auch kein Foto von ihnen sein. Machen sie dann einen Screenshot, auf dem' ' ihr Avatar-Bild gut zu sehen ist, laden sie ihn hoch und geben sie das für diesen Task ab. Achten sie bitte darauf, dass ausser ihrem' ' Nickname keine anderen persönlichen Daten zu sehen sind.<br/><br/>' 'Anmerkung: so ein Screenshot muss nicht ihren ganzen Bildschirm zeigen. Es genügt, wenn man den für den Task jeweils wesentlichen ' 'Ausschnitt sieht.', accepted_files='image/*', course=hci, ) challenge_7.image.save( '1.png', File(open(os.path.join(STATIC_ROOT, 'img', '1.png'), 'rb'))) challenge_7.save() ReviewQuestion(challenge=challenge_7, order=1, text="Wurde die Aufgabe im wesentlichen erfüllt?", boolean_answer=True).save() ReviewQuestion( challenge=challenge_7, order=2, text= "Falls nein: Beschreiben sie, warum die Aufgabe nicht erfüllt wurde!" ).save() ReviewQuestion(challenge=challenge_7, order=3, text="Finden sie den Avatar nett?", boolean_answer=True).save() challenge_8 = Challenge( id=8, title='Kommentieren', subtitle='Kommentieren', prerequisite=challenge_7, description= 'Posten sie einen Kommentar zu den Folien der ersten Vorlesung. Dieser soll entweder einen inhaltlichen Bezug zum Inhalt einer Folie' ' bzw. des entsprechenden Vorlesungsteils haben, oder auf den Kommentar einer Kollegin oder eines Kollegen antworten.<br/>' 'Achten sie auch hier darauf, dass ihre Äusserungen nicht rassistisch oder sexistisch sind, und streben sie ein dem universitären ' 'Umfeld entsprechendes Anspruchsniveau an. Auch wenn Diskussionen hitzig und/oder emotional sind, sollten gewisse Grenzen (Beleidigung, ' 'Herabwürdigung, Beschimpfung etc.) nicht überschritten werden.<br/><br/>' 'Machen sie dann einen Screenshot ihres Kommentars, laden sieh ihn für diesen Task hoch und geben sie ihn ab. Geben sie ausserdem ' 'den Titel der Folie an, zu der sie den Kommentar gepostet haben.', accepted_files='image/*', course=hci, ) challenge_8.image.save( '2.png', File(open(os.path.join(STATIC_ROOT, 'img', '2.png'), 'rb'))) challenge_8.save() ReviewQuestion(challenge=challenge_8, order=1, text="Wurde die Aufgabe im wesentlichen erfüllt?", boolean_answer=True).save() ReviewQuestion( challenge=challenge_8, order=2, text= "Falls nein: Beschreiben sie, warum die Aufgabe nicht erfüllt wurde!" ).save() ReviewQuestion( challenge=challenge_8, order=3, text= "Gibt es inzwischen Antworten auf den Kommentar? Gehen sie dazu zu der angegebenen Folie, und schauen sie, ob der Kommentar zum Zeitpunkt ihres Reviews" " schon eine Antwort bekommen hat.", boolean_answer=True).save() challenge_9 = Challenge( id=9, title='Markieren', subtitle='Markieren', prerequisite=challenge_8, description= 'Markieren Sie Folien! Im Bereich »Slides« gibt es bei jeder Folie rechts oben drei »Lesezeichen«-Symbole, mit denen sie verwirrende ' 'Folien [??], wichtige Folien [!] und Folien, die ihnen gefallen [*], markieren können.<br/><br/>' 'Markieren sie aus der ersten Vorlesung jeweils mindestens eine Folie als [??], [!] und [*]. Öffnen sie dann die drei ' '»Lesezeichen«-Seiten (direkt im Slides-Bereich, zweite Zeile) und machen sie drei Screenshots, die die so markierten Folien zeigen.<br/>' 'Geben sie diese drei Screenshots ab.', accepted_files='image/*', course=hci, ) challenge_9.image.save( '3.png', File(open(os.path.join(STATIC_ROOT, 'img', '3.png'), 'rb'))) challenge_9.save() ReviewQuestion(challenge=challenge_9, order=1, text="Wurde die Aufgabe im wesentlichen erfüllt?", boolean_answer=True).save() ReviewQuestion( challenge=challenge_9, order=2, text= "Falls nein: Beschreiben sie, warum die Aufgabe nicht erfüllt wurde!" ).save() challenge_10 = Challenge( id=10, title='Bewerten', subtitle='Bewerten', prerequisite=challenge_9, description= 'Bewerten sie einen oder mehrere Kommentare in den Slides mit Hilfe der Bewertungspfeile rechts oben im Kommentar. ' 'Setzen sie diese Funktion ein, um auszudrücken, ob sie den Kommentar inhaltlich lesenswert finden - oder eben nicht.<br/><br/>' 'Machen sie einen Screenshot von einem Kommentar, den sie bewertet haben, und geben sie diesen ab.', accepted_files='image/*', course=hci, ) challenge_10.image.save( '4.png', File(open(os.path.join(STATIC_ROOT, 'img', '4.png'), 'rb'))) challenge_10.save() ReviewQuestion(challenge=challenge_10, order=1, text="Wurde die Aufgabe im wesentlichen erfüllt?", boolean_answer=True).save() ReviewQuestion( challenge=challenge_10, order=2, text= "Falls nein: Beschreiben sie, warum die Aufgabe nicht erfüllt wurde!" ).save() challenge_11 = Challenge( id=11, title='Vormerken', subtitle='Vormerken', prerequisite=challenge_10, description= 'Markieren sie Kommentare! Möchten sie einen Kommentar vormerken, zB. weil er wichtige Informationen enthält, oder weil' ' sie ihn weiter verfolgen möchten? Markieren sie mindestens einen Kommentar (im Newsfeed, in den Kommentaren, oder überall,' ' wo es Kommentare gibt) mit Hilfe der »BOOKMARK«-Funktion links unter dem Kommentar.<br/><br/>' 'Öffnen sie dann die »Bookmarks«-Seite (Hauptnavigation), und machen sie einen Screenshot von der Sammlung vorgemerkter ' 'Kommentare. Geben sie diesen Screenshot ab.', accepted_files='image/*', course=hci, ) challenge_11.image.save( '5.png', File(open(os.path.join(STATIC_ROOT, 'img', '5.png'), 'rb'))) challenge_11.save() ReviewQuestion(challenge=challenge_11, order=1, text="Wurde die Aufgabe im wesentlichen erfüllt?", boolean_answer=True).save() ReviewQuestion( challenge=challenge_11, order=2, text= "Falls nein: Beschreiben sie, warum die Aufgabe nicht erfüllt wurde!" ).save() ReviewQuestion( challenge=challenge_11, order=3, text="Schätzen sie: wurden hier sinnvolle Kommentare markiert?", boolean_answer=True).save() challenge_12 = Challenge( id=12, title='Erwarten', subtitle='Erwarten', prerequisite=challenge_11, description= 'Was erwarten Sie sich von dieser Lehrveranstaltung? Was, meinen sie, werden sie hier lernen? Schreiben sie etwa einen Absatz' ' Text über ihre <b>inhaltlichen</b> Erwartungen an diese LVA. Schreiben sie als Abschluss einen Satz zu anderen Erwartungen' ' zu dieser Lehrveranstaltung (Organisation, Experience, Unterhaltungswert, etc.).', accepted_files='', course=hci, ) challenge_12.image.save( '6.png', File(open(os.path.join(STATIC_ROOT, 'img', '6.png'), 'rb'))) challenge_12.save() # create stacks print('adding stack aurora gsi') aurora_gsi = Stack( title='Einstieg - Aurora kennenlernen', description= 'Diese Challenge soll ermöglichen, Aurora besser kennenzulernen, und gibt auch uns Gelegenheit, das System bei voller Nutzerlast testen zu können. ' 'Rechnen sie mit Problemen und Bugs, und nutzen sie gegebenenfalls bitte den Menüpunkt »Bugs & Feedback«, um diese zu dokumentieren.<br/><br/>' 'Im Gegensatz zu allen anderen Challenges sind sie bei diesen Tasks gegenüber ihren Kollegen im Review <b>nicht anonym</b>, da sie ja Screenshots ' 'abgeben, mit denen sie identifiziert werden können. Das ist leider unvermeidbar, und wird, wenn alles gut geht, die einzige Ausnahme bleiben.', course=gsi, ) aurora_gsi.save() print('adding aurora hci') aurora_hci = Stack( title='Einstieg - Aurora kennenlernen', description= 'Diese Challenge soll ermöglichen, Aurora besser kennenzulernen, und gibt auch uns Gelegenheit, das System bei voller Nutzerlast testen zu können. ' 'Rechnen sie mit Problemen und Bugs, und nutzen sie gegebenenfalls bitte den Menüpunkt »Bugs & Feedback«, um diese zu dokumentieren.' 'Im Gegensatz zu allen anderen Challenges sind sie bei diesen Tasks gegenüber ihren Kollegen im Review <b>nicht anonym</b>, da sie ja Screenshots ' 'abgeben, mit denen sie identifiziert werden können. Das ist leider unvermeidbar, und wird, wenn alles gut geht, die einzige Ausnahme bleiben.', course=hci, ) aurora_hci.save() # create stack-challenge relations print('adding stack challenge relations') StackChallengeRelation(stack=aurora_gsi, challenge=challenge_1).save() StackChallengeRelation(stack=aurora_gsi, challenge=challenge_2).save() StackChallengeRelation(stack=aurora_gsi, challenge=challenge_3).save() StackChallengeRelation(stack=aurora_gsi, challenge=challenge_4).save() StackChallengeRelation(stack=aurora_gsi, challenge=challenge_5).save() StackChallengeRelation(stack=aurora_gsi, challenge=challenge_6).save() StackChallengeRelation(stack=aurora_hci, challenge=challenge_7).save() StackChallengeRelation(stack=aurora_hci, challenge=challenge_8).save() StackChallengeRelation(stack=aurora_hci, challenge=challenge_9).save() StackChallengeRelation(stack=aurora_hci, challenge=challenge_10).save() StackChallengeRelation(stack=aurora_hci, challenge=challenge_11).save() StackChallengeRelation(stack=aurora_hci, challenge=challenge_12).save() print('Adding Sample Lectures') Lecture( course=gsi, start=datetime(2013, 2, 15, 15, 00, 17, 345952), end=datetime(2013, 2, 15, 17, 20, 17, 345952), active=True, ).save() Lecture( course=gsi, start=datetime(2013, 2, 16, 15, 00, 17, 345952), end=datetime(2013, 2, 16, 17, 20, 17, 345952), active=True, ).save() Lecture( course=gsi, start=datetime(2013, 2, 17, 15, 00, 17, 345952), end=datetime(2013, 2, 17, 17, 20, 17, 345952), active=True, ).save() # Lecture( # course=gsi, # start=datetime(2013, 2, 24, 15, 00, 17, 345952), # end=datetime(2014, 2, 24, 17, 20, 17, 345952), # active=True, # ).save() Lecture( course=hci, start=datetime(2013, 1, 15, 15, 00, 17, 345952), end=datetime(2013, 1, 15, 17, 20, 17, 345952), active=True, ).save() Lecture( course=hci, start=datetime(2013, 1, 16, 15, 00, 17, 345952), end=datetime(2013, 1, 16, 17, 20, 17, 345952), active=True, ).save() print('Adding Sample Slides') Slide( lecture_id=1, title="Preparation Slide #1 - Lecture 1", pub_date=datetime(2013, 2, 10, 15, 21, 17, 345952), filename="vo_10_02_13_1", tags='.preparation', ).save() Slide( lecture_id=1, title="Preparation Slide #2 - Lecture 1", pub_date=datetime(2013, 2, 10, 15, 22, 17, 345952), filename="vo_10_02_13_2", tags='.preparation', ).save() Slide( lecture_id=1, title="Preparation Slide #3 - Lecture 1", pub_date=datetime(2013, 2, 10, 15, 23, 17, 345952), filename="vo_10_02_13_3", tags='.preparation', ).save() Slide( lecture_id=1, title="Super Sample Slide #1 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 20, 17, 345952), filename="vo_15_02_13_1", tags='.exercise', ).save() Slide( lecture_id=1, title="Super Sample Slide #2 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 22, 17, 345952), filename="vo_15_02_13_2", ).save() Slide( lecture_id=1, title="Super Sample Slide #3 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 24, 17, 345952), filename="vo_15_02_13_3", ).save() Slide( lecture_id=1, title="Super Sample Slide #4 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 26, 17, 345952), filename="vo_15_02_13_4", ).save() Slide( lecture_id=1, title="Super Sample Slide #5 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 28, 17, 345952), filename="vo_15_02_13_5", tags='.exercise', ).save() Slide( lecture_id=1, title="Super Sample Slide #6 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 30, 17, 345952), filename="vo_15_02_13_6", ).save() Slide( lecture_id=1, title="Super Sample Slide #7 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 32, 17, 345952), filename="vo_15_02_13_7", ).save() Slide( lecture_id=1, title="Super Sample Slide #8 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 34, 17, 345952), filename="vo_15_02_13_8", ).save() Slide( lecture_id=1, title="Super Sample Slide #9 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 36, 17, 345952), filename="vo_15_02_13_9", tags='.exercise', ).save() Slide( lecture_id=2, title="Super Sample Slide #1 - Lecture 2", pub_date=datetime(2013, 2, 16, 15, 20, 17, 345952), filename="vo_16_02_13_1", ).save() Slide( lecture_id=2, title="Super Sample Slide #2 - Lecture 2", pub_date=datetime(2013, 2, 16, 15, 22, 17, 345952), filename="vo_16_02_13_2", ).save() Slide( lecture_id=2, title="Super Sample Slide #2 - Lecture 2", pub_date=datetime(2013, 2, 16, 15, 24, 17, 345952), filename="vo_16_02_13_3", ).save() Slide( lecture_id=3, title="Super Sample Slide #1 - Lecture 3", pub_date=datetime(2013, 2, 17, 15, 20, 17, 345952), filename="vo_17_02_13_1", ).save() Slide( lecture_id=3, title="Super Sample Slide #2 - Lecture 3", pub_date=datetime(2013, 2, 17, 15, 22, 17, 345952), filename="vo_17_02_13_2", tags='.exercise', ).save() print("Adding sample stream") Stream( lecture_id=1, url="rtmp://video.zserv.tuwien.ac.at/lecturetube_public", type="rtmp", clipname="gsiss13e10", offset=-656, ).save()
class ChallengeTest(TestCase): def setUp(self): self.create_test_users(4) self.create_course() self.create_stack() self.create_challenge() self.create_review_question() def create_test_user(self, username): user = AuroraUser(username=username) user.email = '%[email protected].' % username user.first_name = 'Firstname_%s' % username user.last_name = 'Lastname_%s' % username user.nickname = 'Nickname_%s' % username user.is_staff = False user.is_superuser = False password = username user.set_password(password) user.save() return user def create_test_users(self, amount): self.users = [] for i in range(amount): self.users.append(self.create_test_user("s%s" % i)) def create_course(self): self.course = Course( title='test_title', short_title='test_short_title', description='test_description', course_number='test_course_number', ) self.course.save() for user in self.users: CourseUserRelation(course=self.course, user=user).save() def create_stack(self): self.stack = Stack(title="test stack", description="test description", course=self.course) self.stack.save() def create_challenge(self): self.challenge = Challenge( title='test_title', subtitle='test_subtitle', description='test_description', course=self.course, ) self.challenge.save() StackChallengeRelation(stack=self.stack, challenge=self.challenge).save() def create_review_question(self): self.review_question = ReviewQuestion( challenge=self.challenge, order=1, text="Can you find any additional material not included in this submission?" ) self.review_question.save() def create_review(self, elaboration, reviewer): Review(elaboration=elaboration, submission_time=datetime.now(), reviewer=reviewer, appraisal='S').save() def test_next(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() assert challenge1.get_next() == challenge2 assert challenge2.get_next() == challenge3 assert challenge3.get_next() is None def test_get_elaboration(self): user = self.users[0] assert self.challenge.get_elaboration(user) is None elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test") elaboration.save() assert self.challenge.get_elaboration(user) == elaboration def test_get_stack(self): challenge = Challenge( title='test_title', subtitle='test_subtitle', description='test_description', course=self.course ) challenge.save() assert challenge.get_stack() is None assert self.challenge.get_stack() == self.stack def test_is_first_challenge(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() assert challenge1.is_first_challenge() assert not challenge2.is_first_challenge() assert not challenge3.is_first_challenge() def test_is_final_challenge(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() assert not challenge1.is_final_challenge() assert not challenge2.is_final_challenge() assert challenge3.is_final_challenge() def test_get_final_challenge(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() assert challenge1.get_final_challenge() == challenge3 assert challenge2.get_final_challenge() == challenge3 assert challenge3.get_final_challenge() == challenge3 def test_get_first_challenge(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() assert challenge1.get_first_challenge() == challenge1 assert challenge2.get_first_challenge() == challenge1 assert challenge3.get_first_challenge() == challenge1 def test_has_enough_user_reviews(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() user1 = self.users[0] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() user2 = self.users[1] elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() user3 = self.users[2] elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() user4 = self.users[3] elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert not challenge1.has_enough_user_reviews(user1) Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert not challenge1.has_enough_user_reviews(user1) Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert not challenge1.has_enough_user_reviews(user1) Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge1.has_enough_user_reviews(user1) def test_is_started(self): user = self.users[0] elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="") elaboration.save() assert self.challenge.is_started(user) is False elaboration.elaboration_text="test" elaboration.save() assert self.challenge.is_started(user) is True def test_submitted_by_user(self): user = self.users[0] elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test") elaboration.save() assert not self.challenge.submitted_by_user(user) elaboration.submission_time = datetime.now() elaboration.save() assert self.challenge.submitted_by_user(user) def test_get_review_written_by_user(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() user1 = self.users[0] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() user2 = self.users[1] elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() user3 = self.users[2] elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() user4 = self.users[3] elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert len(challenge1.get_reviews_written_by_user(user1)) == 0 review1 = Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS) review1.save() assert len(challenge1.get_reviews_written_by_user(user1)) == 1 assert review1 in challenge1.get_reviews_written_by_user(user1) review2 = Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS) review2.save() assert len(challenge1.get_reviews_written_by_user(user1)) == 2 assert review1 in challenge1.get_reviews_written_by_user(user1) assert review2 in challenge1.get_reviews_written_by_user(user1) review3 = Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS) review3.save() assert len(challenge1.get_reviews_written_by_user(user1)) == 3 assert review1 in challenge1.get_reviews_written_by_user(user1) assert review2 in challenge1.get_reviews_written_by_user(user1) assert review3 in challenge1.get_reviews_written_by_user(user1) def test_get_elaborations(self): assert len(self.challenge.get_elaborations()) == 0 user = self.users[0] elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test") elaboration.save() assert len(self.challenge.get_elaborations()) == 1 assert elaboration in self.challenge.get_elaborations() def test_first_challenge_is_always_enabled(self): user = self.users[0] assert self.challenge.is_enabled_for_user(user) def test_already_submitted_challenges_are_enabled(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() user = self.users[0] assert not challenge2.is_enabled_for_user(user) elaboration = Elaboration(challenge=challenge2, user=user, elaboration_text="test") elaboration.save() assert not challenge2.is_enabled_for_user(user) elaboration.submission_time = datetime.now() elaboration.save() assert challenge2.is_enabled_for_user(user) def test_enough_user_reviews_required(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert not challenge2.is_enabled_for_user(user1) Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert not challenge2.is_enabled_for_user(user1) Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert not challenge2.is_enabled_for_user(user1) Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge2.is_enabled_for_user(user1) def test_if_stack_blocked_challenge_is_not_enabled_fail(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge2.is_enabled_for_user(user1) Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.FAIL).save() # a failed review does not block the stack assert challenge2.is_enabled_for_user(user1) def test_if_stack_blocked_challenge_is_not_enabled_nothing(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge2.is_enabled_for_user(user1) Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.NOTHING).save() # nothing should not block a user from working assert challenge2.is_enabled_for_user(user1) def test_final_challenge_enabled(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert not challenge2.is_enabled_for_user(user1) Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() assert challenge2.is_enabled_for_user(user1) def test_final_challenge_enabled_bug_issue_114(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert not challenge3.is_enabled_for_user(user1) Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() assert not challenge3.is_enabled_for_user(user1) def test_status_not_started(self): user = self.users[0] assert self.challenge.is_enabled_for_user(user) assert self.challenge.get_status(user) == Challenge.NOT_STARTED def test_status_not_submitted(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() user = self.users[0] assert challenge1.get_status(user) == Challenge.NOT_STARTED elaboration = Elaboration(challenge=challenge1, user=user, elaboration_text="test") elaboration.save() assert challenge1.is_enabled_for_user(user) assert challenge1.get_status(user) == Challenge.NOT_SUBMITTED assert not challenge2.is_enabled_for_user(user) assert challenge2.get_status(user) == Challenge.NOT_ENABLED def test_status_blocked_bad_review_fail(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert not challenge2.is_enabled_for_user(user1) assert challenge1.get_status(user1) == Challenge.USER_REVIEW_MISSING assert challenge2.get_status(user1) == Challenge.NOT_ENABLED bad_review = Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.FAIL) bad_review.save() assert not challenge2.is_enabled_for_user(user1) assert challenge1.get_status(user1) == Challenge.USER_REVIEW_MISSING assert challenge2.get_status(user1) == Challenge.NOT_ENABLED bad_review.appraisal = Review.SUCCESS bad_review.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge1.has_enough_user_reviews(user1) assert challenge1.get_status(user1) == Challenge.DONE_MISSING_PEER_REVIEW assert challenge2.is_enabled_for_user(user1) assert challenge2.get_status(user1) == Challenge.NOT_STARTED bad_review.appraisal = Review.FAIL bad_review.save() assert challenge2.is_enabled_for_user(user1) assert challenge2.get_status(user1) == Challenge.NOT_STARTED def test_status_blocked_bad_review_nothing(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert not challenge2.is_enabled_for_user(user1) assert challenge1.get_status(user1) == Challenge.USER_REVIEW_MISSING assert challenge2.get_status(user1) == Challenge.NOT_ENABLED bad_review = Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.NOTHING) bad_review.save() assert not challenge2.is_enabled_for_user(user1) assert challenge1.get_status(user1) == Challenge.BLOCKED_BAD_REVIEW assert challenge2.get_status(user1) == Challenge.NOT_ENABLED bad_review.appraisal = Review.SUCCESS bad_review.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge1.has_enough_user_reviews(user1) assert challenge1.get_status(user1) == Challenge.DONE_MISSING_PEER_REVIEW assert challenge2.is_enabled_for_user(user1) assert challenge2.get_status(user1) == Challenge.NOT_STARTED bad_review.appraisal = Review.NOTHING bad_review.save() assert challenge2.is_enabled_for_user(user1) assert challenge2.get_status(user1) == Challenge.NOT_STARTED def test_status_user_review_missing(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert challenge1.is_enabled_for_user(user1) assert challenge1.get_status(user1) == Challenge.USER_REVIEW_MISSING assert not challenge2.is_enabled_for_user(user1) assert challenge2.get_status(user1) == Challenge.NOT_ENABLED Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge1.is_enabled_for_user(user1) assert challenge1.get_status(user1) == Challenge.USER_REVIEW_MISSING assert not challenge2.is_enabled_for_user(user1) assert challenge2.get_status(user1) == Challenge.NOT_ENABLED Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge1.is_enabled_for_user(user1) assert challenge1.get_status(user1) == Challenge.USER_REVIEW_MISSING assert not challenge2.is_enabled_for_user(user1) assert challenge2.get_status(user1) == Challenge.NOT_ENABLED Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge1.is_enabled_for_user(user1) assert challenge1.get_status(user1) == Challenge.DONE_MISSING_PEER_REVIEW assert challenge2.is_enabled_for_user(user1) assert challenge2.get_status(user1) == Challenge.NOT_STARTED def test_status_done_missing_peer_review(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge1.get_status(user1) == Challenge.DONE_MISSING_PEER_REVIEW Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() assert challenge1.get_status(user1) == Challenge.DONE_MISSING_PEER_REVIEW Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() assert challenge1.get_status(user1) == Challenge.DONE_MISSING_PEER_REVIEW def test_status_final_challenge(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() user1 = self.users[0] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() user2 = self.users[1] elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() user3 = self.users[2] elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() user4 = self.users[3] elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge1.get_status(user1) == Challenge.DONE_MISSING_PEER_REVIEW assert challenge2.get_status(user1) == Challenge.NOT_ENABLED Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() assert challenge1.get_status(user1) == Challenge.DONE_PEER_REVIEWED assert challenge2.get_status(user1) == Challenge.NOT_STARTED final_elaboration = Elaboration(challenge=challenge2, user=user1, elaboration_text="test", submission_time=datetime.now()) final_elaboration.save() assert challenge2.get_status(user1) == Challenge.WAITING_FOR_EVALUATION tutor = user4 tutor.staff = True tutor.save() Evaluation(submission=final_elaboration, tutor=tutor, evaluation_text="test evaluation", evaluation_points=10, submission_time=datetime.now()).save() assert challenge2.get_status(user1) == Challenge.EVALUATED
class SimpleTest(TestCase): def setUp(self): self.create_test_users(4) self.create_course() self.create_challenge() self.create_review_question() self.create_elaborations() def create_test_user(self, username): user = AuroraUser(username=username) user.email = '%[email protected].' % username user.first_name = 'Firstname_%s' % username user.last_name = 'Lastname_%s' % username user.nickname = 'Nickname_%s' % username user.is_staff = False user.is_superuser = False password = username user.set_password(password) user.save() return user def create_test_users(self, amount): self.users = [] for i in range(amount): self.users.append(self.create_test_user("s%s" % i)) def create_course(self): self.course = Course( title='test_title', short_title='test_short_title', description='test_description', course_number='test_course_number', ) self.course.save() for user in self.users: CourseUserRelation(course=self.course, user=user).save() def create_challenge(self): self.challenge = Challenge( title='test_title', subtitle='test_subtitle', description='test_description', course=self.course, ) self.challenge.save() def create_review_question(self): self.review_question = ReviewQuestion( challenge=self.challenge, order=1, text="Can you find any additional material not included in this submission?" ) self.review_question.save() def create_elaborations(self): self.elaborations = [] for user in self.users: elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test_text", submission_time=datetime.now()) elaboration.save() self.elaborations.append(elaboration) def create_review_without_submission_date(self, elaboration, reviewer): Review(elaboration=elaboration, reviewer=reviewer, appraisal='S').save() def create_review(self, elaboration, reviewer): Review(elaboration=elaboration, reviewer=reviewer, submission_time=datetime.now(), appraisal='S').save() def test_get_open_review(self): user1 = self.users[0] user2 = self.users[2] elaboration = self.elaborations[0] self.create_review_without_submission_date(elaboration=elaboration, reviewer=user1) # there should be an open review for user1 review = Review.get_open_review(self.challenge, user1) assert review assert review.reviewer == user1 assert review.elaboration == elaboration # there should be no open review for user1 since the review is already submitted review.submission_time = datetime.now() review.save() review = Review.get_open_review(self.challenge, user1) assert not review # there should be no open review for user2 review = Review.get_open_review(self.challenge, user2) assert not review # user1 and user2 both have separate open reviews self.create_review_without_submission_date(elaboration=elaboration, reviewer=user1) self.create_review_without_submission_date(elaboration=elaboration, reviewer=user2) review1 = Review.get_open_review(self.challenge, user1) review2 = Review.get_open_review(self.challenge, user2) assert review1 assert review2 assert review1.id != review2.id assert review1.reviewer == user1 assert review2.reviewer == user2 assert review1.elaboration == elaboration and review2.elaboration == elaboration def test_review_config_offset(self): assert ReviewConfig.get_candidate_offset_min() == 0 assert ReviewConfig.get_candidate_offset_max() == 0 ReviewConfig(candidate_offset_min=1, candidate_offset_max=2).save() assert ReviewConfig.get_candidate_offset_min() == 1 assert ReviewConfig.get_candidate_offset_max() == 2 def test_notification_too_soon(self): challenge1 = self.challenge challenge2 = Challenge( course=self.course, prerequisite=challenge1, ) challenge2.save() challenge3 = Challenge( course=self.course, prerequisite=challenge2, ) challenge3.save() stack = Stack(course=self.course) stack.save() StackChallengeRelation(stack=stack, challenge=challenge1).save() StackChallengeRelation(stack=stack, challenge=challenge2).save() StackChallengeRelation(stack=stack, challenge=challenge3).save() elab1 = challenge1.get_elaboration(self.users[0]) elab2 = Elaboration(challenge=challenge2, user=self.users[0]) elab2.save() assert stack.has_enough_peer_reviews(self.users[0]) is False Review(elaboration=elab2, reviewer=self.users[1], appraisal='S', submission_time=datetime.now()).save() Review(elaboration=elab2, reviewer=self.users[2], appraisal='S', submission_time=datetime.now()).save() assert stack.has_enough_peer_reviews(self.users[0]) is False Review(elaboration=elab1, reviewer=self.users[1], appraisal='S', submission_time=datetime.now()).save() Review(elaboration=elab1, reviewer=self.users[2], appraisal='S', submission_time=datetime.now()).save() assert stack.has_enough_peer_reviews(self.users[0]) is True
class StackTest(TestCase): def setUp(self): self.create_test_users(4) self.create_course() self.create_stack() self.create_challenge() self.create_review_question() def create_test_user(self, username): user = AuroraUser(username=username) user.email = '%[email protected].' % username user.first_name = 'Firstname_%s' % username user.last_name = 'Lastname_%s' % username user.nickname = 'Nickname_%s' % username user.is_staff = False user.is_superuser = False password = username user.set_password(password) user.save() return user def create_test_users(self, amount): self.users = [] for i in range(amount): self.users.append(self.create_test_user("s%s" % i)) def create_course(self): self.course = Course( title='test_title', short_title='test_short_title', description='test_description', course_number='test_course_number', ) self.course.save() for user in self.users: CourseUserRelation(course=self.course, user=user).save() def create_stack(self): self.stack = Stack(title="test stack", description="test description", course=self.course) self.stack.save() def create_challenge(self): self.challenge = Challenge( title='test_title', subtitle='test_subtitle', description='test_description', course=self.course, ) self.challenge.save() StackChallengeRelation(stack=self.stack, challenge=self.challenge).save() def create_review_question(self): self.review_question = ReviewQuestion( challenge=self.challenge, order=1, text= "Can you find any additional material not included in this submission?" ) self.review_question.save() def create_review(self, elaboration, reviewer): Review(elaboration=elaboration, submission_time=datetime.now(), reviewer=reviewer, appraisal='S').save() def test_get_challenges(self): challenge1 = self.challenge assert challenge1 in self.stack.get_challenges() self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() assert challenge1 in self.stack.get_challenges() assert challenge2 in self.stack.get_challenges() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() assert challenge1 in self.stack.get_challenges() assert challenge2 in self.stack.get_challenges() assert challenge3 in self.stack.get_challenges() def test_final_challenge(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() assert self.stack.get_final_challenge().id is challenge3.id def test_first_challenge(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() assert self.stack.get_first_challenge().id is challenge1.id def test_is_started(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user = self.users[0] elaboration = Elaboration(challenge=challenge1, user=user, elaboration_text="") elaboration.save() assert self.stack.is_started(user) is False elaboration.elaboration_text = "test" elaboration.save() assert self.stack.is_started(user) is True def test_is_evaluated(self): user = self.users[0] tutor = self.users[1] tutor.staff = True tutor.save() assert self.stack.is_evaluated(user) is False elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test elaboration", submission_time=datetime.now()) elaboration.save() evaluation = Evaluation(submission=elaboration, tutor=tutor, evaluation_text="test_evaluation") evaluation.save() assert self.stack.is_evaluated(user) is False evaluation.submission_time = datetime.now() evaluation.evaluation_points = 10 evaluation.save() assert self.stack.is_evaluated(user) is True def test_get_points(self): user = self.users[0] tutor = self.users[1] tutor.staff = True tutor.save() assert self.stack.get_points_earned(user) == 0 elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test elaboration", submission_time=datetime.now()) elaboration.save() evaluation = Evaluation(submission=elaboration, tutor=tutor, evaluation_text="test_evaluation", submission_time=datetime.now()) for points in range(10): evaluation.evaluation_points = points evaluation.save() assert self.stack.get_points_earned(user) == points def test_last_available_challenge(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert self.stack.get_last_available_challenge(user1) == challenge1 Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert self.stack.get_last_available_challenge(user1) == challenge2 Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() elaboration5 = Elaboration(challenge=challenge2, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration5.save() elaboration6 = Elaboration(challenge=challenge2, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration6.save() elaboration7 = Elaboration(challenge=challenge2, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration7.save() elaboration8 = Elaboration(challenge=challenge2, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration8.save() assert self.stack.get_last_available_challenge(user1) == challenge2 Review(elaboration=elaboration6, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration7, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration8, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert self.stack.get_last_available_challenge(user1) == challenge2 Review(elaboration=elaboration5, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration5, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() assert self.stack.get_last_available_challenge(user1) == challenge3 def test_is_blocked(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert not self.stack.is_blocked(user2) review = Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user2) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user2) assert not self.stack.is_blocked(user3) review = Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user3) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user3) assert not self.stack.is_blocked(user4) review = Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user4) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user4) assert not self.stack.is_blocked(user1) review = Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user1) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user1) review = Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user1) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user1) elaboration5 = Elaboration(challenge=challenge2, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration5.save() elaboration6 = Elaboration(challenge=challenge2, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration6.save() elaboration7 = Elaboration(challenge=challenge2, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration7.save() elaboration8 = Elaboration(challenge=challenge2, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration8.save() assert not self.stack.is_blocked(user2) review = Review(elaboration=elaboration6, submission_time=datetime.now(), reviewer=user1, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user2) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user2) assert not self.stack.is_blocked(user3) review = Review(elaboration=elaboration7, submission_time=datetime.now(), reviewer=user1, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user3) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user3) assert not self.stack.is_blocked(user4) review = Review(elaboration=elaboration8, submission_time=datetime.now(), reviewer=user1, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user4) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user4) assert not self.stack.is_blocked(user1) review = Review(elaboration=elaboration5, submission_time=datetime.now(), reviewer=user2, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user1) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user1) review = Review(elaboration=elaboration5, submission_time=datetime.now(), reviewer=user3, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user1) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user1) def test_has_enough_peer_reviews(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert not self.stack.has_enough_peer_reviews(user1) Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() assert not self.stack.has_enough_peer_reviews(user1) Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() assert not self.stack.has_enough_peer_reviews(user1) elaboration5 = Elaboration(challenge=challenge2, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration5.save() elaboration6 = Elaboration(challenge=challenge2, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration6.save() elaboration7 = Elaboration(challenge=challenge2, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration7.save() elaboration8 = Elaboration(challenge=challenge2, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration8.save() Review(elaboration=elaboration6, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration7, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration8, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert not self.stack.has_enough_peer_reviews(user1) Review(elaboration=elaboration5, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() assert not self.stack.has_enough_peer_reviews(user1) Review(elaboration=elaboration5, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() assert self.stack.has_enough_peer_reviews(user1)
def import_data(): CommentsConfig.setup() number_of_users = 50 number_of_tutors = 5 users = [] dummy_users = [] tutors = [] for i in range(number_of_users): print("adding student %s of %s" % (i, number_of_users)) username = "******" % i user = AuroraUser(username=username) user.email = '*****@*****.**' % username user.first_name = 'Firstname_%s' % username user.last_name = 'Lastname_%s' % username user.nickname = 'Nickname_%s' % username user.matriculation_number = "{0:0=2d}".format(i) + ''.join(["%s" % random.randint(0, 9) for num in range(0, 5)]) user.is_staff = False user.is_superuser = False password = username user.set_password(password) user.save() users.append(user) s0 = users[0] # create the three dummy users for jumpstarting the peer review process for i in range(4): print("adding dummy user %s of %s" % (i, 3)) username = "******" % i dummy_user = AuroraUser(username=username) dummy_user.email = '*****@*****.**' % username dummy_user.first_name = 'Firstname_%s' % username dummy_user.last_name = 'Lastname_%s' % username dummy_user.nickname = 'Nickname_%s' % username dummy_user.is_staff = True dummy_user.is_superuser = False password = username dummy_user.set_password(password) dummy_user.save() dummy_users.append(dummy_user) d1 = dummy_users[0] d2 = dummy_users[1] d3 = dummy_users[2] d4 = dummy_users[3] # adding tutors for i in range(number_of_tutors): print("adding tutor %s of %s" % (i, number_of_tutors)) username = "******" % i tutor = AuroraUser(username=username) tutor.email = '*****@*****.**' % username tutor.first_name = 'Firstname_%s' % username tutor.last_name = 'Lastname_%s' % username tutor.nickname = 'Nickname_%s' % username tutor.is_staff = True tutor.is_superuser = False password = username tutor.set_password(password) tutor.save() print("***tutor username: %s" % tutor.username) tutors.append(tutor) # create an admin user with password amanaman print('adding superuser') #username = "******" amanaman = AuroraUser(username="******") amanaman.first_name = 'Firstname_%s' % "amanaman" amanaman.last_name = 'Lastname_%s' % "amanaman" amanaman.nickname = 'Nickname_%s' % "amanaman" amanaman.set_password("amanaman") amanaman.is_staff = True amanaman.is_superuser = True amanaman.save() # hagrid staff user print('adding staff') username = "******" superuser = AuroraUser(username=username) superuser.first_name = 'Firstname_%s' % username superuser.last_name = 'Lastname_%s' % username superuser.nickname = 'Nickname_%s' % username superuser.set_password(username) superuser.is_staff = True superuser.is_superuser = False superuser.save() # create courses "GSI" and "HCI" print('adding course gsi') gsi = Course( title='Gesellschaftliche Spannungsfelder der Informatik', short_title='gsi', description='GSI Description', course_number='123.456', start_date=date.today() - timedelta(days=100), end_date=date.today() + timedelta(days=100), ) gsi.save() print('adding course hci') hci = Course( title='Human Computer Interaction', short_title='hci', description='HCI Description', course_number='123.457', start_date=date.today() - timedelta(days=100), end_date=date.today() + timedelta(days=100), ) hci.save() # add faq print('adding faq') faqs = [ ( Faq( question="Wie unterscheidet sich der Modus zu dem des Vorjahres?", answer="So gut wie gar nicht. Aurora wurde überarbeitet, viele Bugs wurden behoben, und es wurden einige " "kleine Verbesserungen implementiert. Wir haben aber noch Pläne, über das Semester hinweg ein paar " "neue Dinge zu versuchen.", order=0 ), [hci, gsi] ), ( Faq( question="Kann ich einfach irgendwelche Challenges machen, bis ich genug Punkte habe?", answer="Nein. Sie müssen für eine positive Note aus jeder der vier Kategorien (s.u.) mindestens " "eine Challenge absolvieren. Ansonsten steht Ihnen frei, was sie wann machen.", order=1 ), [hci, gsi] ), ( Faq( question="Was sind die 4 Kategorien in BHCI?", answer="<ul><li>Kategorie 1: User-centered design + design basics (B1cX)</li>" "<li>Kategorie 2: Methoden (B2cX)</li>" "<li>Kategorie 3: psycholog. Grundlagen, Evaluation (B3cX)</li>" "<li>Kategorie 4: Prototyping, Beyond the desktop (B4cX)</li></ul>", order=2 ), [hci] ), ( Faq( question="Was sind die 4 Kategorien in GSI?", answer="<ul><li>Kategorie 1: Praxis (G1cX)</li>" "<li>Kategorie 2: IT-Branche (G2cX)</li>" "<li>Kategorie 3: Ideen (G3cX)</li>" "<li>Kategorie 4: Gesellschaft (G4cX)</li></ul>", order=2 ), [gsi] ), ( Faq( question="Wann ist die Deadline für (eine/diese/alle) Challenges?", answer="Für eine positive Note müssen sie bis Ende des Semesters (Fr 3.7., 23:59) ausreichend Punkte " "gesammelt haben, und aus jeder Kategorie (s.o.) mindestens eine Challenge geschafft haben. " "Punkte bekommen sie für fertiggestellte Challenges, aber zB. auch für ausgezeichnete Kommentare " "bei den Folien. Beachten sie jedoch, dass sie nach dem Abgeben einer Challenge (also des Final " "Tasks) 11 Tage warten müssen (ab 22.6.: 7 Tage), bevor sie wieder einen Final Task einreichen " "können!", order=3 ), [hci, gsi] ), ( Faq( question="Was kann ich machen, wenn die Bewertung meiner Arbeit nicht meinen Erwartungen entspricht?", answer="Sie können einen Kommentar zu ihrer Arbeit formulieren, in dem sie zb. eine Frage stellen, " "oder ihre Arbeit noch einmal besser erklären. Damit wird ihre Arbeit intern markiert und für " "uns noch einmal sichtbar. Ihr Kommentar wird jedenfalls beantwortet werden, auch wenn es " "manchmal etwas dauert.", order=4 ), [hci, gsi] ), ( Faq( question="Ab wann werde ich bewertet?", answer="Sobald sie eine Challenge abgeschlossen haben, wird für sie am Ende des Semesters ein " "Zeugnis ausgestellt.", order=5 ), [hci,gsi] ), ( Faq( question="Wie sind die Bewertungskategorien am Ende jedes Reviews zu verstehen?", answer='Siehe <a href="http://igw.tuwien.ac.at/aurora/aurora_reviews.pdf">Zum Schreiben von Reviews</a>', order=6 ), [hci, gsi] ), ( Faq( question="Wie ist das jetzt mit den Punkten?", answer="Sie <b>müssen</b> Challenges im Umfang von mind. 60 Punkten komplett abarbeiten. Die Punkte sind " "bei der Beschreibung von Challenges explizit angeführt (zB. »Sie können für Ihre Arbeit hier bis " "zu 10 Punkten bekommen«) Wir bewerten eine Challenge, wenn der final Task abgegeben wurde. Für " "Mängel bei einzelnen Tasks ziehen wir Punkte vom erreichbaren Maximum ab, wobei die relative " "Wertigkeit der Tasks in der Taskbeschreibung in % angegeben ist. Diese Bewertung erfolgt unabhängig " "von den Review-Ergebnissen, die Sie bekommen haben. Die Summe der Punkte, die Sie für alle " "Challenges bekommen, bestimmt Ihre Note nach dem oben angegebenen Notenspiegel.", order=7 ), [hci, gsi] ), ] for (faq, courses) in faqs: print("Adding faq") faq.save() for c in courses: faq.course.add(c) # create course-user relations print('adding course-user relations') CourseUserRelation(course=gsi, user=amanaman).save() CourseUserRelation(course=hci, user=amanaman).save() CourseUserRelation(course=gsi, user=superuser).save() CourseUserRelation(course=hci, user=superuser).save() for tutor in tutors: CourseUserRelation(course=gsi, user=tutor).save() CourseUserRelation(course=hci, user=tutor).save() Notification(user=tutor, course=gsi, text="Welcome to GSI!").save() Notification(user=tutor, course=hci, text="Welcome to HCI!").save() for user in users: CourseUserRelation(course=gsi, user=user).save() CourseUserRelation(course=hci, user=user).save() Notification(user=user, course=gsi, text="Welcome to GSI!").save() Notification(user=user, course=hci, text="Welcome to HCI!").save() # create challenges print('adding challenges') challenge_1 = Challenge(title='meine meinung', subtitle='meine meinung', description='Gehen Sie nach derstandard.at, suchen Sie einen beliebigen Artikel und posten Sie den Text dieses Artikels hier.', accepted_files='', course=gsi, points=15, ) challenge_1.image.save('1.png', File(open(os.path.join(STATIC_ROOT, 'img', '1.png'), 'rb'))) challenge_1.save() ReviewQuestion(challenge=challenge_1, order=1, text='In wie fern stellt der gepostete Artikel einen Beitrag zur Entwicklung der Gesellschaft dar?').save() ReviewQuestion(challenge=challenge_1, order=2, text='Was würden Sie verbessern bzw. wo könnte die Autorin oder der Autor ansetzen, damit die Abgabe besser wird?').save() ReviewQuestion(challenge=challenge_1, order=3, text="Anmerkungen an das LVA-Team:", visible_to_author=False).save() challenge_2 = Challenge(title='rage-comic', subtitle='rage-comic', prerequisite=challenge_1, description='Finden Sie einen Webcomic, den Sie lustig finden und laden Sie ihn hier hoch. Beschreiben Sie kurz, wie lange Sie diesen Webcomic schon lesen.', accepted_files='image/*', course=gsi, points=10, ) challenge_2.image.save('2.png', File(open(os.path.join(STATIC_ROOT, 'img', '2.png'), 'rb'))) challenge_2.save() ReviewQuestion(challenge=challenge_2, order=1, text="Empfinden Sie den Webcomic als lustig? Begründen Sie Ihre Antwort.").save() ReviewQuestion(challenge=challenge_2, order=2, text='Was würden Sie verbessern bzw. wo könnte die Autorin oder der Autor ansetzen, damit die Abgabe besser wird?').save() ReviewQuestion(challenge=challenge_2, order=3, text="Anmerkungen an das LVA-Team:", visible_to_author=False).save() challenge_3 = Challenge(title='wikipedia', subtitle='wikipedia', prerequisite=challenge_2, description='Kopieren Sie 4 Absätze aus einem Wikipedia-Artikel und geben Sie sie ab! Setzen Sie ans Ende der arbeit den Link auf den Wikipedia-Artikel!', accepted_files='', course=gsi, points=8, ) challenge_3.image.save('3.png', File(open(os.path.join(STATIC_ROOT, 'img', '3.png'), 'rb'))) challenge_3.save() ReviewQuestion(challenge=challenge_3, order=1, text="Was möchte die Autorin bzw. der Autor mit den 4 Absätzen ausdrücken?").save() ReviewQuestion(challenge=challenge_3, order=2, text='Was würden Sie verbessern bzw. wo könnte die Autorin oder der Autor ansetzen, damit die Abgabe besser wird?').save() ReviewQuestion(challenge=challenge_3, order=3, text="Anmerkungen an das LVA-Team:", visible_to_author=False).save() challenge_4 = Challenge(title='wissenschaft', subtitle='wissenschaft', prerequisite=challenge_3, description='Finden Sie einen pseudowissenschaftlichen Artikel und laden Sie ihn hier hoch.', accepted_files='application/pdf', course=gsi, points=9, ) challenge_4.image.save('4.png', File(open(os.path.join(STATIC_ROOT, 'img', '4.png'), 'rb'))) challenge_4.save() challenge_5 = Challenge(title='ping', subtitle='ping', description='Laden Sie drei Bilder im png-Format hoch. Beschreiben Sie dann kurz, was auf diesen Bildern zu sehen ist.', accepted_files='image/png', course=gsi, points=10, ) challenge_5.image.save('5.png', File(open(os.path.join(STATIC_ROOT, 'img', '5.png'), 'rb'))) challenge_5.save() ReviewQuestion(challenge=challenge_5, order=1, text="In welchem Zusammenhang stehen die Bilder? Ist ein Muster erkennbar?").save() ReviewQuestion(challenge=challenge_5, order=2, text='Was würden Sie verbessern bzw. wo könnte die Autorin oder der Autor ansetzen, damit die Abgabe besser wird?').save() ReviewQuestion(challenge=challenge_5, order=3, text="Anmerkungen an das LVA-Team:", visible_to_author=False).save() challenge_6 = Challenge(title='advice animal', subtitle='advice animal', prerequisite=challenge_5, description='Suchen Sie ein »advice animal« Bild und posten Sie es hier. Geben sie die Quelle dazu an.', accepted_files='image/*', course=gsi, points=12, ) challenge_6.image.save('6.png', File(open(os.path.join(STATIC_ROOT, 'img', '6.png'), 'rb'))) challenge_6.save() ReviewQuestion(challenge=challenge_6, order=1, text="Was steckt hinter dem »advice«? Welche Probleme werden dadurch aufgezeigt?").save() ReviewQuestion(challenge=challenge_6, order=2, text='Was würden Sie verbessern bzw. wo könnte die Autorin oder der Autor ansetzen, damit die Abgabe besser wird?').save() ReviewQuestion(challenge=challenge_6, order=3, text="Anmerkungen an das LVA-Team:", visible_to_author=False).save() challenge_7 = Challenge(title='animated gif', subtitle='animated gif', prerequisite=challenge_6, description='suchen sie ein animated gif und posten sie es. geben sie die quelle dazu an.', accepted_files='image/gif', course=gsi, points=14, ) challenge_7.image.save('7.png', File(open(os.path.join(STATIC_ROOT, 'img', '7.png'), 'rb'))) challenge_7.save() ReviewQuestion(challenge=challenge_7, order=1, text="Weshalb wurde das GIF animiert? Würde es auch ohne Animation funktionieren? Begründen Sie Ihre Antwort.").save() ReviewQuestion(challenge=challenge_7, order=2, text='Was würden Sie verbessern bzw. wo könnte die Autorin oder der Autor ansetzen, damit die Abgabe besser wird?').save() ReviewQuestion(challenge=challenge_7, order=3, text="Anmerkungen an das LVA-Team:", visible_to_author=False).save() challenge_8 = Challenge(title='zwei menschen', subtitle='zwei menschen', prerequisite=challenge_7, description='Laden Sie zwei Bilder von zwei verschiedenen Menschen hoch. Erklären Sie dann, wer diese beiden Menschen sind. Vergessen Sie nicht auf die Quellenangabe!!11elf', accepted_files='image/*', course=gsi, points=5, ) challenge_8.image.save('8.png', File(open(os.path.join(STATIC_ROOT, 'img', '8.png'), 'rb'))) challenge_8.save() challenge_9 = Challenge(title='youtube', subtitle='youtube', description='Suchen Sie ein gutes YouTube-Video und posten Sie den Link hier. Wenn Sherlock Holmes darin vorkommt, dann können Sie auch einen Extrapunkt bekommen.', accepted_files='', course=gsi, points=25, ) challenge_9.image.save('9.png', File(open(os.path.join(STATIC_ROOT, 'img', '9.png'), 'rb'))) challenge_9.save() ReviewQuestion(challenge=challenge_9, order=1, text="Beschreiben Sie jemandem der Blind ist die Szene. Versuchen Sie dabei auch auf Details einzugehen, die für das Gesamtverständnis von Relevanz sein könnten.").save() ReviewQuestion(challenge=challenge_9, order=2, text='Was würden Sie verbessern bzw. wo könnte die Autorin oder der Autor ansetzen, damit die Abgabe besser wird?').save() ReviewQuestion(challenge=challenge_9, order=3, text="Kommt in dem Video Sherlock Holmes vor?", visible_to_author=False, boolean_answer=True).save() ReviewQuestion(challenge=challenge_9, order=4, text="Anmerkungen an das LVA-Team:", visible_to_author=False).save() challenge_10 = Challenge(title='schmetterling', subtitle='schmetterling', prerequisite=challenge_9, description='Suchen Sie in Google Image Search Schmetterlingsbilder und laden Sie diese hier hoch. Vergessen Sie nicht auf die Quellenangaben!', accepted_files='image/*', course=gsi, points=3, ) challenge_10.image.save('4.png', File(open(os.path.join(STATIC_ROOT, 'img', '4.png'), 'rb'))) challenge_10.save() # create stacks print('adding stack accessibility') accessibility = Stack( title='Universal Design', description='In diesem Block setzen sie sich mit »Unversal Design« auseinander. Universal Design (Universelles Design) ist ein internationales Design-Konzept, das Produkte, Geräte, Umgebungen und Systeme derart gestaltet, dass sie für so viele Menschen wie möglich ohne weitere Anpassung oder Spezialisierung nutzbar sind. In der Informatik bedeutet das im allgemeinen, Systeme so zu gestalten, dass sie von Menschen mit Behinderungen, insbesondere blinde Menschen, auch benutzt werden können.', course=gsi, start_date=date.today() - timedelta(days=100), end_date=date.today() + timedelta(days=100), ) accessibility.save() print('adding stack digital life') digitallife = Stack( title='Copyleft vs. Business', description='In diesem Block geht es um die Suche nach neuen Business-Modellen für die geänderten Bedingngen, die durch neue Technologien geschaffen wurden. Viele traditionelel Business-Modelle gehen dabei den Bach runter, neue Ansätze sind gefragt.', course=gsi, start_date=date.today() - timedelta(days=100), end_date=date.today() + timedelta(days=100), ) digitallife.save() print('adding stack gtav') gtav = Stack( title='Geschichte der Informatik', description='Dieser Block führt sie in die Geschichte der Informatik, zurück zu den Anfängen des interaktiven Computers. Sie setzen sich damit auseinander, welche Vorstellungen von Interaktivität im Laufe der Geschichte entstanden, probiert und wieder verworfen wurden. Dabei werden Darstellungen in Film und Fernsehen ebenso aufgearbeitet wie die Visionen der Techniker und wissenschaftliche Diskussionen.', course=gsi, start_date=date.today() - timedelta(days=100), end_date=date.today() + timedelta(days=100), ) gtav.save() # create dummy elaborations challenges = Challenge.objects.all() for challenge in challenges: for dummy_user in dummy_users: if not challenge.is_final_challenge(): Elaboration(challenge=challenge, user=dummy_user, elaboration_text=PlagcheckTestData.get_random_text(), submission_time='2013-11-01 10:00:00').save() print('adding final elaboration 1 for challenge 10') de4 = Elaboration(challenge=challenge_10, user=d1, elaboration_text="final submission user d1 " + PlagcheckTestData.get_random_text(), submission_time=datetime.now()) de4.save() print('adding FAIL review for dummy user d1') Review(elaboration=de4, reviewer=d3, appraisal='F', submission_time=datetime.now()).save() print('adding final elaboration 2 for challenge 10') de5 = Elaboration(challenge=challenge_10, user=d2, elaboration_text="final submission user d2 " + PlagcheckTestData.get_random_text(), submission_time=datetime.now()) de5.save() print('adding final elaboration 1 for challenge 8') text = PlagcheckTestData.get_random_text() de6 = Elaboration(challenge=challenge_8, user=d3, elaboration_text="final submission user d3 " + text, submission_time=datetime.now()) de6.save() # create elaboration for challenge 1 for s0 print('adding elaboration for challenge 1 for s0 and use same text as elaboration 1 for challenge 8 (=plagcheck test)') e1 = Elaboration(challenge=challenge_1, user=s0, elaboration_text="this is a copy of elaboration 1/challenge 8 from user d3 " + PlagcheckTestData.get_random_text(), submission_time=datetime.now()) e1.save() print('adding elaboration for challenge ') elaborations = Elaboration.objects.all() e1 = elaborations[0] e2 = elaborations[1] e3 = elaborations[2] # # trigger plagcheck daemon to verify documents # for elab in elaborations: # plagcheck_elaboration(elab) # create review for elaboration print('adding review 1 for elaboration for challenge 1 for s0') r1 = Review(elaboration=e1, reviewer=s0, appraisal='N', submission_time=datetime.now()) r1.save() print('adding review 2 for elaboration for challenge 1 for s0') r2 = Review(elaboration=e2, reviewer=s0, appraisal='F', submission_time=datetime.now()) r2.save() print('adding review 3 for elaboration for challenge 1 for s0') Review(elaboration=e3, reviewer=s0, appraisal='A', submission_time=datetime.now()).save() print('adding review 4 for elaboration for challenge 1 for s0') Review(elaboration=e3, reviewer=d2, appraisal='F', submission_time=datetime.now()).save() # create elaboration for challenge 2 for s0 print('adding elaboration for challenge 2 for s0') e2 = Elaboration(challenge=challenge_2, user=s0, elaboration_text="this elaboration text is from populate demo data " + PlagcheckTestData.get_random_text(), submission_time=datetime.now()) e2.save() # create review for elaboration print('adding review 1 for elaboration for challenge 2 for s0') Review(elaboration=de4, reviewer=s0, appraisal='N', submission_time=datetime.now()).save() de5.save() print('adding review 1 for elaboration for challenge 2 for s0') Review(elaboration=de5, reviewer=d1, appraisal='A', submission_time=datetime.now()).save() print('adding review 2 for elaboration for challenge 2 for s0') Review(elaboration=de5, reviewer=d2, appraisal='S', submission_time=datetime.now()).save() # create stack-challenge relations print('adding stack challenge relations') StackChallengeRelation(stack=accessibility, challenge=challenge_1).save() StackChallengeRelation(stack=accessibility, challenge=challenge_2).save() StackChallengeRelation(stack=accessibility, challenge=challenge_3).save() StackChallengeRelation(stack=accessibility, challenge=challenge_4).save() StackChallengeRelation(stack=digitallife, challenge=challenge_5).save() StackChallengeRelation(stack=digitallife, challenge=challenge_6).save() StackChallengeRelation(stack=digitallife, challenge=challenge_7).save() StackChallengeRelation(stack=digitallife, challenge=challenge_8).save() StackChallengeRelation(stack=gtav, challenge=challenge_9).save() StackChallengeRelation(stack=gtav, challenge=challenge_10).save() print('adding escalation for challenge 1 for s0') com1 = Comment(text="escalation for review 1 for challenge 1 for d1", author=superuser, post_date=datetime.now(), content_type=ContentType.objects.get_for_model(Review), object_id=r1.id, visibility=Comment.STAFF) com1.save() com2 = Comment(text="escalation for review 2 for challenge 1 for d2", author=superuser, post_date=datetime.now(), content_type=ContentType.objects.get_for_model(Review), object_id=r2.id, visibility=Comment.PUBLIC) com2.save() for user in AuroraUser.objects.all(): if not user.avatar: user.get_gravatar()
class AuroraUserTest(TestCase): def setUp(self): self.create_test_users(4) self.create_course() self.create_stack() self.create_challenge() self.create_review_question() def create_test_user(self, username): user = AuroraUser(username=username) user.email = '%[email protected].' % username user.first_name = 'Firstname_%s' % username user.last_name = 'Lastname_%s' % username user.nickname = 'Nickname_%s' % username user.is_staff = False user.is_superuser = False password = username user.set_password(password) user.matriculation_number = username + '2857289' user.save() return user def create_test_users(self, amount): self.users = [] for i in range(amount): self.users.append(self.create_test_user("s%s" % i)) def create_course(self): self.course = Course( title='test_title', short_title='test_short_title', description='test_description', course_number='test_course_number', ) self.course.save() for user in self.users: CourseUserRelation(course=self.course, user=user).save() def create_stack(self): self.stack = Stack(title="test stack", description="test description", course=self.course) self.stack.save() def create_challenge(self): self.challenge = Challenge( title='test_title', subtitle='test_subtitle', description='test_description', course=self.course, ) self.challenge.save() StackChallengeRelation(stack=self.stack, challenge=self.challenge).save() def create_review_question(self): self.review_question = ReviewQuestion( challenge=self.challenge, order=1, text="Can you find any additional material not included in this submission?" ) self.review_question.save() def create_review(self, elaboration, reviewer): Review(elaboration=elaboration, submission_time=datetime.now(), reviewer=reviewer, appraisal='S').save() @staticmethod def ipython_test(): user = AuroraUser.objects.get(username='******') c = Client() shared_secret = settings.SSO_SHARED_SECRET.encode(encoding='latin1') oid = '258' now = int((datetime.utcnow() - datetime(1970, 1, 1)).total_seconds() / 10) values_string = oid + user.matriculation_number + user.first_name + user.last_name + user.email + str(now) hmac_calced = hmac_new(shared_secret, values_string.encode(encoding='latin1'), sha1).hexdigest() values = {'oid': oid, 'mn': user.matriculation_number, 'firstName': user.first_name, 'lastName': user.last_name, 'mail': user.email, 'sKey': hmac_calced} # response = c.get('sso_auth_callback', values, follow=True) from django.http import QueryDict q = QueryDict('', mutable=True) for key in values.keys(): q[key] = values[key] url = 'http://localhost:8000/sso_auth_callback?' + q.urlencode() return url def test_sso(self): c = Client() shared_secret = settings.SSO_SHARED_SECRET.encode(encoding='latin1') oid = '258' user = self.users[0] now = int((datetime.utcnow() - datetime(1970, 1, 1)).total_seconds() / 10) values_string = oid + user.matriculation_number + user.first_name + user.last_name + user.email + str(now) hmac_calced = hmac_new(shared_secret, values_string.encode(encoding='latin1'), sha1).hexdigest() values = {'oid': oid, 'mn': user.matriculation_number, 'firstName': user.first_name, 'lastName': user.last_name, 'mail': user.email, 'sKey': hmac_calced} response = c.get('sso_auth_callback', values, follow=True) def test_get_elaborations(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] assert len(user1.get_elaborations()) == 0 assert len(user2.get_elaborations()) == 0 assert len(user3.get_elaborations()) == 0 assert len(user4.get_elaborations()) == 0 elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() assert len(user1.get_elaborations()) == 1 assert elaboration1 in user1.get_elaborations() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() assert len(user2.get_elaborations()) == 1 assert elaboration2 in user2.get_elaborations() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() assert len(user3.get_elaborations()) == 1 assert elaboration3 in user3.get_elaborations() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert len(user4.get_elaborations()) == 1 assert elaboration4 in user4.get_elaborations() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() elaboration5 = Elaboration(challenge=challenge2, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration5.save() assert len(user1.get_elaborations()) == 2 assert elaboration1 in user1.get_elaborations() assert elaboration5 in user1.get_elaborations() elaboration6 = Elaboration(challenge=challenge2, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration6.save() assert len(user2.get_elaborations()) == 2 assert elaboration2 in user2.get_elaborations() assert elaboration6 in user2.get_elaborations() elaboration7 = Elaboration(challenge=challenge2, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration7.save() assert len(user3.get_elaborations()) == 2 assert elaboration3 in user3.get_elaborations() assert elaboration7 in user3.get_elaborations() elaboration8 = Elaboration(challenge=challenge2, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration8.save() assert len(user4.get_elaborations()) == 2 assert elaboration4 in user4.get_elaborations() assert elaboration8 in user4.get_elaborations() def test_get_challenge_elaboration(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] assert not user1.get_challenge_elaboration(challenge1) assert not user2.get_challenge_elaboration(challenge1) assert not user3.get_challenge_elaboration(challenge1) assert not user4.get_challenge_elaboration(challenge1) elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert user1.get_challenge_elaboration(challenge1) == elaboration1 assert user2.get_challenge_elaboration(challenge1) == elaboration2 assert user3.get_challenge_elaboration(challenge1) == elaboration3 assert user4.get_challenge_elaboration(challenge1) == elaboration4 Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() assert not user1.get_challenge_elaboration(challenge2) assert not user2.get_challenge_elaboration(challenge2) assert not user3.get_challenge_elaboration(challenge2) assert not user4.get_challenge_elaboration(challenge2) elaboration5 = Elaboration(challenge=challenge2, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration5.save() elaboration6 = Elaboration(challenge=challenge2, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration6.save() elaboration7 = Elaboration(challenge=challenge2, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration7.save() elaboration8 = Elaboration(challenge=challenge2, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration8.save() assert user1.get_challenge_elaboration(challenge2) == elaboration5 assert user2.get_challenge_elaboration(challenge2) == elaboration6 assert user3.get_challenge_elaboration(challenge2) == elaboration7 assert user4.get_challenge_elaboration(challenge2) == elaboration8 def test_get_stack_elaborations(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] assert len(user1.get_stack_elaborations(self.stack)) == 0 assert len(user2.get_stack_elaborations(self.stack)) == 0 assert len(user3.get_stack_elaborations(self.stack)) == 0 assert len(user4.get_stack_elaborations(self.stack)) == 0 elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert len(user1.get_stack_elaborations(self.stack)) == 1 assert len(user2.get_stack_elaborations(self.stack)) == 1 assert len(user3.get_stack_elaborations(self.stack)) == 1 assert len(user4.get_stack_elaborations(self.stack)) == 1 assert elaboration1 in user1.get_stack_elaborations(self.stack) assert elaboration2 in user2.get_stack_elaborations(self.stack) assert elaboration3 in user3.get_stack_elaborations(self.stack) assert elaboration4 in user4.get_stack_elaborations(self.stack) Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() elaboration5 = Elaboration(challenge=challenge2, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration5.save() elaboration6 = Elaboration(challenge=challenge2, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration6.save() elaboration7 = Elaboration(challenge=challenge2, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration7.save() elaboration8 = Elaboration(challenge=challenge2, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration8.save() assert len(user1.get_stack_elaborations(self.stack)) == 2 assert len(user2.get_stack_elaborations(self.stack)) == 2 assert len(user3.get_stack_elaborations(self.stack)) == 2 assert len(user4.get_stack_elaborations(self.stack)) == 2 assert elaboration1 in user1.get_stack_elaborations(self.stack) assert elaboration2 in user2.get_stack_elaborations(self.stack) assert elaboration3 in user3.get_stack_elaborations(self.stack) assert elaboration4 in user4.get_stack_elaborations(self.stack) assert elaboration5 in user1.get_stack_elaborations(self.stack) assert elaboration6 in user2.get_stack_elaborations(self.stack) assert elaboration7 in user3.get_stack_elaborations(self.stack) assert elaboration8 in user4.get_stack_elaborations(self.stack)
def import_data(): CommentsConfig.setup() number_of_users = 30 number_of_tutors = 10 users = [] dummy_users = [] tutors = [] for i in range(number_of_users): print("adding student %s of %s" % (i, number_of_users)) username = "******" % i user = AuroraUser(username=username) user.email = '*****@*****.**' % username user.first_name = 'Firstname_%s' % username user.last_name = 'Lastname_%s' % username user.nickname = 'Nickname_%s' % username user.matriculation_number = "{0:0=2d}".format(i) + ''.join( ["%s" % random.randint(0, 9) for num in range(0, 5)]) user.is_staff = False user.is_superuser = False password = username user.set_password(password) user.save() users.append(user) s0 = users[0] # create the three dummy users for jumpstarting the peer review process for i in range(4): print("adding dummy user %s of %s" % (i, 3)) username = "******" % i dummy_user = AuroraUser(username=username) dummy_user.email = '*****@*****.**' % username dummy_user.first_name = 'Firstname_%s' % username dummy_user.last_name = 'Lastname_%s' % username dummy_user.nickname = 'Nickname_%s' % username dummy_user.is_staff = True dummy_user.is_superuser = False password = username dummy_user.set_password(password) dummy_user.save() dummy_users.append(dummy_user) d1 = dummy_users[0] d2 = dummy_users[1] d3 = dummy_users[2] d4 = dummy_users[3] # adding tutors for i in range(number_of_tutors): print("adding tutor %s of %s" % (i, number_of_tutors)) username = "******" % i tutor = AuroraUser(username=username) tutor.email = '*****@*****.**' % username tutor.first_name = 'Firstname_%s' % username tutor.last_name = 'Lastname_%s' % username tutor.nickname = 'Nickname_%s' % username tutor.is_staff = True tutor.is_superuser = False password = username tutor.set_password(password) tutor.save() print("***tutor username: %s" % tutor.username) tutors.append(tutor) # create an admin user with password amanaman print('adding superuser') username = "******" amanaman = AuroraUser(username=username) amanaman.first_name = 'Firstname_%s' % username amanaman.last_name = 'Lastname_%s' % username amanaman.nickname = 'Nickname_%s' % username amanaman.set_password(username) amanaman.is_staff = True amanaman.is_superuser = True amanaman.save() # hagrid staff user print('adding staff') username = "******" superuser = AuroraUser(username=username) superuser.first_name = 'Firstname_%s' % username superuser.last_name = 'Lastname_%s' % username superuser.nickname = 'Nickname_%s' % username superuser.set_password(username) superuser.is_staff = True superuser.is_superuser = False superuser.save() # create course "GSI" print('adding course gsi') gsi = Course( title='Gesellschaftliche Spannungsfelder der Informatik', short_title='gsi', description='GSI Description', course_number='123.456', ) gsi.save() # create course-user relations print('adding course-user relations') CourseUserRelation(course=gsi, user=amanaman).save() CourseUserRelation(course=gsi, user=superuser).save() for tutor in tutors: CourseUserRelation(course=gsi, user=tutor).save() Notification(user=tutor, course=gsi, text="Welcome to GSI!").save() for user in users: CourseUserRelation(course=gsi, user=user).save() Notification(user=user, course=gsi, text="Welcome to GSI!").save() # create challenges print('adding challenges') challenge_1 = Challenge( id=1, title='meine meinung', subtitle='meine meinung', description= 'gehen sie nach derstandard.at, suchen sie einen beliebigen artikel, und posten sie den text dieses artikels hier.', accepted_files='', course=gsi, points=15, ) challenge_1.image.save( '1.png', File(open(os.path.join(STATIC_ROOT, 'img', '1.png'), 'rb'))) challenge_1.save() ReviewQuestion(challenge=challenge_1, order=1, text="Erfüllt diese Arbeit die gestellte Aufgabe?", boolean_answer=True).save() ReviewQuestion( challenge=challenge_1, order=2, text="Falls nicht: Was fehlt? Was sollte anders sein? Was ist zuviel?" ).save() challenge_2 = Challenge( id=2, title='rage-comic', subtitle='rage-comic', prerequisite=challenge_1, description= 'finden sie einen web-comic, den sie lustig finden, und laden sie ihn hier hoch. beschreiben sie kurz, wie lange sie diesen webcomic schon lesen.', accepted_files='image/*', course=gsi, points=10, ) challenge_2.image.save( '2.png', File(open(os.path.join(STATIC_ROOT, 'img', '2.png'), 'rb'))) challenge_2.save() ReviewQuestion(challenge=challenge_2, order=1, text="Erfüllt diese Arbeit die gestellte Aufgabe?", boolean_answer=True).save() ReviewQuestion( challenge=challenge_2, order=2, text="Falls nicht: Was fehlt? Was sollte anders sein? Was ist zuviel?" ).save() ReviewQuestion(challenge=challenge_2, order=3, text="Ist der Webcomic lustig?", boolean_answer=True).save() ReviewQuestion(challenge=challenge_2, order=4, text="Ist dieser Webcomic interessant?", boolean_answer=True, visible_to_author=False).save() challenge_3 = Challenge( id=3, title='wikipedia', subtitle='wikipedia', prerequisite=challenge_2, description= 'kopieren sie 4 absätze aus einem wikipedia-artikel und geben sie sie ab! setzen sie ans ende der arbeit den link auf den wikipedia-artikel!', accepted_files='', course=gsi, points=8, ) challenge_3.image.save( '3.png', File(open(os.path.join(STATIC_ROOT, 'img', '3.png'), 'rb'))) challenge_3.save() ReviewQuestion(challenge=challenge_3, order=1, text="Erfüllt diese Arbeit die gestellte Aufgabe?", boolean_answer=True).save() ReviewQuestion( challenge=challenge_3, order=2, text="Falls nicht: Was fehlt? Was sollte anders sein? Was ist zuviel?" ).save() challenge_4 = Challenge( id=4, title='wissenschaft', subtitle='wissenschaft', prerequisite=challenge_3, description= 'finden sie einen pseudowissenschaftlichen artikel und laden sie ihn hier hoch.', accepted_files='application/pdf', course=gsi, points=9, ) challenge_4.image.save( '4.png', File(open(os.path.join(STATIC_ROOT, 'img', '4.png'), 'rb'))) challenge_4.save() challenge_5 = Challenge( id=5, title='ping', subtitle='ping', description= 'laden sie drei bilder im png-format hoch. beschreiben sie dann kurz, was auf diesen bildern zu sehen ist.', accepted_files='image/png', course=gsi, points=10, ) challenge_5.image.save( '5.png', File(open(os.path.join(STATIC_ROOT, 'img', '5.png'), 'rb'))) challenge_5.save() ReviewQuestion(challenge=challenge_5, order=1, text="Erfüllt diese Arbeit die gestellte Aufgabe?", boolean_answer=True).save() ReviewQuestion( challenge=challenge_5, order=2, text="Falls nicht: Was fehlt? Was sollte anders sein? Was ist zuviel?" ).save() challenge_6 = Challenge( id=6, title='advice animal', subtitle='advice animal', prerequisite=challenge_5, description= 'suchen sie ein »advice animal« bild und posten sie es hier. geben sie die quelle dazu an.', accepted_files='image/*', course=gsi, points=12, ) challenge_6.image.save( '6.png', File(open(os.path.join(STATIC_ROOT, 'img', '6.png'), 'rb'))) challenge_6.save() ReviewQuestion(challenge=challenge_6, order=1, text="Erfüllt diese Arbeit die gestellte Aufgabe?", boolean_answer=True).save() ReviewQuestion( challenge=challenge_6, order=2, text="Falls nicht: Was fehlt? Was sollte anders sein? Was ist zuviel?" ).save() challenge_7 = Challenge( id=7, title='animated gif', subtitle='animated gif', prerequisite=challenge_6, description= 'suchen sie ein animated gif und posten sie es. geben sie die quelle dazu an.', accepted_files='image/gif', course=gsi, points=14, ) challenge_7.image.save( '7.png', File(open(os.path.join(STATIC_ROOT, 'img', '7.png'), 'rb'))) challenge_7.save() ReviewQuestion(challenge=challenge_7, order=1, text="Erfüllt diese Arbeit die gestellte Aufgabe?", boolean_answer=True).save() ReviewQuestion( challenge=challenge_7, order=2, text="Falls nicht: Was fehlt? Was sollte anders sein? Was ist zuviel?" ).save() challenge_8 = Challenge( id=8, title='zwei menschen', subtitle='zwei menschen', prerequisite=challenge_7, description= 'laden sie zwei bilder von zwei verschiedenen menschen hoch. erklären sie dann, wer diese beiden menschen sind. vergessen sie nicht auf die quellenangabe!', accepted_files='image/*', course=gsi, points=5, ) challenge_8.image.save( '8.png', File(open(os.path.join(STATIC_ROOT, 'img', '8.png'), 'rb'))) challenge_8.save() challenge_9 = Challenge( id=9, title='youtube', subtitle='youtube', description= 'suchen sie ein gutes youtube-video und posten sie den link hier. wenn sherlock holmes darin vorkommt, dann können sie auch einen extrapunkt bekommen.', accepted_files='', course=gsi, points=25, ) challenge_9.image.save( '9.png', File(open(os.path.join(STATIC_ROOT, 'img', '9.png'), 'rb'))) challenge_9.save() ReviewQuestion(challenge=challenge_9, order=1, text="Erfüllt diese Arbeit die gestellte Aufgabe?", boolean_answer=True).save() ReviewQuestion( challenge=challenge_9, order=2, text="Falls nicht: Was fehlt? Was sollte anders sein? Was ist zuviel?" ).save() challenge_10 = Challenge( id=10, title='schmetterling', subtitle='schmetterling', prerequisite=challenge_9, description= 'suchen sie in google image search schmetterlingsbilder und laden sie diese hier hoch. vergessen sie nicht auf die quellenangaben!', accepted_files='image/*', course=gsi, points=3, ) challenge_10.image.save( '4.png', File(open(os.path.join(STATIC_ROOT, 'img', '4.png'), 'rb'))) challenge_10.save() # create stacks print('adding stack accessibility') accessibility = Stack( title='Universal Design', description= 'In diesem Block setzen sie sich mit »Unversal Design« auseinander. Universal Design (Universelles Design) ist ein internationales Design-Konzept, das Produkte, Geräte, Umgebungen und Systeme derart gestaltet, dass sie für so viele Menschen wie möglich ohne weitere Anpassung oder Spezialisierung nutzbar sind. In der Informatik bedeutet das im allgemeinen, Systeme so zu gestalten, dass sie von Menschen mit Behinderungen, insbesondere blinde Menschen, auch benutzt werden können.', course=gsi, ) accessibility.save() print('adding stack digital life') digitallife = Stack( title='Copyleft vs. Business', description= 'In diesem Block geht es um die Suche nach neuen Business-Modellen für die geänderten Bedingngen, die durch neue Technologien geschaffen wurden. Viele traditionelel Business-Modelle gehen dabei den Bach runter, neue Ansätze sind gefragt.', course=gsi, ) digitallife.save() print('adding stack gtav') gtav = Stack( title='Geschichte der Informatik', description= 'Dieser Block führt sie in die Geschichte der Informatik, zurück zu den Anfängen des interaktiven Computers. Sie setzen sich damit auseinander, welche Vorstellungen von Interaktivität im Laufe der Geschichte entstanden, probiert und wieder verworfen wurden. Dabei werden Darstellungen in Film und Fernsehen ebenso aufgearbeitet wie die Visionen der Techniker und wissenschaftliche Diskussionen.', course=gsi, ) gtav.save() # create dummy elaborations challenges = Challenge.objects.all() for challenge in challenges: for dummy_user in dummy_users: if not challenge.is_final_challenge(): Elaboration(challenge=challenge, user=dummy_user, elaboration_text="dummy elaboration %s" % dummy_user.username, submission_time='2013-11-01 10:00:00').save() # create stack-challenge relations print('adding stack challenge relations') StackChallengeRelation(stack=accessibility, challenge=challenge_1).save() StackChallengeRelation(stack=accessibility, challenge=challenge_2).save() StackChallengeRelation(stack=accessibility, challenge=challenge_3).save() StackChallengeRelation(stack=accessibility, challenge=challenge_4).save() StackChallengeRelation(stack=digitallife, challenge=challenge_5).save() StackChallengeRelation(stack=digitallife, challenge=challenge_6).save() StackChallengeRelation(stack=digitallife, challenge=challenge_7).save() StackChallengeRelation(stack=digitallife, challenge=challenge_8).save() StackChallengeRelation(stack=gtav, challenge=challenge_9).save() StackChallengeRelation(stack=gtav, challenge=challenge_10).save() print('Adding Sample Lectures') Lecture( course=gsi, start=datetime(2013, 2, 15, 15, 00, 17, 345952), end=datetime(2013, 2, 15, 17, 20, 17, 345952), active=True, ).save() Lecture( course=gsi, start=datetime(2013, 2, 16, 15, 00, 17, 345952), end=datetime(2013, 2, 16, 17, 20, 17, 345952), active=True, ).save() Lecture( course=gsi, start=datetime(2013, 2, 17, 15, 00, 17, 345952), end=datetime(2013, 2, 17, 17, 20, 17, 345952), active=True, ).save() # Lecture( # course=gsi, # start=datetime(2013, 2, 24, 15, 00, 17, 345952), # end=datetime(2014, 2, 24, 17, 20, 17, 345952), # active=True, # ).save() print('Adding Sample Slides') Slide( lecture_id=1, title="Preparation Slide #1 - Lecture 1", pub_date=datetime(2013, 2, 10, 15, 21, 17, 345952), filename="vo_10_02_13_1", tags='.preparation', ).save() Slide( lecture_id=1, title="Preparation Slide #2 - Lecture 1", pub_date=datetime(2013, 2, 10, 15, 22, 17, 345952), filename="vo_10_02_13_2", tags='.preparation', ).save() Slide( lecture_id=1, title="Preparation Slide #3 - Lecture 1", pub_date=datetime(2013, 2, 10, 15, 23, 17, 345952), filename="vo_10_02_13_3", tags='.preparation', ).save() Slide( lecture_id=1, title="Super Sample Slide #1 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 20, 17, 345952), filename="vo_15_02_13_1", tags='.exercise', ).save() Slide( lecture_id=1, title="Super Sample Slide #2 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 22, 17, 345952), filename="vo_15_02_13_2", ).save() Slide( lecture_id=1, title="Super Sample Slide #3 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 24, 17, 345952), filename="vo_15_02_13_3", ).save() Slide( lecture_id=1, title="Super Sample Slide #4 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 26, 17, 345952), filename="vo_15_02_13_4", ).save() Slide( lecture_id=1, title="Super Sample Slide #5 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 28, 17, 345952), filename="vo_15_02_13_5", tags='.exercise', ).save() Slide( lecture_id=1, title="Super Sample Slide #6 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 30, 17, 345952), filename="vo_15_02_13_6", ).save() Slide( lecture_id=1, title="Super Sample Slide #7 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 32, 17, 345952), filename="vo_15_02_13_7", ).save() Slide( lecture_id=1, title="Super Sample Slide #8 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 34, 17, 345952), filename="vo_15_02_13_8", ).save() Slide( lecture_id=1, title="Super Sample Slide #9 - Lecture 1", pub_date=datetime(2013, 2, 15, 15, 36, 17, 345952), filename="vo_15_02_13_9", tags='.exercise', ).save() Slide( lecture_id=2, title="Super Sample Slide #1 - Lecture 2", pub_date=datetime(2013, 2, 16, 15, 20, 17, 345952), filename="vo_16_02_13_1", ).save() Slide( lecture_id=2, title="Super Sample Slide #2 - Lecture 2", pub_date=datetime(2013, 2, 16, 15, 22, 17, 345952), filename="vo_16_02_13_2", ).save() Slide( lecture_id=2, title="Super Sample Slide #2 - Lecture 2", pub_date=datetime(2013, 2, 16, 15, 24, 17, 345952), filename="vo_16_02_13_3", ).save() Slide( lecture_id=3, title="Super Sample Slide #1 - Lecture 3", pub_date=datetime(2013, 2, 17, 15, 20, 17, 345952), filename="vo_17_02_13_1", ).save() Slide( lecture_id=3, title="Super Sample Slide #2 - Lecture 3", pub_date=datetime(2013, 2, 17, 15, 22, 17, 345952), filename="vo_17_02_13_2", tags='.exercise', ).save() print("Adding sample stream") Stream( lecture_id=1, url="rtmp://video.zserv.tuwien.ac.at/lecturetube_public", type="rtmp", clipname="gsiss13e10", offset=-656, ).save() for user in AuroraUser.objects.all(): if not user.avatar: user.get_gravatar()
class AuroraUserTest(TestCase): def setUp(self): self.create_test_users(4) self.create_course() self.create_stack() self.create_challenge() self.create_review_question() def create_test_user(self, username): user = AuroraUser(username=username) user.email = '%[email protected].' % username user.first_name = 'Firstname_%s' % username user.last_name = 'Lastname_%s' % username user.nickname = 'Nickname_%s' % username user.is_staff = False user.is_superuser = False password = username user.set_password(password) user.matriculation_number = username + '2857289' user.save() return user def create_test_users(self, amount): self.users = [] for i in range(amount): self.users.append(self.create_test_user("s%s" % i)) def create_course(self): self.course = Course( title='test_title', short_title='test_short_title', description='test_description', course_number='test_course_number', ) self.course.save() for user in self.users: CourseUserRelation(course=self.course, user=user).save() def create_stack(self): self.stack = Stack(title="test stack", description="test description", course=self.course) self.stack.save() def create_challenge(self): self.challenge = Challenge( title='test_title', subtitle='test_subtitle', description='test_description', course=self.course, ) self.challenge.save() StackChallengeRelation(stack=self.stack, challenge=self.challenge).save() def create_review_question(self): self.review_question = ReviewQuestion( challenge=self.challenge, order=1, text= "Can you find any additional material not included in this submission?" ) self.review_question.save() def create_review(self, elaboration, reviewer): Review(elaboration=elaboration, submission_time=datetime.now(), reviewer=reviewer, appraisal='S').save() @staticmethod def ipython_test(): user = AuroraUser.objects.get(username='******') c = Client() shared_secret = settings.SSO_SHARED_SECRET.encode(encoding='latin1') oid = '258' now = int( (datetime.utcnow() - datetime(1970, 1, 1)).total_seconds() / 10) values_string = oid + user.matriculation_number + user.first_name + user.last_name + user.email + str( now) hmac_calced = hmac_new(shared_secret, values_string.encode(encoding='latin1'), sha1).hexdigest() values = { 'oid': oid, 'mn': user.matriculation_number, 'firstName': user.first_name, 'lastName': user.last_name, 'mail': user.email, 'sKey': hmac_calced } # response = c.get('sso_auth_callback', values, follow=True) from django.http import QueryDict q = QueryDict('', mutable=True) for key in values.keys(): q[key] = values[key] url = 'http://localhost:8000/sso_auth_callback?' + q.urlencode() return url def test_sso(self): c = Client() shared_secret = settings.SSO_SHARED_SECRET.encode(encoding='latin1') oid = '258' user = self.users[0] now = int( (datetime.utcnow() - datetime(1970, 1, 1)).total_seconds() / 10) values_string = oid + user.matriculation_number + user.first_name + user.last_name + user.email + str( now) hmac_calced = hmac_new(shared_secret, values_string.encode(encoding='latin1'), sha1).hexdigest() values = { 'oid': oid, 'mn': user.matriculation_number, 'firstName': user.first_name, 'lastName': user.last_name, 'mail': user.email, 'sKey': hmac_calced } response = c.get('sso_auth_callback', values, follow=True) def test_get_elaborations(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] assert len(user1.get_elaborations()) == 0 assert len(user2.get_elaborations()) == 0 assert len(user3.get_elaborations()) == 0 assert len(user4.get_elaborations()) == 0 elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() assert len(user1.get_elaborations()) == 1 assert elaboration1 in user1.get_elaborations() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() assert len(user2.get_elaborations()) == 1 assert elaboration2 in user2.get_elaborations() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() assert len(user3.get_elaborations()) == 1 assert elaboration3 in user3.get_elaborations() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert len(user4.get_elaborations()) == 1 assert elaboration4 in user4.get_elaborations() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() elaboration5 = Elaboration(challenge=challenge2, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration5.save() assert len(user1.get_elaborations()) == 2 assert elaboration1 in user1.get_elaborations() assert elaboration5 in user1.get_elaborations() elaboration6 = Elaboration(challenge=challenge2, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration6.save() assert len(user2.get_elaborations()) == 2 assert elaboration2 in user2.get_elaborations() assert elaboration6 in user2.get_elaborations() elaboration7 = Elaboration(challenge=challenge2, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration7.save() assert len(user3.get_elaborations()) == 2 assert elaboration3 in user3.get_elaborations() assert elaboration7 in user3.get_elaborations() elaboration8 = Elaboration(challenge=challenge2, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration8.save() assert len(user4.get_elaborations()) == 2 assert elaboration4 in user4.get_elaborations() assert elaboration8 in user4.get_elaborations() def test_get_challenge_elaboration(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] assert not user1.get_challenge_elaboration(challenge1) assert not user2.get_challenge_elaboration(challenge1) assert not user3.get_challenge_elaboration(challenge1) assert not user4.get_challenge_elaboration(challenge1) elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert user1.get_challenge_elaboration(challenge1) == elaboration1 assert user2.get_challenge_elaboration(challenge1) == elaboration2 assert user3.get_challenge_elaboration(challenge1) == elaboration3 assert user4.get_challenge_elaboration(challenge1) == elaboration4 Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() assert not user1.get_challenge_elaboration(challenge2) assert not user2.get_challenge_elaboration(challenge2) assert not user3.get_challenge_elaboration(challenge2) assert not user4.get_challenge_elaboration(challenge2) elaboration5 = Elaboration(challenge=challenge2, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration5.save() elaboration6 = Elaboration(challenge=challenge2, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration6.save() elaboration7 = Elaboration(challenge=challenge2, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration7.save() elaboration8 = Elaboration(challenge=challenge2, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration8.save() assert user1.get_challenge_elaboration(challenge2) == elaboration5 assert user2.get_challenge_elaboration(challenge2) == elaboration6 assert user3.get_challenge_elaboration(challenge2) == elaboration7 assert user4.get_challenge_elaboration(challenge2) == elaboration8 def test_get_stack_elaborations(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] assert len(user1.get_stack_elaborations(self.stack)) == 0 assert len(user2.get_stack_elaborations(self.stack)) == 0 assert len(user3.get_stack_elaborations(self.stack)) == 0 assert len(user4.get_stack_elaborations(self.stack)) == 0 elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert len(user1.get_stack_elaborations(self.stack)) == 1 assert len(user2.get_stack_elaborations(self.stack)) == 1 assert len(user3.get_stack_elaborations(self.stack)) == 1 assert len(user4.get_stack_elaborations(self.stack)) == 1 assert elaboration1 in user1.get_stack_elaborations(self.stack) assert elaboration2 in user2.get_stack_elaborations(self.stack) assert elaboration3 in user3.get_stack_elaborations(self.stack) assert elaboration4 in user4.get_stack_elaborations(self.stack) Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() elaboration5 = Elaboration(challenge=challenge2, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration5.save() elaboration6 = Elaboration(challenge=challenge2, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration6.save() elaboration7 = Elaboration(challenge=challenge2, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration7.save() elaboration8 = Elaboration(challenge=challenge2, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration8.save() assert len(user1.get_stack_elaborations(self.stack)) == 2 assert len(user2.get_stack_elaborations(self.stack)) == 2 assert len(user3.get_stack_elaborations(self.stack)) == 2 assert len(user4.get_stack_elaborations(self.stack)) == 2 assert elaboration1 in user1.get_stack_elaborations(self.stack) assert elaboration2 in user2.get_stack_elaborations(self.stack) assert elaboration3 in user3.get_stack_elaborations(self.stack) assert elaboration4 in user4.get_stack_elaborations(self.stack) assert elaboration5 in user1.get_stack_elaborations(self.stack) assert elaboration6 in user2.get_stack_elaborations(self.stack) assert elaboration7 in user3.get_stack_elaborations(self.stack) assert elaboration8 in user4.get_stack_elaborations(self.stack)
class ChallengeTest(TestCase): def setUp(self): self.create_test_users(4) self.create_course() self.create_stack() self.create_challenge() self.create_review_question() def create_test_user(self, username): user = AuroraUser(username=username) user.email = '%[email protected].' % username user.first_name = 'Firstname_%s' % username user.last_name = 'Lastname_%s' % username user.nickname = 'Nickname_%s' % username user.is_staff = False user.is_superuser = False password = username user.set_password(password) user.save() return user def create_test_users(self, amount): self.users = [] for i in range(amount): self.users.append(self.create_test_user("s%s" % i)) def create_course(self): self.course = Course( title='test_title', short_title='test_short_title', description='test_description', course_number='test_course_number', ) self.course.save() for user in self.users: CourseUserRelation(course=self.course, user=user).save() def create_stack(self): self.stack = Stack(title="test stack", description="test description", course=self.course) self.stack.save() def create_challenge(self): self.challenge = Challenge( title='test_title', subtitle='test_subtitle', description='test_description', course=self.course, ) self.challenge.save() StackChallengeRelation(stack=self.stack, challenge=self.challenge).save() def create_review_question(self): self.review_question = ReviewQuestion( challenge=self.challenge, order=1, text= "Can you find any additional material not included in this submission?" ) self.review_question.save() def create_review(self, elaboration, reviewer): Review(elaboration=elaboration, submission_time=datetime.now(), reviewer=reviewer, appraisal='S').save() def test_next(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() assert challenge1.get_next() == challenge2 assert challenge2.get_next() == challenge3 assert challenge3.get_next() is None def test_get_elaboration(self): user = self.users[0] assert self.challenge.get_elaboration(user) is None elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test") elaboration.save() assert self.challenge.get_elaboration(user) == elaboration def test_get_stack(self): challenge = Challenge(title='test_title', subtitle='test_subtitle', description='test_description', course=self.course) challenge.save() assert challenge.get_stack() is None assert self.challenge.get_stack() == self.stack def test_is_first_challenge(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() assert challenge1.is_first_challenge() assert not challenge2.is_first_challenge() assert not challenge3.is_first_challenge() def test_is_final_challenge(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() assert not challenge1.is_final_challenge() assert not challenge2.is_final_challenge() assert challenge3.is_final_challenge() def test_get_final_challenge(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() assert challenge1.get_final_challenge() == challenge3 assert challenge2.get_final_challenge() == challenge3 assert challenge3.get_final_challenge() == challenge3 def test_get_first_challenge(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() assert challenge1.get_first_challenge() == challenge1 assert challenge2.get_first_challenge() == challenge1 assert challenge3.get_first_challenge() == challenge1 def test_has_enough_user_reviews(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() user1 = self.users[0] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() user2 = self.users[1] elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() user3 = self.users[2] elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() user4 = self.users[3] elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert not challenge1.has_enough_user_reviews(user1) Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert not challenge1.has_enough_user_reviews(user1) Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert not challenge1.has_enough_user_reviews(user1) Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge1.has_enough_user_reviews(user1) def test_is_started(self): user = self.users[0] elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="") elaboration.save() assert self.challenge.is_started(user) is False elaboration.elaboration_text = "test" elaboration.save() assert self.challenge.is_started(user) is True def test_submitted_by_user(self): user = self.users[0] elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test") elaboration.save() assert not self.challenge.submitted_by_user(user) elaboration.submission_time = datetime.now() elaboration.save() assert self.challenge.submitted_by_user(user) def test_get_review_written_by_user(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() user1 = self.users[0] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() user2 = self.users[1] elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() user3 = self.users[2] elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() user4 = self.users[3] elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert len(challenge1.get_reviews_written_by_user(user1)) == 0 review1 = Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS) review1.save() assert len(challenge1.get_reviews_written_by_user(user1)) == 1 assert review1 in challenge1.get_reviews_written_by_user(user1) review2 = Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS) review2.save() assert len(challenge1.get_reviews_written_by_user(user1)) == 2 assert review1 in challenge1.get_reviews_written_by_user(user1) assert review2 in challenge1.get_reviews_written_by_user(user1) review3 = Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS) review3.save() assert len(challenge1.get_reviews_written_by_user(user1)) == 3 assert review1 in challenge1.get_reviews_written_by_user(user1) assert review2 in challenge1.get_reviews_written_by_user(user1) assert review3 in challenge1.get_reviews_written_by_user(user1) def test_get_elaborations(self): assert len(self.challenge.get_elaborations()) == 0 user = self.users[0] elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test") elaboration.save() assert len(self.challenge.get_elaborations()) == 1 assert elaboration in self.challenge.get_elaborations() def test_first_challenge_is_always_enabled(self): user = self.users[0] assert self.challenge.is_enabled_for_user(user) def test_already_submitted_challenges_are_enabled(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() user = self.users[0] assert not challenge2.is_enabled_for_user(user) elaboration = Elaboration(challenge=challenge2, user=user, elaboration_text="test") elaboration.save() assert not challenge2.is_enabled_for_user(user) elaboration.submission_time = datetime.now() elaboration.save() assert challenge2.is_enabled_for_user(user) def test_enough_user_reviews_required(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert not challenge2.is_enabled_for_user(user1) Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert not challenge2.is_enabled_for_user(user1) Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert not challenge2.is_enabled_for_user(user1) Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge2.is_enabled_for_user(user1) def test_if_stack_blocked_challenge_is_not_enabled_fail(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge2.is_enabled_for_user(user1) Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.FAIL).save() # a failed review does not block the stack assert challenge2.is_enabled_for_user(user1) def test_if_stack_blocked_challenge_is_not_enabled_nothing(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge2.is_enabled_for_user(user1) Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.NOTHING).save() # nothing should not block a user from working assert challenge2.is_enabled_for_user(user1) def test_final_challenge_enabled(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert not challenge2.is_enabled_for_user(user1) Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() assert challenge2.is_enabled_for_user(user1) def test_final_challenge_enabled_bug_issue_114(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert not challenge3.is_enabled_for_user(user1) Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() assert not challenge3.is_enabled_for_user(user1) def test_status_not_started(self): user = self.users[0] assert self.challenge.is_enabled_for_user(user) assert self.challenge.get_status(user) == Challenge.NOT_STARTED def test_status_not_submitted(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() user = self.users[0] assert challenge1.get_status(user) == Challenge.NOT_STARTED elaboration = Elaboration(challenge=challenge1, user=user, elaboration_text="test") elaboration.save() assert challenge1.is_enabled_for_user(user) assert challenge1.get_status(user) == Challenge.NOT_SUBMITTED assert not challenge2.is_enabled_for_user(user) assert challenge2.get_status(user) == Challenge.NOT_ENABLED def test_status_blocked_bad_review_fail(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert not challenge2.is_enabled_for_user(user1) assert challenge1.get_status(user1) == Challenge.USER_REVIEW_MISSING assert challenge2.get_status(user1) == Challenge.NOT_ENABLED bad_review = Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.FAIL) bad_review.save() assert not challenge2.is_enabled_for_user(user1) assert challenge1.get_status(user1) == Challenge.USER_REVIEW_MISSING assert challenge2.get_status(user1) == Challenge.NOT_ENABLED bad_review.appraisal = Review.SUCCESS bad_review.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge1.has_enough_user_reviews(user1) assert challenge1.get_status( user1) == Challenge.DONE_MISSING_PEER_REVIEW assert challenge2.is_enabled_for_user(user1) assert challenge2.get_status(user1) == Challenge.NOT_STARTED bad_review.appraisal = Review.FAIL bad_review.save() assert challenge2.is_enabled_for_user(user1) assert challenge2.get_status(user1) == Challenge.NOT_STARTED def test_status_blocked_bad_review_nothing(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert not challenge2.is_enabled_for_user(user1) assert challenge1.get_status(user1) == Challenge.USER_REVIEW_MISSING assert challenge2.get_status(user1) == Challenge.NOT_ENABLED bad_review = Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.NOTHING) bad_review.save() assert not challenge2.is_enabled_for_user(user1) assert challenge1.get_status(user1) == Challenge.BLOCKED_BAD_REVIEW assert challenge2.get_status(user1) == Challenge.NOT_ENABLED bad_review.appraisal = Review.SUCCESS bad_review.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge1.has_enough_user_reviews(user1) assert challenge1.get_status( user1) == Challenge.DONE_MISSING_PEER_REVIEW assert challenge2.is_enabled_for_user(user1) assert challenge2.get_status(user1) == Challenge.NOT_STARTED bad_review.appraisal = Review.NOTHING bad_review.save() assert challenge2.is_enabled_for_user(user1) assert challenge2.get_status(user1) == Challenge.NOT_STARTED def test_status_user_review_missing(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert challenge1.is_enabled_for_user(user1) assert challenge1.get_status(user1) == Challenge.USER_REVIEW_MISSING assert not challenge2.is_enabled_for_user(user1) assert challenge2.get_status(user1) == Challenge.NOT_ENABLED Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge1.is_enabled_for_user(user1) assert challenge1.get_status(user1) == Challenge.USER_REVIEW_MISSING assert not challenge2.is_enabled_for_user(user1) assert challenge2.get_status(user1) == Challenge.NOT_ENABLED Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge1.is_enabled_for_user(user1) assert challenge1.get_status(user1) == Challenge.USER_REVIEW_MISSING assert not challenge2.is_enabled_for_user(user1) assert challenge2.get_status(user1) == Challenge.NOT_ENABLED Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge1.is_enabled_for_user(user1) assert challenge1.get_status( user1) == Challenge.DONE_MISSING_PEER_REVIEW assert challenge2.is_enabled_for_user(user1) assert challenge2.get_status(user1) == Challenge.NOT_STARTED def test_status_done_missing_peer_review(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge1.get_status( user1) == Challenge.DONE_MISSING_PEER_REVIEW Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() assert challenge1.get_status( user1) == Challenge.DONE_MISSING_PEER_REVIEW Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() assert challenge1.get_status( user1) == Challenge.DONE_MISSING_PEER_REVIEW def test_status_final_challenge(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() user1 = self.users[0] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() user2 = self.users[1] elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() user3 = self.users[2] elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() user4 = self.users[3] elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert challenge1.get_status( user1) == Challenge.DONE_MISSING_PEER_REVIEW assert challenge2.get_status(user1) == Challenge.NOT_ENABLED Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() assert challenge1.get_status(user1) == Challenge.DONE_PEER_REVIEWED assert challenge2.get_status(user1) == Challenge.NOT_STARTED final_elaboration = Elaboration(challenge=challenge2, user=user1, elaboration_text="test", submission_time=datetime.now()) final_elaboration.save() assert challenge2.get_status(user1) == Challenge.WAITING_FOR_EVALUATION tutor = user4 tutor.staff = True tutor.save() Evaluation(submission=final_elaboration, tutor=tutor, evaluation_text="test evaluation", evaluation_points=10, submission_time=datetime.now()).save() assert challenge2.get_status(user1) == Challenge.EVALUATED
class SimpleTest(TestCase): def setUp(self): self.create_test_users(4) self.create_course() self.create_challenge() self.create_review_question() self.create_elaborations() def create_test_user(self, username): user = AuroraUser(username=username) user.email = '%[email protected].' % username user.first_name = 'Firstname_%s' % username user.last_name = 'Lastname_%s' % username user.nickname = 'Nickname_%s' % username user.is_staff = False user.is_superuser = False password = username user.set_password(password) user.save() return user def create_test_users(self, amount): self.users = [] for i in range(amount): self.users.append(self.create_test_user("s%s" % i)) def create_course(self): self.course = Course( title='test_title', short_title='test_short_title', description='test_description', course_number='test_course_number', ) self.course.save() for user in self.users: CourseUserRelation(course=self.course, user=user).save() def create_challenge(self): self.challenge = Challenge( title='test_title', subtitle='test_subtitle', description='test_description', course=self.course, ) self.challenge.save() def create_review_question(self): self.review_question = ReviewQuestion( challenge=self.challenge, order=1, text= "Can you find any additional material not included in this submission?" ) self.review_question.save() def create_elaborations(self): self.elaborations = [] for user in self.users: elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test_text", submission_time=datetime.now()) elaboration.save() self.elaborations.append(elaboration) def create_review_without_submission_date(self, elaboration, reviewer): Review(elaboration=elaboration, reviewer=reviewer, appraisal='S').save() def create_review(self, elaboration, reviewer): Review(elaboration=elaboration, reviewer=reviewer, submission_time=datetime.now(), appraisal='S').save() def test_get_open_review(self): user1 = self.users[0] user2 = self.users[2] elaboration = self.elaborations[0] self.create_review_without_submission_date(elaboration=elaboration, reviewer=user1) # there should be an open review for user1 review = Review.get_open_review(self.challenge, user1) assert review assert review.reviewer == user1 assert review.elaboration == elaboration # there should be no open review for user1 since the review is already submitted review.submission_time = datetime.now() review.save() review = Review.get_open_review(self.challenge, user1) assert not review # there should be no open review for user2 review = Review.get_open_review(self.challenge, user2) assert not review # user1 and user2 both have separate open reviews self.create_review_without_submission_date(elaboration=elaboration, reviewer=user1) self.create_review_without_submission_date(elaboration=elaboration, reviewer=user2) review1 = Review.get_open_review(self.challenge, user1) review2 = Review.get_open_review(self.challenge, user2) assert review1 assert review2 assert review1.id != review2.id assert review1.reviewer == user1 assert review2.reviewer == user2 assert review1.elaboration == elaboration and review2.elaboration == elaboration def test_review_config_offset(self): assert ReviewConfig.get_candidate_offset_min() == 0 assert ReviewConfig.get_candidate_offset_max() == 0 ReviewConfig(candidate_offset_min=1, candidate_offset_max=2).save() assert ReviewConfig.get_candidate_offset_min() == 1 assert ReviewConfig.get_candidate_offset_max() == 2 def test_notification_too_soon(self): challenge1 = self.challenge challenge2 = Challenge( course=self.course, prerequisite=challenge1, ) challenge2.save() challenge3 = Challenge( course=self.course, prerequisite=challenge2, ) challenge3.save() stack = Stack(course=self.course) stack.save() StackChallengeRelation(stack=stack, challenge=challenge1).save() StackChallengeRelation(stack=stack, challenge=challenge2).save() StackChallengeRelation(stack=stack, challenge=challenge3).save() elab1 = challenge1.get_elaboration(self.users[0]) elab2 = Elaboration(challenge=challenge2, user=self.users[0]) elab2.save() assert stack.has_enough_peer_reviews(self.users[0]) is False Review(elaboration=elab2, reviewer=self.users[1], appraisal='S', submission_time=datetime.now()).save() Review(elaboration=elab2, reviewer=self.users[2], appraisal='S', submission_time=datetime.now()).save() assert stack.has_enough_peer_reviews(self.users[0]) is False Review(elaboration=elab1, reviewer=self.users[1], appraisal='S', submission_time=datetime.now()).save() Review(elaboration=elab1, reviewer=self.users[2], appraisal='S', submission_time=datetime.now()).save() assert stack.has_enough_peer_reviews(self.users[0]) is True
class StackTest(TestCase): def setUp(self): self.create_test_users(4) self.create_course() self.create_stack() self.create_challenge() self.create_review_question() def create_test_user(self, username): user = AuroraUser(username=username) user.email = '%[email protected].' % username user.first_name = 'Firstname_%s' % username user.last_name = 'Lastname_%s' % username user.nickname = 'Nickname_%s' % username user.is_staff = False user.is_superuser = False password = username user.set_password(password) user.save() return user def create_test_users(self, amount): self.users = [] for i in range(amount): self.users.append(self.create_test_user("s%s" % i)) def create_course(self): self.course = Course( title='test_title', short_title='test_short_title', description='test_description', course_number='test_course_number', ) self.course.save() for user in self.users: CourseUserRelation(course=self.course, user=user).save() def create_stack(self): self.stack = Stack(title="test stack", description="test description", course=self.course) self.stack.save() def create_challenge(self): self.challenge = Challenge( title='test_title', subtitle='test_subtitle', description='test_description', course=self.course, ) self.challenge.save() StackChallengeRelation(stack=self.stack, challenge=self.challenge).save() def create_review_question(self): self.review_question = ReviewQuestion( challenge=self.challenge, order=1, text="Can you find any additional material not included in this submission?" ) self.review_question.save() def create_review(self, elaboration, reviewer): Review(elaboration=elaboration, submission_time=datetime.now(), reviewer=reviewer, appraisal='S').save() def test_get_challenges(self): challenge1 = self.challenge assert challenge1 in self.stack.get_challenges() self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() assert challenge1 in self.stack.get_challenges() assert challenge2 in self.stack.get_challenges() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() assert challenge1 in self.stack.get_challenges() assert challenge2 in self.stack.get_challenges() assert challenge3 in self.stack.get_challenges() def test_final_challenge(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() assert self.stack.get_final_challenge().id is challenge3.id def test_first_challenge(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() assert self.stack.get_first_challenge().id is challenge1.id def test_is_started(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user = self.users[0] elaboration = Elaboration(challenge=challenge1, user=user, elaboration_text="") elaboration.save() assert self.stack.is_started(user) is False elaboration.elaboration_text = "test" elaboration.save() assert self.stack.is_started(user) is True def test_is_evaluated(self): user = self.users[0] tutor = self.users[1] tutor.staff = True tutor.save() assert self.stack.is_evaluated(user) is False elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test elaboration", submission_time=datetime.now()) elaboration.save() evaluation = Evaluation(submission=elaboration, tutor=tutor, evaluation_text="test_evaluation") evaluation.save() assert self.stack.is_evaluated(user) is False evaluation.submission_time = datetime.now() evaluation.evaluation_points = 10 evaluation.save() assert self.stack.is_evaluated(user) is True def test_get_points(self): user = self.users[0] tutor = self.users[1] tutor.staff = True tutor.save() assert self.stack.get_points_earned(user) == 0 elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test elaboration", submission_time=datetime.now()) elaboration.save() evaluation = Evaluation(submission=elaboration, tutor=tutor, evaluation_text="test_evaluation", submission_time=datetime.now()) for points in range(10): evaluation.evaluation_points = points evaluation.save() assert self.stack.get_points_earned(user) == points def test_last_available_challenge(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert self.stack.get_last_available_challenge(user1) == challenge1 Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert self.stack.get_last_available_challenge(user1) == challenge2 Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() elaboration5 = Elaboration(challenge=challenge2, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration5.save() elaboration6 = Elaboration(challenge=challenge2, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration6.save() elaboration7 = Elaboration(challenge=challenge2, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration7.save() elaboration8 = Elaboration(challenge=challenge2, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration8.save() assert self.stack.get_last_available_challenge(user1) == challenge2 Review(elaboration=elaboration6, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration7, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration8, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert self.stack.get_last_available_challenge(user1) == challenge2 Review(elaboration=elaboration5, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration5, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() assert self.stack.get_last_available_challenge(user1) == challenge3 def test_is_blocked(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() assert not self.stack.is_blocked(user2) review = Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user2) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user2) assert not self.stack.is_blocked(user3) review = Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user3) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user3) assert not self.stack.is_blocked(user4) review = Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user4) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user4) assert not self.stack.is_blocked(user1) review = Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user1) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user1) review = Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user1) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user1) elaboration5 = Elaboration(challenge=challenge2, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration5.save() elaboration6 = Elaboration(challenge=challenge2, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration6.save() elaboration7 = Elaboration(challenge=challenge2, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration7.save() elaboration8 = Elaboration(challenge=challenge2, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration8.save() assert not self.stack.is_blocked(user2) review = Review(elaboration=elaboration6, submission_time=datetime.now(), reviewer=user1, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user2) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user2) assert not self.stack.is_blocked(user3) review = Review(elaboration=elaboration7, submission_time=datetime.now(), reviewer=user1, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user3) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user3) assert not self.stack.is_blocked(user4) review = Review(elaboration=elaboration8, submission_time=datetime.now(), reviewer=user1, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user4) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user4) assert not self.stack.is_blocked(user1) review = Review(elaboration=elaboration5, submission_time=datetime.now(), reviewer=user2, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user1) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user1) review = Review(elaboration=elaboration5, submission_time=datetime.now(), reviewer=user3, appraisal=Review.NOTHING) review.save() assert self.stack.is_blocked(user1) review.appraisal = Review.SUCCESS review.save() assert not self.stack.is_blocked(user1) def test_has_enough_peer_reviews(self): challenge1 = self.challenge self.create_challenge() challenge2 = self.challenge challenge2.prerequisite = challenge1 challenge2.save() self.create_challenge() challenge3 = self.challenge challenge3.prerequisite = challenge2 challenge3.save() user1 = self.users[0] user2 = self.users[1] user3 = self.users[2] user4 = self.users[3] elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration1.save() elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration2.save() elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration3.save() elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration4.save() Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert not self.stack.has_enough_peer_reviews(user1) Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() assert not self.stack.has_enough_peer_reviews(user1) Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() assert not self.stack.has_enough_peer_reviews(user1) elaboration5 = Elaboration(challenge=challenge2, user=user1, elaboration_text="test", submission_time=datetime.now()) elaboration5.save() elaboration6 = Elaboration(challenge=challenge2, user=user2, elaboration_text="test", submission_time=datetime.now()) elaboration6.save() elaboration7 = Elaboration(challenge=challenge2, user=user3, elaboration_text="test", submission_time=datetime.now()) elaboration7.save() elaboration8 = Elaboration(challenge=challenge2, user=user4, elaboration_text="test", submission_time=datetime.now()) elaboration8.save() Review(elaboration=elaboration6, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration7, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() Review(elaboration=elaboration8, submission_time=datetime.now(), reviewer=user1, appraisal=Review.SUCCESS).save() assert not self.stack.has_enough_peer_reviews(user1) Review(elaboration=elaboration5, submission_time=datetime.now(), reviewer=user2, appraisal=Review.SUCCESS).save() assert not self.stack.has_enough_peer_reviews(user1) Review(elaboration=elaboration5, submission_time=datetime.now(), reviewer=user3, appraisal=Review.SUCCESS).save() assert self.stack.has_enough_peer_reviews(user1)