Skip to content

Commit

Permalink
Merge pull request #59 from Siyavula/feature-add-assignments
Browse files Browse the repository at this point in the history
Adding assignment activity
  • Loading branch information
mareliefi authored Apr 24, 2023
2 parents c74e556 + 456271a commit c53eeb7
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 3 deletions.
22 changes: 22 additions & 0 deletions classes/renderables/assignment_activity_renderable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace filter_siyavula\renderables;
use filter_siyavula\renderables\activity_renderable;

class assignment_activity_renderable extends activity_renderable {
public $assignmentid;
}
28 changes: 28 additions & 0 deletions filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -167,13 +179,29 @@ 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)
// Strip HTML
$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';
}
Expand Down
5 changes: 5 additions & 0 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
130 changes: 128 additions & 2 deletions styles/general.css
Original file line number Diff line number Diff line change
Expand Up @@ -145,28 +145,154 @@ input.toc {
.mastery progress.mastery-bg::-moz-progress-bar {
background-color: #f5bd00;
}

.mastery svg {
position: absolute;
top: 0;
left: 0;
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;
}
8 changes: 8 additions & 0 deletions templates/activity.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@
{{/sectionid}}

<div id="monassis" class="monassis monassis--practice monassis--maths monassis--siyavula-api">
{{#assignmentid}}
<div class="sv-session sv-session--assignment">
<div class="sv-session__title"> Assignment </div>
<div class="sv-session__actions">
<div class="sv-session-badge--assignment"></div>
</div>
</div>
{{/assignmentid}}
<div class="question-wrapper">
<div class="question-content"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

defined('MOODLE_INTERNAL') || die();
$plugin->version = 2022111702; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2023032901; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2019111809; // Requires this Moodle version
$plugin->component = 'filter_siyavula'; // Full name of the plugin (used for diagnostics)
$plugin->maturity = MATURITY_STABLE;

0 comments on commit c53eeb7

Please sign in to comment.