<?php require_once (dirname ( __FILE__ ) . '/../../config.php'); // require_once (dirname ( __FILE__ ) . '/leaderboard_data.php'); // require_once ($CFG->dirroot . '/user/profile/lib.php'); global $OUTPUT, $title; require_login (); $context = context_system::instance (); $PAGE->set_context ( $context ); // $PAGE->requires->css ( '/blocks/leaders/css/style.css' ); $PAGE->set_pagelayout( 'standard' ); $PAGE->set_title ( "Notes" ); $PAGE->requires->css ( '/blocks/mynotes/style.css' ); $PAGE->set_url ( '/blocks/mynotes/view.php' ); $PAGE->set_heading ( "User Notes" ); $PAGE->navbar->add ( 'Notes', new moodle_url ( '/blocks/mynotes/view.php' ) ); $PAGE->requires->js_call_amd ( 'block_mynotes/script', 'init' ); echo $OUTPUT->header (); class notes{ public function allnotes(){ global $DB, $CFG,$USER , $PAGE; $parameter = array ($USER->id); $sql = "select * from {block_mynotes} where userid=? order by courseid asc"; $allNotes = $DB->get_records_sql ( $sql, $parameter ); $sql="select distinct courseid from {block_mynotes} where userid=? order by courseid asc"; $allCourses=$DB->get_records_sql ( $sql, $parameter ); $fullNotes = array (); foreach ( $allNotes as $notes ) { $fullNotes [] = $notes; } $fullCourseIds = array (); foreach ( $allCourses as $courseId ) { $fullCourseIds [] = $courseId; } //full notes list $noteslist = array (); for($i = 0; $i < count ( $fullCourseIds ); $i ++) { foreach ( $fullNotes as $notes ) { if ($fullCourseIds [$i]->courseid == $notes->courseid) { $noteslist [$i] [] = $notes; } } } //coursenames $courseName = array (); foreach ( $fullCourseIds as $courseId ) { $param = array ( $courseId->courseid ); $sql = "select fullname from {course} where id=?"; $name = $DB->get_record_sql ( $sql, $param ); if ($courseId->courseid == 1) { $courseName [] = 'Dashboard Notes'; } else { $courseName [] = $name->fullname; } } return array($fullCourseIds,$noteslist,$courseName); } public function viewNotes(){ global $DB ,$CFG ,$USER ,$PAGE; $getallnotes = new notes (); $Allnotes=$getallnotes->allnotes(); $CourseIds=$Allnotes[0]; $noteslist=$Allnotes[1]; $courseNameList=$Allnotes[2]; if(!empty($noteslist)){ echo '<a href="'.$CFG->wwwroot.'/blocks/mynotes/notes_excel.php" id="excel_download" class="float-md-right" style="text-decoration: none;">Downlaod Notes</a>'; for ($i=0;$i<count($courseNameList);$i++){ echo ('<div class="notes_section" id="'.$CourseIds[$i]->courseid.'"> <a href="#" class="notes_course fa fa-chevron-circle-right" id="icon'.$CourseIds[$i]->courseid.'" style="text-decoration: none;" > '.' '.$courseNameList[$i].'</a></div> <table class="notes_overview" id="notes_table_id'.$CourseIds[$i]->courseid.'">'); for ($j=0;$j<count($noteslist[$i]);$j++){ echo ('<tr class="overall_notes" id="notes'.$noteslist[$i][$j]->id.'"> <td class="notes_data"> <a href="#" class=" delete_note float-right mr-1 fa fa-trash" id="'.$noteslist[$i][$j]->id.'" style="text-decoration: none;" >delete</a> <a href="#" class=" edit_note float-right mr-5 far fa-edit" id="'.$noteslist[$i][$j]->id.'" style="text-decoration: none;">edit</a> <p id="notes_content'.$noteslist[$i][$j]->id.'">'.$noteslist[$i][$j]->content.'</p> </td></tr>'); } echo '</table>'; } /* <i class="fa fa-trash" aria-hidden="true">delete</i> */ }else{ echo '<div class="alert alert-danger"> <strong> User notes are empty!</strong> User notes are not availale to display. Please make note while working with activities to view all notes. </div>'; } } } $viewnotes = new notes (); $viewnotes->viewNotes (); echo $OUTPUT->footer ();