Skip to content

Commit

Permalink
Merge branch 'release/1.5.7'
Browse files Browse the repository at this point in the history
* release/1.5.7: (25 commits)
  feat(icon): Added monologo version of the plugin icon for Moodle 4.0 and above and added changes.md to keep track of plugin changes
  fix(db): fix for wrong type for line field in exammanagement_temp_part after new installation
  fix(version): updated version
  fix(examlabels): now encoding correct url in the qrcodes
  fix(multiple): multiple bugfixes
  feat(multiple): multiple small changes after feedback and adding possibility to choose items per page for paginated tables
  chore(coding style): Changes for coding style compatibility
  feat(gradingscale): reworked configureGradingscale and configureTasks and optimized mobile layout
  chore(coding style): Changes for coding style compatibility
  fix(examlabels): Deleted all previously added thirdparty libraries because tcpdf can also do QR codes :)
  feat(icon): Reworked icon now as svg and small bootstrap fix
  fix(examlabels): Typo in thirdpartylibs
  feat(examlabels): Added libraries for generating qr codes for exam labels
  feat(view): Added possibility to hide exam review phase
  feat(userpreferences): now saving the states of the exam phases (if user has opened or closed the phase) in the user_preferences
  feat(calendar): exam and exam review date now visible in calendar
  fix(multiple): multiple layout fixes for new moodle version and rewriting amd modules to es6
  feat(viewParticipants): minor fix for correctly displaying users with no moodle account
  feat(codingstyle): minor changes for coding style
  feat(pagination): added pagination for rooms and participants overview tables and done many changes to successively improve the moodle coding style compatibility
  ...
  • Loading branch information
Daniel Nolte committed May 11, 2023
2 parents e34af6f + 25d0bf1 commit 601695f
Show file tree
Hide file tree
Showing 143 changed files with 9,240 additions and 8,306 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Changelog ##
- [1.5.7]:
- Added monologo version of the plugin icon for Moodle 4.0 and above.
- Added changes.md to keep track of plugin changes.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.

@package mod_exammanagement
@copyright coactum GmbH 2021
@copyright 2022 coactum GmbH
@license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

# Exam management #
Expand Down Expand Up @@ -51,7 +51,3 @@ To ensure that the exam management plugin works as intended make sure that
- you have configured the mail server for your moodle
- sheduled tasks are performed automatically
- the ldap authentication plugin is installed within your moodle and that you have configured it to connect to your own ldap server to fetch matriculation numbers for your participants

Comments and suggestions are always welcome.

D.
134 changes: 70 additions & 64 deletions addCourseParticipants.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,130 +15,136 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Allows teacher to add course participants to mod_exammanagement.
* Allows to add course participants to mod_exammanagement.
*
* @package mod_exammanagement
* @copyright coactum GmbH 2019
* @copyright 2022 coactum GmbH
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace mod_exammanagement\general;

use mod_exammanagement\forms\addCourseParticipantsForm;
use mod_exammanagement\forms\addcourseparticipants_form;
use stdclass;

require(__DIR__.'/../../config.php');
require_once(__DIR__.'/lib.php');

// Course_module ID, or
// Course_module ID, or.
$id = optional_param('id', 0, PARAM_INT);

// ... module instance id - should be named as the first character of the module
$e = optional_param('e', 0, PARAM_INT);

$MoodleObj = Moodle::getInstance($id, $e);
$MoodleDBObj = MoodleDB::getInstance();
$ExammanagementInstanceObj = exammanagementInstance::getInstance($id, $e);
$UserObj = User::getInstance($id, $e, $ExammanagementInstanceObj->getCm()->instance);
$moodleobj = Moodle::getInstance($id, $e);
$moodledbobj = MoodleDB::getInstance();
$exammanagementinstanceobj = exammanagementInstance::getInstance($id, $e);
$userobj = User::getInstance($id, $e, $exammanagementinstanceobj->getCm()->instance);

if($MoodleObj->checkCapability('mod/exammanagement:viewinstance')){
if ($moodleobj->checkCapability('mod/exammanagement:viewinstance')) {

if($ExammanagementInstanceObj->isExamDataDeleted()){
$MoodleObj->redirectToOverviewPage('beforeexam', get_string('err_examdata_deleted', 'mod_exammanagement'), 'error');
} else if(empty($UserObj->getCourseParticipantsIDs())){
$MoodleObj->redirectToOverviewPage('beforeexam', get_string('err_nocourseparticipants', 'mod_exammanagement'), 'error');
if ($exammanagementinstanceobj->isExamDataDeleted()) {
$moodleobj->redirectToOverviewPage('beforeexam', get_string('err_examdata_deleted', 'mod_exammanagement'), 'error');
} else if (empty($userobj->getCourseParticipantsIDs())) {
$moodleobj->redirectToOverviewPage('beforeexam', get_string('err_nocourseparticipants', 'mod_exammanagement'), 'error');
} else {

if(!isset($ExammanagementInstanceObj->moduleinstance->password) || (isset($ExammanagementInstanceObj->moduleinstance->password) && (isset($SESSION->loggedInExamOrganizationId)&&$SESSION->loggedInExamOrganizationId == $id))){ // if no password for moduleinstance is set or if user already entered correct password in this session: show main page
// If no password for moduleinstance is set or if user already entered correct password in this session: show main page.
if (!isset($exammanagementinstanceobj->moduleinstance->password) || (isset($exammanagementinstanceobj->moduleinstance->password) && (isset($SESSION->loggedInExamOrganizationId)&&$SESSION->loggedInExamOrganizationId == $id))) {

$MoodleObj->setPage('addCourseParticipants');
$MoodleObj->outputPageHeader();
// Instantiate form.
$mform = new addcourseparticipants_form(null, array('id' => $id, 'e' => $e));

//Instantiate form
$mform = new addCourseParticipantsForm(null, array('id'=>$id, 'e'=>$e));

//Form processing and displaying is done here
// Form processing and displaying is done here.
if ($mform->is_cancelled()) {
//Handle form cancel operation, if cancel button is present on form
redirect ($ExammanagementInstanceObj->getExammanagementUrl('viewParticipants', $ExammanagementInstanceObj->getCm()->id), get_string('operation_canceled', 'mod_exammanagement'), null, 'warning');
// Handle form cancel operation, if cancel button is present on form.
redirect ($exammanagementinstanceobj->getExammanagementUrl('viewParticipants', $exammanagementinstanceobj->getCm()->id), get_string('operation_canceled', 'mod_exammanagement'), null, 'warning');

} else if ($fromform = $mform->get_data()) {
//In this case you process validated data. $mform->get_data() returns data posted in form.
// In this case you process validated data. $mform->get_data() returns data posted in form.

$participantsIdsArr = $UserObj->filterCheckedParticipants($fromform);
$deletedParticipantsIdsArr = $UserObj->filterCheckedDeletedParticipants($fromform);
$participantsidsarr = $userobj->filterCheckedParticipants($fromform);
$deletedparticipantsidsarr = $userobj->filterCheckedDeletedParticipants($fromform);

if($participantsIdsArr != false || $deletedParticipantsIdsArr != false){
if ($participantsidsarr != false || $deletedparticipantsidsarr != false) {

$userObjArr = array();
$userobjarr = array();

if($participantsIdsArr){
if ($participantsidsarr) {

$courseid = $ExammanagementInstanceObj->getCourse()->id;
$courseid = $exammanagementinstanceobj->getCourse()->id;

foreach($participantsIdsArr as $participantId){
foreach ($participantsidsarr as $participantid) {

if($UserObj->checkIfAlreadyParticipant($participantId) == false){
if ($userobj->checkIfAlreadyParticipant($participantid) == false) {
$user = new stdClass();
$user->exammanagement = $ExammanagementInstanceObj->getCm()->instance;
$user->exammanagement = $exammanagementinstanceobj->getCm()->instance;
$user->courseid = $courseid;
$user->categoryid = $ExammanagementInstanceObj->moduleinstance->categoryid;
$user->moodleuserid = $participantId;
$user->categoryid = $exammanagementinstanceobj->moduleinstance->categoryid;
$user->moodleuserid = $participantid;
$user->headerid = 0;
$user->plugininstanceid = 0; // for deprecated old version db version, should be removed for ms 3

array_push($userObjArr, $user);
$dbman = $DB->get_manager();
$table = new \xmldb_table('exammanagement_participants');
$field = new \xmldb_field('plugininstanceid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
if ($dbman->field_exists($table, $field)) {
$user->plugininstanceid = 0; // For deprecated old version db version, should be removed.
}

array_push($userobjarr, $user);
}
}
}

if($deletedParticipantsIdsArr){
foreach($deletedParticipantsIdsArr as $identifier){
if ($deletedparticipantsidsarr) {
foreach ($deletedparticipantsidsarr as $identifier) {
$temp = explode('_', $identifier);

if($temp[0]== 'mid'){
$UserObj->deleteParticipant($temp[1], false);
} else {
$UserObj->deleteParticipant(false, $temp[1]);
}
if ($temp[0] == 'mid') {
$userobj->deleteParticipant($temp[1], false);
} else {
$userobj->deleteParticipant(false, $temp[1]);
}
}
}

$MoodleDBObj->InsertBulkRecordsInDB('exammanagement_participants', $userObjArr);
$moodledbobj->InsertBulkRecordsInDB('exammanagement_participants', $userobjarr);

redirect ($ExammanagementInstanceObj->getExammanagementUrl('viewParticipants', $id), get_string('operation_successfull', 'mod_exammanagement'), null, 'success');
redirect ($exammanagementinstanceobj->getExammanagementUrl('viewParticipants', $id), get_string('operation_successfull', 'mod_exammanagement'), null, 'success');

} else {

redirect ($ExammanagementInstanceObj->getExammanagementUrl('viewParticipants', $id), get_string('alteration_failed', 'mod_exammanagement'), null, 'error');
redirect ($exammanagementinstanceobj->getExammanagementUrl('viewParticipants', $id), get_string('alteration_failed', 'mod_exammanagement'), null, 'error');
}

} else {
// this branch is executed if the form is submitted but the data doesn't validate and the form should be redisplayed
// This branch is executed if the form is submitted but the data doesn't validate and the form should be redisplayed
// or on the first display of the form.

# set data if checkboxes should be checked (setDefault in the form is much more time consuming for big amount of participants) #
$default_values = array('id'=>$id);
$courseParticipantsIDs = $UserObj->getCourseParticipantsIDs();
// Set data if checkboxes should be checked (setDefault in the form is much more time consuming for big amount of participants).
$defaultvalues = array('id' => $id);
$courseparticipantsids = $userobj->getCourseParticipantsIDs();

if(isset($courseParticipantsIDs)){
foreach($courseParticipantsIDs as $id){
$default_values['participants['.$id.']'] = true;
}
}
if (isset($courseparticipantsids)) {
foreach ($courseparticipantsids as $id) {
$defaultvalues['participants['.$id.']'] = true;
}
}

//Set default data (if any)
$mform->set_data($default_values);
// Set default data (if any).
$mform->set_data($defaultvalues);

$moodleobj->setPage('addCourseParticipants');
$moodleobj->outputPageHeader();

//displays the form
$mform->display();

$moodleobj->outputFooter();
}
$MoodleObj->outputFooter();

} else { // if user hasnt entered correct password for this session: show enterPasswordPage
redirect ($ExammanagementInstanceObj->getExammanagementUrl('checkPassword', $ExammanagementInstanceObj->getCm()->id), null, null, null);
} else { // If user has not entered correct password for this session: show enterPasswordPage.
redirect ($exammanagementinstanceobj->getExammanagementUrl('checkpassword', $exammanagementinstanceobj->getCm()->id), null, null, null);
}
}
} else {
$MoodleObj->redirectToOverviewPage('', get_string('nopermissions', 'mod_exammanagement'), 'error');
}
$moodleobj->redirectToOverviewPage('', get_string('nopermissions', 'mod_exammanagement'), 'error');
}
44 changes: 22 additions & 22 deletions addCustomRoom.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Allows teacher to add custom rooms to mod_exammanagement.
*
* @package mod_exammanagement
* @copyright coactum GmbH 2019
* @copyright 2022 coactum GmbH
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand All @@ -42,13 +42,13 @@
$MoodleObj = Moodle::getInstance($id, $e);
$MoodleDBObj = MoodleDB::getInstance();

if($MoodleObj->checkCapability('mod/exammanagement:viewinstance')){
if ($MoodleObj->checkCapability('mod/exammanagement:viewinstance')) {

if($ExammanagementInstanceObj->isExamDataDeleted()){
if ($ExammanagementInstanceObj->isExamDataDeleted()) {
$MoodleObj->redirectToOverviewPage('beforeexam', get_string('err_examdata_deleted', 'mod_exammanagement'), 'error');
} else {

if(!isset($ExammanagementInstanceObj->moduleinstance->password) || (isset($ExammanagementInstanceObj->moduleinstance->password) && (isset($SESSION->loggedInExamOrganizationId)&&$SESSION->loggedInExamOrganizationId == $id))){ // if no password for moduleinstance is set or if user already entered correct password in this session: show main page
if (!isset($ExammanagementInstanceObj->moduleinstance->password) || (isset($ExammanagementInstanceObj->moduleinstance->password) && (isset($SESSION->loggedInExamOrganizationId)&&$SESSION->loggedInExamOrganizationId == $id))) { // if no password for moduleinstance is set or if user already entered correct password in this session: show main page

global $USER;

Expand All @@ -70,27 +70,27 @@
$placesCount = $fromform->placescount;
$description = $fromform->description;

if($MoodleDBObj->checkIfRecordExists('exammanagement_rooms', array('roomid' => $roomname.'_'.$USER->id.'c', 'moodleuserid' => $USER->id))){
if ($MoodleDBObj->checkIfRecordExists('exammanagement_rooms', array('roomid' => $roomname.'_'.$USER->id.'c', 'moodleuserid' => $USER->id))) {

$roomObj = $MoodleDBObj->getRecordFromDB('exammanagement_rooms', array('roomid' => $roomname.'_'.$USER->id.'c', 'moodleuserid' => $USER->id));
if($description){

if ($description) {
$roomObj->description = $description;
} else {
$roomObj->description = get_string('no_description_new_room', 'mod_exammanagement');
}

$placesArr = array();

for ($i = 0; $i < $placesCount; $i++) {
array_push($placesArr, strval($i+1));
}

$roomObj->places = json_encode($placesArr);

$update = $MoodleDBObj->UpdateRecordInDB('exammanagement_rooms', $roomObj);
if($update){

if ($update) {
redirect ($ExammanagementInstanceObj->getExammanagementUrl('chooseRooms', $id), get_string('operation_successfull', 'mod_exammanagement'), null, 'success');
} else {
redirect ($ExammanagementInstanceObj->getExammanagementUrl('chooseRooms', $id), get_string('alteration_failed', 'mod_exammanagement'), null, 'error');
Expand All @@ -100,63 +100,63 @@
$roomObj = new stdClass();
$roomObj->roomid = $roomname.'_'.$USER->id.'c';
$roomObj->name = $roomname;
if($description){

if ($description) {
$roomObj->description = $description;
} else {
$roomObj->description = get_string('no_description_new_room', 'mod_exammanagement');
}
$roomObj->seatingplan = base64_encode('');

$placesArr = array();

for ($i = 0; $i < $placesCount; $i++) {
array_push($placesArr, strval($i+1));
}

$roomObj->places = json_encode($placesArr);

$roomObj->type = 'customroom';
$roomObj->moodleuserid = $USER->id;
$roomObj->misc = NULL;

$import = $MoodleDBObj->InsertRecordInDB('exammanagement_rooms', $roomObj);

if($import){
if ($import) {
redirect ($ExammanagementInstanceObj->getExammanagementUrl('chooseRooms', $id), get_string('operation_successfull', 'mod_exammanagement'), null, 'success');
} else {
redirect ($ExammanagementInstanceObj->getExammanagementUrl('chooseRooms', $id), get_string('alteration_failed', 'mod_exammanagement'), null, 'error');
}
}

} else {
// this branch is executed if the form is submitted but the data doesn't validate and the form should be redisplayed
// or on the first display of the form.

//Set default data (if any)

if($roomid){
if ($roomid) {
$roomObj = $ExammanagementInstanceObj->getRoomObj($roomid);

if($roomObj->moodleuserid == $USER->id){
if ($roomObj->moodleuserid == $USER->id) {
$roomname = $roomObj->name;
$placescount = count(json_decode($roomObj->places));
$description = $roomObj->description;
$mform->set_data(array('id'=>$id, 'roomname'=>$roomname, 'placescount'=>$placescount, 'description'=>$description, 'existingroom'=>true));
} else {
$mform->set_data(array('id'=>$id));
$mform->set_data(array('id'=>$id));
}
} else {
$mform->set_data(array('id'=>$id));
}

//displays the form
$mform->display();
}
}

$MoodleObj->outputFooter();
} else { // if user hasnt entered correct password for this session: show enterPasswordPage
redirect ($ExammanagementInstanceObj->getExammanagementUrl('checkPassword', $ExammanagementInstanceObj->getCm()->id), null, null, null);
redirect ($ExammanagementInstanceObj->getExammanagementUrl('checkpassword', $ExammanagementInstanceObj->getCm()->id), null, null, null);
}
}
} else {
Expand Down
Loading

0 comments on commit 601695f

Please sign in to comment.