Commit 3ea2b24b by Kevin Luo Committed by Sarina Canelake

Add HTML editor for authoring bulk email message (adopted from CMS)

parent 907bf6e1
...@@ -23,9 +23,11 @@ from django.core.urlresolvers import reverse ...@@ -23,9 +23,11 @@ from django.core.urlresolvers import reverse
from django.core.mail import send_mail from django.core.mail import send_mail
from django.utils import timezone from django.utils import timezone
from xmodule_modifiers import wrap_xmodule
import xmodule.graders as xmgraders import xmodule.graders as xmgraders
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.html_module import HtmlDescriptor
from courseware import grades from courseware import grades
from courseware.access import (has_access, get_access_group_name, from courseware.access import (has_access, get_access_group_name,
...@@ -83,7 +85,7 @@ def instructor_dashboard(request, course_id): ...@@ -83,7 +85,7 @@ def instructor_dashboard(request, course_id):
msg = '' msg = ''
to = None to = None
subject = None subject = None
html_message = None html_message = ''
problems = [] problems = []
plots = [] plots = []
datatable = {} datatable = {}
...@@ -785,6 +787,13 @@ s (~10k), it may take 1-2 hours to send all emails.</font>" ...@@ -785,6 +787,13 @@ s (~10k), it may take 1-2 hours to send all emails.</font>"
else: else:
instructor_tasks = None instructor_tasks = None
# HTML editor for email
if idash_mode == 'Email':
html_module = HtmlDescriptor(course.system, {'data': html_message})
editor = wrap_xmodule(html_module.get_html, html_module, 'xmodule_edit.html')()
else:
editor = None
# display course stats only if there is no other table to display: # display course stats only if there is no other table to display:
course_stats = None course_stats = None
if not datatable: if not datatable:
...@@ -801,9 +810,9 @@ s (~10k), it may take 1-2 hours to send all emails.</font>" ...@@ -801,9 +810,9 @@ s (~10k), it may take 1-2 hours to send all emails.</font>"
'course_stats': course_stats, 'course_stats': course_stats,
'msg': msg, 'msg': msg,
'modeflag': {idash_mode: 'selectedmode'}, 'modeflag': {idash_mode: 'selectedmode'},
'to': to, # email 'to': to, # email
'subject': subject, # email 'subject': subject, # email
'message': html_message, # email 'editor': editor, # email
'problems': problems, # psychometrics 'problems': problems, # psychometrics
'plots': plots, # psychometrics 'plots': plots, # psychometrics
'course_errors': modulestore().get_item_errors(course.location), 'course_errors': modulestore().get_item_errors(course.location),
......
...@@ -616,6 +616,11 @@ PIPELINE_JS = { ...@@ -616,6 +616,11 @@ PIPELINE_JS = {
'output_filename': 'js/lms-main_vendor.js', 'output_filename': 'js/lms-main_vendor.js',
'test_order': 0, 'test_order': 0,
}, },
'module-descriptor-js': {
'source_filenames': rooted_glob(COMMON_ROOT / 'static/', 'xmodule/descriptors/js/*.js'),
'output_filename': 'js/lms-module-descriptors.js',
'test_order': 8,
},
'module-js': { 'module-js': {
'source_filenames': rooted_glob(COMMON_ROOT / 'static', 'xmodule/modules/js/*.js'), 'source_filenames': rooted_glob(COMMON_ROOT / 'static', 'xmodule/modules/js/*.js'),
'output_filename': 'js/lms-modules.js', 'output_filename': 'js/lms-modules.js',
......
...@@ -41,6 +41,10 @@ $green: rgb(37, 184, 90); ...@@ -41,6 +41,10 @@ $green: rgb(37, 184, 90);
$light-gray: #ddd; $light-gray: #ddd;
$dark-gray: #333; $dark-gray: #333;
// used by descriptor css
$lightGrey: #edf1f5;
$darkGrey: #8891a1;
// edx.org marketing site variables // edx.org marketing site variables
$m-gray: #8A8C8F; $m-gray: #8A8C8F;
$m-gray-l1: #97999B; $m-gray-l1: #97999B;
...@@ -197,4 +201,4 @@ $homepage-bg-image: '../images/homepage-bg.jpg'; ...@@ -197,4 +201,4 @@ $homepage-bg-image: '../images/homepage-bg.jpg';
$login-banner-image: url(../images/bg-banner-login.png); $login-banner-image: url(../images/bg-banner-login.png);
$register-banner-image: url(../images/bg-banner-register.png); $register-banner-image: url(../images/bg-banner-register.png);
$video-thumb-url: '../images/courses/video-thumb.jpg'; $video-thumb-url: '../images/courses/video-thumb.jpg';
\ No newline at end of file
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
@import "course/instructor/instructor"; @import "course/instructor/instructor";
@import "course/instructor/instructor_2"; @import "course/instructor/instructor_2";
@import "course/instructor/email"; @import "course/instructor/email";
@import "xmodule/descriptors/css/module-styles.scss";
// discussion // discussion
@import "course/discussion/form-wmd-toolbar"; @import "course/discussion/form-wmd-toolbar";
.email-editor {
border: 1px solid #c8c8c8;
}
.xmodule_edit {
ul {
margin: 0;
padding: 0;
margin-bottom: 10px;
list-style: none;
}
a {
line-height: (16*1.48) + px;
line-height: 1.48rem;
}
}
.submit-email-action { .submit-email-action {
margin-top: 10px; margin-top: 10px;
line-height: 1.3; line-height: 1.3;
......
...@@ -10,6 +10,12 @@ ...@@ -10,6 +10,12 @@
<script type="text/javascript" src="${static.url('js/vendor/jquery-jvectormap-1.1.1/jquery-jvectormap-1.1.1.min.js')}"></script> <script type="text/javascript" src="${static.url('js/vendor/jquery-jvectormap-1.1.1/jquery-jvectormap-1.1.1.min.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/jquery-jvectormap-1.1.1/jquery-jvectormap-world-mill-en.js')}"></script> <script type="text/javascript" src="${static.url('js/vendor/jquery-jvectormap-1.1.1/jquery-jvectormap-world-mill-en.js')}"></script>
<script type="text/javascript" src="${static.url('js/course_groups/cohorts.js')}"></script> <script type="text/javascript" src="${static.url('js/course_groups/cohorts.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/codemirror-compressed.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/tiny_mce/tiny_mce.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/tiny_mce/jquery.tinymce.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/CodeMirror/htmlmixed.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/CodeMirror/css.js')}"></script>
<%static:js group='module-descriptor-js'/>
%if instructor_tasks is not None: %if instructor_tasks is not None:
<script type="text/javascript" src="${static.url('js/pending_tasks.js')}"></script> <script type="text/javascript" src="${static.url('js/pending_tasks.js')}"></script>
%endif %endif
...@@ -458,12 +464,11 @@ function goto( mode) ...@@ -458,12 +464,11 @@ function goto( mode)
%else: %else:
<input type="text" id="id_subject" name="subject" maxlength="100" size="75"> <input type="text" id="id_subject" name="subject" maxlength="100" size="75">
%endif %endif
<label for="id_message">Message:</label> <label>Message:</label>
%if message: <div class="email-editor">
<textarea cols="100" id="id_message" name="message">${message}</textarea> ${editor}
%else: </div>
<textarea cols="100" id="id_message" name="message"></textarea> <input type="hidden" name="message" value="">
%endif
</p> </p>
<div class="submit-email-action"> <div class="submit-email-action">
Please try not to email students more than once a day. Important things to consider before sending: Please try not to email students more than once a day. Important things to consider before sending:
...@@ -473,6 +478,13 @@ function goto( mode) ...@@ -473,6 +478,13 @@ function goto( mode)
</ul> </ul>
<input type="submit" name="action" value="Send email"> <input type="submit" name="action" value="Send email">
</div> </div>
<script type="text/javascript">
var emailEditor = XModule.loadModule($('.xmodule_edit'));
document.idashform.onsubmit = function() {
this.message.value = emailEditor.save()['data'];
return true;
}
</script>
%endif %endif
</form> </form>
......
<%! from django.utils.translation import ugettext as _ %>
<section class="html-editor editor">
<ul class="editor-tabs">
<li><a href="#" class="visual-tab tab current" data-tab="visual">${_("Visual")}</a></li>
<li><a href="#" class="html-tab tab" data-tab="advanced">${_("HTML")}</a></li>
</ul>
<div class="row">
<textarea class="tiny-mce">${data | h}</textarea>
<textarea name="" class="edit-box">${data | h}</textarea>
</div>
</section>
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