Skip to content

Commit

Permalink
Merge pull request #4230 from rtibbles/zone_space_coach_reports
Browse files Browse the repository at this point in the history
Zone space coach reports
  • Loading branch information
jamalex committed Aug 13, 2015
2 parents 8adb6f3 + 28541a2 commit 68c6ffe
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 157 deletions.
8 changes: 5 additions & 3 deletions docs/installguide/install_all.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ Raspberry Pi
============

For a Raspberry Pi running a Debian system, you can install the special Debian
package, 'ka-lite-raspberry-pi'.
package (``ka-lite-raspberry-pi_0.X-buildYZ.deb``).

You can find here (TODO)
Download the latest .deb manually from
`the Launchpad archive server <http://ppa.launchpad.net/learningequality/ka-lite/ubuntu/pool/main/k/ka-lite-source/?C=M;O=D>`_.
Look for the latest ``ka-lite-raspberry-pi`` file with a ``.deb`` extension, download it and install it from command line with ``dpkg -i ka-lite-raspberry-pi_0.*.deb``.



Expand Down Expand Up @@ -329,6 +331,6 @@ it may be located somewhere else.

Example of setting up kalite for the www-data user: ::

$> su -s /bin/bash www-data
$> sudo su -s /bin/bash www-data
$> kalite manage setup
$> exit
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<input type="text" id="start" class="form-control date-range" value={{ start_date }} name="start" />
<span class="input-group-addon">→</span>
<input type="text" id="end" class="form-control date-range" value={{ end_date }} name="end" />
<span class="input-group-addon btn btn-success setrange"><i class="glyphicon glyphicon-refresh"></i></span>
<span class="input-group-addon btn-success setrange"><i class="glyphicon glyphicon-refresh"></i></span>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,11 @@ var FacilitySelectView = Backbone.View.extend({
_.bindAll(this);
this.facility_list = new FacilityCollection();
this.listenTo(this.facility_list, 'sync', this.render);
this.facility_list.fetch();
this.facility_list.fetch({
data: $.param({
zone_id: ZONE_ID
})
});
},

render: function() {
Expand Down
3 changes: 2 additions & 1 deletion kalite/coachreports/templates/coachreports/coach.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
var FACILITY_RESOURCE_URL = "{% url 'api_dispatch_list' resource_name='facility' %}";
var GROUP_RESOURCE_URL = "{% url 'api_dispatch_list' resource_name='group' %}";
var FACILITY_ID = {% if facility_id %}"{{ facility_id }}"{% else %}undefined{% endif %};
var ZONE_ID = "{{ zone_id }}";
</script>
<script src="{% static 'js/bootstrap-datepicker.min.js' %}"></script>
<script src="{% url 'handlebars_templates' module_name='coach_nav' %}"></script>
Expand All @@ -29,7 +30,7 @@
<script>
$(function() {
window.coach_router = new CoachReportRouter({facility: FACILITY_ID});
Backbone.history.start({pushState: true, root: "{% url 'coach_reports' %}"});
Backbone.history.start({pushState: true, root: "{% url 'coach_reports' zone_id=zone_id %}"});
});
</script>
{% endblock headjs %}
Expand Down
2 changes: 1 addition & 1 deletion kalite/coachreports/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


urlpatterns = patterns(__package__ + '.views',
url(r'^teach/', 'coach_reports', {}, 'coach_reports'),
url(r'^coach/zone/(?P<zone_id>\w+)', 'coach_reports', {}, 'coach_reports'),

url(r'^student/$', 'student_view', {}, 'student_view'),
url(r'^student/(?P<xaxis>[^/]+)/(?P<yaxis>[^/]+)/$', 'student_view', {}, 'student_view'),
Expand Down
13 changes: 11 additions & 2 deletions kalite/coachreports/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from annoying.decorators import render_to
from annoying.functions import get_object_or_None

from django.conf import settings; logging = settings.LOG
from django.core.exceptions import ValidationError
Expand All @@ -8,6 +9,8 @@
from kalite.shared.decorators.auth import require_authorized_access_to_student_data, require_authorized_admin, get_user_from_request
from kalite.facility.decorators import facility_from_request

from securesync.models import Zone

@require_authorized_access_to_student_data
@render_to("coachreports/student_view.html")
def student_view(request):
Expand Down Expand Up @@ -37,14 +40,20 @@ def student_view_context(request):
@require_authorized_admin
@facility_from_request
@render_to("coachreports/coach.html")
def coach_reports(request, facility=None):
def coach_reports(request, facility=None, zone_id=None):
"""Landing page needs plotting context in order to generate the navbar"""
zone = get_object_or_None(Zone, pk=zone_id)

if not zone:
raise Http404("Zone not found.")

if facility:
facility_id = facility.id
else:
facility_id = None
return {
"facility_id": facility_id
"facility_id": facility_id,
"zone_id": zone.id
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,16 @@ <h2>
{% endif %}
</td>
<td>
{% if group.id %}

{# Translators: this is a verb; by clicking this link, the user will be able to coach students. #}
<a title="{% blocktrans with groupname=group.name %}Coach group {{ groupname }}.{% endblocktrans %}" href="{% url 'coach_reports' %}{{ facility_id }}/{{ group.id }}/">
<a title="{% blocktrans with groupname=group.name %}Coach group {{ groupname }}.{% endblocktrans %}" href="{% url 'coach_reports' zone_id=zone_id %}{{ facility_id }}/{% if group.id %}{{ group.id }}{% else %}{{ ungrouped_id }}{% endif %}/">
<div class="sparklines" sparkType="bar" sparkBarColor="green">
<!--
{{ group.total_logins }},
{{ group.total_videos }},
{{ group.total_exercises }}
-->
</div></a>
{% endif %}
</td>
<td>{{ group.total_users }}</td>
<td>{{ group.total_logins }}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h2>
<td>
{% if student.group %}
{% if group_id %}
<a title="{% blocktrans with groupname=student.group.name %}Manage group {{ groupname }}{% endblocktrans %}" href="{% url 'coach_reports' %}/{{ facility.id }}/{{ student.group.id }}/">
<a title="{% blocktrans with groupname=student.group.name %}Manage group {{ groupname }}{% endblocktrans %}" href="{% url 'coach_reports' zone_id=zone_id %}/{{ facility.id }}/{{ student.group.id }}/">
{% else %}
<a title="{% blocktrans with groupname=student.group.name %}Coach group {{ groupname }}{% endblocktrans %}" href="{% url 'group_management' zone_id=zone_id facility_id=facility_id group_id=student.group.id %}">
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion kalite/distributed/hbtemplates/user/navigation.handlebars
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#if is_admin }}
<li class="teach-tab"><a href="{{ url "coach_reports" }}">{{_ "Teach" }}</a></li>
<li class="teach-tab"><a href="{{ url "coach_reports" zone_id }}">{{_ "Teach" }}</a></li>
<li class="manage-tab"><a href="{{#unless is_django_user }}{{ url "facility_management" "None" facility_id }}{{else}}{{url "zone_redirect" }}{{/unless}}">{{_ "Manage" }}</a></li>
{{/if}}
{{!-- Learn for all --}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ var StatusModel = Backbone.Model.extend({

pageType: function() {

if ( window.location.pathname.search(Urls.coach_reports()) > -1 ) {
if ( window.location.pathname.search(Urls.coach_reports(window.statusModel.get("zone_id"))) > -1 ) {
return "teachPage";
}
if ( window.location.pathname.search(Urls.learn()) > -1 ) {
Expand Down
2 changes: 1 addition & 1 deletion kalite/distributed/templates/distributed/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
CENTRAL_SERVER_HOST : "{{ central_server_host }}",
SECURESYNC_PROTOCOL : "{{ securesync_protocol }}",
CURRENT_LANGUAGE : "{{ current_language }}",
CHANNEL : "{{ channel }}",
CHANNEL : "{{ channel }}"
});
$(function() {
window.statusModel.fetch_data();
Expand Down
2 changes: 1 addition & 1 deletion kalite/distributed/templates/distributed/base_teach.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<ul>
<div class="mobile-nav">
<li class="reports {% block reports_active %}{% endblock reports_active %}">
<a href="{% url 'coach_reports' %}" title="{% trans 'Track the progress of your learners' %}"><div class=""><span class="icon icon-uniE605"></span><br/>{% trans "Reports" %}</div></a>
<a href="{% url 'coach_reports' zone_id=zone_id %}" title="{% trans 'Track the progress of your learners' %}"><div class=""><span class="icon icon-uniE605"></span><br/>{% trans "Reports" %}</div></a>
</li>
<li class="playlist {% block playlist_active %}{% endblock playlist_active %}">
<a class="link-width" href="{% url 'assign_playlists' %}" title="{% trans 'Assign playlists to learner groups' %}"><div><span class="icon icon-uniE604"></span><br/>{% trans "Playlists" %}</div></a>
Expand Down
3 changes: 3 additions & 0 deletions kalite/facility/api_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
from kalite.distributed.api_views import compute_total_points, get_messages_for_api_calls
from kalite.main.models import UserLog

from securesync.models import Device


class FacilityResource(ModelResource):
class Meta:
Expand Down Expand Up @@ -185,6 +187,7 @@ def generate_status(self, request, **kwargs):
"facilities": request.session.get("facilities"),
"simplified_login": settings.SIMPLIFIED_LOGIN,
"docs_exist": getattr(settings, "DOCS_EXIST", False),
"zone_id": Device.get_own_device().get_zone().id
}

# Override properties using facility data
Expand Down
4 changes: 2 additions & 2 deletions kalite/i18n/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class LanguageNotFoundError(Exception):

def get_localized_exercise_dirpath(lang_code):
ka_lang_code = lang_code.lower()
return os.path.join(settings.USER_DATA_ROOT, "exercises", ka_lang_code) # Translations live in user data space
return os.path.join(settings.USER_STATIC_FILES, "perseus", "ke", "exercises", ka_lang_code) # Translations live in user data space


def get_locale_path(lang_code=None):
Expand Down Expand Up @@ -339,7 +339,7 @@ def _get_installed_language_packs():
# This is idiotic, it just assumes that every directory / file is
# a valid language code
for django_disk_code in os.listdir(locale_dir):

# Skip if it's a file
if not os.path.isdir(os.path.join(locale_dir, django_disk_code)):
continue
Expand Down
20 changes: 10 additions & 10 deletions kalite/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@

if not _data_path:
_data_path = '.'

# This is getting deprecated as we will not explicitly operate with a static
# source structure, but have shared system-wide data and user data.
# It's not actually even a project root, because it's also the application's
Expand All @@ -124,10 +124,10 @@
default_project_root
)
)

else:
_data_path = os.path.join(ROOT_DATA_PATH,)

# BEING DEPRECATED, PLEASE DO NOT USE PROJECT_PATH!
PROJECT_PATH = os.environ.get(
"KALITE_HOME",
Expand Down Expand Up @@ -186,7 +186,7 @@
USER_WRITABLE_LOCALE_DIR = os.path.join(USER_DATA_ROOT, 'locale')
LOCALE_PATHS = getattr(local_settings, "LOCALE_PATHS", (USER_WRITABLE_LOCALE_DIR,))
LOCALE_PATHS = tuple([os.path.realpath(lp) + "/" for lp in LOCALE_PATHS])

# This is the legacy location kalite/database/data.sqlite
DEFAULT_DATABASE_PATH = os.path.join(_data_path, "kalite", "database", "data.sqlite")

Expand All @@ -196,22 +196,22 @@

# Storing data in a user directory
else:

# Ensure that path exists
if not os.path.exists(USER_DATA_ROOT):
os.mkdir(USER_DATA_ROOT)

USER_WRITABLE_LOCALE_DIR = os.path.join(USER_DATA_ROOT, 'locale')
KALITE_APP_LOCALE_DIR = os.path.join(USER_DATA_ROOT, 'locale')

LOCALE_PATHS = getattr(local_settings, "LOCALE_PATHS", (USER_WRITABLE_LOCALE_DIR, KALITE_APP_LOCALE_DIR))
if not os.path.exists(USER_WRITABLE_LOCALE_DIR):
os.mkdir(USER_WRITABLE_LOCALE_DIR)

DEFAULT_DATABASE_PATH = os.path.join(USER_DATA_ROOT, "database",)
if not os.path.exists(DEFAULT_DATABASE_PATH):
os.mkdir(DEFAULT_DATABASE_PATH)

DEFAULT_DATABASE_PATH = os.path.join(DEFAULT_DATABASE_PATH, 'data.sqlite')

# Stuff that can be served by the HTTP server is located the same place
Expand Down Expand Up @@ -466,7 +466,7 @@

# Separate session caching from file caching.
SESSION_ENGINE = getattr(
local_settings, "SESSION_ENGINE", 'django.contrib.sessions.backends.cache' + (''))
local_settings, "SESSION_ENGINE", 'django.contrib.sessions.backends.signed_cookies' + (''))

# Use our custom message storage to avoid adding duplicate messages
MESSAGE_STORAGE = 'fle_utils.django_utils.classes.NoDuplicateMessagesSessionStorage'
Expand Down
9 changes: 4 additions & 5 deletions kalite/topic_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def cache_file_path(basename):
CACHE_VARS.append("TOPICS")
CNT=0
def get_topic_tree(force=False, annotate=False, channel=None, language=None, parent=None):

# Hardcode the Brazilian Portuguese mapping that only the central server knows about
# TODO(jamalex): BURN IT ALL DOWN!
if language == "pt-BR":
Expand Down Expand Up @@ -193,16 +193,15 @@ def get_exercise_cache(force=False, language=None):
EXERCISES[language] = exercises
return EXERCISES[language]
EXERCISES[language] = softload_json(settings.EXERCISES_FILEPATH, logger=logging.debug, raises=False)

# English-language exercises live in application space, translations in user space
if language == "en":
exercise_root = os.path.join(settings.KHAN_EXERCISES_DIRPATH, "exercises")
else:
exercise_root = os.path.join(django_settings.USER_DATA_ROOT, "exercises")
exercise_root = i18n.get_localized_exercise_dirpath(language)
if os.path.exists(exercise_root):
exercise_path = os.path.join(exercise_root, language) if language != "en" else exercise_root
try:
exercise_templates = os.listdir(exercise_path)
exercise_templates = os.listdir(exercise_root)
except OSError:
exercise_templates = []
else:
Expand Down
2 changes: 0 additions & 2 deletions setup_mac.command

This file was deleted.

72 changes: 0 additions & 72 deletions setup_unix.sh

This file was deleted.

Loading

0 comments on commit 68c6ffe

Please sign in to comment.