本文整理汇总了Python中xmodule.util.duedate.get_extended_due_date函数的典型用法代码示例。如果您正苦于以下问题:Python get_extended_due_date函数的具体用法?Python get_extended_due_date怎么用?Python get_extended_due_date使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_extended_due_date函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mobi_toc_for_course
def mobi_toc_for_course(user, request, course):
course_module = get_module_for_descriptor(user, request, course, '', course.id)
if course_module is None:
return None
chapters = list()
for chapter in course_module.get_display_items():
sections = list()
for section in chapter.get_display_items():
units = list()
i = 0
for unit in section.get_display_items():
i = i + 1
units.append({'display_name': unit.display_name_with_default,
'location': i,
'type': unit.get_icon_class()})
sections.append({'display_name': section.display_name_with_default,
'url_name': section.url_name,
'format': section.format if section.format is not None else '',
'due': get_extended_due_date(section),
'graded': section.graded,
'units': units
})
chapters.append({'display_name': chapter.display_name_with_default,
'url_name': chapter.url_name,
'sections': sections,})
return chapters
示例2: _past_due
def _past_due(self):
"""
Return whether due date has passed.
"""
due = get_extended_due_date(self)
if due is not None:
return self._now() > due
return False
示例3: _allow_checking
def _allow_checking(self, dt):
# HTML Academy возращает время по МСК без указания таймзоны, поэтому приведём руками
tz = pytz.timezone('Europe/Moscow')
dt = tz.localize(dt.replace(tzinfo=None))
due = get_extended_due_date(self)
if due is not None:
return dt < due
return True
示例4: past_due
def past_due(self):
"""Returns True if the assignment is past due"""
due = get_extended_due_date(self)
if due is not None:
return _now() > due
else:
return False
示例5: past_due
def past_due(self):
"""
Проверка, истекла ли дата для выполнения задания.
"""
due = get_extended_due_date(self)
if due is not None:
if _now() > due:
return False
return True
示例6: get_student_data
def get_student_data(module):
"""
Packages data from a student module for display to staff.
"""
state = json.loads(module.state)
instructor = self.is_instructor()
score = state.get('score')
approved = state.get('score_approved')
submitted = state.get('is_submitted')
submission_time = state.get('submission_time')
#can a grade be entered
due = get_extended_due_date(self)
may_grade = (instructor or not approved)
if due is not None:
may_grade = may_grade and (submitted or (due < _now()))
uploaded = []
if (state.get('is_submitted')):
for sha1, metadata in get_file_metadata(state.get("uploaded_files")).iteritems():
uploaded.append({
"sha1": sha1,
"filename": metadata.filename,
"timestamp": metadata.timestamp
})
annotated = []
for sha1, metadata in get_file_metadata(state.get("annotated_files")).iteritems():
annotated.append({
"sha1": sha1,
"filename": metadata.filename,
"timestamp": metadata.timestamp
})
return {
'module_id': module.id,
'username': module.student.username,
'fullname': module.student.profile.name,
'uploaded': uploaded,
'annotated': annotated,
'timestamp': state.get("uploaded_files_last_timestamp"),
'published': state.get("score_published"),
'score': score,
'approved': approved,
'needs_approval': instructor and score is not None
and not approved,
'may_grade': may_grade,
'comment': state.get("comment", ''),
'submitted': submitted,
'submission_time': submission_time
}
示例7: mobi_toc_for_course
def mobi_toc_for_course(user, request, course, active_chapter=None, active_section=None, field_data_cache=None):
course_module = get_module_for_descriptor(user, request, course, field_data_cache, course.id)
if course_module is None:
return None
show_url = list()
chapters = list()
for chapter in course_module.get_display_items():
chapter_descriptor = course.get_child_by(lambda m: m.url_name == chapter.url_name)
chapter_module = course_module.get_child_by(lambda m: m.url_name == chapter.url_name)
sections = list()
for section in chapter_module.get_display_items():
i = 0
section_descriptor = chapter_descriptor.get_child_by(lambda m: m.url_name == section.url_name)
section_descriptor = modulestore().get_instance(course.id, section_descriptor.location, depth=None)
section_field_data_cache = FieldDataCache.cache_for_descriptor_descendents(
course.id, user, section_descriptor, depth=None)
section_module = get_module_for_descriptor(request.user,
request,
section_descriptor,
section_field_data_cache,
course.id,
i
)
units = list()
for unit in section_module.get_display_items():
for child in unit.get_display_items():
if child.get_icon_class()=='video':
if child.source:
show_url.append(child.source)
elif child.html5_sources:
show_url.append(child.html5_sources[0])
units.append({'display_name': unit.display_name_with_default,
'location': i,
'type': unit.get_icon_class()})
sections.append({'display_name': section.display_name_with_default,
'url_name': section.url_name,
'format': section.format if section.format is not None else '',
'due': get_extended_due_date(section),
'active': False,
'graded': section.graded,
'units': units
})
chapters.append({'display_name': chapter.display_name_with_default,
'url_name': chapter.url_name,
'sections': sections,
'show_url': show_url})
return chapters
示例8: past_due
def past_due(self):
"""
Return whether due date has passed.
"""
due = get_extended_due_date(self)
try:
graceperiod = self.graceperiod
except AttributeError:
# graceperiod and due are defined in InheritanceMixin
# It's used automatically in edX but the unit tests will need to mock it out
graceperiod = None
if graceperiod is not None and due:
close_date = due + graceperiod
else:
close_date = due
if close_date is not None:
return utcnow() > close_date
return False
示例9: __init__
def __init__(self, *args, **kwargs):
super(PeerGradingModule, self).__init__(*args, **kwargs)
# Copy this to a new variable so that we can edit it if needed.
# We need to edit it if the linked module cannot be found, so
# we can revert to panel model.
self.use_for_single_location_local = self.use_for_single_location
# We need to set the location here so the child modules can use it.
self.runtime.set('location', self.location)
if (self.runtime.open_ended_grading_interface):
self.peer_gs = PeerGradingService(self.system.open_ended_grading_interface, self.system.render_template)
else:
self.peer_gs = MockPeerGradingService()
if self.use_for_single_location_local:
linked_descriptors = self.descriptor.get_required_module_descriptors()
if len(linked_descriptors) == 0:
error_msg = "Peer grading module {0} is trying to use single problem mode without "
"a location specified.".format(self.location)
log.error(error_msg)
# Change module over to panel mode from single problem mode.
self.use_for_single_location_local = False
else:
self.linked_problem = self.system.get_module(linked_descriptors[0])
try:
self.timeinfo = TimeInfo(
get_extended_due_date(self), self.graceperiod)
except Exception:
log.error("Error parsing due date information in location {0}".format(self.location))
raise
self.display_due_date = self.timeinfo.display_due_date
try:
self.student_data_for_location = json.loads(self.student_data_for_location)
except Exception: # pylint: disable=broad-except
# OK with this broad exception because we just want to continue on any error
pass
示例10: toc_for_course
def toc_for_course(request, course, active_chapter, active_section, field_data_cache):
'''
Create a table of contents from the module store
Return format:
[ {'display_name': name, 'url_name': url_name,
'sections': SECTIONS, 'active': bool}, ... ]
where SECTIONS is a list
[ {'display_name': name, 'url_name': url_name,
'format': format, 'due': due, 'active' : bool, 'graded': bool}, ...]
active is set for the section and chapter corresponding to the passed
parameters, which are expected to be url_names of the chapter+section.
Everything else comes from the xml, or defaults to "".
chapters with name 'hidden' are skipped.
NOTE: assumes that if we got this far, user has access to course. Returns
None if this is not the case.
field_data_cache must include data from the course module and 2 levels of its descendents
'''
with modulestore().bulk_operations(course.id):
course_module = get_module_for_descriptor(request.user, request, course, field_data_cache, course.id)
if course_module is None:
return None
toc_chapters = list()
chapters = course_module.get_display_items()
# See if the course is gated by one or more content milestones
required_content = milestones_helpers.get_required_content(course, request.user)
# The user may not actually have to complete the entrance exam, if one is required
if not user_must_complete_entrance_exam(request, request.user, course):
required_content = [content for content in required_content if not content == course.entrance_exam_id]
for chapter in chapters:
# Only show required content, if there is required content
# chapter.hide_from_toc is read-only (boo)
local_hide_from_toc = False
if required_content:
if unicode(chapter.location) not in required_content:
local_hide_from_toc = True
# Skip the current chapter if a hide flag is tripped
if chapter.hide_from_toc or local_hide_from_toc:
continue
sections = list()
for section in chapter.get_display_items():
active = (chapter.url_name == active_chapter and
section.url_name == active_section)
if not section.hide_from_toc:
sections.append({'display_name': section.display_name_with_default,
'url_name': section.url_name,
'format': section.format if section.format is not None else '',
'due': get_extended_due_date(section),
'active': active,
'graded': section.graded,
})
toc_chapters.append({
'display_name': chapter.display_name_with_default,
'url_name': chapter.url_name,
'sections': sections,
'active': chapter.url_name == active_chapter
})
return toc_chapters
示例11: past_due
def past_due(self):
due = get_extended_due_date(self)
if due is not None:
return _now() > due
return False
示例12: _progress_summary
#.........这里部分代码省略.........
course: A Descriptor containing the course to grade
If the student does not have access to load the course module, this function
will return None.
"""
with manual_transaction():
field_data_cache = FieldDataCache.cache_for_descriptor_descendents(
course.id, student, course, depth=None
)
# TODO: We need the request to pass into here. If we could
# forego that, our arguments would be simpler
course_module = get_module_for_descriptor(student, request, course, field_data_cache, course.id)
if not course_module:
# This student must not have access to the course.
return None
submissions_scores = sub_api.get_scores(course.id.to_deprecated_string(), anonymous_id_for_user(student, course.id))
chapters = []
# Don't include chapters that aren't displayable (e.g. due to error)
for chapter_module in course_module.get_display_items():
# Skip if the chapter is hidden
if chapter_module.hide_from_toc:
continue
sections = []
for section_module in chapter_module.get_display_items():
# Skip if the section is hidden
with manual_transaction():
if section_module.hide_from_toc:
continue
graded = section_module.graded
scores = []
module_creator = section_module.xmodule_runtime.get_module
inforExerc = []
# Adicionarei mais algumas informacoes para que seja possivel pegar o que foi digitado pelo aluno
# A quantidade de tentativas, que opcao o usuario escolheu ou que informacao foi digitada
for module_descriptor in yield_dynamic_descriptor_descendents(section_module, module_creator):
course_id = course.id
(correct, total) = get_score(
course_id, student, module_descriptor, module_creator, scores_cache=submissions_scores
)
tentativas, valorDigitado, idProblem = get_InforExerc(
course_id, student, module_descriptor
)
if correct is None and total is None:
continue
print "USUARIO: ", student
print "TENTATIVAS ", tentativas, " VALOR DIGITADO: ", valorDigitado
print "CORRECT: ", correct, " total ", total
print "IDPROBLEM: ", idProblem
vals=[]
vals.append(tentativas)
vals.append(valorDigitado)
vals.append(idProblem)
inforExerc.append(vals)
scores.append(Score(correct, total, graded, module_descriptor.display_name_with_default))
scores.reverse()
inforExerc.reverse()
section_total, _ = graders.aggregate_scores(
scores, section_module.display_name_with_default)
module_format = section_module.format if section_module.format is not None else ''
sections.append({
'display_name': section_module.display_name_with_default,
'url_name': section_module.url_name,
'scores': scores,
'inforExerc': inforExerc,
'section_total': section_total,
'format': module_format,
'due': get_extended_due_date(section_module),
'graded': graded,
})
chapters.append({
'course': course.display_name_with_default,
'display_name': chapter_module.display_name_with_default,
'url_name': chapter_module.url_name,
'sections': sections
})
return chapters
示例13: _allow_checking_now
def _allow_checking_now(self):
due = get_extended_due_date(self)
if due is not None:
return self._now() < due
return True
示例14: toc_for_course
def toc_for_course(request, course, active_chapter, active_section, field_data_cache):
"""
Create a table of contents from the module store
Return format:
[ {'display_name': name, 'url_name': url_name,
'sections': SECTIONS, 'active': bool}, ... ]
where SECTIONS is a list
[ {'display_name': name, 'url_name': url_name,
'format': format, 'due': due, 'active' : bool, 'graded': bool}, ...]
active is set for the section and chapter corresponding to the passed
parameters, which are expected to be url_names of the chapter+section.
Everything else comes from the xml, or defaults to "".
chapters with name 'hidden' are skipped.
NOTE: assumes that if we got this far, user has access to course. Returns
None if this is not the case.
field_data_cache must include data from the course module and 2 levels of its descendents
"""
with modulestore().bulk_operations(course.id):
course_module = get_module_for_descriptor(request.user, request, course, field_data_cache, course.id)
if course_module is None:
return None
# Check to see if the course is gated on required content (such as an Entrance Exam)
required_content = _get_required_content(course, request.user)
chapters = list()
for chapter in course_module.get_display_items():
# Only show required content, if there is required content
# chapter.hide_from_toc is read-only (boo)
local_hide_from_toc = False
if len(required_content):
if unicode(chapter.location) not in required_content:
local_hide_from_toc = True
# Skip the current chapter if a hide flag is tripped
if chapter.hide_from_toc or local_hide_from_toc:
continue
sections = list()
for section in chapter.get_display_items():
active = chapter.url_name == active_chapter and section.url_name == active_section
if not section.hide_from_toc:
sections.append(
{
"display_name": section.display_name_with_default,
"url_name": section.url_name,
"format": section.format if section.format is not None else "",
"due": get_extended_due_date(section),
"active": active,
"graded": section.graded,
}
)
chapters.append(
{
"display_name": chapter.display_name_with_default,
"url_name": chapter.url_name,
"sections": sections,
"active": chapter.url_name == active_chapter,
}
)
return chapters
示例15: _progress_summary
def _progress_summary(student, request, course):
"""
Unwrapped version of "progress_summary".
This pulls a summary of all problems in the course.
Returns
- courseware_summary is a summary of all sections with problems in the course.
It is organized as an array of chapters, each containing an array of sections,
each containing an array of scores. This contains information for graded and
ungraded problems, and is good for displaying a course summary with due dates,
etc.
Arguments:
student: A User object for the student to grade
course: A Descriptor containing the course to grade
If the student does not have access to load the course module, this function
will return None.
"""
with manual_transaction():
field_data_cache = FieldDataCache.cache_for_descriptor_descendents(
course.id, student, course, depth=None
)
# TODO: We need the request to pass into here. If we could
# forego that, our arguments would be simpler
course_module = get_module_for_descriptor(student, request, course, field_data_cache, course.id)
if not course_module:
# This student must not have access to the course.
return None
chapters = []
# Don't include chapters that aren't displayable (e.g. due to error)
for chapter_module in course_module.get_display_items():
# Skip if the chapter is hidden
if chapter_module.hide_from_toc:
continue
sections = []
for section_module in chapter_module.get_display_items():
# Skip if the section is hidden
with manual_transaction():
if section_module.hide_from_toc:
continue
graded = section_module.graded
scores = []
module_creator = section_module.xmodule_runtime.get_module
for module_descriptor in yield_dynamic_descriptor_descendents(section_module, module_creator):
course_id = course.id
(correct, total) = get_score(course_id, student, module_descriptor, module_creator)
if correct is None and total is None:
continue
scores.append(Score(correct, total, graded, module_descriptor.display_name_with_default))
scores.reverse()
section_total, _ = graders.aggregate_scores(
scores, section_module.display_name_with_default)
module_format = section_module.format if section_module.format is not None else ''
sections.append({
'display_name': section_module.display_name_with_default,
'url_name': section_module.url_name,
'scores': scores,
'section_total': section_total,
'format': module_format,
'due': get_extended_due_date(section_module),
'graded': graded,
})
chapters.append({
'course': course.display_name_with_default,
'display_name': chapter_module.display_name_with_default,
'url_name': chapter_module.url_name,
'sections': sections
})
return chapters