Commit d891361b by cahrens

Merge branch 'master' into bug/christina/misc

parents b0106a41 59250225
from xmodule.templates import update_templates
update_templates()
from xmodule.templates import update_templates
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = \
'''Imports and updates the Studio component templates from the code pack and put in the DB'''
def handle(self, *args, **options):
update_templates()
\ No newline at end of file
...@@ -317,6 +317,10 @@ class CourseDescriptor(SequenceDescriptor): ...@@ -317,6 +317,10 @@ class CourseDescriptor(SequenceDescriptor):
self.metadata['enrollment_end'] = stringify_time(value) self.metadata['enrollment_end'] = stringify_time(value)
@property @property
def grader(self):
return grader_from_conf(self.raw_grader)
@property
def raw_grader(self): def raw_grader(self):
return self._grading_policy['RAW_GRADER'] return self._grading_policy['RAW_GRADER']
......
...@@ -64,7 +64,11 @@ class CachingDescriptorSystem(MakoDescriptorSystem): ...@@ -64,7 +64,11 @@ class CachingDescriptorSystem(MakoDescriptorSystem):
location = Location(location) location = Location(location)
json_data = self.module_data.get(location) json_data = self.module_data.get(location)
if json_data is None: if json_data is None:
return self.modulestore.get_item(location) module = self.modulestore.get_item(location)
if module is not None:
# update our own cache after going to the DB to get cache miss
self.module_data.update(module.system.module_data)
return module
else: else:
# load the module and apply the inherited metadata # load the module and apply the inherited metadata
try: try:
......
...@@ -307,6 +307,10 @@ def index(request, course_id, chapter=None, section=None, ...@@ -307,6 +307,10 @@ def index(request, course_id, chapter=None, section=None,
# Specifically asked-for section doesn't exist # Specifically asked-for section doesn't exist
raise Http404 raise Http404
# cdodge: this looks silly, but let's refetch the section_descriptor with depth=None
# which will prefetch the children more efficiently than doing a recursive load
section_descriptor = modulestore().get_instance(course.id, section_descriptor.location, depth=None)
# Load all descendants of the section, because we're going to display its # Load all descendants of the section, because we're going to display its
# html, which in general will need all of its children # html, which in general will need all of its children
section_module_cache = StudentModuleCache.cache_for_descriptor_descendents( section_module_cache = StudentModuleCache.cache_for_descriptor_descendents(
......
...@@ -3,6 +3,7 @@ import json ...@@ -3,6 +3,7 @@ import json
from datetime import datetime from datetime import datetime
from django.http import Http404 from django.http import Http404
from mitxmako.shortcuts import render_to_response from mitxmako.shortcuts import render_to_response
from django.db import connection
from student.models import CourseEnrollment, CourseEnrollmentAllowed from student.models import CourseEnrollment, CourseEnrollmentAllowed
from django.contrib.auth.models import User from django.contrib.auth.models import User
...@@ -12,16 +13,18 @@ def dictfetchall(cursor): ...@@ -12,16 +13,18 @@ def dictfetchall(cursor):
'''Returns a list of all rows from a cursor as a column: result dict. '''Returns a list of all rows from a cursor as a column: result dict.
Borrowed from Django documentation''' Borrowed from Django documentation'''
desc = cursor.description desc = cursor.description
table=[] table = []
table.append([col[0] for col in desc]) table.append([col[0] for col in desc])
table = table + cursor.fetchall()
print "Table: " + str(table) # ensure response from db is a list, not a tuple (which is returned
# by MySQL backed django instances)
rows_from_cursor=cursor.fetchall()
table = table + [list(row) for row in rows_from_cursor]
return table return table
def SQL_query_to_list(cursor, query_string): def SQL_query_to_list(cursor, query_string):
cursor.execute(query_string) cursor.execute(query_string)
raw_result=dictfetchall(cursor) raw_result=dictfetchall(cursor)
print raw_result
return raw_result return raw_result
def dashboard(request): def dashboard(request):
...@@ -50,7 +53,6 @@ def dashboard(request): ...@@ -50,7 +53,6 @@ def dashboard(request):
results["scalars"]["Total Enrollments Across All Courses"]=CourseEnrollment.objects.count() results["scalars"]["Total Enrollments Across All Courses"]=CourseEnrollment.objects.count()
# establish a direct connection to the database (for executing raw SQL) # establish a direct connection to the database (for executing raw SQL)
from django.db import connection
cursor = connection.cursor() cursor = connection.cursor()
# define the queries that will generate our user-facing tables # define the queries that will generate our user-facing tables
......
...@@ -441,6 +441,13 @@ namespace :cms do ...@@ -441,6 +441,13 @@ namespace :cms do
end end
namespace :cms do namespace :cms do
desc "Imports all the templates from the code pack"
task :update_templates do
sh(django_admin(:cms, :dev, :update_templates))
end
end
namespace :cms do
desc "Import course data within the given DATA_DIR variable" desc "Import course data within the given DATA_DIR variable"
task :xlint do task :xlint do
if ENV['DATA_DIR'] and ENV['COURSE_DIR'] if ENV['DATA_DIR'] and ENV['COURSE_DIR']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment