mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-15758 - chat module portfolio export
This commit is contained in:
parent
d2baf40e75
commit
47cfd33174
@ -8,6 +8,8 @@ $string['cantlogin'] = 'Could not log in to chat room!!';
|
|||||||
$string['cantinsert'] = 'Could not insert a chat message!';
|
$string['cantinsert'] = 'Could not insert a chat message!';
|
||||||
$string['chat:chat'] = 'Talk in a chat';
|
$string['chat:chat'] = 'Talk in a chat';
|
||||||
$string['chat:deletelog'] = 'Delete chat logs';
|
$string['chat:deletelog'] = 'Delete chat logs';
|
||||||
|
$string['chat:exportsession'] = 'Export chat session';
|
||||||
|
$string['chat:exportparticipatedsession'] = 'Export participated-in chat session';
|
||||||
$string['chat:readlog'] = 'Read chat logs';
|
$string['chat:readlog'] = 'Read chat logs';
|
||||||
$string['chatintro'] = 'Introduction text';
|
$string['chatintro'] = 'Introduction text';
|
||||||
$string['chatname'] = 'Name of this chat room';
|
$string['chatname'] = 'Name of this chat room';
|
||||||
|
@ -68,7 +68,35 @@ $mod_chat_capabilities = array(
|
|||||||
'editingteacher' => CAP_ALLOW,
|
'editingteacher' => CAP_ALLOW,
|
||||||
'admin' => CAP_ALLOW
|
'admin' => CAP_ALLOW
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
|
|
||||||
|
'mod/chat:exportparticipatedsession' => array(
|
||||||
|
|
||||||
|
'riskbitmask' => RISK_PERSONAL,
|
||||||
|
|
||||||
|
'captype' => 'read',
|
||||||
|
'contextlevel' => CONTEXT_MODULE,
|
||||||
|
'legacy' => array(
|
||||||
|
'teacher' => CAP_ALLOW,
|
||||||
|
'editingteacher' => CAP_ALLOW,
|
||||||
|
'admin' => CAP_ALLOW,
|
||||||
|
// not student - nervous about allowing this by default
|
||||||
|
),
|
||||||
|
|
||||||
|
),
|
||||||
|
|
||||||
|
'mod/chat:exportsession' => array(
|
||||||
|
|
||||||
|
'riskbitmask' => RISK_PERSONAL,
|
||||||
|
|
||||||
|
'captype' => 'read',
|
||||||
|
'contextlevel' => CONTEXT_MODULE,
|
||||||
|
'legacy' => array(
|
||||||
|
'teacher' => CAP_ALLOW,
|
||||||
|
'editingteacher' => CAP_ALLOW,
|
||||||
|
'admin' => CAP_ALLOW,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -819,4 +819,91 @@ function chat_get_extra_capabilities() {
|
|||||||
return array('moodle/site:accessallgroups', 'moodle/site:viewfullnames');
|
return array('moodle/site:accessallgroups', 'moodle/site:viewfullnames');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require_once($CFG->libdir . '/portfoliolib.php');
|
||||||
|
class chat_portfolio_caller extends portfolio_module_caller_base {
|
||||||
|
|
||||||
|
private $chat;
|
||||||
|
private $start;
|
||||||
|
private $end;
|
||||||
|
|
||||||
|
public function __construct($callbackargs) {
|
||||||
|
global $DB, $USER;
|
||||||
|
if (!$this->cm = get_coursemodule_from_id('chat', $callbackargs['id'])) {
|
||||||
|
portfolio_exporter::raise_error('invalidid', 'chat');
|
||||||
|
}
|
||||||
|
$this->chat = $DB->get_record('chat', array('id' => $this->cm->instance));
|
||||||
|
$select = 'chatid = ?';
|
||||||
|
$params = array($this->chat->id);
|
||||||
|
if (array_key_exists('start', $callbackargs) && array_key_exists('end', $callbackargs)
|
||||||
|
&& !empty($callbackargs['start']) && !empty($callbackargs['end'])) {
|
||||||
|
$select .= ' AND timestamp >= ? AND timestamp <= ?';
|
||||||
|
$params[] = $callbackargs['start'];
|
||||||
|
$params[] = $callbackargs['end'];
|
||||||
|
$this->start = $callbackargs['start'];
|
||||||
|
$this->end = $callbackargs['end'];
|
||||||
|
}
|
||||||
|
$this->messages = $DB->get_records_select(
|
||||||
|
'chat_messages',
|
||||||
|
$select,
|
||||||
|
$params,
|
||||||
|
'timestamp ASC'
|
||||||
|
);
|
||||||
|
$select .= ' AND userid = ?';
|
||||||
|
$params[] = $USER->id;
|
||||||
|
$this->participated = $DB->record_exists_select(
|
||||||
|
'chat_messages',
|
||||||
|
$select,
|
||||||
|
$params
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function expected_time() {
|
||||||
|
return PORTFOLIO_TIME_LOW;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_sha1() {
|
||||||
|
$str = '';
|
||||||
|
ksort($this->messages);
|
||||||
|
foreach ($this->messages as $m) {
|
||||||
|
$str .= implode('', (array)$m);
|
||||||
|
}
|
||||||
|
return sha1($str);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function check_permissions() {
|
||||||
|
$context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
|
||||||
|
return has_capability('mod/chat:exportsession', $context)
|
||||||
|
|| ($this->participated
|
||||||
|
&& has_capability('mod/chat:exportparticipatedsession', $context));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function prepare_package() {
|
||||||
|
$content = '';
|
||||||
|
foreach ($this->messages as $message) { // We are walking FORWARDS through messages
|
||||||
|
$m = clone $message; // grrrrrr
|
||||||
|
$formatmessage = chat_format_message($m, null, $this->user);
|
||||||
|
if (!isset($formatmessage->html)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$content .= $formatmessage->html;
|
||||||
|
}
|
||||||
|
$content = preg_replace('/\<img[^>]*\>/', '', $content);
|
||||||
|
|
||||||
|
return $this->exporter->write_new_file($content, clean_filename($this->cm->name . '-session.html'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function display_name() {
|
||||||
|
return get_string('modulename', 'chat');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_return_url() {
|
||||||
|
global $CFG;
|
||||||
|
|
||||||
|
return $CFG->wwwroot . '/mod/chat/report.php?id='
|
||||||
|
. $this->cm->id . ((isset($this->start))
|
||||||
|
? '&start=' . $this->start . '&end=' . $this->end
|
||||||
|
: '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -75,6 +75,17 @@
|
|||||||
echo $formatmessage->html;
|
echo $formatmessage->html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (has_capability('mod/chat:exportsession', $context)
|
||||||
|
|| (array_key_exists($USER->id, $sessionusers)
|
||||||
|
&& has_capability('mod/chat:exportparticipatedsession', $context))) {
|
||||||
|
require_once($CFG->libdir . '/portfoliolib.php');
|
||||||
|
$p = array(
|
||||||
|
'id' => $cm->id,
|
||||||
|
'start' => $start,
|
||||||
|
'end' => $end,
|
||||||
|
);
|
||||||
|
echo '<br />' . portfolio_add_button('chat_portfolio_caller', $p, '/mod/chat/lib.php', PORTFOLIO_ADD_FULL_FORM, null, true);
|
||||||
|
}
|
||||||
print_simple_box_end();
|
print_simple_box_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,6 +191,17 @@
|
|||||||
|
|
||||||
echo '<p align="right">';
|
echo '<p align="right">';
|
||||||
echo "<a href=\"report.php?id=$cm->id&start=$sessionstart&end=$sessionend\">$strseesession</a>";
|
echo "<a href=\"report.php?id=$cm->id&start=$sessionstart&end=$sessionend\">$strseesession</a>";
|
||||||
|
if (has_capability('mod/chat:exportsession', $context)
|
||||||
|
|| (array_key_exists($USER->id, $sessionusers)
|
||||||
|
&& has_capability('mod/chat:exportparticipatedsession', $context))) {
|
||||||
|
require_once($CFG->libdir . '/portfoliolib.php');
|
||||||
|
$p = array(
|
||||||
|
'id' => $cm->id,
|
||||||
|
'start' => $sessionstart,
|
||||||
|
'end' => $sessionend,
|
||||||
|
);
|
||||||
|
echo '<br />' . portfolio_add_button('chat_portfolio_caller', $p, '/mod/chat/lib.php', PORTFOLIO_ADD_TEXT_LINK, null, true);
|
||||||
|
}
|
||||||
if (has_capability('mod/chat:deletelog', $context)) {
|
if (has_capability('mod/chat:deletelog', $context)) {
|
||||||
echo "<br /><a href=\"report.php?id=$cm->id&start=$sessionstart&end=$sessionend&deletesession=1\">$strdeletesession</a>";
|
echo "<br /><a href=\"report.php?id=$cm->id&start=$sessionstart&end=$sessionend&deletesession=1\">$strdeletesession</a>";
|
||||||
}
|
}
|
||||||
@ -194,6 +216,15 @@
|
|||||||
$lasttime = $message->timestamp;
|
$lasttime = $message->timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (has_capability('mod/chat:exportsession', $context)) {
|
||||||
|
require_once($CFG->libdir . '/portfoliolib.php');
|
||||||
|
$p = array(
|
||||||
|
'id' => $cm->id,
|
||||||
|
);
|
||||||
|
echo '<br />' . portfolio_add_button('chat_portfolio_caller', $p, '/mod/chat/lib.php', PORTFOLIO_ADD_FULL_FORM, get_string('addalltoportfolio', 'portfolio'), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Finish the page
|
/// Finish the page
|
||||||
print_footer($course);
|
print_footer($course);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
$module->version = 2008072400; // The (date) version of this module
|
$module->version = 2008081400; // The (date) version of this module
|
||||||
$module->requires = 2007101509; // Requires this Moodle version
|
$module->requires = 2007101509; // Requires this Moodle version
|
||||||
$module->cron = 300; // How often should cron check this module (seconds)?
|
$module->cron = 300; // How often should cron check this module (seconds)?
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user