Skip to content

Commit

Permalink
Code cleanup, notes, and version bump.
Browse files Browse the repository at this point in the history
  • Loading branch information
drachels committed Aug 22, 2020
1 parent 5c19183 commit 3771ed9
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 33 deletions.
43 changes: 21 additions & 22 deletions classes/local/results.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public static function download_entries($context, $course, $diary) {
$csv->filename .= clean_filename(get_string('exportfilenamep2', 'diary').gmdate("Ymd_Hi").'GMT.csv');

$fields = array();

$fields = array(get_string('firstname'),
get_string('lastname'),
get_string('pluginname', 'diary'),
Expand Down Expand Up @@ -114,35 +113,35 @@ public static function download_entries($context, $course, $diary) {
d.teacher AS teacher,
to_char(to_timestamp(d.timemarked), 'YYYY-MM-DD HH24:MI:SS') AS timemarked,
d.mailed AS mailed
FROM {diary_entries} d
JOIN {user} u ON u.id = d.userid
WHERE d.userid > 0 ";
FROM {diary_entries} d
JOIN {user} u ON u.id = d.userid
WHERE d.userid > 0 ";
} else {
$sql = "SELECT d.id AS entry,
u.firstname AS 'firstname',
u.lastname AS 'lastname',
d.diary AS diary,
d.userid AS userid,
FROM_UNIXTIME(d.timecreated) AS TIMECREATED,
FROM_UNIXTIME(d.timemodified) AS TIMEMODIFIED,
d.text AS text,
d.format AS format,
d.rating AS rating,
d.entrycomment AS entrycomment,
d.teacher AS teacher,
FROM_UNIXTIME(d.timemarked) AS TIMEMARKED,
d.mailed AS mailed
FROM {diary_entries} d
JOIN {user} u ON u.id = d.userid
WHERE d.userid > 0 ";
u.lastname AS 'lastname',
d.diary AS diary,
d.userid AS userid,
FROM_UNIXTIME(d.timecreated) AS TIMECREATED,
FROM_UNIXTIME(d.timemodified) AS TIMEMODIFIED,
d.text AS text,
d.format AS format,
d.rating AS rating,
d.entrycomment AS entrycomment,
d.teacher AS teacher,
FROM_UNIXTIME(d.timemarked) AS TIMEMARKED,
d.mailed AS mailed
FROM {diary_entries} d
JOIN {user} u ON u.id = d.userid
WHERE d.userid > 0 ";
}

$sql .= ($whichdiary);
$sql .= ($whichuser);
$sql .= " GROUP BY u.lastname, u.firstname, d.diary, d.id
$sql .= " GROUP BY u.lastname, u.firstname, d.diary, d.id
ORDER BY u.lastname ASC, u.firstname ASC, d.diary ASC, d.id ASC";

// Add the list of users and diarys to our data array.
// Add the list of users and diaries to our data array.
if ($ds = $DB->get_records_sql($sql, $fields)) {
foreach ($ds as $d) {
$output = array($d->firstname, $d->lastname, $d->diary, $d->userid, $d->timecreated, $d->timemodified, $d->format,
Expand All @@ -152,7 +151,7 @@ public static function download_entries($context, $course, $diary) {
}
// Download the completed array.
$csv->download_file();
exit;
//exit;
}

/**
Expand Down
11 changes: 11 additions & 0 deletions db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
)
),

'mod/diary:rate' => array(

'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
),

'mod/diary:addentries' => array(

'captype' => 'write',
Expand Down
8 changes: 0 additions & 8 deletions edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ class mod_diary_entry_form extends moodleform {
public function definition() {
global $CFG, $DB;

//$data = $this->_customdata['current'];

//$action = $this->_customdata['editoroptions']['action'];

//$firstkey = $this->_customdata['editoroptions']['firstkey'];

//$temp = $this->_customdata['editoroptions'];

$mform = $this->_form;

$mform->addElement('editor', 'text_editor', get_string('entry', 'mod_diary'),
Expand Down
1 change: 1 addition & 0 deletions lang/en/diary.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
$string['diary:addentries'] = 'Add diary entries';
$string['diary:addinstance'] = 'Add diary instances';
$string['diary:manageentries'] = 'Manage diary entries';
$string['diary:rate'] = 'Rate diary entries';
$string['diarymail'] = '{$a->teacher} has posted some feedback on your diary entry for \'{$a->diary}\'
You can see it appended to your diary entry:
Expand Down
7 changes: 7 additions & 0 deletions notes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Diary is based on a highly modified version of the Journal plugin.
It allows a user to create a new entry each day. Each entry can be
individually graded, with results being shown based on the selected
aggregate type of rating.
Currently, the user can edit any entry, but cannot start a new
entry on a skipped day.

Sometime ago, due to a forum inquiry, I started to
modify a copy of journal and create a diary module.
Eventually, I removed it from all my Moodle sites,
Expand Down
6 changes: 3 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

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

$plugin->version = 2020082200; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2020082203; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2015111600; // Requires Moodle 3.0 version.
$plugin->cron = 60; // Period for cron to check this module (secs).
$plugin->component = 'mod_diary';
$plugin->maturity = MATURITY_BETA;
$plugin->release = '0.14.0 (Build: 2020082200)'; // User-friendly version number.
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '1.0.0 (Build: 2020082203)'; // User-friendly version number.

0 comments on commit 3771ed9

Please sign in to comment.