Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redminefixes #9

Merged
merged 2 commits into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions common/lib/xmodule/xmodule/graders.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ def grade(self, grade_sheet, generate_random_scores=False):

subgrade_result = subgrader.grade(grade_sheet, generate_random_scores)

#oleg2106 recount the weight becouse of dropped attempts
section_weight = weight / (subgrade_result['sections_count'] - subgrader.drop_count)
for key, section_info in enumerate(subgrade_result['section_breakdown']):
subgrade_result['section_breakdown'][key]['weight'] = section_weight
subgrade_result['section_breakdown'][key]['weight_percent'] = subgrade_result['section_breakdown'][key]['percent'] * section_weight

weighted_percent = subgrade_result['percent'] * weight
section_detail = u"{0} = {1:.2%} of a possible {2:.2%}".format(assignment_type, weighted_percent, weight)

Expand Down Expand Up @@ -409,6 +415,7 @@ def total_with_drops(breakdown, drop_count):
scores = grade_sheet.get(self.type, {}).values()
breakdown = []
for i in range(max(self.min_count, len(scores))):
section_url_name = ""
if i < len(scores) or generate_random_scores:
if generate_random_scores: # for debugging!
earned = random.randint(2, 15)
Expand All @@ -419,6 +426,7 @@ def total_with_drops(breakdown, drop_count):
earned = scores[i].graded_total.earned
possible = scores[i].graded_total.possible
section_name = scores[i].display_name
section_url_name = scores[i].url_name

percentage = self._calc_percentage(earned, possible)
summary_format = u"{section_type} {index} - {name} - {percent:.0%} ({earned:.3n}/{possible:.3n})"
Expand All @@ -443,18 +451,23 @@ def total_with_drops(breakdown, drop_count):
)

breakdown.append({'percent': percentage, 'label': short_label,
'detail': summary, 'category': self.category})
'detail': summary, 'category': self.category,
'url_name': section_url_name})

total_percent, dropped_indices = total_with_drops(breakdown, self.drop_count)

for dropped_index in dropped_indices:
breakdown[dropped_index]['dropped'] = True
breakdown[dropped_index]['mark'] = {
'detail': u"The lowest {drop_count} {section_type} scores are dropped.".format(
drop_count=self.drop_count,
section_type=self.section_type
)
}

#oleg2106 amount of sections
sections_count = len(breakdown)

if len(breakdown) == 1:
# if there is only one entry in a section, suppress the existing individual entry and the average,
# and just display a single entry for the section.
Expand All @@ -464,7 +477,8 @@ def total_with_drops(breakdown, drop_count):
)
total_label = u"{short_label}".format(short_label=self.short_label)
breakdown = [{'percent': total_percent, 'label': total_label,
'detail': total_detail, 'category': self.category, 'prominent': True}, ]
'detail': total_detail, 'category': self.category,
'prominent': True, 'url_name': breakdown[0]['url_name']}, ]
else:
total_detail = u"{section_type} Average = {percent:.0%}".format(
percent=total_percent,
Expand All @@ -482,6 +496,7 @@ def total_with_drops(breakdown, drop_count):
return {
'percent': total_percent,
'section_breakdown': breakdown,
'sections_count': sections_count,
# No grade_breakdown here
}

Expand Down
10 changes: 9 additions & 1 deletion lms/djangoapps/courseware/date_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,15 @@ class CourseEndDate(DateSummary):
Displays the end date of the course.
"""
css_class = 'end-date'
title = ugettext_lazy('Course End')

#oleg2106 we want to split title into present and past
#title = ugettext_lazy('Course End')
@property
def title(self):
if datetime.now(utc) <= self.date:
return ugettext_lazy('Course End')
else:
return ugettext_lazy('Course finished on')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Минутку. А в локальное django.mo/po ты это не вписал? Потому что translation-overrides сработают только во время обновления версии edx...


@property
def is_enabled(self):
Expand Down