From 746433218072baa65337895460cc3e4507c54ca7 Mon Sep 17 00:00:00 2001 From: Kyle Fiedler Date: Wed, 22 Aug 2012 15:09:20 -0400 Subject: [PATCH 1/9] added fix for error styles and swapped some the button order --- lms/static/sass/course/wiki/_wiki.scss | 23 ++++++++++++++++++++++- lms/templates/wiki/create.html | 9 +++++---- lms/templates/wiki/edit.html | 17 +++++++++-------- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/lms/static/sass/course/wiki/_wiki.scss b/lms/static/sass/course/wiki/_wiki.scss index 6ddfe0caef..9178f7719f 100644 --- a/lms/static/sass/course/wiki/_wiki.scss +++ b/lms/static/sass/course/wiki/_wiki.scss @@ -390,7 +390,6 @@ section.wiki { .CodeMirror { background: #fafafa; border: 1px solid #c8c8c8; - @include border-radius(3px); @include box-shadow(0 1px 0 0 rgba(255, 255, 255, 0.6), inset 0 0 3px 0 rgba(0, 0, 0, 0.1)); } @@ -690,6 +689,28 @@ section.wiki { margin-top: 9px; } + .error { + font-size: 1em; + color: $pink; + + .help-block { + margin-top: 10px; + } + + input { + border-color: $pink; + } + } + + .back { + float: right; + } + + + + + + /*----------------- Directory diff --git a/lms/templates/wiki/create.html b/lms/templates/wiki/create.html index 25cc197bc4..886764ba84 100644 --- a/lms/templates/wiki/create.html +++ b/lms/templates/wiki/create.html @@ -32,14 +32,15 @@
{% wiki_form create_form %}
diff --git a/lms/templates/wiki/edit.html b/lms/templates/wiki/edit.html index e2c6cb64a5..3d36cf2869 100644 --- a/lms/templates/wiki/edit.html +++ b/lms/templates/wiki/edit.html @@ -9,14 +9,14 @@
{% include "wiki/includes/editor.html" %}
- + @@ -29,14 +29,15 @@
From 960cf5792b6265dc90d6d306b9a626a4169c6e67 Mon Sep 17 00:00:00 2001 From: kimth Date: Wed, 22 Aug 2012 15:12:49 -0400 Subject: [PATCH 2/9] Dynamically disable syllabus per-course --- common/lib/xmodule/xmodule/course_module.py | 5 +++++ lms/templates/courseware/course_navigation.html | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index 5cc4a09165..f8496dd67c 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -3,6 +3,7 @@ import time import logging import requests from lxml import etree +from path import path # NOTE (THK): Only used for detecting presence of syllabus from xmodule.util.decorators import lazyproperty from xmodule.graders import load_grading_policy @@ -75,6 +76,10 @@ class CourseDescriptor(SequenceDescriptor): # NOTE: relies on the modulestore to call set_grading_policy() right after # init. (Modulestore is in charge of figuring out where to load the policy from) + # NOTE (THK): This is a last-minute addition for Fall 2012 launch to dynamically + # disable the syllabus content for courses that do not provide a syllabus + self.syllabus_present = self.system.resources_fs.exists(path('syllabus')) + def set_grading_policy(self, policy_str): """Parse the policy specified in policy_str, and save it""" diff --git a/lms/templates/courseware/course_navigation.html b/lms/templates/courseware/course_navigation.html index 63fec53c4c..af2100f042 100644 --- a/lms/templates/courseware/course_navigation.html +++ b/lms/templates/courseware/course_navigation.html @@ -19,7 +19,7 @@ def url_class(url):
  1. Courseware
  2. Course Info
  3. -% if settings.MITX_FEATURES.get('ENABLE_SYLLABUS'): +% if course.syllabus_present:
  4. Syllabus
  5. % endif % if user.is_authenticated(): From 64788a73aadf3787c9d04d6ce4b78e2270d0b533 Mon Sep 17 00:00:00 2001 From: kimth Date: Wed, 22 Aug 2012 15:22:58 -0400 Subject: [PATCH 3/9] Remove ENABLE_SYLLABUS flag from envs/common --- lms/envs/common.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lms/envs/common.py b/lms/envs/common.py index a217f0e7b9..bc49de6d76 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -55,10 +55,6 @@ MITX_FEATURES = { # course_ids (see dev_int.py for an example) 'SUBDOMAIN_COURSE_LISTINGS' : False, - # TODO: This will be removed once course-specific tabs are in place. see - # courseware/courses.py - 'ENABLE_SYLLABUS' : True, - 'ENABLE_TEXTBOOK' : True, 'ENABLE_DISCUSSION' : False, 'ENABLE_DISCUSSION_SERVICE': True, From f4f8b7bf73c08ba1cd375b3df9ebd594bb1b5fa4 Mon Sep 17 00:00:00 2001 From: Kyle Fiedler Date: Wed, 22 Aug 2012 15:39:24 -0400 Subject: [PATCH 4/9] Added delete page and padding and hid th on overflow --- lms/static/sass/course/wiki/_wiki.scss | 5 +++++ lms/templates/wiki/edit.html | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lms/static/sass/course/wiki/_wiki.scss b/lms/static/sass/course/wiki/_wiki.scss index 9178f7719f..9868989eff 100644 --- a/lms/static/sass/course/wiki/_wiki.scss +++ b/lms/static/sass/course/wiki/_wiki.scss @@ -757,6 +757,7 @@ section.wiki { th, td { border-bottom: 1px solid $light-gray; padding: 8px; + overflow: hidden; } tr:nth-child(even) { @@ -860,6 +861,10 @@ section.wiki { } } + section.delete { + padding: 40px; + } + diff --git a/lms/templates/wiki/edit.html b/lms/templates/wiki/edit.html index 3d36cf2869..f4bd7d138f 100644 --- a/lms/templates/wiki/edit.html +++ b/lms/templates/wiki/edit.html @@ -39,7 +39,7 @@ {% trans "Back to editor" %} - + {% endblock %} From cca5fe2f040a063d2db267dba263cd3fa23ea257 Mon Sep 17 00:00:00 2001 From: Kyle Fiedler Date: Wed, 22 Aug 2012 15:40:56 -0400 Subject: [PATCH 5/9] Delete page --- lms/templates/wiki/delete.html | 64 ++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 lms/templates/wiki/delete.html diff --git a/lms/templates/wiki/delete.html b/lms/templates/wiki/delete.html new file mode 100644 index 0000000000..6cb2b36707 --- /dev/null +++ b/lms/templates/wiki/delete.html @@ -0,0 +1,64 @@ +{% extends "wiki/base.html" %} +{% load wiki_tags i18n sekizai_tags %} +{% load url from future %} + +{% block pagetitle %}{% trans "Delete article" %}{% endblock %} + +{% block wiki_contents %} +
    +

    {% trans "Delete" %} "{{ article.current_revision.title }}"

    + + {% if cannot_delete_root %} +

    {% trans "You cannot delete a root article." %}

    +

    {% trans "Go back" %}

    + {% else %} + + {% if cannot_delete_children %} + +

    {% trans "You cannot delete this article because you do not have permission to delete articles with children. Try to remove the children manually one-by-one." %}

    + + {% endif %} + + {% if delete_children %} + +

    {% trans "You are deleting an article. This means that its children will be deleted as well. If you choose to purge, children will also be purged!" %}

    + +

    {% trans "Articles that will be deleted" %}

    + +
      + {% for child in delete_children %} +
    • {{ child.article }}
    • + {% if delete_children_more %} +
    • {% trans "...and more!" %}
    • + {% endif %} + {% endfor %} +
    + + {% endif %} + + {% if not cannot_delete_children %} +

    {% trans "You are deleting an article. Please confirm." %}

    + +
    + {% wiki_form delete_form %} + +
    + + + + {% trans "Go back" %} + +
    +
    + {% endif %} + + {% endif %} +
    + +{% endblock %} + From a301abd5adeb0a0346014007982b2bb113289b4a Mon Sep 17 00:00:00 2001 From: Piotr Mitros Date: Wed, 22 Aug 2012 15:49:48 -0400 Subject: [PATCH 6/9] Enrollment hack for allowing Berkeley to add their students. --- lms/djangoapps/courseware/views.py | 42 ++++++++++++++++++++++++++++++ lms/urls.py | 3 ++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index 98444c176d..f67f79cf11 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -393,3 +393,45 @@ def instructor_dashboard(request, course_id): context = {'course': course, 'staff_access': True,} return render_to_response('courseware/instructor_dashboard.html', context) + +@ensure_csrf_cookie +@cache_control(no_cache=True, no_store=True, must_revalidate=True) +def enroll_students(request, course_id): + course = get_course_with_access(request.user, course_id, 'staff') + ''' Allows a staff member to enroll students in a course. + + This is a short-term hack for Berkeley courses launching fall + 2012. In the long term, we would like functionality like this, but + we would like both the instructor and the student to agree. Right + now, this allows any instructor to add students to their course, + which we do not want. + + It is poorly written and poorly tested, but it's designed to be + stripped out. + ''' + + course = get_course_with_access(request.user, course_id, 'staff') + existing_students = [ce.user.email for ce in CourseEnrollment.objects.filter(course_id = course_id)] + print request.POST + if 'new_students' in request.POST: + new_students = request.POST['new_students'].split('\n') + else: + new_students = [] + new_students = [s.strip() for s in new_students] + + added_students = [] + rejected_students = [] + + for student in new_students: + try: + nce = CourseEnrollment(user=User.objects.get(email = student), course_id = course_id) + nce.save() + added_students.append(student) + except: + rejected_students.append(student) + + return render_to_response("enroll_students.html", {'course':course_id, + 'existing_students': existing_students, + 'added_students': added_students, + 'rejected_students': rejected_students, + 'debug':new_students}) diff --git a/lms/urls.py b/lms/urls.py index 6e6ad4300e..af21b8bf45 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -154,7 +154,8 @@ if settings.COURSEWARE_ENABLED: 'courseware.views.gradebook', name='gradebook'), url(r'^courses/(?P[^/]+/[^/]+/[^/]+)/grade_summary$', 'courseware.views.grade_summary', name='grade_summary'), - + url(r'^courses/(?P[^/]+/[^/]+/[^/]+)/enroll_students$', + 'courseware.views.enroll_students', name='enroll_students'), ) # discussion forums live within courseware, so courseware must be enabled first From a694d1034ee6ec9ba177bc66fd4296b71e125587 Mon Sep 17 00:00:00 2001 From: Bridger Maxwell Date: Wed, 22 Aug 2012 15:57:44 -0400 Subject: [PATCH 7/9] We use django-wiki's built-in wikilinks markdown extension. They were clashing. --- .../plugins/markdownedx/mdx_wikipath.py | 92 ------------------- .../plugins/markdownedx/wiki_plugin.py | 7 +- lms/envs/common.py | 1 + repo-requirements.txt | 2 +- 4 files changed, 4 insertions(+), 98 deletions(-) delete mode 100755 lms/djangoapps/course_wiki/plugins/markdownedx/mdx_wikipath.py diff --git a/lms/djangoapps/course_wiki/plugins/markdownedx/mdx_wikipath.py b/lms/djangoapps/course_wiki/plugins/markdownedx/mdx_wikipath.py deleted file mode 100755 index 4c6f6fadd7..0000000000 --- a/lms/djangoapps/course_wiki/plugins/markdownedx/mdx_wikipath.py +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env python - -''' -Wikipath Extension for Python-Markdown -====================================== - -Converts [Link Name](wiki:ArticleName) to relative links pointing to article. Requires Python-Markdown 2.0+ - -Basic usage: - - >>> import markdown - >>> text = "Some text with a [Link Name](wiki:ArticleName)." - >>> html = markdown.markdown(text, ['wikipath(base_url="/wiki/view/")']) - >>> html - u'

    Some text with a Link Name.

    ' - -Dependencies: -* [Python 2.3+](http://python.org) -* [Markdown 2.0+](http://www.freewisdom.org/projects/python-markdown/) -''' - - -import markdown -try: - # Markdown 2.1.0 changed from 2.0.3. We try importing the new version first, - # but import the 2.0.3 version if it fails - from markdown.util import etree -except: - from markdown import etree - - -class WikiPathExtension(markdown.Extension): - def __init__(self, configs): - # set extension defaults - self.config = { - 'base_url' : ['/', 'String to append to beginning of URL.'], - 'html_class' : ['wikipath', 'CSS hook. Leave blank for none.'] - } - - # Override defaults with user settings - for key, value in configs : - # self.config[key][0] = value - self.setConfig(key, value) - - - def extendMarkdown(self, md, md_globals): - self.md = md - - # append to end of inline patterns - WIKI_RE = r'\[(?P.+?)\]\(wiki:(?P[a-zA-Z\d/_-]*)\)' - wikiPathPattern = WikiPath(WIKI_RE, self.config) - wikiPathPattern.md = md - md.inlinePatterns.add('wikipath', wikiPathPattern, " Date: Wed, 22 Aug 2012 16:15:24 -0400 Subject: [PATCH 8/9] Added missing file --- lms/templates/enroll_students.html | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lms/templates/enroll_students.html diff --git a/lms/templates/enroll_students.html b/lms/templates/enroll_students.html new file mode 100644 index 0000000000..2f0b6ccc01 --- /dev/null +++ b/lms/templates/enroll_students.html @@ -0,0 +1,29 @@ +

    Student Enrollment Form

    + +

    Course: ${ course } + +

    + +

    Add new students

    + + +
    + +

    Existing students: + +

    ${ existing_students } + +

    New students added: +${ added_students } + +

    Students rejected: +${ rejected_students } + +

    Debug: +

    ${ debug } + + +

    foo +

    bar +

    biff From 69a3ea63bcd0497bc9786b4d805eab6294b7a33a Mon Sep 17 00:00:00 2001 From: Piotr Mitros Date: Wed, 22 Aug 2012 16:32:14 -0400 Subject: [PATCH 9/9] Fixed minor issues (removed two unnecessary lines) --- lms/djangoapps/courseware/views.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index f67f79cf11..640dd7c08d 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -397,7 +397,6 @@ def instructor_dashboard(request, course_id): @ensure_csrf_cookie @cache_control(no_cache=True, no_store=True, must_revalidate=True) def enroll_students(request, course_id): - course = get_course_with_access(request.user, course_id, 'staff') ''' Allows a staff member to enroll students in a course. This is a short-term hack for Berkeley courses launching fall @@ -412,7 +411,7 @@ def enroll_students(request, course_id): course = get_course_with_access(request.user, course_id, 'staff') existing_students = [ce.user.email for ce in CourseEnrollment.objects.filter(course_id = course_id)] - print request.POST + if 'new_students' in request.POST: new_students = request.POST['new_students'].split('\n') else: