diff --git a/classes/renderables/assignment_activity_renderable.php b/classes/renderables/assignment_activity_renderable.php new file mode 100644 index 0000000..36fa1a7 --- /dev/null +++ b/classes/renderables/assignment_activity_renderable.php @@ -0,0 +1,22 @@ +. + +namespace filter_siyavula\renderables; +use filter_siyavula\renderables\activity_renderable; + +class assignment_activity_renderable extends activity_renderable { + public $assignmentid; +} diff --git a/filter.php b/filter.php index 57a11b5..4c596a1 100644 --- a/filter.php +++ b/filter.php @@ -19,12 +19,15 @@ use filter_siyavula\renderables\practice_activity_renderable; use filter_siyavula\renderables\standalone_activity_renderable; use filter_siyavula\renderables\standalone_list_activity_renderable; +use filter_siyavula\renderables\assignment_activity_renderable; class filter_siyavula extends moodle_text_filter { public function get_activity_type($text) { if (strpos($text, '[[syp') !== false) { $activitytype = 'practice'; + } else if (strpos($text, '[[sya') !== false) { + $activitytype = 'assignment'; } else if (strpos($text, '[[sy') !== false) { if (strpos($text, ',') == true) { $activitytype = 'standaloneList'; @@ -49,6 +52,7 @@ public function parse_filter_text($text) { // Strip "sy-" and "syp-" identifiers. $text = str_replace("sy-", "", $text); $text = str_replace("syp-", "", $text); + $text = str_replace("sya-", "", $text); // Convert filter string to array. $textarray = explode(",", $text); @@ -97,6 +101,14 @@ public function get_practice_activity_data($text) { return $sectionid; } + public function get_assignment_activity_data($text) { + $templatelist = $this->parse_filter_text($text)[0]; + $assignmentid = $templatelist[0]; + + return $assignmentid; + } + + public function filter($text, array $options = array()) { global $OUTPUT, $USER, $PAGE, $CFG, $DB; @@ -167,6 +179,20 @@ public function filter($text, array $options = array()) { $activityrenderable->sectionid = $sectionid; $result .= $renderer->render_practice_activity($activityrenderable); + } else if ($activitytype == 'assignment') { + $assignmentid = $this->get_assignment_activity_data($text); + + $renderer = $PAGE->get_renderer('filter_siyavula'); + $activityrenderable = new assignment_activity_renderable(); + $activityrenderable->wwwroot = $CFG->wwwroot; + $activityrenderable->baseurl = $baseurl; + $activityrenderable->showlivepreview = $showlivepreview; + $activityrenderable->token = $token; + $activityrenderable->usertoken = $usertoken->token; + $activityrenderable->activitytype = $activitytype; + $activityrenderable->assignmentid = $assignmentid; + + $result .= $renderer->render_assignment_activity($activityrenderable); } // TODO: Refactor this (LC) @@ -174,6 +200,8 @@ public function filter($text, array $options = array()) { $newtext = strip_tags($text); if ($activitytype == 'practice') { $re = '/\[{2}[syp\-\d{1,},?|]*\]{2}/m'; + } if ($activitytype == 'assignment') { + $re = '/\[{2}[sya\-\d{1,},?|]*\]{2}/m'; } else { $re = '/\[{2}[sy\-\d{1,},?|]*\]{2}/m'; } diff --git a/renderer.php b/renderer.php index efa4e92..9562d4f 100644 --- a/renderer.php +++ b/renderer.php @@ -20,12 +20,17 @@ use filter_siyavula\renderables\standalone_activity_renderable; use filter_siyavula\renderables\standalone_list_activity_renderable; use filter_siyavula\renderables\question_feedback_renderable; +use filter_siyavula\renderables\assignment_activity_renderable; class filter_siyavula_renderer extends plugin_renderer_base { public function render_practice_activity(practice_activity_renderable $practiceactivityrenderable) { return $this->render_from_template('filter_siyavula/activity', $practiceactivityrenderable); } + public function render_assignment_activity(assignment_activity_renderable $assignmentactivityrenderable) { + return $this->render_from_template('filter_siyavula/activity', $assignmentactivityrenderable); + } + public function render_standalone_activity(standalone_activity_renderable $standaloneactivityrenderable) { return $this->render_from_template('filter_siyavula/activity', $standaloneactivityrenderable); } diff --git a/styles/general.css b/styles/general.css index 1483269..c8149a9 100644 --- a/styles/general.css +++ b/styles/general.css @@ -145,6 +145,7 @@ input.toc { .mastery progress.mastery-bg::-moz-progress-bar { background-color: #f5bd00; } + .mastery svg { position: absolute; top: 0; @@ -152,21 +153,146 @@ input.toc { width: 100%; height: 100%; } + .sv-toc__chapter-mastery{ margin-left: auto; margin-right: 5%; } + .item-toc{ display: flex; padding: 1em; font-size: 1.1em; } + .item-toc a{ height: 10%; color: black; font-weight: bold; } + .sv-toc__section-mastery{ - margin-left: auto; - margin-right: 5%; + margin-left: auto; + margin-right: 5%; + } + + .sv .sv-session { + display: table; + margin: 0 auto 1.03125em; + width: 100%; + } + + .sv .sv-session-badge { + display: inline-block; + font-size: 1em; + line-height: 1; + padding: 0.4375em 0.75em; + border-radius: 1.0625em; + white-space: nowrap; + background: #008bb2; + color: #ffffff; } + + .sv .sv-session-badge__label { + display: inline-block; + vertical-align: middle; + font-size: 0.875em; + line-height: 1em; + margin: 0 0 1.125px; + margin: 0 0 0.0625rem; + padding: 0 0.25em; + font-weight: bold; + } + + .sv .sv-session--assignment .sv-session__title { + color: #0daa88; + } + + .sv .sv-session__title { + font-family: Helvetica, Arial, sans-serif ; + color: inherit ; + font-size: 1em ; + font-weight: 700 ; + line-height: 1.375em ; + display: table-cell; + text-align: left; + vertical-align: middle; + padding-right: 1em; + margin: 0; + text-transform: uppercase; + color: #008bb2; + } + + .sv .sv-session__actions { + display: table-cell; + text-align: right; + vertical-align: middle; + } + + .sv .sv-session--assignment .sv-session__title { + color: #0daa88; + } + + .sv .sv-session-badge--assignment { + background: #0daa88; + color: #ffffff; + border-radius: 1.0625em; + padding: .4375em .75em; + display: inline-block; + white-space: nowrap; + } + + .sv .sv-session-badge__label { + font-family: Helvetica, Arial, sans-serif; + font-size: 1em; + font-weight: 700; + margin: 0 0 .0625rem; + padding: 0 .25em; + vertical-align: middle; + display: inline-block + } + + .sv .sv-state-message { + -webkit-box-sizing: border-box; + box-sizing: border-box; + display: block; + position: relative; + margin: 0 auto 1.03125em; } + + .sv .sv-state-message.sv-state-message--filled { + border-radius: 4px; + padding: 1.2em 0.8em; } + + .sv .sv-state-message .sv-state-message__title { + font-family: Helvetica, Arial, sans-serif ; + color: inherit ; + font-size: 1em ; + font-weight: 400 ; + line-height: 1.375em ; + margin: 0 auto 1.03125em ; + font-weight: bold; + max-width: 24em; } + + .sv .sv-state-message .sv-state-message__description { + margin-top: -0.51562em; } + + .sv .sv-state-message.sv-state-message--completed .sv-state-message__figure { + color: #45b449; + font-size: 3.5em; + } + + .sv img.icon { + width: 56px; + height: 56px; + vertical-align: middle; + margin-bottom: 1em; + } + + .sv .sv-state-message.sv-state-message--filled.sv-state-message--completed.sv-state-message--assignment { + background: #e3f4e4; + border: 1px solid #e3f4e4; + max-width: 40em; + min-width: 40em; + line-height: 1.5em; + text-align: center; + } diff --git a/templates/activity.mustache b/templates/activity.mustache index 7e1932c..50a4577 100644 --- a/templates/activity.mustache +++ b/templates/activity.mustache @@ -75,6 +75,14 @@ {{/sectionid}}