--- /dev/null
+<?php // $Id$\r
+ // note.php \r
+\r
+$string['note'] = 'Note';\r
+$string['notes'] = 'Notes';\r
+$string['sitenotes'] = 'Site notes';\r
+$string['coursenotes'] = 'Course notes';\r
+$string['personalnotes'] = 'Personal notes';\r
+$string['created'] = 'created';\r
+$string['nonotes'] = 'There are no notes.';\r
+$string['notesnotvisible'] = 'You are not allowed to view the notes.';\r
+$string['addnewnote'] = 'Add a new note';\r
+$string['editnote'] = 'Edit note';\r
+$string['groupaddnewnote'] = 'Add a new note for all';\r
+$string['deleteconfirm'] = 'Delete this note?';\r
+$string['content'] = 'Content';\r
+$string['nocontent'] = 'Note content can not be empty';\r
+$string['nouser'] = 'You must select a user';\r
+$string['rating'] = 'Rating';\r
+$string['low'] = 'low';\r
+$string['belownormal'] = 'below normal';\r
+$string['normal'] = 'normal';\r
+$string['abovenormal'] = 'above normal';\r
+$string['high'] = 'high';\r
+$string['unknown'] = 'unknown';\r
+$string['bynameondate'] = 'by $a->name - $a->date';\r
+$string['publishstate'] = 'Status';\r
+$string['personal'] = 'personal';\r
+$string['course'] = 'course';\r
+$string['site'] = 'site';
\ No newline at end of file
--- /dev/null
+<h1>Status</h1>\r
+\r
+<p>There are 3 possible settings here</p>\r
+<ul>\r
+<li><strong>Personal</strong> - The note will be visible only to you</li>\r
+<li><strong>Course</strong> - The note will be visible to teachers in this course</li>\r
+<li><strong>Site</strong> - The note will be visible to teachers in all courses</li>\r
+</ul>
\ No newline at end of file
if (!($course = get_record('course', 'id', $courseid))) {\r
error('Incorrect course id found');\r
}\r
+// require login to access notes\r
+require_login($course->id);\r
\r
// locate context information\r
$context = get_context_instance(CONTEXT_COURSE, $course->id);\r
$note->courseid = $formdata->course;\r
$note->content = $formdata->content;\r
$note->format = FORMAT_PLAIN;\r
- $note->rating = $formdata->rating;\r
$note->userid = $formdata->user;\r
$note->publishstate = $formdata->publishstate;\r
if (note_save($note)) {\r
$note->id = 0;\r
$note->course = $courseid;\r
$note->user = $userid;\r
- \r
+ $note->publishstate = optional_param('state', NOTES_STATE_PUBLIC, PARAM_ALPHA);\r
}\r
$noteform->set_data($note);\r
-$strnotes = get_string('notes', 'notes');\r
+$strnotes = get_string('addnewnote', 'notes');\r
\r
// output HTML\r
-print_header($course->shortname . ': ' . $strnotes, $course->fullname);\r
+$crumbs = array(array('name' => $strnotes, 'link' => '', 'type' => 'activity'));\r
+print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($crumbs));\r
$noteform->display();\r
print_footer();\r
if (!$course = get_record('course', 'id', $note->courseid)) {\r
error('Incorrect course id found');\r
}\r
+// require login to access notes\r
+require_login($course->id);\r
\r
// locate context information\r
$context = get_context_instance(CONTEXT_COURSE, $course->id);\r
$strnotes = get_string('notes', 'notes');\r
$optionsyes = array('note'=>$noteid, 'sesskey'=>sesskey());\r
$optionsno = array('course'=>$course->id, 'user'=>$note->userid);\r
- print_header($course->shortname . ': ' . $strnotes, $course->fullname);\r
+\r
+// output HTML\r
+ $crumbs = array(array('name' => $strnotes, 'link' => '', 'type' => 'activity'));\r
+ print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($crumbs));\r
notice_yesno(get_string('deleteconfirm', 'notes'), 'delete.php', 'index.php', $optionsyes, $optionsno, 'post', 'get');\r
echo '<br />';\r
note_print($note, NOTES_SHOW_BODY | NOTES_SHOW_HEAD);\r
print_footer();\r
-}\r
+}
\ No newline at end of file
if (!$course = get_record('course', 'id', $note->courseid)) {\r
error('Incorrect course id found');\r
}\r
+// require login to access notes\r
+require_login($course->id);\r
\r
// locate context information\r
$context = get_context_instance(CONTEXT_COURSE, $course->id);\r
$note->userid = $formdata->user;\r
$note->content = $formdata->content;\r
$note->format = FORMAT_PLAIN;\r
- $note->rating = $formdata->rating;\r
$note->publishstate = $formdata->publishstate;\r
if (note_save($note)) {\r
add_to_log($note->courseid, 'notes', 'update', 'index.php?course='.$note->courseid.'&user='.$note->userid . '#note-' . $note->id, 'update note');\r
$note->note = $note->id;\r
}\r
$noteform->set_data($note);\r
-$strnotes = get_string('notes', 'notes');\r
+$strnotes = get_string('editnote', 'notes');\r
\r
// output HTML\r
-print_header($course->shortname . ': ' . $strnotes, $course->fullname);\r
+$crumbs = array(array('name' => $strnotes, 'link' => '', 'type' => 'activity'));\r
+print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($crumbs));\r
$noteform->display();\r
print_footer();\r
\r
function definition() {\r
$mform =& $this->_form;\r
-\r
- $mform->addElement('header', 'general', get_string('general', 'form'));\r
+ $strcontent = get_string('content', 'notes');\r
+ $strpublishstate = get_string('publishstate', 'notes');\r
+ $mform->addElement('header', 'general', get_string('note', 'notes'));\r
\r
$mform->addElement('select', 'user', get_string('user'), $this->_customdata['userlist']);\r
$mform->addRule('user', get_string('nouser', 'notes'), 'required', null, 'client');\r
\r
- $mform->addElement('textarea', 'content', get_string('content', 'notes'), array('rows'=>15, 'cols'=>40));\r
+ $mform->addElement('textarea', 'content', $strcontent, array('rows'=>15, 'cols'=>40));\r
$mform->setType('content', PARAM_RAW);\r
$mform->addRule('content', get_string('nocontent', 'notes'), 'required', null, 'client');\r
- $mform->setHelpButton('content', array('writing', 'richtext'), false, 'editorhelpbutton');\r
-\r
- $mform->addElement('select', 'rating', get_string('rating', 'notes'), note_get_rating_names());\r
- $mform->setDefault('rating', 3);\r
+ $mform->setHelpButton('content', 'writing');\r
\r
- $mform->addElement('select', 'publishstate', get_string('publishstate', 'notes'), note_get_state_names());\r
+ $mform->addElement('select', 'publishstate', $strpublishstate, note_get_state_names());\r
$mform->setDefault('publishstate', NOTES_STATE_PUBLIC);\r
$mform->setType('publishstate', PARAM_ALPHA);\r
+ $mform->setHelpButton('publishstate', array('status', $strpublishstate, 'notes'));\r
\r
$this->add_action_buttons();\r
\r
\r
require_once($CFG->dirroot .'/user/tabs.php');\r
\r
+$strsitenotes = get_string('sitenotes', 'notes');\r
+$strcoursenotes = get_string('coursenotes', 'notes');\r
+$strpersonalnotes = get_string('personalnotes', 'notes');\r
+$straddnewnote = get_string('addnewnote', 'notes');\r
+\r
if($courseid != SITEID) {\r
+ echo '<a href="#sitenotes">' . $strsitenotes . '</a> | <a href="#coursenotes">' . $strcoursenotes . '</a> | <a href="#personalnotes">' . $strpersonalnotes . '</a>';\r
$context = get_context_instance(CONTEXT_COURSE, $courseid);\r
- if (has_capability('moodle/notes:manage', $context)) {\r
- $addlink = $CFG->wwwroot .'/notes/add.php?course=' . $courseid . '&user=' . $userid;\r
- echo '<p><a href="'. $addlink . '">' . get_string('addnewnote', 'notes') . '</a></p>';\r
- }\r
- note_print_notes(get_string('sitenotes', 'notes'), $context, 0, $userid, NOTES_STATE_SITE, 0);\r
- note_print_notes(get_string('coursenotes', 'notes'), $context, $courseid, $userid, NOTES_STATE_PUBLIC, 0);\r
- note_print_notes(get_string('personalnotes', 'notes'), $context, $courseid, $userid, NOTES_STATE_DRAFT, $USER->id);\r
+ $addid = has_capability('moodle/notes:manage', $context) ? $courseid : 0;\r
+ $view = has_capability('moodle/notes:view', $context);\r
+ note_print_notes('<a name="sitenotes"></a>' . $strsitenotes, $addid, $view, 0, $userid, NOTES_STATE_SITE, 0);\r
+ note_print_notes('<a name="coursenotes"></a>' . $strcoursenotes, $addid, $view, $courseid, $userid, NOTES_STATE_PUBLIC, 0);\r
+ note_print_notes('<a name="personalnotes"></a>' . $strpersonalnotes, $addid, $view, $courseid, $userid, NOTES_STATE_DRAFT, $USER->id);\r
} else {\r
- $context = get_context_instance(CONTEXT_SYSTEM);\r
- note_print_notes(get_string('sitenotes', 'notes'), $context, 0, $userid, NOTES_STATE_SITE, 0);\r
+ echo '<a href="#sitenotes">' . $strsitenotes . '</a> | <a href="#coursenotes">' . $strcoursenotes . '</a>';\r
+ $view = has_capability('moodle/notes:view', get_context_instance(CONTEXT_SYSTEM));\r
+ note_print_notes('<a name="sitenotes"></a>' . $strsitenotes, 0, $view, 0, $userid, NOTES_STATE_SITE, 0);\r
+ echo '<a name="coursenotes"></a>';\r
if($userid) {\r
$courses = get_my_courses($userid);\r
foreach($courses as $c) {\r
$header = '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $c->id . '">' . $c->fullname . '</a>';\r
- note_print_notes($header, $context, $c->id, $userid, NOTES_STATE_PUBLIC, 0);\r
+ if (has_capability('moodle/notes:manage', get_context_instance(CONTEXT_COURSE, $c->id))) {\r
+ $addid = $c->id;\r
+ }else {\r
+ $addid = 0;\r
+ }\r
+ note_print_notes($header, $addid, $view, $c->id, $userid, NOTES_STATE_PUBLIC, 0);\r
}\r
}\r
} \r
\r
add_to_log($courseid, 'notes', 'view', 'index.php?course='.$courseid.'&user='.$userid, 'view notes');\r
\r
-print_footer($course);\r
+print_footer($course);
\ No newline at end of file
* Library of functions and constants for notes\r
*/\r
\r
-/**\r
- * Constants for ratings.\r
- */\r
-define('NOTES_RATING_LOW', '1');\r
-define('NOTES_RATING_BELOWNORMAL', '2');\r
-define('NOTES_RATING_NORMAL', '3');\r
-define('NOTES_RATING_ABOVENORMAL', '4');\r
-define('NOTES_RATING_HIGH', '5');\r
-\r
/**\r
* Constants for states.\r
*/\r
}\r
$selects[] = 'module="notes"';\r
$select = implode(' AND ', $selects);\r
- $fields = 'id,courseid,userid,content,format,rating,created,lastmodified,usermodified,publishstate';\r
+ $fields = 'id,courseid,userid,content,format,created,lastmodified,usermodified,publishstate';\r
// retrieve data\r
$rs =& get_recordset_select('post', $select, $order, $fields, $limitfrom, $limitnum);\r
return recordset_to_array($rs);\r
* @return note object\r
*/\r
function note_load($note_id) {\r
- $fields = 'id,courseid,userid,content,format,rating,created,lastmodified,usermodified,publishstate';\r
+ $fields = 'id,courseid,userid,content,format,created,lastmodified,usermodified,publishstate';\r
return get_record_select('post', 'id=' . $note_id . ' AND module="notes"', $fields);\r
}\r
\r
$note->module = 'notes';\r
$note->lastmodified = time();\r
$note->usermodified = $USER->id;\r
- if(empty($note->rating)) {\r
- $note->rating = NOTES_RATING_NORMAL;\r
- }\r
if(empty($note->format)) {\r
$note->format = FORMAT_PLAIN;\r
}\r
return delete_records_select('post', 'id=' . $noteid . ' AND module="notes"');\r
}\r
\r
-/**\r
- * Converts a rating value to its corespondent name\r
- *\r
- * @param int $rating rating value to convert\r
- * @return string corespondent rating name\r
- */\r
-function note_get_rating_name($rating) {\r
- // cache rating names\r
- static $ratings;\r
- if (empty($ratings)) {\r
- $ratings =& note_get_rating_names();\r
- }\r
- return @$ratings[$rating];\r
-}\r
-\r
-/**\r
- * Returns an array of mappings from rating values to rating names\r
- *\r
- * @return array of mappings\r
- */\r
-function note_get_rating_names() {\r
- return array(\r
- 1 => get_string('low', 'notes'),\r
- 2 => get_string('belownormal', 'notes'),\r
- 3 => get_string('normal', 'notes'),\r
- 4 => get_string('abovenormal', 'notes'),\r
- 5 => get_string('high', 'notes'),\r
- );\r
-}\r
-\r
/**\r
* Converts a state value to its corespondent name\r
*\r
($note->usermodified == $USER->id ? ' ownnotepost' : '') .\r
'" id="note-'. $note->id .'">';\r
\r
- // print note head (e.g. author, user refering to, rating, etc)\r
+ // print note head (e.g. author, user refering to, etc)\r
if($detail & NOTES_SHOW_HEAD) {\r
echo '<div class="header">';\r
echo '<div class="user">';\r
print_user_picture($user->id, $note->courseid, $user->picture);\r
echo fullname($user) . '</div>';\r
- echo '<div class="rating rating' . $note->rating . '">' . get_string('rating', 'notes') . ': ' . note_get_rating_name($note->rating) . '</div>';\r
echo '<div class="info">' . \r
get_string('bynameondate', 'notes', $authoring) . \r
' (' . get_string('created', 'notes') . ': ' . userdate($note->created) . ')</div>';\r
if($detail & NOTES_SHOW_FOOT) {\r
if (has_capability('moodle/notes:manage', $sitecontext) && $note->publishstate == NOTES_STATE_SITE || \r
has_capability('moodle/notes:manage', $context) && ($note->publishstate == NOTES_STATE_PUBLIC || $note->usermodified == $USER->id)) {\r
- echo '<div class="footer">';\r
- echo '<a href="'.$CFG->wwwroot.'/notes/edit.php?note='.$note->id. '">'. get_string('edit') .'</a>';\r
+ echo '<div class="footer"><p>';\r
+ echo '<a href="'.$CFG->wwwroot.'/notes/edit.php?note='.$note->id. '">'. get_string('edit') .'</a> | ';\r
echo '<a href="'.$CFG->wwwroot.'/notes/delete.php?note='.$note->id. '">'. get_string('delete') .'</a>';\r
- echo '</div>';\r
+ echo '</p></div>';\r
}\r
}\r
echo '</div>';\r
* Retrieves and prints a list of note objects with specific atributes.\r
*\r
* @param string $header HTML to print above the list\r
- * @param object $context context in which the notes will be displayed (used to check capabilities)\r
+ * @param int $addcourseid id of the course for the add notes link (0 hide link)\r
+ * @param boolean $viewnotes true if the notes should be printed; false otherwise (print notesnotvisible string)\r
* @param int $courseid id of the course in which the notes were posted (0 means any)\r
* @param int $userid id of the user to which the notes refer (0 means any)\r
* @param string $state state of the notes (i.e. draft, public, site) ('' means any)\r
* @param int $author id of the user who modified the note last time (0 means any)\r
*/\r
-function note_print_notes($header, $context, $courseid = 0, $userid = 0, $state = '', $author = 0)\r
+function note_print_notes($header, $addcourseid = 0, $viewnotes = true, $courseid = 0, $userid = 0, $state = '', $author = 0)\r
{\r
global $CFG;\r
if ($header) {\r
echo '<h3 id="notestitle">' . $header . '</h3>';\r
}\r
- if (has_capability('moodle/notes:view', $context)) {\r
+ if ($addcourseid) {\r
+ echo '<p><a href="'. $CFG->wwwroot .'/notes/add.php?course=' . $addcourseid . '&user=' . $userid . '&state=' . $state . '">' . get_string('addnewnote', 'notes') . '</a></p>';\r
+ }\r
+ if ($viewnotes) {\r
$notes =& note_list($courseid, $userid, $state, $author);\r
if($notes) {\r
note_print_list($notes);\r
} else {\r
echo '<p>' . get_string('notesnotvisible', 'notes') . '</p>';\r
}\r
-}\r
+}
\ No newline at end of file
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php\r
/////////////////////////////////////////////////////////////////////////////////\r
\r
-$note_version = 2007070300; // The current version of note module (Date: YYYYMMDDXX)\r
+$note_version = 2007070700; // The current version of note module (Date: YYYYMMDDXX)\r
$module->cron = 1800; // Period for cron to check this module (secs)\r
***/
.notepost {
margin-bottom: 1em;
- background-color: #F0F0F0;
+ background-color: #EEE;
}
.sitenotepost {
- background-color: #FFFFF0;
}
.coursenotepost {
}
}
.notepost .header {
+ background: #DDD;
+ padding: 5px;
}
.notepost .user {
.notepost .userpicture {
float: left;
- margin: 5px;
+ margin-right: 5px;
}
-.notepost .rating5 {
- color: red;
-}
-.notepost .rating1 {
- color: orange;
-}
-.notepost .info, .notepost .rating {
+
+.notepost .info {
font-size: smaller;
}
.notepost .content {
+ clear: both;
}
.notepost .footer {
+ clear: both;
}
/***
$id = required_param('id', PARAM_INT); // course id\r
$users = optional_param('userid', array(), PARAM_INT); // array of user id\r
$contents = optional_param('contents', array(), PARAM_RAW); // array of user notes\r
-$ratings = optional_param('ratings', array(), PARAM_INT); // array of notes ratings\r
$states = optional_param('states', array(), PARAM_ALPHA); // array of notes states\r
if (! $course = get_record('course', 'id', $id)) {\r
error("Course ID is incorrect");\r
require_capability('moodle/notes:manage', $context);\r
\r
if (!empty($users) && confirm_sesskey()) {\r
- if (count($users) != count($contents) || count($users) != count($ratings) || count($users) != count($states)) {\r
+ if (count($users) != count($contents) || count($users) != count($states)) {\r
error('Parameters malformation', $CFG->wwwroot.'/user/index.php?id='.$id);\r
}\r
\r
}\r
$note->id = 0;\r
$note->content = $contents[$k];\r
- $note->rating = $ratings[$k];\r
$note->publishstate = $states[$k];\r
$note->userid = $v;\r
if (note_save($note)) {\r
echo '<form method="post" action="addnote.php">';\r
echo '<input type="hidden" name="id" value="'.$course->id.'" />';\r
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';\r
-$table->head = array (get_string('fullname'), get_string('content', 'notes'), get_string('rating', 'notes'), get_string('publishstate', 'notes'), );\r
-$table->align = array ('left', 'center', 'center', 'center');\r
-$rating_names = note_get_rating_names();\r
+$table->head = array (get_string('fullname'), \r
+ get_string('content', 'notes') . helpbutton('writing', get_string('helpwriting'), 'moodle', true, false, '', true), \r
+ get_string('publishstate', 'notes') . helpbutton('status', get_string('publishstate', 'notes'), 'notes', true, false, '', true), \r
+ );\r
+$table->align = array ('left', 'center', 'center');\r
$state_names = note_get_state_names();\r
\r
// the first time list hack\r
if(!$user = get_record('user', 'id', $v)) {\r
continue;\r
}\r
- $checkbox = choose_from_menu($rating_names, 'ratings[' . $k . ']', empty($ratings[$k]) ? NOTES_RATING_NORMAL : $ratings[$k], '', '', '0', true);\r
- $checkbox2 = choose_from_menu($state_names, 'states[' . $k . ']', empty($states[$k]) ? NOTES_STATE_PUBLIC : $states[$k], '', '', '0', true);\r
+ $checkbox = choose_from_menu($state_names, 'states[' . $k . ']', empty($states[$k]) ? NOTES_STATE_PUBLIC : $states[$k], '', '', '0', true);\r
$table->data[] = array(\r
'<input type="hidden" name="userid['.$k.']" value="'.$v.'" />'. fullname($user, true),\r
- '<textarea name="contents['. $k . ']" rows="2" cols="30">' . strip_tags(@$contents[$k]) . '</textarea>',\r
- $checkbox,\r
- $checkbox2,\r
+ '<textarea name="contents['. $k . ']" rows="2" cols="40">' . strip_tags(@$contents[$k]) . '</textarea>',\r
+ $checkbox\r
);\r
}\r
print_table($table);\r
$id = required_param('id', PARAM_INT); // course id\r
$users = optional_param('userid', array(), PARAM_INT); // array of user id\r
$content = optional_param('content', '', PARAM_RAW); // note content\r
-$rating = optional_param('rating', 0, PARAM_INT); // note rating\r
$state = optional_param('state', '', PARAM_ALPHA); // note publish state\r
\r
if (! $course = get_record('course', 'id', $id)) {\r
$note->courseid = $id;\r
$note->format = FORMAT_PLAIN;\r
$note->content = $content;\r
- $note->rating = $rating;\r
$note->publishstate = $state;\r
foreach ($users as $k => $v) {\r
if(!$user = get_record('user', 'id', $v)) {\r
echo '<div style="width:100%;text-align:center;">';\r
echo '<input type="hidden" name="id" value="'.$course->id.'" />';\r
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';\r
-$rating_names = note_get_rating_names();\r
$state_names = note_get_state_names();\r
\r
// the first time list hack\r
}\r
}\r
\r
+$strpublishstate = get_string('publishstate', 'notes');\r
+\r
$userlist = array();\r
foreach ($users as $k => $v) {\r
if(!$user = get_record('user', 'id', $v)) {\r
echo get_string('users'). ': ' . implode(', ', $userlist) . '.';\r
echo '</p>';\r
\r
-echo '<p>' . get_string('content', 'notes') . '<br /><textarea name="content" rows="5" cols="50">' . strip_tags(@$content) . '</textarea></p>';\r
-echo '<p>' . get_string('rating', 'notes') . ' ' . choose_from_menu($rating_names, 'rating', empty($rating) ? NOTES_RATING_NORMAL : $rating, '', '', '0', true) . '</p>';\r
-echo '<p>' . get_string('publishstate', 'notes') . ' ' . choose_from_menu($state_names, 'state', empty($state) ? NOTES_STATE_PUBLIC : $state, '', '', '0', true) . '</p>';\r
+echo '<p>' . get_string('content', 'notes');\r
+helpbutton('writing', get_string('helpwriting'));\r
+echo '<br /><textarea name="content" rows="5" cols="50">' . strip_tags(@$content) . '</textarea></p>';\r
+\r
+echo '<p>' . $strpublishstate;\r
+helpbutton('status', $strpublishstate, 'notes');\r
+choose_from_menu($state_names, 'state', empty($state) ? NOTES_STATE_PUBLIC : $state, '');\r
+echo '</p>';\r
\r
echo '<input type="submit" value="' . get_string('savechanges'). '" /></div></form>';\r
print_footer($course);\r