Exemplo n.º 1
0
    def test_get_max_points(self):

        # ---------- SETUP -------------------
        subject1 = Subject(subject_code='TDT4100',
                           subject_name='Matte',
                           professor_firstname='Jan',
                           professor_lastname='Teigen',
                           professor_email='*****@*****.**')
        subject1.save()
        chapter1 = Chapter(chapter_number=1,
                           chapter_name="Multiplikasjon",
                           subject=subject1)
        chapter1.save()
        ex1 = Exercise_Page(chapter=chapter1,
                            easy_points=1,
                            medium_points=4,
                            hard_points=5)
        ex2 = Exercise_Page(chapter=chapter1,
                            easy_points=2,
                            medium_points=3,
                            hard_points=5)
        ex1.save(), ex2.save()

        # ----------------------------------

        self.assertEqual(views.get_max_points(subject1), 20)
Exemplo n.º 2
0
 def setUp(self):
     Subject(subject_code='TDT4100',
             subject_name='Matte',
             professor_firstname='Jan',
             professor_lastname='Teigen',
             professor_email='*****@*****.**').save()
     Subject(subject_code='TDT4110',
             subject_name='Matte',
             professor_firstname='Jan',
             professor_lastname='Teigen',
             professor_email='*****@*****.**').save()
Exemplo n.º 3
0
    def setUp(self):
        # create a user
        user = User.objects.create_user('Hans', '*****@*****.**', '123zxc')
        user.save()

        # create s subject the user can add
        subject = Subject(subject_code='TDT4100', subject_name='Matte',
                    professor_firstname='Jan', professor_lastname='Teigen', professor_email='*****@*****.**')
        subject.save()

        user.userprofile.add_subject(subject)
Exemplo n.º 4
0
    def test_create_subject_graph_values(self):
        # ----------- SETUP --------------
        subject1 = Subject(subject_code='TDT4100',
                           subject_name='Matte',
                           professor_firstname='Jan',
                           professor_lastname='Teigen',
                           professor_email='*****@*****.**')
        subject1.save()
        chapter1 = Chapter(chapter_number=1,
                           chapter_name="Multiplikasjon",
                           subject=subject1)
        chapter1.save()
        ex1 = Exercise_Page(chapter=chapter1,
                            easy_points=1,
                            medium_points=4,
                            hard_points=5)
        ex2 = Exercise_Page(chapter=chapter1,
                            easy_points=1,
                            medium_points=4,
                            hard_points=5)

        ex1.save(), ex2.save()

        user1 = User(username='******', password='******')
        user2 = User(username='******', password='******')
        user3 = User(username='******', password='******')

        user1.save(), user2.save(), user3.save()

        user1.userprofile.add_subject(subject1.pk)
        user2.userprofile.add_subject(subject1.pk)
        user3.userprofile.add_subject(subject1.pk)

        # --------------------------------

        connection1 = StudentConnectSubject.objects.get(user=user1,
                                                        subject=subject1)
        connection2 = StudentConnectSubject.objects.get(user=user2,
                                                        subject=subject1)
        connection3 = StudentConnectSubject.objects.get(user=user3,
                                                        subject=subject1)

        connection1.points = 20
        connection2.points = 1
        connection3.points = 10

        connection1.save(), connection2.save(), connection3.save()

        data = views.create_subject_graph_values(subject1)
        correct_data = [1, 0, 0, 0, 1, 0, 0, 0, 0, 1]

        self.assertEqual(data, correct_data)
Exemplo n.º 5
0
 def setUp(self):
     subject1 = Subject(subject_code='TMT4100',
                        subject_name='Matte',
                        professor_firstname='Jan',
                        professor_lastname='Teigen',
                        professor_email='*****@*****.**')
     subject1.save()
     subject2 = Subject(subject_code='TMT4140',
                        subject_name='Matte 2',
                        professor_firstname='Jan',
                        professor_lastname='Teigen',
                        professor_email='*****@*****.**')
     subject2.save()
     chapter1 = Chapter(chapter_number=1,
                        chapter_name="Integrasjon",
                        subject=Subject.objects.get(pk="TMT4100"))
     chapter1.save()
     chapter2 = Chapter(chapter_number=1,
                        chapter_name="Diff lign",
                        subject=Subject.objects.get(pk="TMT4140"))
     chapter2.save()
     exercise = Exercise_Page(chapter=chapter1,
                              headline="Oppgave 1",
                              easy_question="Hvorfor funker dette?",
                              easy_answer="Because Django",
                              easy_points=3)
     exercise.save()
Exemplo n.º 6
0
 def setUp(self):
     Subject(subject_code='TDT4100',
             subject_name='Matte',
             professor_firstname='Jan',
             professor_lastname='Teigen',
             professor_email='*****@*****.**').save()
     user = User.objects.create_user(username='******', password='******')
     user.save()
     self.client.login(username='******', password='******')
Exemplo n.º 7
0
    def test_fix_highscore_info(self):

        # ----------- SETUP --------------
        # Subject
        subject1 = Subject(subject_code='TDT4100',
                           subject_name='Matte',
                           professor_firstname='Jan',
                           professor_lastname='Teigen',
                           professor_email='*****@*****.**')
        subject1.save()

        # students
        user1 = User(username='******', password='******')
        user2 = User(username='******', password='******')
        user1.save(), user2.save()

        # connects students to
        user1.userprofile.add_subject(subject1.pk)
        user2.userprofile.add_subject(subject1.pk)

        # fix the users points in the subject
        StudentConnectSubject.objects.get(user=user1,
                                          subject=subject1).points = 10
        StudentConnectSubject.objects.get(user=user2,
                                          subject=subject1).points = 5

        # ----------------------------------------------

        highscore_info = views.fix_highscore_info(subject1)

        # testing the length of highscore_info
        self.assertEqual(len(highscore_info), 2)

        # testing that the ranks is in the correct order
        self.assertTrue(highscore_info[0][0] == 1)
        self.assertTrue(highscore_info[1][0] == 2)

        # testing that user1 has rank=1 (first)
        self.assertTrue(highscore_info[0][1].user == user1)

        # testing that the value of the last index is in the correct format
        self.assertTrue(highscore_info[1][2] == "0 %")
Exemplo n.º 8
0
    def setUp(self):
        # create a subject
        subject = Subject(subject_code='TDT4100', subject_name='Matte',
                          professor_firstname='Jan', professor_lastname='Teigen', professor_email='*****@*****.**')
        subject.save()
        # create a chapter
        chapter = Chapter(chapter_number=1, chapter_name="Multiplikasjon", subject=subject)
        chapter.save()

        # create some exercises
        ex1 = Exercise_Page(chapter=chapter, easy_points=1, medium_points=4, hard_points=5)
        ex2 = Exercise_Page(chapter=chapter, easy_points=2, medium_points=3, hard_points=5)
        ex1.save(), ex2.save()

        # create a user
        user = User.objects.create_user('Hans', '*****@*****.**', '123zxc')
        user.save()

        # let user follow subject
        user.userprofile.add_subject(subject.pk)
Exemplo n.º 9
0
    def test_create_means(self):
        # ----------- SETUP --------------
        subject1 = Subject(subject_code='TDT4100',
                           subject_name='Matte',
                           professor_firstname='Jan',
                           professor_lastname='Teigen',
                           professor_email='*****@*****.**')
        subject1.save()
        chapter1 = Chapter(chapter_number=1,
                           chapter_name="Multiplikasjon",
                           subject=subject1)
        chapter1.save()
        ex1 = Exercise_Page(chapter=chapter1,
                            easy_points=1,
                            medium_points=4,
                            hard_points=5)
        ex1.save()

        user1 = User(username='******', password='******')
        user2 = User(username='******', password='******')
        user1.save(), user2.save()

        user1.userprofile.add_subject(subject1.pk)
        user2.userprofile.add_subject(subject1.pk)
        # --------------------------------

        connection1 = StudentConnectExercise(user=user1, exercise=ex1)
        connection1.completed_easy = True
        connection1.completed_hard = True
        connection1.save()

        connection2 = StudentConnectExercise(user=user2, exercise=ex1)
        connection2.completed_easy = True
        connection2.completed_medium = True
        connection2.save()

        data = views.create_means(ex1)
        correct_data = (2, 1, 1)

        self.assertEqual(data, correct_data)
Exemplo n.º 10
0
 def test_exercise_bargraph(self):
     user = User.objects.create_user(username='******', password='******')
     user.save()
     self.client.login(username='******', password='******')
     subject = Subject(subject_code='TDT4100',
                       subject_name='Matte',
                       professor_firstname='Jan',
                       professor_lastname='Teigen',
                       professor_email='*****@*****.**')
     subject.save()
     chapter = Chapter(chapter_number=1,
                       chapter_name="Multiplikasjon",
                       subject=subject)
     chapter.save()
     ex = Exercise_Page(chapter=chapter,
                        easy_points=2,
                        medium_points=3,
                        hard_points=5)
     ex.save()
     url = '/adminpage/statistics/TDT4100/graph/' + str(ex.pk) + '/'
     response = self.client.get(url)
     self.assertEqual(response.status_code, 200)
Exemplo n.º 11
0
    def test_get_number_of_students(self):

        # -------- SETUP ------------------
        subject1 = Subject(subject_code='TDT4100',
                           subject_name='Matte',
                           professor_firstname='Jan',
                           professor_lastname='Teigen',
                           professor_email='*****@*****.**')
        user1 = User(username='******', password='******')
        user2 = User(username='******', password='******')
        user3 = User(username='******', password='******')

        subject1.save(), user1.save(), user2.save(), user3.save()
        # -------------------------------------

        self.assertEqual(views.get_number_of_students(subject1), 0)

        user1.userprofile.add_subject(subject1.pk)
        user2.userprofile.add_subject(subject1.pk)
        user3.userprofile.add_subject(subject1.pk)

        self.assertEqual(views.get_number_of_students(subject1), 3)
Exemplo n.º 12
0
 def setUp(self):
     subject1 = Subject(subject_code='TDT4100',
                        subject_name='Matte',
                        professor_firstname='Jan',
                        professor_lastname='Teigen',
                        professor_email='*****@*****.**')
     subject1.save()
     chapter1 = Chapter(chapter_number=1,
                        chapter_name="Multiplikasjon",
                        subject=subject1)
     chapter1.save()
     ex1 = Exercise_Page(chapter=chapter1,
                         easy_points=1,
                         medium_points=4,
                         hard_points=5)
     ex2 = Exercise_Page(chapter=chapter1,
                         easy_points=2,
                         medium_points=3,
                         hard_points=5)
     ex1.save(), ex2.save()
     user = User.objects.create_user(username='******', password='******')
     user.save()
     self.client.login(username='******', password='******')
Exemplo n.º 13
0
    def setUp(self):
        # create some users
        hans = User.objects.create_user('Hans', '*****@*****.**', '123zxc')
        hans.save()
        grete = User.objects.create_user('Grete', '*****@*****.**', '123zxc')
        grete.save()
        peder = User.objects.create_user('Peder', '*****@*****.**', '123zxc')
        peder.save()

        # create a subject
        subject = Subject(subject_code='TDT4100', subject_name='Matte',
                    professor_firstname='Jan', professor_lastname='Teigen', professor_email='*****@*****.**')
        subject.save()
        # create a chapter
        chapter = Chapter(chapter_number=1, chapter_name="Multiplikasjon", subject=subject)
        chapter.save()

        # create some exercises
        ex1 = Exercise_Page(chapter=chapter, easy_points=1, medium_points=4, hard_points=5)
        ex2 = Exercise_Page(chapter=chapter, easy_points=2, medium_points=3, hard_points=5)
        ex1.save(), ex2.save()

        # make the users follow the subject
        hans.userprofile.add_subject(subject.pk)
        grete.userprofile.add_subject(subject.pk)
        peder.userprofile.add_subject(subject.pk)

        # fix the user points
        grete_conn = StudentConnectSubject.objects.get(user=grete, subject=subject)
        hans_conn =StudentConnectSubject.objects.get(user=hans, subject=subject)
        peder_conn = StudentConnectSubject.objects.get(user=peder, subject=subject)

        grete_conn.points = 20
        hans_conn.points = 7
        peder_conn.points = 3
        grete_conn.save(), hans_conn.save(), peder_conn.save()
Exemplo n.º 14
0
    def test_set_view_context(self):
        # create some more subjects
        subject1 = Subject(subject_code='TDT4101', subject_name='Matte',
                          professor_firstname='Jan', professor_lastname='Teigen', professor_email='*****@*****.**')
        subject1.save()
        subject2 = Subject(subject_code='TDT4102', subject_name='Matte',
                          professor_firstname='Jan', professor_lastname='Teigen', professor_email='*****@*****.**')
        subject2.save()

        grete = User.objects.get(username='******')
        grete.userprofile.add_subject(subject1.pk)
        grete.userprofile.add_subject(subject2.pk)

        grete_subjects = StudentConnectSubject.objects.filter(user=grete)
        context = views.set_view_context(grete_subjects, grete)

        self.assertTrue(context[0][0][2] == "100.0%")
        self.assertTrue(context[1][0][2] == "0 %")
        self.assertTrue(context[2][0][2] == "0 %")
Exemplo n.º 15
0
    def test_split_subjects(self):

        # because grete follows three subjects, all the lists should have length 1 because the subjects are divided by three
        # create some more subjects
        subject1 = Subject(subject_code='TDT4101', subject_name='Matte',
                          professor_firstname='Jan', professor_lastname='Teigen', professor_email='*****@*****.**')
        subject1.save()
        subject2 = Subject(subject_code='TDT4102', subject_name='Matte',
                          professor_firstname='Jan', professor_lastname='Teigen', professor_email='*****@*****.**')
        subject2.save()

        grete = User.objects.get(username='******')
        grete.userprofile.add_subject(subject1.pk)
        grete.userprofile.add_subject(subject2.pk)
        grete_subjects = StudentConnectSubject.objects.filter(user=grete)

        split = views.split_subjects(grete_subjects)

        self.assertTrue(len(split[0]) == 1)
        self.assertTrue(len(split[1]) == 1)
        self.assertTrue(len(split[2]) == 1)
import sys
sys.path.append("/home/course-share.org/requests")
import requests
import csv
import getpass
import re

from main.models import Subject, Building, TeachingBuilding, ClassRoom, PortalCourse, PortalSection, PortalMeeting, Professor, Book, Is_Textbook_For, BookCopy, Teaches

departments = {}
f = open("main/prepare/subjects.csv", "rU")
for row in csv.reader(f):
    departments[row[0]] = row[1].strip()
    Subject(code=row[0].strip(), name=row[1].strip()).save()
f.close()

url_0 = "https://portal.claremontmckenna.edu/ics/Portlets/CRM/CXWebLinks/Portlet.CXFacultyAdvisor/CXFacultyAdvisorPage.aspx?SessionID={4e4ee664-797e-43ac-86bc-b508cd139b14}&MY_SCP_NAME=/cgi-bin/course/pccrscatarea.cgi&DestURL=http://cx-cmc.cx.claremont.edu:51081/cgi-bin/course/pccrslistarea.cgi?crsarea="
url_1 = "&yr="
url_2 = "&sess="
years = range(2002, 2015)
years = [i for j in zip(years, years) for i in j]
years = map(str, years)
semesters = ["SP", "FA"] * 15
params = zip(years, semesters)


def process(row):
    year, semester, coursecode, subject_name, section, instructors, enrollment, credit, campus, building, room, days, start, end, title, textbook = row

    # Final: Get PortalCourse object
    semester = semester + str(year)[-2:]
Exemplo n.º 17
0
    "11-801", "11-803"
]
ress = [
    "не использую", "stepik", "youtube", "матпрофи", "гуглю", "javarush",
    "acmp"
]
maxSem = 6

print("started generating groups (группы)")
for gr in groups:
    g = Group(name=gr)
    g.save()
print("groups generated")
print("started generating subjects")
for sb in subjects:
    s = Subject(name=sb)
    s.save()
print("subjects generated")
print("started generating res")
for re in ress:
    r = AdditionalEduResource(name=re, url="somesite.com")
    r.save()
i = 0
print("res generated")
print("started generating users")
while i < len(surnames):
    user = User.objects.create_user(username=surnames[i] + str(i),
                                    password=surnames[i] + surnames[i])
    user.save()
    i += 1
print("users generated")
Exemplo n.º 18
0
    ['Computer Networks', 'CS8553', 'CSE', 5, '2020-12-14', '350'],

    ['Thermal Engineering 2', 'ME8651', 'Mech', 6, '2020-12-10', '350'],
    ['Dynamics and Machines', 'ME8652', 'Mech', 6, '2020-12-12', '350'],
    ['Design of Machine Elements', 'ME8653', 'Mech', 6, '2020-12-14', '350'],

    ['Mechatronics', 'ME8751', 'Mech', 7, '2020-12-10', '350'],
    ['Power Plant Engineering', 'ME8752', 'Mech', 7, '2020-12-12', '350'],
    ['Process and Plan Cost Estimation', 'ME8753', 'Mech', 7, '2020-12-14', '350'],

    ['Fundamentals Of Nano Science', 'GE8851', 'Mech', 8, '2020-12-10', '350'],
    ['Vibration and Noise Control', 'ME8852', 'Mech', 8, '2020-12-12', '350'],

]

for subject in subjects:
    sub = Subject(Name= subject[0], Sub_code= subject[1], Department= subject[2], Semester= subject[3], DateofExam = subject[4], Fee= subject[5])
    sub.save()

users = [
    ['310618104102', '*****@*****.**', '13dec2000', 'Sudharshanam', ''], ['2000-12-13', 'Male', 'CSE', 5],
    ['310618104130', '*****@*****.**', '01jan2000', 'ABC', ''], ['2000-12-31', 'Female', 'CSE', 3],
    ['310618104121', '*****@*****.**', '01jan2000', 'New User', ''], ['2000-12-01', 'Male', 'IT', 4],
]

for i in range(0, len(users), 2):
    user = User(username = users[i][0], password = users[i][2], email = users[i][1], first_name= users[i][3], last_name = users[i][4])
    user.save()
    stud = Student(user = user, DOB= users[i+1][0], Gender= users[i+1][1], Department= users[i+1][2], Semester = users[i+1][3])
    stud.save()