Beispiel #1
0
def AddSection(course_id, instructor_id, quarter, section, instructor_title, ratings):
	try:
		q = quarter[:2].upper()
		y = quarter[2:]
		#print course_id
		#print "%s %s"%(q, y)
		r = AddRating(ratings)
		i = Section(quarter = q, year = y, idinstructor = instructor_id, idcourse = course_id, idrating = r, instructortitle = instructor_title, section = section )
		i.save()
		return i.id
	except Exception, e:
		print "exception: ", e
		return None
Beispiel #2
0
def add_section(request):


	name=request.POST.get('section_name')
	title=request.POST.get('section_title')
	language=str(request.LANGUAGE_CODE)
	next_index=int(request.POST.get('section_index'))

	new_section=Section(section_name=name, section_title=title, section_lang=language, section_author=request.user, section_index=next_index)

	new_section.save()
	new_content=Content(section_id=new_section, text="No se ha definido contenido para esta sección")
	new_content.save()

	return HttpResponseRedirect("/")
Beispiel #3
0
def add_section(exam_in_db,section_dict):
	# add simple properties
	properties_to_add=["name","info","comment","postinfo",
		"allowed_attempts",
		"show_correct_answer",
		"show_solution",
		"max_questions_to_attempt"]
	section = Section()
	for key in properties_to_add:
		if key in section_dict and hasattr(section,key):
			setattr(section,key,section_dict[key])
	section.exam = exam_in_db

	# add compound properties
	if "marking_scheme" in section_dict:
		subdict = section_dict["marking_scheme"]
		if "correct" in subdict:
			section.correct_marks = subdict["correct"]
		if "wrong" in subdict:
			section.wrong_marks = subdict["wrong"]
		if "na" in subdict:
			section.na_marks = subdict["na"]
		if "hint_deduction" in subdict:
			section.hint_deduction = subdict["hint_deduction"]
	if "unlock" in section_dict:
		subdict = section_dict["unlock"]
		if "marks" in subdict:
			section.unlock_marks = subdict["marks"]
		if "questions" in subdict:
			section.unlock_questions = subdict["questions"]
		if "both_needed" in subdict:
			section.unlock_both_needed = subdict["both_needed"]
	if "shuffle" in section_dict:
		subdict = section_dict["shuffle"]
		if "questions" in subdict:
			section.shuffle_questions = subdict["questions"]
		if "options" in subdict:
			section.shuffle_options = subdict["options"]
	section.save()

	# add tags
	if "tags" in section_dict:
		for tagname in section_dict["tags"]:
			section.add_tag(tagname)

	# add questions
	for question_dict in section_dict["questions"]:
		add_question(section,question_dict)
Beispiel #4
0
def add_section(exam_in_db, section_dict):
    # add simple properties
    properties_to_add = [
        "name", "info", "comment", "postinfo", "allowed_attempts",
        "show_correct_answer", "show_solution", "max_questions_to_attempt"
    ]
    section = Section()
    for key in properties_to_add:
        if key in section_dict and hasattr(section, key):
            setattr(section, key, section_dict[key])
    section.exam = exam_in_db

    # add compound properties
    if "marking_scheme" in section_dict:
        subdict = section_dict["marking_scheme"]
        if "correct" in subdict:
            section.correct_marks = subdict["correct"]
        if "wrong" in subdict:
            section.wrong_marks = subdict["wrong"]
        if "na" in subdict:
            section.na_marks = subdict["na"]
        if "hint_deduction" in subdict:
            section.hint_deduction = subdict["hint_deduction"]
    if "unlock" in section_dict:
        subdict = section_dict["unlock"]
        if "marks" in subdict:
            section.unlock_marks = subdict["marks"]
        if "questions" in subdict:
            section.unlock_questions = subdict["questions"]
        if "both_needed" in subdict:
            section.unlock_both_needed = subdict["both_needed"]
    if "shuffle" in section_dict:
        subdict = section_dict["shuffle"]
        if "questions" in subdict:
            section.shuffle_questions = subdict["questions"]
        if "options" in subdict:
            section.shuffle_options = subdict["options"]
    section.save()

    # add tags
    if "tags" in section_dict:
        for tagname in section_dict["tags"]:
            section.add_tag(tagname)

    # add questions
    for question_dict in section_dict["questions"]:
        add_question(section, question_dict)
Beispiel #5
0
def AddSection(course_id, instructor_id, quarter, section, instructor_title,
               ratings):
    try:
        q = quarter[:2].upper()
        y = quarter[2:]
        #print course_id
        #print "%s %s"%(q, y)
        r = AddRating(ratings)
        i = Section(quarter=q,
                    year=y,
                    idinstructor=instructor_id,
                    idcourse=course_id,
                    idrating=r,
                    instructortitle=instructor_title,
                    section=section)
        i.save()
        return i.id
    except Exception, e:
        print "exception: ", e
        return None