Beispiel #1
0
def get_myla_globals(current_user):
    username = ""
    user_courses_info = []
    login_url = ""
    logout_url = ""
    google_analytics_id = ""

    is_superuser = current_user.is_superuser
    if current_user.is_authenticated:
        username = current_user.get_username()
        user_courses_info = get_user_courses_info(username)

    if settings.LOGIN_URL:
        login_url = settings.LOGIN_URL
    if settings.LOGOUT_URL:
        logout_url = settings.LOGOUT_URL
    if settings.GA_ID:
        google_analytics_id = settings.GA_ID
    primary_ui_color = settings.PRIMARY_UI_COLOR
    help_url = settings.HELP_URL

    myla_globals = {
        "username": username,
        "is_superuser": is_superuser,
        "user_courses_info": user_courses_info,
        "login": login_url,
        "logout": logout_url,
        "primary_ui_color": primary_ui_color,
        "google_analytics_id": google_analytics_id,
        "help_url": help_url
    }
    return myla_globals
Beispiel #2
0
def get_myla_globals(request):
    current_user = request.user
    username = ""
    display_name = ""
    initials = ""
    user_courses_info = []
    login_url = ""
    logout_url = ""
    google_analytics_id = ""
    course_id = get_course_id_from_request_url(request.path)

    is_superuser = current_user.is_staff
    if current_user.is_authenticated:
        username = current_user.get_username()
        user_courses_info = db_util.get_user_courses_info(username, course_id)

        display_name = current_user.get_full_name()
        # if full name blank, use username instead
        if display_name.strip() == '':
            display_name = username

        # get first initial only
        initials = display_name[:1].upper()

    if settings.SHOW_LOGOUT_LINK:
        login_url = settings.LOGIN_URL
        logout_url = settings.LOGOUT_URL

    if settings.GA_ID:
        google_analytics_id = settings.GA_ID
    primary_ui_color = settings.PRIMARY_UI_COLOR

    myla_globals = {
        "username": username,
        "display_name": display_name,
        "initials": initials,
        "is_superuser": is_superuser,
        "user_courses_info": user_courses_info,
        "login": login_url,
        "logout": logout_url,
        "primary_ui_color": primary_ui_color,
        "google_analytics_id": google_analytics_id,
        "view_help_urls": {
            'ra': settings.URL_VIEW_RESOURCES_ACCESSED,
            'apv1': settings.URL_VIEW_ASSIGNMENT_PLANNING_V1,
            'ap': settings.URL_VIEW_ASSIGNMENT_PLANNING,
            'gd': settings.URL_VIEW_GRADE_DISTRIBUTION,
            'home': settings.HELP_URL
        },
        "survey_link": {
            "url": config.SURVEY_URL,
            "text": config.SURVEY_TEXT
        }
    }
    return myla_globals
def get_myla_globals(request):
    current_user = request.user
    username = ""
    user_courses_info = []
    login_url = ""
    logout_url = ""
    google_analytics_id = ""
    course_id = get_course_id_from_request_url(request.path)

    is_superuser = current_user.is_staff
    if current_user.is_authenticated:
        username = current_user.get_username()
        user_courses_info = db_util.get_user_courses_info(username, course_id)

    if settings.SHOW_LOGOUT_LINK:
        login_url = settings.LOGIN_URL
        logout_url = settings.LOGOUT_URL

    if settings.GA_ID:
        google_analytics_id = settings.GA_ID
    primary_ui_color = settings.PRIMARY_UI_COLOR

    myla_globals = {
        "username": username,
        "is_superuser": is_superuser,
        "user_courses_info": user_courses_info,
        "login": login_url,
        "logout": logout_url,
        "primary_ui_color": primary_ui_color,
        "google_analytics_id": google_analytics_id,
        "view_help_urls": {
            'ra': settings.URL_VIEW_RESOURCES_ACCESSED,
            'apv1': settings.URL_VIEW_ASSIGNMENT_PLANNING_V1,
            'ap': settings.URL_VIEW_ASSIGNMENT_PLANNING,
            'gd': settings.URL_VIEW_GRADE_DISTRIBUTION,
            'home': settings.HELP_URL
        }
    }
    return myla_globals
Beispiel #4
0
def get_home_template(request: HttpRequest) -> HttpResponse:
    username = ""
    user_courses_info = []
    login_url = ""
    logout_url = ""
    google_analytics_id = ""

    current_user = request.user
    is_superuser = current_user.is_superuser
    if current_user.is_authenticated:
        username = current_user.get_username()
        user_courses_info = get_user_courses_info(username)

    if settings.LOGIN_URL:
        login_url = settings.LOGIN_URL
    if settings.LOGOUT_URL:
        logout_url = settings.LOGOUT_URL
    if settings.GA_ID:
        google_analytics_id = settings.GA_ID
    flatpages = FlatPage.objects.all()
    if flatpages:
        help_url = flatpages[0].content
    else:
        help_url = "https://sites.google.com/umich.edu/my-learning-analytics-help/home"

    myla_globals = {
        "username": username,
        "is_superuser": is_superuser,
        "user_courses_info": user_courses_info,
        "login": login_url,
        "logout": logout_url,
        "google_analytics_id": google_analytics_id,
        "help_url": help_url
    }

    return render(request,
                  'frontend/index.html',
                  context={'myla_globals': json.dumps(myla_globals)})
Beispiel #5
0
def current_user_courses_info(request):
    logger.info(current_user_courses_info.__name__)
    courses_info_by_user = db_util.get_user_courses_info(request.user.username)
    return {'current_user_courses_info': courses_info_by_user}