Skip to content

Commit

Permalink
Merge pull request #15 from andreasschenkel/develop
Browse files Browse the repository at this point in the history
v2.0.4
  • Loading branch information
andreasschenkel authored Jan 31, 2022
2 parents 5a67ece + 96d0d48 commit 51c3c7a
Show file tree
Hide file tree
Showing 18 changed files with 125 additions and 105 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,19 @@ By default only editing teacher can use this generator. If other roles should be

### D: Changelog ###

[[v2.0.4]]

- fixed: add "ranked" to pluginname and refactored to new name feedbackcankedchoicegenerator
- fixed: Wrong link URL if Moodle not installed in the server root.
- fixed: wrong namespaces
- fixed: pull request with correct language strings
- fixed: do not hard-code the word "Option"



[[v2.0.3]]

- setting to allow generator on frontpage with courseid=1. Use URL moodleurl/local/feedbackchoicegenerator/index.php?id=1'
- setting to allow generator on frontpage with courseid=1. Use URL moodleurl/local/feedbackrankedchoicegenerator/index.php?id=1'


[[v2.0.2]]
Expand Down Expand Up @@ -97,7 +107,7 @@ unknown
- 02.12.2021 set capability für role editingteacher instead of teacher
- 02.12.2021 check, if user has capability to view report also by checking the capapility
- 02.12.2021 do not prevent capability for student
- 02.12.2021 added missing languagestring feedbackchoicegenerator:view
- 02.12.2021 added missing languagestring feedbackrankedchoicegenerator:view


[[v1.0.1]] beta
Expand All @@ -121,7 +131,7 @@ unknown

The plugin can be also installed by putting the contents of this directory to

{your/moodle/dirroot}/local/feedbackchoicegenerator
{your/moodle/dirroot}/local/feedbackrankedchoicegenerator

Afterwards, log in to your Moodle site as an admin and go to _Site administration >
Notifications_ to complete the installation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace local_feedbackchoicegenerator\View;
namespace local_feedbackrankedchoicegenerator;

use stdClass;
use moodle_database;

use local_feedbackchoicegenerator\Helper;
use local_feedbackchoicegenerator\Manager;
use local_feedbackrankedchoicegenerator\Helper;
use local_feedbackrankedchoicegenerator\Manager;

/**
* @package local_feedbackchoicegenerator
* Class FeedbackChoiceGenerator
* @package local_feedbackrankedchoicegenerator
* Class FeedbackrankedChoiceGenerator
*/
class FeedbackChoiceGenerator
class FeedbackrankedChoiceGenerator
{

/**
Expand All @@ -46,7 +46,7 @@ class FeedbackChoiceGenerator
private $apim;

/**
* FeedbackChoiceGenerator constructor.
* FeedbackrankedChoiceGenerator constructor.
* @param moodle_database $db
* @param int $courseid
* @param moodle_page $page
Expand Down Expand Up @@ -77,8 +77,10 @@ public function get_page(): Page {
*/
public function init() {
global $CFG;
$maxlength = (int)$CFG->local_feedbackchoicegenerator_maxlength;
$maxoptionslength = (int)$CFG->local_feedbackchoicegenerator_maxoptionslength;
$maxlength = (int)$CFG->local_feedbackrankedchoicegenerator_maxlength;
$maxoptionslength = (int)$CFG->local_feedbackrankedchoicegenerator_maxoptionslength;
$optionlabel = '';
$optionlabel = get_string('optionlabel', 'local_feedbackrankedchoicegenerator');

$this->apim->security()->user_is_allowed_to_view_the_course_and_has_capability_to_use_generator($this->courseid);

Expand Down Expand Up @@ -110,7 +112,7 @@ public function init() {
$optioncounter = substr($optioncounter , 0, $maxoptionslength);
$options[] = array(
'optionnumber' => $i,
'optionlabel' => "Option $i",
'optionlabel' => "$optionlabel $i",
'optionname' => "option$i",
'optionvalue' => $optioncounter
);
Expand All @@ -120,32 +122,35 @@ public function init() {
$textareacontent = $this->textareagenerator($optionsarray);
$dataurl = 'data:application/xml;charset=UTF-8;utf8,' . $textareacontent;

$wwwroot = $CFG->wwwroot;

echo $this->get_page()->get_output()->render_from_template(
'local_feedbackchoicegenerator/mainpage',
'local_feedbackrankedchoicegenerator/mainpage',
[
'wwwroot' => $wwwroot,
'courseid' => $this->courseid,
'backtocourselabel' => get_string('backtocourselabel', 'local_feedbackchoicegenerator'),
'backtocourselabel' => get_string('backtocourselabel', 'local_feedbackrankedchoicegenerator'),

'title' => $this->get_page()->get_title(),
'header3' => get_string('header3', 'local_feedbackchoicegenerator'),
'summary' => get_string('summary', 'local_feedbackchoicegenerator'),
'header3' => get_string('header3', 'local_feedbackrankedchoicegenerator'),
'summary' => get_string('summary', 'local_feedbackrankedchoicegenerator'),

'courseidlabel' => get_string('courseidlabel', 'local_feedbackchoicegenerator'),
'sizelabel' => get_string('sizelabel', 'local_feedbackchoicegenerator'),
'courseidlabel' => get_string('courseidlabel', 'local_feedbackrankedchoicegenerator'),
'sizelabel' => get_string('sizelabel', 'local_feedbackrankedchoicegenerator'),
'maxlength' => $maxlength,

'optionslengthinfo' => get_string('optionslengthinfo', 'local_feedbackchoicegenerator'),
'description' => get_string('description', 'local_feedbackchoicegenerator'),
'optionslengthinfo' => get_string('optionslengthinfo', 'local_feedbackrankedchoicegenerator'),
'description' => get_string('description', 'local_feedbackrankedchoicegenerator'),

'size' => $size,
'filename' => $filename,
'options' => $options,
'maxoptionslength' => $maxoptionslength,
'textareacontent' => $textareacontent,
'buttonlabel' => get_string('buttonlabel', 'local_feedbackchoicegenerator'),
'downloadbuttonlabel' => get_string('downloadbuttonlabel', 'local_feedbackchoicegenerator'),
'updatebuttonlabel' => get_string('updatebuttonlabel', 'local_feedbackchoicegenerator'),
'resetbuttonlabel' => get_string('resetbuttonlabel', 'local_feedbackchoicegenerator'),
'buttonlabel' => get_string('buttonlabel', 'local_feedbackrankedchoicegenerator'),
'downloadbuttonlabel' => get_string('downloadbuttonlabel', 'local_feedbackrankedchoicegenerator'),
'updatebuttonlabel' => get_string('updatebuttonlabel', 'local_feedbackrankedchoicegenerator'),
'resetbuttonlabel' => get_string('resetbuttonlabel', 'local_feedbackrankedchoicegenerator'),
'dataurl' => $dataurl
]
);
Expand Down
10 changes: 5 additions & 5 deletions classes/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace local_feedbackchoicegenerator;
namespace local_feedbackrankedchoicegenerator;
defined('MOODLE_INTERNAL') || die;
use html_writer;

Expand Down Expand Up @@ -111,12 +111,12 @@ public static function generate_selection_overview($level,
$itemnumber,
$firstchoicereferencenumber,
$alloptionstoadd, $option) {
$selectlabel = get_string('selectlabel', 'local_feedbackchoicegenerator');
$selectlabel = get_string('selectlabel', 'local_feedbackrankedchoicegenerator');
if ($level === 1) {
$choicelabel = get_string('firstchoicelabel', 'local_feedbackchoicegenerator');
$choicelabel = get_string('firstchoicelabel', 'local_feedbackrankedchoicegenerator');
$firstchoicereferencenumber = 0;
} else {
$choicelabel = get_string('secondchoicelabel', 'local_feedbackchoicegenerator');;
$choicelabel = get_string('secondchoicelabel', 'local_feedbackrankedchoicegenerator');;
}
$output = "";
$output = $output . html_writer::start_tag('ITEM', array('TYPE' => 'multichoice', 'REQUIRED' => '0')) . "\n";
Expand Down Expand Up @@ -145,7 +145,7 @@ public static function generate_label($itemnumber, $firstchoicereferencenumber,
$output = $output . html_writer::tag('ITEMTEXT', "<![CDATA[]]>") . "\n";
$output = $output . html_writer::tag('ITEMLABEL', "<![CDATA[]]>") . "\n";
$output = $output . html_writer::tag('PRESENTATION',
"<![CDATA[$option " . get_string('firstchoicelabel', 'local_feedbackchoicegenerator') . "]]>") . "\n";
"<![CDATA[$option " . get_string('firstchoicelabel', 'local_feedbackrankedchoicegenerator') . "]]>") . "\n";
$output = $output . html_writer::tag('OPTIONS', "<![CDATA[]]>") . "\n";
$output = $output . html_writer::tag('DEPENDITEM', "<![CDATA[$firstchoicereferencenumber]]>") . "\n";
$output = $output . html_writer::tag('DEPENDVALUE', "<![CDATA[$option]]>") . "\n";
Expand Down
8 changes: 4 additions & 4 deletions classes/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace local_feedbackchoicegenerator;
namespace local_feedbackrankedchoicegenerator;
defined('MOODLE_INTERNAL') || die;
use moodle_database;
use local_feedbackchoicegenerator\Database\Factory as DatabaseFactory;
use local_feedbackchoicegenerator\Security\Security;
use local_feedbackrankedchoicegenerator\local\Database\Factory as DatabaseFactory;
use local_feedbackrankedchoicegenerator\Security;

defined('MOODLE_INTERNAL') || die();

/**
* @package local_feedbackchoicegenerator
* @package local_feedbackrankedchoicegenerator
* Class manager
*/
class Manager
Expand Down
9 changes: 6 additions & 3 deletions classes/View/Page.php → classes/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace local_feedbackchoicegenerator\View;
namespace local_feedbackrankedchoicegenerator;

defined('MOODLE_INTERNAL') || die;
use moodle_url;

Expand All @@ -35,12 +36,14 @@ public function __construct($page, $course, $courseid, $output) {
$this->page = $page;
$this->output = $output;
$this->course = $course;
$this->title = get_string('pluginname', 'local_feedbackchoicegenerator');
$this->title = get_string('pluginname', 'local_feedbackrankedchoicegenerator');

$page->set_url(new moodle_url('/local/feedbackchoicegenerator/index.php', ['id' => $courseid]));
$page->set_context(\context_course::instance($courseid));
$page->set_url(new moodle_url('/local/feedbackrankedchoicegenerator/index.php', ['id' => $courseid]));
$page->set_title($this->get_title());
$page->set_heading($course->fullname);
$page->set_pagelayout('incourse');

}

public function get_output() {
Expand Down
7 changes: 4 additions & 3 deletions classes/Security/Security.php → classes/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace local_feedbackchoicegenerator\Security;
namespace local_feedbackrankedchoicegenerator;

defined('MOODLE_INTERNAL') || die;
use coding_exception;
use context_course;
Expand All @@ -24,7 +25,7 @@
use stdClass;

/**
* @package local_feedbackchoicegenerator
* @package local_feedbackrankedchoicegenerator
* Class Security
*/
class Security
Expand Down Expand Up @@ -55,6 +56,6 @@ public function user_is_allowed_to_view_the_course_and_has_capability_to_use_gen
require_login($course);

$coursecontext = context_course::instance($courseid);
require_capability('local/feedbackchoicegenerator:view', $coursecontext);
require_capability('local/feedbackrankedchoicegenerator:view', $coursecontext);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace local_feedbackchoicegenerator\Database;
namespace local_feedbackrankedchoicegenerator\local\Database;
defined('MOODLE_INTERNAL') || die();
use moodle_database;

/**
* @package local_feedbackchoicegenerator
* @package local_feedbackrankedchoicegenerator
* This class provides high-level functionality for the module. Concepts like
* enumerating files belonging to a specific component are mapped to the
* relevant SQL queries, therefore encapsulating low-level database access inside
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace local_feedbackchoicegenerator\Database;
namespace local_feedbackrankedchoicegenerator\local\Database;
defined('MOODLE_INTERNAL') || die;
use moodle_database;

/**
* @package local_feedbackchoicegenerator
* @package local_feedbackrankedchoicegenerator
* This is a straightfoward implementation of the Factory Pattern. The
* class provides access to objects that are necessary for interaction
* with the Moodle database via a DataFiles abstraction.
Expand Down
3 changes: 1 addition & 2 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

namespace local_feedbackchoicegenerator\privacy;
namespace local_feedbackrankedchoicegenerator\privacy;

class provider implements
// This plugin does not store any personal user data.
Expand Down
4 changes: 2 additions & 2 deletions db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Plugin capabilities are defined here.
*
* @package local_feedbackchoicegenerator
* @package local_feedbackrankedchoicegenerator
* @category access
* @copyright Andreas Schenkel
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -26,7 +26,7 @@
defined('MOODLE_INTERNAL') || die();

$capabilities = [
'local/feedbackchoicegenerator:view' => [
'local/feedbackrankedchoicegenerator:view' => [
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => [
Expand Down
12 changes: 6 additions & 6 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
require_once(__DIR__ . '/../../config.php');
require_login();

use local_feedbackchoicegenerator\View\FeedbackChoiceGenerator;
use local_feedbackrankedchoicegenerator\FeedbackRankedChoiceGenerator;

// Assign global variables to local (parameter) variables.
// At the moment, this approach is used for documentation purposes.
Expand All @@ -25,22 +25,22 @@
$output = $OUTPUT;
$db = $DB;

$feedbackchoicegeneratorinstance = new FeedbackChoiceGenerator($db, $courseid, $page, $output);
$feedbackrankedchoicegeneratorinstance = new FeedbackRankedChoiceGenerator($db, $courseid, $page, $output);

global $CFG;

$isallowedonfrontpage = $CFG->local_feedbackchoicegenerator_isallowedonfrontpage;
$isactive = $CFG->local_feedbackchoicegenerator_isactive;
$isallowedonfrontpage = $CFG->local_feedbackrankedchoicegenerator_isallowedonfrontpage;
$isactive = $CFG->local_feedbackrankedchoicegenerator_isactive;

if ($isactive) {
if ($courseid === (int)'1') {
if ($isallowedonfrontpage) {
$feedbackchoicegeneratorinstance->init();
$feedbackrankedchoicegeneratorinstance->init();
} else {
echo "not supported on frontpage";
}
} else {
$feedbackchoicegeneratorinstance->init();
$feedbackrankedchoicegeneratorinstance->init();
}
} else {
echo "is not activ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Plugin strings are defined here.
*
* @package local_feedbackchoicegenerator
* @package local_feedbackrankedchoicegenerator
* @category string
* @copyright Andreas Schenkel
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -27,14 +27,14 @@

$string['pluginname'] = '1./2. Wahl Feedback-Generator';

$string['feedbackchoicegenerator:view'] = '1./2. Wahl Feedback-Generator anzeigen';
$string['feedbackrankedchoicegenerator:view'] = '1./2. Wahl Feedback-Generator anzeigen';

$string['isactive'] = 'Generator aktivieren';
$string['configisactive'] = 'Wenn aktiviert kann der Generator bei vorhandenen Berechtigungen im der Kursnavigation aufgerufen werden.';

$string['isallowedonfrontpage'] = 'Generator auf Startseite mit Kursid=1 erlauben';
$string['configisallowedonfrontpage'] = 'Wenn aktiviert kann der Generator auf der Startseite aufgerufen werden.
Link wird allerdings nicht angezeigt. URL ist: moodleurl/local/feedbackchoicegenerator/index.php?id=1';
Link wird allerdings nicht angezeigt. URL ist: moodleurl/local/feedbackrankedchoicegenerator/index.php?id=1';

$string['maxoptionslength'] = 'Max. Länge der Optionen';
$string['configmaxoptionslength'] = 'Bis zu dieser Länge kann der Text einer Option eingegeben werden.';
Expand Down Expand Up @@ -63,3 +63,4 @@
$string['resetbuttonlabel'] = 'Eingaben zurücksetzen';

$string['selectlabel'] = 'auswählen';
$string['optionlabel'] = 'Option';
Loading

0 comments on commit 51c3c7a

Please sign in to comment.