Skip to content

Commit

Permalink
Merge pull request #10 from tilde-nlp/development
Browse files Browse the repository at this point in the history
v 4.1.1
  • Loading branch information
e-kornejeva authored Nov 9, 2023
2 parents 444b1fc + 32bc224 commit 5129adf
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 19 deletions.
8 changes: 7 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
#### Changes
-------


### 4.1.1

* 2023-09-11 - Enhanced Security
* 2023-09-11 - Functions added to be used in bot backend

### 3.2.1
* 2023-11-02 - Added support for Moodle versions 3.9 and 4.3.

### 2.2.4
* 2023-08-25 - Enhanced Scenarios
* 2023-08-25 - Plugin functional and stabilization improvements

### 2.2.2

* 2023-08-17 - Enhanced Scenarios
Expand Down
68 changes: 52 additions & 16 deletions chat_ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
$input = optional_param('chat_msg', '', PARAM_RAW);




if (!$chatsession = $DB->get_record('chat_sessions', array('userid' => $userid, 'courseid' => $courseid))) {
$chatsession = new stdClass();
$chatsession->conversationid = 0;
Expand Down Expand Up @@ -94,18 +92,8 @@
$params = explode("|", $command);
if (count($params) == 3) {
$sql = $params[1];
if ((strncmp($sql, "UPDATE", 6) === 0) || (strncmp($sql, "INSERT", 6) === 0)) {
$result = $DB->execute($sql);
if ($result) {
echo "success";
} else {
echo "error";
}
} else {
$response[$params[2]] = $DB->get_records_sql($sql);
echo json_encode($response);
}

$response[$params[2]] = $DB->get_records_sql($sql);
echo json_encode($response);
} else {
echo json_encode($command);
}
Expand Down Expand Up @@ -158,6 +146,27 @@
echo json_encode("Feedback activity not found.");
}
}
} else if (strncmp($command, "getpostbyname", 13) === 0) {
$params = explode("|", $command);
if (count($params) == 2) {
$sql = "SELECT p.message AS post_body, d.id AS discussion_id, p.id AS post_id
FROM {forum_discussions} d
LEFT JOIN {forum_posts} p ON d.id = p.discussion
WHERE (d.name = :dname OR p.subject = :pname) AND d.course = :course
LIMIT 1";

$params = array('dname' => $params[1], 'pname' => $params[1], 'course' => $courseid);

$result = $DB->get_records_sql($sql, $params);

if ($result) {
echo json_encode($result);
} else {
echo json_encode("Post not found.");
}
} else {
echo json_encode("Post not found.");
}
} else if (strncmp($command, "sendmsg", 7) === 0) {
$params = explode("|", $command);
if (count($params) == 3) {
Expand Down Expand Up @@ -200,8 +209,8 @@
'send' => get_string_manager()->get_string('send', 'message', null, $eventdata->userto->lang),
],
'placeholders' => [
'send' => get_string_manager()->get_string('writeamessage', 'message', null, $eventdata->userto->lang),
],
'send' => get_string_manager()->get_string('writeamessage', 'message', null, $eventdata->userto->lang),
],
];
$messageId = message_send($eventdata);

Expand Down Expand Up @@ -239,6 +248,24 @@
$response['userinfo']['userroles'] = implode(", ", $roleNames);
echo json_encode($response);
break;
case 'getteacherinfo':
$teacherRoleId = $DB->get_field('role', 'id', array('shortname' => 'teacher'));
$editingTeacherRoleId = $DB->get_field('role', 'id', array('shortname' => 'editingteacher'));

// Get the list of users with both teacher and editingteacher roles in the current course
$teachers = array_merge(
get_role_users($teacherRoleId, $courseContext),
get_role_users($editingTeacherRoleId, $courseContext)
);
echo json_encode($teachers);
break;
case 'getcoursesections':
$params = array('course' => $courseid);

$sql = "SELECT name, section FROM {course_sections} WHERE course = :course ORDER BY id ASC";
$sections = $DB->get_records_sql($sql, $params);
echo json_encode($sections);
break;
case 'getcourseinfo':
$currentCourse = get_course($courseid);
$response['courseinfo']['courseid'] = $courseid;
Expand Down Expand Up @@ -315,6 +342,15 @@

echo json_encode($testResults);
break;
case 'getversion':



$response['moodleversion'] = $CFG->version;
$response['pluginversion'] = get_config('block_tildeva')->version;
echo json_encode($response);
break;

default:
echo json_encode($command);
break;
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
defined('MOODLE_INTERNAL') || die();


$plugin->version = 2023110203; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2023110935; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2020061524; // Requires this Moodle version
$plugin->maturity = MATURITY_ALPHA;
$plugin->release = '3.2.1';
$plugin->release = '4.1.1';
$plugin->component = 'block_tildeva'; // Full name of the plugin (used for diagnostics)

0 comments on commit 5129adf

Please sign in to comment.