<commit_before>import datetime
import json
import logging

from django.conf import settings
from django.utils.translation import ugettext_lazy as _

from xmodule.open_ended_grading_classes import peer_grading_service
from xmodule.open_ended_grading_classes.controller_query_service import ControllerQueryService

from xmodule.modulestore.django import ModuleI18nService

from courseware.access import has_access
from lms.lib.xblock.runtime import LmsModuleSystem
from edxmako.shortcuts import render_to_string
from student.models import unique_id_for_user
from util.cache import cache

from .staff_grading_service import StaffGradingService

log = logging.getLogger(__name__)

NOTIFICATION_CACHE_TIME = 300
KEY_PREFIX = "open_ended_"

NOTIFICATION_TYPES = (
    # Translators: "Peer Grading" is a panel where peer can grade student-provided answers.
    ('student_needs_to_peer_grade', 'peer_grading', _('Peer Grading')),
    # Translators: "Staff Grading" is a panel where instructor can grade student-provided answers.
    ('staff_needs_to_grade', 'staff_grading', _('Staff Grading')),
    # Translators: "Problems you have submitted" refers to the problems that the currently-logged-in
    # student has provided an answer for.
    ('new_student_grading_to_view', 'open_ended_problems', _('Problems you have submitted')),
    # Translators: "Flagged Submissions" refers to student-provided answers to a problem which are
    # marked by instructor or peer graders as 'flagged' potentially inappropriate.
    ('flagged_submissions_exist', 'open_ended_flagged_problems', _('Flagged Submissions'))
)


def staff_grading_notifications(course, user):
    staff_gs = StaffGradingService(settings.OPEN_ENDED_GRADING_INTERFACE)
    pending_grading = False
    img_path = ""
    course_id = course.id
    student_id = unique_id_for_user(user)
    notification_type = "staff"

    success, notification_dict = get_value_from_cache(student_id, course_id, notification_type)
    if success:
        return notification_dict

    try:
        notifications = json.loads(staff_gs.get_notifications(course_id))
        if notifications['success']:
            if notifications['staff_needs_to_grade']:<commit_msg>Revert "Open ended panel headings not internationalized."<commit_after>import datetime
import json
import logging

from django.conf import settings

from xmodule.open_ended_grading_classes import peer_grading_service
from xmodule.open_ended_grading_classes.controller_query_service import ControllerQueryService

from xmodule.modulestore.django import ModuleI18nService

from courseware.access import has_access
from lms.lib.xblock.runtime import LmsModuleSystem
from edxmako.shortcuts import render_to_string
from student.models import unique_id_for_user
from util.cache import cache

from .staff_grading_service import StaffGradingService

log = logging.getLogger(__name__)

NOTIFICATION_CACHE_TIME = 300
KEY_PREFIX = "open_ended_"

NOTIFICATION_TYPES = (
    ('student_needs_to_peer_grade', 'peer_grading', 'Peer Grading'),
    ('staff_needs_to_grade', 'staff_grading', 'Staff Grading'),
    ('new_student_grading_to_view', 'open_ended_problems', 'Problems you have submitted'),
    ('flagged_submissions_exist', 'open_ended_flagged_problems', 'Flagged Submissions')
)


def staff_grading_notifications(course, user):
    staff_gs = StaffGradingService(settings.OPEN_ENDED_GRADING_INTERFACE)
    pending_grading = False
    img_path = ""
    course_id = course.id
    student_id = unique_id_for_user(user)
    notification_type = "staff"

    success, notification_dict = get_value_from_cache(student_id, course_id, notification_type)
    if success:
        return notification_dict

    try:
        notifications = json.loads(staff_gs.get_notifications(course_id))
        if notifications['success']:
            if notifications['staff_needs_to_grade']:
{'fraction_non_alphanumeric': 0.0709476954945624, 'fraction_numerical': 0.002589331952356292, 'mean_word_length': 5.5809199318569, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4042665', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1133, 'n_words': 276}