Exemple #1
0
    def post(self):
        
        message = ""
        assignToSyllabus = self.request.get('assignToSyllabus')
        loadFile = self.request.get('loadFile')
        generateDates = self.request.get('generateCalendar')
        rowInsert = self.request.get('insertRow')
        rowRemove = self.request.get('removeRow')
        save = self.request.get('save')
        
        user = self.current_user
        syllabus = self.current_syllabus
        term = self.current_term


        syllabusCalendars = CalendarClass.query(ancestor=user.key).filter(CalendarClass.workingCalendar == True).fetch()
        if syllabusCalendars:
            #should have exactly 1 calendar
            for i in syllabusCalendars:
                mySched = i
        else:
            #should not be reachable state
            mySched = None
            
        if assignToSyllabus:
            assign = self.request.get('onSyllabus')
            if assign:
                if mySched:
                    if not mySched.onSyllabus:
                        mySched.workingCalendar = False
                        mySched.put()
                        onScheduleCalendar = CalendarClass.query(ancestor=syllabus.key).filter(CalendarClass.onSyllabus == True).fetch()
                        if onScheduleCalendar:
                            for i in onScheduleCalendar:
                                i.key.delete()                                
                        mySched = mySched.clone(syllabus.key)
                        mySched.onSyllabus = True
                        mySched.workingCalendar = True
                        mySched.put()
                    
        if loadFile:
            message = "loadFile"
            loadFileName = self.request.get('fileName')
            if loadFileName == 'new': 
                message = "newFile"
                if mySched:
                    mySched.workingCalendar = False
                    mySched.put()

                if syllabus.info and term and syllabus.info.days:            
                    mySched = CalendarClass(parent = user.key)
                    mySched.schedule.append('Date')
                    mySched.schedule.append('Reading')
                    mySched.schedule.append('Topic')
                    mySched.workingCalendar = True
                    
                    if 'M' in syllabus.info.days:
                        mySched.meetDays.append(0)                        
                    if 'T' in syllabus.info.days:
                        mySched.meetDays.append(1)
                    if 'W' in syllabus.info.days:
                        mySched.meetDays.append(2)
                    if 'R' in syllabus.info.days:
                        mySched.meetDays.append(3)
                    if 'F' in syllabus.info.days:
                        mySched.meetDays.append(4)
                        
                    mySched.startMonth = int(syllabus.info.startDate.split('/')[0])
                    mySched.startDate = int(syllabus.info.startDate.split('/')[1])
                    mySched.startYear = int(term.year)
                    mySched.numWeeks = 15
                    #mySched.generateDates()
                    mySched.myFilename = syllabus.info.subject + "-" + str(syllabus.info.number) + "-" + term.semester + str(term.year)
                        
                    mySched.put()
                else:                    
                    mySched = CalendarClass(parent = user.key)
                    mySched.schedule.append('Date')
                    mySched.schedule.append('Reading')
                    mySched.schedule.append('Topic')
                    mySched.workingCalendar = True
                    mySched.put()
            else:
                savedCalendars = CalendarClass.query(ancestor=user.key).filter(CalendarClass.workingCalendar == False).fetch()
                queriedCalendars = []
                for i in savedCalendars:
                    queriedCalendars.append(i)
                if mySched:
                    mySched.workingCalendar = False
                    mySched.put()
                mySched = queriedCalendars[int(loadFileName)]
                mySched.workingCalendar = True
                mySched.put()
        
        if generateDates:
            message = "generateDates"
            try:
                startMonth = int(self.request.get("startMonth"))
                startDate = int(self.request.get("startDate"))
                startYear = int(self.request.get("startYear"))
                numWeeks = int(self.request.get("weeksThisSemester"))
            except:
                message = "invalid input"
                startMonth = mySched.startMonth
                startDate = mySched.startDate
                startYear = mySched.startYear
                numWeeks = mySched.numWeeks
            
            meetMonday = self.request.get('Monday')
            meetTuesday = self.request.get('Tuesday')
            meetWednesday = self.request.get('Wednesday')
            meetThursday = self.request.get('Thursday')
            meetFriday = self.request.get('Friday')
            meetSaturday = self.request.get('Saturday')
            meetSunday = self.request.get('Sunday')

            mySched.startMonth = startMonth
            mySched.startDate = startDate
            mySched.startYear = startYear
            mySched.numWeeks = numWeeks
            mySched.meetDays = []
            if meetMonday:
                mySched.meetDays.append(0)
            if meetTuesday:
                mySched.meetDays.append(1)
            if meetWednesday:
                mySched.meetDays.append(2)
            if meetThursday:
                mySched.meetDays.append(3)
            if meetFriday:
                mySched.meetDays.append(4)
            if meetSaturday:
                mySched.meetDays.append(5)
            if meetSunday:
                mySched.meetDays.append(6)
                
            mySched.generateDates()
            mySched.put()
                
        if rowInsert:
            message = "insertRow"
            try:
                mySched.insertNewRowAfter(int(self.request.get("targetRowInsert")))
                mySched.put()
            except:
                message = "invalidInput"
                
        if rowRemove:
            message = "removeRow"
            try:
                mySched.deleteRow(int(self.request.get("targetRowRemove")))
                mySched.put()
            except:
                message = "invalidInput"
        
        if save:
            message = "saved"
            newFileName = self.request.get('fileName')
            if newFileName == mySched.myFilename:                
                for i in range(len(mySched.schedule)):
                    for j in range(3):
                        mySched.setCell(j,i,self.request.get("r"+str(i)+"c"+str(j)))            
            else:
                mySched.workingCalendar = False
                mySched.put()
                mySched = mySched.clone(user.key)
                for i in range(len(mySched.schedule)):
                    for j in range(3):
                        mySched.setCell(j,i,self.request.get("r"+str(i)+"c"+str(j)))            
                mySched.myFilename = newFileName
                mySched.workingCalendar = True
            mySched.put()
            
        return self.redirect('/editcalendar')
Exemple #2
0
    def get(self):
    
        message = ""
        user = self.current_user
        syllabus = self.current_syllabus
        term = self.current_term
        
        savedCalendars = CalendarClass.query(ancestor=user.key).filter(CalendarClass.workingCalendar == False).fetch()
        savedCalendarNames = []
        for i in savedCalendars:
            savedCalendarNames.append(i.myFilename)
        
        syllabusCalendars = CalendarClass.query(ancestor=user.key).filter(CalendarClass.workingCalendar == True).fetch()
        if syllabusCalendars:
            #should have exactly 0 or 1 calendar
            for i in syllabusCalendars:
                mySched = i
        else:
            mySched = None
            
        message = str(len(syllabusCalendars))
        
        moChecked = ""
        tuChecked = ""
        weChecked = ""
        thChecked = ""
        frChecked = ""
        saChecked = ""
        suChecked = ""
        
        if mySched:
            if 0 in mySched.meetDays:
                moChecked = "checked"
            if 1 in mySched.meetDays:
                tuChecked = "checked"
            if 2 in mySched.meetDays:
                weChecked = "checked"
            if 3 in mySched.meetDays:
                thChecked = "checked"
            if 4 in mySched.meetDays:
                frChecked = "checked"
            if 5 in mySched.meetDays:
                saChecked = "checked"
            if 6 in mySched.meetDays:
                suChecked = "checked"
           
        template_values = {
            'mySchedule': mySched,
            'savedCalendars': savedCalendarNames,
            'mondayChecked': moChecked,
            'tuesdayChecked': tuChecked,
            'wednesdayChecked': weChecked,
            'thursdayChecked': thChecked,
            'fridayChecked': frChecked,
            'saturdayChecked': saChecked,
            'sundayChecked': suChecked,
            'msg': message
        }

        template = JINJA_ENVIRONMENT.get_template("calendarEdit.html")
        self.response.out.write(template.render(template_values))
Exemple #3
0
    def createDummyContext():
        course = {
                'subject': 'COMPSCI',
                'number': '361',
                'title': 'Intro to Software Engineering',
        }

        term = {
                'fullName': 'Fall 2015'
        }

        instructors = [
            {
                'first': 'Jayson',
                'last': 'Rock',
                'email': '*****@*****.**',
                'class': 'COMPSCI 361-401 EMS E145 MW 10-10:50am',
                'building': 'EMS',
                'room': 'E307',
                'phone': '(262) 825-4129',
                'hours': 'MTR 11am'
            },
            {
                'first': 'Tanawat',
                'last': 'Khunlertkit',
                'email': '*****@*****.**',
                'class': '',
                'building': 'EMS',
                'room': '962',
                'phone': '(262) 825-4129',
                'hours': ''
            }
        ]

        textbooks = [
            {
                'title': 'Essential Skills for the Agile Developer',
                'author': 'Shalloway',
                'edition': '',
                'publisher': 'Addison-Wesley Professional',
                'isbn': '0785342543735'
            },
            {
                'title': 'Programming Google App Engine',
                'author': 'Sanderson',
                'edition': '2nd Ed.',
                'publisher': 'O\'Reilly Media',
                'isbn': '9781449398262'
            }
        ]

        assessments = [
            {
                'title': 'Project',
                'percentage': '40',
                'description': 'The course project is implemented in phases by small groups of students. There are several phases of creating and refining deliverables such as requirements specifications, design documents, etc.'
            },
            {
                'title': 'Quizzes',
                'percentage': '10',
                'description': 'Online quizzes will be posted in D2L. You may take each quiz up to 2 times. The score of the best attempt is recorded in the grade book. Unannounced quizzes in lecture are given to assess comprehension of concepts from the previous assignment, encourage attendance, and give you feedback about your progress. The low score will be dropped.'
            },
            {
                'title': 'Midterm',
                'percentage': '20',
                'description': 'The midterm will be given during regular lecture time.'
            },
            {
                'title': 'Final',
                'percentage': '20',
                'description': 'The final exam is cumulative; it is scheduled according to university policy.'
            },
            {
                'title': 'Labs',
                'percentage': '10',
                'description': 'Weekly activities in lab for check-off.<br>Half credit for incomplete or inadequate work is possible.'
            }
        ]
            
        gradingScale = {
            'A':    '92',
            'A-':   '88',
            'B+':   '84',
            'B':    '80',
            'B-':   '76',
            'C+':   '72',
            'C':    '68',
            'C-':   '64',
            'D+':   '60',
            'D':    '56',
            'D-':   '52',
            'F':    '0'
        }
        
        policies = [
            {'title': 'Participation by Students with Disabilities', 'description': 'If you need special accommodations in order to meet any of the requirements of this course, please contact me as soon as possible.'},
            {'title': 'Accommodation for Religious Observances', 'description': 'Students will be allowed to complete examinations or other requirements that are missed because of a religious observance. See <a href="http://www.uwm.edu/Dept/SecU/acad+admin_policies/S1.5.htm">http://www.uwm.edu/Dept/SecU/acad+admin_policies/S1.5.htm</a>.'},
            {'title': 'Academic Misconduct', 'description': 'The university has a responsibility to promote academic honesty and integrity and to develop procedures to deal effectively with instances of academic dishonesty. Students are responsible for the honest completion and representation of their work, for the appropriate citation of sources, and for respect of others\' academic endeavors. A more detailed description of Student Academic Disciplinary Procedures may be found at <a href="http://www4.uwm.edu/acad_aff/policy/academicmisconduct.cfm">http://www4.uwm.edu/acad_aff/policy/academicmisconduct.cfm</a>'},
            {'title': 'Makeup/Late Policy', 'description': 'Assignments are submitted electronically via D2L.uwm.edu. An assignment is penalized 20% for each day (or part of a day) that it is late. The lowest quiz score is dropped to accommodate students who have life circumstances that prevent them from taking a quiz. There are no makeup quizzes.<br><br>Exams can be made up only if each of the following criteria are met:<br><br>1.      The circumstance that caused the student to miss the exam is unexpected, verifiable, and beyond the student\'s control.<br><br>2.      The student contacts the instructor as soon as possible by leaving a message at the phone number listed on the syllabus or by sending an email to <a href="mailto:[email protected]">[email protected]</a>. The message/email must contain a phone number the instructor can use to contact the student.<br><br>With sufficient advance notice, the instructor may allow students to take the exam at an alternate time to accommodate travel for extramural activities, work schedule, etc. Arranging to take the exam at an alternate time in advance is not considered a makeup exam.'},
        ]
        
        calendar = [ CalendarClass.generateDummyCalendar() ]

        contextDict = {
            'course': course,
            'term': term,
            'instructors': instructors,
            'textbooks': textbooks,
            'assessments': assessments,
            'gradingScale': OrderedDict(sorted(gradingScale.items(), key=lambda t: t[1], reverse=True)),
            'policies': policies,
            'calendar': calendar
        }
            
        return contextDict
Exemple #4
0
 def calendars(self):
     from calendarClass import CalendarClass
     return CalendarClass.query(ancestor = self.key).fetch()
     
Exemple #5
0
 def savedCalendars(self):
     from calendarClass import CalendarClass
     return CalendarClass.query(ancestor = self.key).filter(CalendarClass.onSyllabus == False).fetch()