Exemplo n.º 1
0
def AddCourse(
    dept,
    number,
    name,
    comment="",
    descr="",
    genedreqs=0,
    firstyear=None,
    firstquarter=None,
    lastyear=None,
    lastquarter=None,
    mincredits=None,
    maxcredits=None,
):
    try:
        c = Course.objects.get(idcurriculum=dept, number=long(number))
        return c
    except Course.DoesNotExist, e:
        try:
            c = Course(name=name, number=long(number), idcurriculum=dept, comment=comment, description=descr)
            c.genedreqs = genedreqs
            c.firstyear = firstyear
            c.firstquarter = firstquarter
            c.lastyear = lastyear
            c.lastquarter = lastquarter
            c.mincredits = mincredits
            c.maxcredits = maxcredits
            c.save()
            return c
        except Exception, e:
            print "exception!"
            print e
            return None
Exemplo n.º 2
0
def AddCourse(dept,
              number,
              name,
              comment="",
              descr="",
              genedreqs=0,
              firstyear=None,
              firstquarter=None,
              lastyear=None,
              lastquarter=None,
              mincredits=None,
              maxcredits=None):
    try:
        c = Course.objects.get(idcurriculum=dept, number=long(number))
        return c
    except Course.DoesNotExist, e:
        try:
            c = Course(name=name,
                       number=long(number),
                       idcurriculum=dept,
                       comment=comment,
                       description=descr)
            c.genedreqs = genedreqs
            c.firstyear = firstyear
            c.firstquarter = firstquarter
            c.lastyear = lastyear
            c.lastquarter = lastquarter
            c.mincredits = mincredits
            c.maxcredits = maxcredits
            c.save()
            return c
        except Exception, e:
            print "exception!"
            print e
            return None
Exemplo n.º 3
0
def courseregistration(request):
    if request.method == "POST":
        course_details = Course()
        course_details.subject = request.POST['catagory']
        course_details.coursename = request.POST['coursename']
        course_details.description = request.POST['description']
        course_details.image = request.FILES['image']
        course_details.coursestartdate = request.POST['startdate']
        course_details.courseenddate = request.POST['enddate']
        course_details.duration = request.POST['duration']
        course_details.course_id = request.POST['coursename']
        course_details.faculty_id = request.user
        course_details.save()
        '''for f in request.FILES.get('videopath'):
            print("hello")
            print(f)'''

        n = int(request.POST['number'])
        titles = request.POST.getlist('title')
        videos = request.FILES.getlist('videopath')
        for i in range(n):
            lecture_details = Lecture()
            lecture_details.lecture_id = str(
                request.POST['coursename']) + str(i)
            lecture_details.course_id = Course.objects.last()
            lecture_details.lecturedate = date.today()
            lecture_details.lecturename = titles[i]
            lecture_details.lecturevideo = videos[i]
            lecture_details.save()

        return redirect(request, 'addingcourseconfirmation.html')

    else:
        return render(request, 'courseregistration.html')
Exemplo n.º 4
0
    def test_tutorAllowedTeamsNumberNotExceeded(self):
        testCourse = Course(id=self.COURSE_ID)
        testCourse.save()

        tutorHas2AllowedTeamsNumber(self.tutor, testCourse)
        assign3TeamsToTutor(self.tutor, testCourse)

        tutorProject = Project.objects.get(id=1)

        self.assertEqual(tutorAllowedTeamsNumberNotExceeded(tutorProject), False)
Exemplo n.º 5
0
def new_course(request):
    if request.method == "POST":
        error_time = False
        department = request.POST.get("department")
        name = request.POST.get("name")
        course_number = request.POST.get("course_number")
        group_number = request.POST.get("group_number")
        teacher = request.POST.get("teacher")
        start_time = request.POST.get("start_time")
        end_time = request.POST.get("end_time")
        first_day = request.POST.get("first_day")
        second_day = request.POST.get("second_day")
        exam_date = request.POST.get("exam_date")

        try:
            time.strptime(start_time, '%H:%M')
        except ValueError:
            error_time = True
            return render(request, "new-course.html",
                          {"error_time": error_time})

        try:
            time.strptime(end_time, '%H:%M')
        except ValueError:
            error_time = True
            return render(request, "new-course.html",
                          {"error_time": error_time})
        try:
            datetime.strptime(exam_date, '%Y-%m-%d')
        except ValueError:
            error_time = True
            return render(request, "new-course.html",
                          {"error_time": error_time})

        course = Course(department=department,
                        name=name,
                        course_number=course_number,
                        group_number=group_number,
                        teacher=teacher,
                        start_time=start_time,
                        end_time=end_time,
                        exam_date=exam_date,
                        first_day=first_day,
                        second_day=second_day)
        course.save()
        return render(request, "panel.html")

    return render(request, "new-course.html")
Exemplo n.º 6
0
def addCourseResualt(request):

    tempNews = Course()
    tempNews.course_no = request.GET['course_no']
    tempNews.name = request.GET['name']
    tempNews.course_type = request.GET['course_type']
    tempNews.student_level = request.GET['student_level']
    tempNews.semester = request.GET['semester']
    tempNews.start_week = request.GET['start_week']
    tempNews.end_week = request.GET['end_week']
    tempNews.remarks = request.GET['remarks']
    tempNews.valid = 1
    tempNews.save()
    posts = tempNews.__class__.objects.all()
    t = loader.get_template('jiaoxuegongzuo.html')
    c = Context({'posts': posts})
    return HttpResponse(t.render(c))
Exemplo n.º 7
0
def addCourseResualt(request):
    
    tempNews=Course()
    tempNews.course_no= request.GET['course_no']
    tempNews.name= request.GET['name']
    tempNews.course_type= request.GET['course_type']
    tempNews.student_level= request.GET['student_level']
    tempNews.semester= request.GET['semester']
    tempNews.start_week= request.GET['start_week']
    tempNews.end_week= request.GET['end_week']
    tempNews.remarks= request.GET['remarks']
    tempNews.valid=1
    tempNews.save()
    posts = tempNews.__class__.objects.all()
    t =loader.get_template('jiaoxuegongzuo.html')
    c =Context({'posts':posts})
    return HttpResponse(t.render(c))