06ce11f1 by logesh

dev:changes in notes

1 parent 892007c9
Copyright (c) 2013-2016 GitHub, Inc. and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
<?php
define('AJAX_SCRIPT', true);
define('NO_DEBUG_DISPLAY', true);
require_once('../../config.php');
require_once($CFG->dirroot . '/blocks/mynotes/lib.php');
require_login ();
$context = context_system::instance ();
$PAGE->set_context ( $context );
$action = optional_param('action', '', PARAM_ALPHA);
$PAGE->requires->js_call_amd('block_mynotes/script', 'init');
$PAGE->set_url('/blocks/mynotes/allnotes_ajax.php');
switch ($action){
case 'edit':
$noteid = required_param('noteid', PARAM_INT);
$notes = required_param('newnotes', PARAM_TEXT);
$manager = new block_mynotes_manager();
if ($manager->edit($noteid,$notes)) {
echo json_encode(array('result' => "successfully updated"));
}else{
echo json_encode(array('error' => 'Unable to update edited note'));
}
die();
break;
case 'delete':
$noteid = required_param('noteid', PARAM_INT);
$manager = new block_mynotes_manager();
// $noteid=547;
if ($manager->delete($noteid)) {
echo json_encode(array('noteid' => $noteid, 'result' => "deleted"));
}
else {
echo json_encode(array('error' => 'Unable to delete note'));
}
die();
break;
}
die();
\ No newline at end of file
define(["jquery"],function(e){return{init:function(){var n=e(location).attr("href");e("document").ready(function(){if(n.includes("/mod/page/view.php")){var e=document.querySelector("iframe");new Vimeo.Player(e)}})}}});
\ No newline at end of file
define(['jquery','core/config',], function($,config) {
return {
init: function() {
var CONFIG;
$('.notes_overview').hide();
var url= $(location).attr('href');
if(url.includes('/mynotes/view.php')){
$('.page-header').css('margin-top','2em !important');
$('.page-title').css('margin-top','inherit !important');
}
$(document).ready(function(){
$(".notes_section").click(function(){
var eventId=this.id;
$('#notes_table_id'+eventId).toggle();
});
$(".notes_section").click(function(){
var eventId=this.id;
var classname=$( "div#"+eventId ).children()[0].className;
if (classname === 'notes_course fa fa-chevron-circle-right'){
$( "#icon"+eventId ).removeClass( 'notes_course fa fa-chevron-circle-right' );
$( "#icon"+eventId ).addClass( 'notes_course fa fa-chevron-circle-down' );
}
else if (classname === 'notes_course fa fa-chevron-circle-down'){
$( "#icon"+eventId ).removeClass( 'notes_course fa fa-chevron-circle-down' );
$( "#icon"+eventId ).addClass( 'notes_course fa fa-chevron-circle-right' );
}
});
$("#excel_download").click(function(){
var rootPath = M.cfg.wwwroot
var arg = {
action: 'download',
};
$.ajax({
url: rootPath+"/blocks/mynotes/notes_excel.php",
type: "POST",
data: arg,
success: function(response){
//do action
},
error: function(){
// do action
}
});
});
$("a.delete_note").click(function(){
var deleteId=this.id;
var arg = {
action: 'delete',
noteid: deleteId,
};
var rootPath = M.cfg.wwwroot;
$.ajax({
type: 'post',
url: rootPath+'/blocks/mynotes/allnotes_ajax.php',
data:arg,
success: function( data ) {
var deleteid=data.noteid;
$("#notes"+deleteid).remove();
},
error: function(data, errorThrown)
{
alert('request failed :'+errorThrown);
}
});
});
$("a.edit_note").click(function(){
var editId=this.id;
// notes_content+editId;
var vals=document.getElementById('notes_content'+editId).contentEditable = true;
document.getElementById('notes_content'+editId).focus();
// console.log('notes_content'+editId);
$('#notes_content'+editId).keypress(function(event) {
if (event.keyCode == 13) {
var newstring= $('#notes_content'+editId).text();
// console.log(newstring);
var vals=document.getElementById('notes_content'+editId).contentEditable = false;
var arg = {
action: 'edit',
noteid: editId,
newnotes:newstring,
};
var rootPath = M.cfg.wwwroot;
$.ajax({
type: 'post',
url: rootPath+'/blocks/mynotes/allnotes_ajax.php',
data:arg,
success: function( data ) {
},
error: function(data, errorThrown)
{
alert('request failed :'+errorThrown);
var vals=document.getElementById('notes_content'+editId).contentEditable = true;
}
});
}
});
});
});
}
};
});
......
define(['jquery'], function($) {
define(['jquery','core/config',], function($,config) {
return {
init: function() {
// tab-mynotes_user
// tab-mynotes_user mynotepencil
var CONFIG;
console.log('init function got invoked ');
$('#mynotepencil').click(function(){
console.log('init function got invoked ');
$('.notes_overview').hide();
var url= $(location).attr('href');
if(url.includes('/mynotes/view.php')){
$('.page-header').css('margin-top','2em !important');
$('.page-title').css('margin-top','inherit !important');
}
$(document).ready(function(){
$(".notes_section").click(function(){
var eventId=this.id;
$('#notes_table_id'+eventId).toggle();
});
$(".notes_section").click(function(){
var eventId=this.id;
var classname=$( "div#"+eventId ).children()[0].className;
if (classname === 'notes_course fa fa-chevron-circle-right'){
$( "#icon"+eventId ).removeClass( 'notes_course fa fa-chevron-circle-right' );
$( "#icon"+eventId ).addClass( 'notes_course fa fa-chevron-circle-down' );
}
else if (classname === 'notes_course fa fa-chevron-circle-down'){
$( "#icon"+eventId ).removeClass( 'notes_course fa fa-chevron-circle-down' );
$( "#icon"+eventId ).addClass( 'notes_course fa fa-chevron-circle-right' );
}
});
$("#excel_download").click(function(){
var rootPath = M.cfg.wwwroot
var arg = {
action: 'download',
};
$.ajax({
url: rootPath+"/blocks/mynotes/notes_excel.php",
type: "POST",
data: arg,
success: function(response){
//do action
},
error: function(){
// do action
}
});
});
$("a.delete_note").click(function(){
var deleteId=this.id;
var arg = {
action: 'delete',
noteid: deleteId,
};
var rootPath = M.cfg.wwwroot;
$.ajax({
type: 'post',
url: rootPath+'/blocks/mynotes/allnotes_ajax.php',
data:arg,
success: function( data ) {
var deleteid=data.noteid;
$("#notes"+deleteid).remove();
},
error: function(data, errorThrown)
{
alert('request failed :'+errorThrown);
}
});
});
$("a.edit_note").click(function(){
var editId=this.id;
// notes_content+editId;
var vals=document.getElementById('notes_content'+editId).contentEditable = true;
document.getElementById('notes_content'+editId).focus();
// console.log('notes_content'+editId);
$('#notes_content'+editId).keypress(function(event) {
if (event.keyCode == 13) {
var newstring= $('#notes_content'+editId).text();
// console.log(newstring);
var vals=document.getElementById('notes_content'+editId).contentEditable = false;
var arg = {
action: 'edit',
noteid: editId,
newnotes:newstring,
};
var rootPath = M.cfg.wwwroot;
$.ajax({
type: 'post',
url: rootPath+'/blocks/mynotes/allnotes_ajax.php',
data:arg,
success: function( data ) {
},
error: function(data, errorThrown)
{
alert('request failed :'+errorThrown);
var vals=document.getElementById('notes_content'+editId).contentEditable = true;
}
});
}
});
});
});
// document.getElementById("panel").style.display = "none"; Nothing to display
// $("#tab-mynotes_user").removeAttr("style").hide();
}
};
});
......
<?php
require_once (dirname ( __FILE__ ) . '/../../config.php');
require_once(dirname( __FILE__ ) .'/../../lib/phpexcel/PHPExcel.php');
global $OUTPUT, $title;
require_login ();
$context = context_system::instance ();
$PAGE->set_context ( $context );
function download_excel(){
global $DB, $CFG,$USER ,$PAGE;
$contextid;
if (isset($_GET['cid'])) {
$contextid=$_GET['cid'];
}
$parameter;
if ($contextid){
$parameter = array ($USER->id,$contextid);
}else{
$parameter = array ($USER->id);
}
$sql="select id,courseid from {block_mynotes} where userid=? and contextid=?";
$courseids = $DB->get_records_sql ( $sql, $parameter );
$courseid;
foreach ( $courseids as $value){
$courseid=$value->courseid;
}
$param=array($USER->id,$courseid);
$sql="select * from {block_mynotes} where userid=? and courseid=?";
$allNotes = $DB->get_records_sql ( $sql, $param );
$fullNotes = array ();
$i=0;
foreach ($allNotes as $notes ) {
$courseid=$notes->courseid;
$parameter = array ($courseid);
$sql="select fullname from {course} where id=?";
$coursename = $DB->get_record_sql ( $sql, $parameter );
$fullNotes [$i]['Sl.no']=$i+1;
$fullNotes [$i]['Course']=$coursename->fullname;
if($notes->activityname){
$fullNotes [$i]['activityname']=$notes->activityname;
}
$fullNotes [$i]['Content']=$notes->content;
$time=date('d M Y H:i A (T)', $notes->timecreated);
$fullNotes [$i]['Timecreated']=$time;
$fullNotes [$i]['Videotime']=$notes->notestime;
$fullNotes [$i]['Notesurl']=$notes->notesurl;
$i=$i+1;
}
if (!empty($fullNotes)){
$name = "Student_notes";
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setTitle('Notes');
$default_border = array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array('rgb'=>'9999ff')
);
$style_header = array(
'borders' => array(
'bottom' => $default_border,
'left' => $default_border,
'top' => $default_border,
'right' => $default_border,
),
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('rgb'=>'E1E0F7'),
),
'font' => array(
'bold' => true,
)
);
$default_border1 = array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array('rgb'=>'ff9999')
);
$style_header1 = array(
'borders' => array(
'bottom' => $default_border1,
'left' => $default_border1,
'top' => $default_border1,
'right' => $default_border1,
),
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('rgb'=>'ff9999'),
),
'font' => array(
'bold' => true,
)
);
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(8);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(50);
$objPHPExcel->getActiveSheet()->getCell("A1")->setValue("SL.No");
$objPHPExcel->getActiveSheet()->getCell("A1")->getStyle('A1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("B1")->setValue("Course");
$objPHPExcel->getActiveSheet()->getCell("B1")->getStyle('B1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("C1")->setValue("Activity ");
$objPHPExcel->getActiveSheet()->getCell("C1")->getStyle('C1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("D1")->setValue("Note");
$objPHPExcel->getActiveSheet()->getCell("D1")->getStyle('D1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("E1")->setValue("Time Created");
$objPHPExcel->getActiveSheet()->getCell("E1")->getStyle('E1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("F1")->setValue("Time in clip");
$objPHPExcel->getActiveSheet()->getCell("F1")->getStyle('F1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("G1")->setValue("URL");
$objPHPExcel->getActiveSheet()->getCell("G1")->getStyle('G1')->applyFromArray($style_header);
for($i=1;$i<=count($fullNotes)+1;$i++){
$objPHPExcel->getActiveSheet()->getCell('A'.($i+1))->setValue($i);
$objPHPExcel->getActiveSheet()->getCell('B'.($i+1))->setValue($fullNotes[$i-1]['Course']);
$objPHPExcel->getActiveSheet()->getCell('C'.($i+1))->setValue($fullNotes[$i-1]['activityname']);
$objPHPExcel->getActiveSheet()->getCell('D'.($i+1))->setValue($fullNotes[$i-1]['Content']);
$objPHPExcel->getActiveSheet()->getCell('E'.($i+1))->setValue($fullNotes[$i-1]['Timecreated']);
$objPHPExcel->getActiveSheet()->getCell('F'.($i+1))->setValue($fullNotes[$i-1]['Videotime']);
$objPHPExcel->getActiveSheet()->getCell('G'.($i+1))->setValue($fullNotes[$i-1]['Notesurl']);
}
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
ob_end_clean();
header("Content-Disposition: attachment; filename=$name.xlsx");
header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
$objWriter->save('php://output');
exit();
}
}
download_excel();
......@@ -11,6 +11,7 @@
<FIELD NAME="contextarea" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="content" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="activityname" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="format" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
......
......@@ -31,7 +31,7 @@ function xmldb_block_mynotes_upgrade($oldversion) {
$dbman = $DB->get_manager();
//Upgrade to add an extra column to local_qharvest_qns_count table
if( $oldversion < 2018011201 ){
if( $oldversion < 2018011203 ){
$table = new xmldb_table('block_mynotes');
......@@ -44,6 +44,7 @@ function xmldb_block_mynotes_upgrade($oldversion) {
$table->add_field('contextarea', XMLDB_TYPE_CHAR,'255', null, null, null,null);
$table->add_field('content', XMLDB_TYPE_TEXT, null, null, null,null);
$table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
$table->add_field('activityname', XMLDB_TYPE_TEXT, null, null, null,null);
$table->add_field('format', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
......
......@@ -63,9 +63,9 @@ class block_mynotes_manager {
$where .= ' AND m.courseid = :courseid';
$params['courseid'] = $options->courseid;
} */
if(isset($options->contextid) && $options->contextid){
$where .= ' AND m.contextid = :contextid';
$params['contextid'] = $options->contextid;
if(isset($options->courseid) && $options->courseid){
$where .= ' AND m.courseid = :courseid';
$params['courseid'] = $options->courseid;
}
$sql = "SELECT $ufields,
......@@ -86,10 +86,20 @@ class block_mynotes_manager {
$c->id = $u->mynoteid;
$c->userid = $u->id;
if ($u->courseid != SITEID) {
// $c->coursename = html_writer::link(course_get_url($u->courseid), $u->coursename);
// $c->coursename = html_writer::link(course_get_url($u->courseid), $u->coursename);
if (!empty($u->notestime)){
$c->coursename='<a href="#" class="notes_button_redirect" name="'.$u->notestime.'" id="'.course_get_url(($u->courseid), $u->coursename).'">'.$u->coursename.'</a>';
}else{
$c->coursename='<a href="#" class="notes_button_redirect" id="'.course_get_url(($u->courseid), $u->coursename).'">'.$u->coursename.'</a>';
}
if (! empty ( $u->notesurl )) {
$c->coursename = html_writer::link ( $u->notesurl, $u->coursename );
// $c->coursename = html_writer::link ( $u->notesurl, $u->coursename );
if (!empty($u->notestime)){
$c->coursename='<a href="#" class="notes_button_redirect" name="'.$u->notestime.'" id="'.$u->notesurl.'">'.$u->coursename.'</a>';
}else{
$c->coursename='<a href="#" class="notes_button_redirect" id="'.$u->notesurl.'">'.$u->coursename.'</a>';
}
} else {
$c->coursename = $u->coursename;
......@@ -153,6 +163,34 @@ class block_mynotes_manager {
} */
/* public function count_notes($options) {
global $DB, $USER;
$params = array();
$userid=$USER->id;
$contextarea='';
$courseid;
if (isset($options->contextarea) && !empty($options->contextarea)) {
$contextarea=$options->contextarea;
}
if (isset($options->courseid) && !empty($options->courseid)) {
$courseid=$options->courseid;
}
$param=array($userid,$contextarea,$courseid);
$sql='select count(contextarea) from {block_mynotes} where userid=? and contextarea=? and courseid=?';
$result=$DB->get_records_sql($sql,$param);
$count;
foreach ($result as $val){
$count=$val->count;
}
return $count;
// return $DB->count_records('block_mynotes', $params);
} */
public function count_mynotes($options) {
......@@ -160,14 +198,20 @@ class block_mynotes_manager {
$params = array();
$params['userid'] = $USER->id;
// $userid=$USER->id;
// $contextarea='';
// $courseid;
if (isset($options->contextarea) && !empty($options->contextarea)) {
$params['contextarea'] = $options->contextarea;
}
if (isset($options->contextid) && !empty($options->contextid)) {
$params['contextid'] = $options->contextid;
// $contextarea=$options->contextarea;
}
$sql='select count(contextarea) from {block_mynotes} where userid=? and contextarea=? and contextid=?';
if (isset($options->courseid) && !empty($options->courseid)) {
$params['courseid'] = $options->courseid;
// $courseid=$options->courseid;
}
// $param=array($userid,$contextarea,$courseid);
$sql='select count(contextarea) from {block_mynotes} where userid=? and contextarea=? and courseid=?';
$result=$DB->get_records_sql($sql,$params);
......@@ -202,7 +246,7 @@ class block_mynotes_manager {
*
* @return object of single mynote record if insert to DB else false
*/
public function addmynote($context, $contextarea, $course, $content,$timer,$activityUrl, $format = FORMAT_MOODLE) {
public function addmynote($context, $contextarea, $course, $content,$timer,$activityUrl,$activityname, $format = FORMAT_MOODLE) {
global $CFG, $DB, $USER, $OUTPUT;
// $content=$content.$timer;
......@@ -211,6 +255,7 @@ class block_mynotes_manager {
$newnote->contextarea = $contextarea;
$newnote->content = $content;
$newnote->courseid = $course->id;
$newnote->activityname = $activityname;
$newnote->format = $format;
$newnote->userid = $USER->id;
$newnote->timecreated = time();
......@@ -361,6 +406,24 @@ class block_mynotes_manager {
}
public function all_note_edit($mynoteid,$notes){
global $DB, $USER;
if (!$mynote = $DB->get_record('block_mynotes', array('id' => $mynoteid))) {
throw new mynotes_exception('editfailed', 'block_mynotes');
}
if ($USER->id != $mynote->userid) {
throw new mynotes_exception('nopermissiontoedit', 'block_mynotes');
}
$param = array ($notes,$mynoteid );
$sql4 = 'update {block_mynotes} set content=? , timecreated=? where id=? ';
return $update_record = $DB->execute ( $sql4, $param );
}
}
/**
......
......@@ -71,10 +71,11 @@ switch ($action) {
$content = optional_param('content', '', PARAM_RAW);
$timer = optional_param('notestime', '', PARAM_TEXT);
$activityUrl = optional_param('urllink', '', PARAM_TEXT);
$activityname = optional_param('activity', '', PARAM_TEXT);
$manager = new block_mynotes_manager();
if ($note = $manager->addmynote($context, $contextarea, $course, $content,$timer,$activityUrl)) {
if ($note = $manager->addmynote($context, $contextarea, $course, $content,$timer,$activityUrl,$activityname)) {
$options = new stdClass();
$options->page = $page;
$options->courseid = $course->id;
......@@ -82,9 +83,10 @@ switch ($action) {
$options->context = $context;
$options->contextarea = $contextarea;
// $options->notestime=$timer;
unset($options->courseid);
// unset($options->courseid);
$count = $manager->count_mynotes($options);
echo json_encode(array('notes' => array($note), 'count' => $count));
} else {
echo json_encode(array('error' => 'Unable to add note'));
......
<?php
require_once (dirname ( __FILE__ ) . '/../../config.php');
require_once(dirname( __FILE__ ) .'/../../lib/phpexcel/PHPExcel.php');
global $OUTPUT, $title;
require_login ();
$context = context_system::instance ();
$PAGE->set_context ( $context );
function download_excel(){
global $DB, $CFG,$USER , $PAGE;
$parameter = array ($USER->id);
$sql="select * from {block_mynotes} where userid=?";
$allNotes = $DB->get_records_sql ( $sql, $parameter );
$fullNotes = array ();
$i=0;
foreach ($allNotes as $notes ) {
$courseid=$notes->courseid;
$parameter = array ($courseid);
$sql="select fullname from {course} where id=?";
$coursename = $DB->get_record_sql ( $sql, $parameter );
$fullNotes [$i]['Sl.no']=$i+1;
$fullNotes [$i]['Course']=$coursename->fullname;
if($notes->activityname){
$fullNotes [$i]['activityname']=$notes->activityname;
}
$fullNotes [$i]['Content']=$notes->content;
$time=date('d M Y H:i A (T)', $notes->timecreated);
$fullNotes [$i]['Timecreated']=$time;
$fullNotes [$i]['Videotime']=$notes->notestime;
$fullNotes [$i]['Notesurl']=$notes->notesurl;
$i=$i+1;
}
/* xls format
$fileName = "user_full_notes" . rand(1,100) . ".xls";
if ($fullNotesssss){
function filterData(&$str) {
$str = preg_replace("/\t/", "\\t", $str);
$str = preg_replace("/\r?\n/", "\\n", $str);
if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"';
}
// headers for download
header("Content-Disposition: attachment; filename=\"$fileName\"");
header("Content-Type: application/vnd.ms-excel");
$flag = false;
$i=0;
foreach($fullNotes as $row) {
if(!$flag) {
// display column names as first row
echo implode("\t", array_keys($row)) . "\n";
$i=$i+1;
$flag = true;
}
// filter data
array_walk($row, 'filterData');
echo implode("\t", array_values($row)) . "\n";
}
exit;
}
*/
$name = "Student_notes";
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setTitle('Notes');
$default_border = array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array('rgb'=>'9999ff')
);
$style_header = array(
'borders' => array(
'bottom' => $default_border,
'left' => $default_border,
'top' => $default_border,
'right' => $default_border,
),
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('rgb'=>'E1E0F7'),
),
'font' => array(
'bold' => true,
)
);
$default_border1 = array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array('rgb'=>'ff9999')
);
$style_header1 = array(
'borders' => array(
'bottom' => $default_border1,
'left' => $default_border1,
'top' => $default_border1,
'right' => $default_border1,
),
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('rgb'=>'ff9999'),
),
'font' => array(
'bold' => true,
)
);
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(5);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(50);
$objPHPExcel->getActiveSheet()->getCell("A1")->setValue("SL.No");
$objPHPExcel->getActiveSheet()->getCell("A1")->getStyle('A1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("B1")->setValue("Course");
$objPHPExcel->getActiveSheet()->getCell("B1")->getStyle('B1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("C1")->setValue("Activity");
$objPHPExcel->getActiveSheet()->getCell("C1")->getStyle('C1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("D1")->setValue("Note");
$objPHPExcel->getActiveSheet()->getCell("D1")->getStyle('D1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("E1")->setValue("Time Created");
$objPHPExcel->getActiveSheet()->getCell("E1")->getStyle('E1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("F1")->setValue("Time in Clip");
$objPHPExcel->getActiveSheet()->getCell("F1")->getStyle('F1')->applyFromArray($style_header);
$objPHPExcel->getActiveSheet()->getCell("G1")->setValue("URL");
$objPHPExcel->getActiveSheet()->getCell("G1")->getStyle('G1')->applyFromArray($style_header);
for($i=1;$i<=count($fullNotes)+1;$i++){
$objPHPExcel->getActiveSheet()->getCell('A'.($i+1))->setValue($i);
$objPHPExcel->getActiveSheet()->getCell('B'.($i+1))->setValue($fullNotes[$i-1]['Course']);
$objPHPExcel->getActiveSheet()->getCell('C'.($i+1))->setValue($fullNotes[$i-1]['activityname']);
$objPHPExcel->getActiveSheet()->getCell('D'.($i+1))->setValue($fullNotes[$i-1]['Content']);
$objPHPExcel->getActiveSheet()->getCell('E'.($i+1))->setValue($fullNotes[$i-1]['Timecreated']);
$objPHPExcel->getActiveSheet()->getCell('F'.($i+1))->setValue($fullNotes[$i-1]['Videotime']);
$objPHPExcel->getActiveSheet()->getCell('G'.($i+1))->setValue($fullNotes[$i-1]['Notesurl']);
}
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
ob_end_clean();
header("Content-Disposition: attachment; filename=$name.xlsx");
header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
$objWriter->save('php://output');
exit();
}
download_excel();
\ No newline at end of file
......@@ -26,14 +26,14 @@ defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
$perpageoptions = array();
for ($i = 1; $i < 20; $i++) {
for ($i = 1; $i < 30; $i++) {
$perpageoptions[$i] = $i;
}
$settings->add(new admin_setting_configselect('block_mynotes/mynotesperpage', get_string('mynotesperpage', 'block_mynotes'),
get_string('mynotesperpage_help', 'block_mynotes'), 5, $perpageoptions));
get_string('mynotesperpage_help', 'block_mynotes'), 20, $perpageoptions));
$settings->add(new admin_setting_configtext('block_mynotes/characterlimit', get_string('characterlimit', 'block_mynotes'),
get_string('characterlimit_help', 'block_mynotes'), 180, PARAM_INT, 3));
get_string('characterlimit_help', 'block_mynotes'), 450, PARAM_INT, 3));
$positionoptions = array();
$positionoptions['mynotes-pos-rb'] = get_string('bottomright', 'block_mynotes');
......
#mynotes-opener { position: absolute; bottom:0px; background: #443355; width: 25px; height: 25px; }
div.mdl-align { min-height: 470px;}
#mynote-edit{position: absolute !important;right: 0 !important; margin: 0px 20px !important;}
#mynote-update{position: absolute !important; right: 0 !important; margin:0px 40px !important;}
#mynote-edit{display:none;position: absolute;right: 0; margin: 0 28px;}
#mynote-update{visibility: hidden;position: absolute !important; right: 0 !important; margin:0px 40px !important;}
#notes_edit_option{color: #2310c3 !important;}
.mdl-align { padding:inherit !important; }
.mynotes-pos-inline-text { padding: 10px; margin-left: 35px; cursor: pointer; }
......@@ -26,9 +26,9 @@ div.mdl-align { min-height: 470px;}
.mynotes_base input[type="submit"], .mynotes_base input[type="submit"]:hover { margin: 0; padding: 3px 10px; border: none; background: #63ab36; color: #fff; }
.mynotes_base input[type="submit"][disabled="disabled"]:hover { background: #63ab36; cursor: not-allowed; }
.mynotes_base span.warning { color: #bd3c2f; margin-left: 15px; }
.mynotes_base .responsetext { color: #33b733; line-height: 20px; }
.mynotes_base .responsetext { color: #33b733; line-height: 15px; }
.mynotes_base .tabs-menu { height: 30px; float: left; clear: both; margin-bottom: 1px; }
.mynotes_base .tabs-menu li { padding: 0 10px; margin-right: 1px; height: 30px; line-height: 30px; float: left; list-style: none; background-color: #d84e36; cursor: pointer; }
.mynotes_base .tabs-menu li { padding: 0 10px; margin-right: 1px; height: 30px; line-height: 20px; float: left; list-style: none; background-color: #d84e36; cursor: pointer; }
.mynotes_base .tabs-menu li:first-child { border-radius: 7px 0 0 0; }
.mynotes_base .tabs-menu li:last-child { border-radius: 0 7px 0 0; }
.mynotes_base .tabs-menu li.current { position: relative; background-color: #ffe6a4; border-bottom: 1px solid #fff; z-index: 5; border-bottom: 2px solid #ffe6a4; }
......@@ -39,16 +39,103 @@ div.mdl-align { min-height: 470px;}
.mynotes_base .tab { border: 1px solid #d4d4d1; clear: both; width: auto; background: #f7f7f4; }
.mynotes_base .tab .tab-content { display: none; }
.mynotes_base .tab .tab-content .notes-info { background: #ffe6a4; padding: 5px; position: relative; }
.mynotes_base .tab .tab-content .notes-info { background: #ffe6a4; padding: 3px; position: relative; }
.mynotes_base .tab .tab-content .notes-info .count { color: #000; }
.mynotes_base .tab .tab-content .notes-info .mynotes-paging { position: absolute; right: 0; }
.mynotes_base .tab .tab-content .notes-info .mynotes-paging .paging a { margin: 5px; background: #c1621e; padding: 4px 10px; border-radius: 15px; color: #fff; }
.mynotes_base .tab .tab-content .notes-info .mynotes-paging { position: absolute; right: 0;}
.mynotes_base .tab .tab-content .notes-info .mynotes-paging .paging a { margin: 5px; background: #c1621e; padding: 1px 3px; border-radius: 15px; color: #fff; }
.mynotes_base .tab .tab-content .notes-info .mynotes-paging .paging .separator { border-left: 1px solid gray; }
.mynotes_base .tab .tab-content ul.mynotes_lists { margin:0; clear: both; }
.mynotes_base .tab .tab-content ul.mynotes_lists li { list-style: none; position: relative; margin: 0 0 5px 0; padding: 5px; list-style: none; background-color: #fff; border-top: 1px solid #e3e4e4; }
.mynotes_base .tab .tab-content ul.mynotes_lists {overflow: scroll; height: 250px; margin:0; clear: both; }
.mynotes_base .tab .tab-content ul.mynotes_lists li { list-style: none; position: relative; margin: 0 0 1px 0; padding: 6px; list-style: none; background-color: #fff; border-top: 1px solid #e3e4e4; }
.mynotes_base .tab .tab-content ul.mynotes_lists li .content { margin-right: 10px; word-wrap: break-word; }
.mynotes_base .tab .tab-content ul.mynotes_lists li .note-detail { display: inline-block; font-size: 11px; }
.mynotes_base .tab .tab-content ul.mynotes_lists li .time { color: #888; font-style: italic; display: inline-block; margin-left: 5px; font-size: 11px; }
.mynotes_base .tab .tab-content ul.mynotes_lists li a.mynote-delete { position: absolute; right: 0; margin:0 -1px; }
.mynotes_base .tab .tab-content ul.mynotes_lists li a.mynote-delete span { color: #bbb; }
.mynotes_base .tab .tab-content ul.mynotes_lists li a.mynote-delete { display:none;position: absolute; right: 1px; margin:0px -1px; }
.mynotes_base .tab .tab-content ul.mynotes_lists li a.mynote-delete span { color: #bbb;}
ul#mynotes_user-list{
padding-left: 0rem !important;
}
/* Overridden style for positioning the notes box */
.moodle-dialogue-wrap.moodle-dialogue-content.yui3-widget-stdmod{
position: fixed !important;
left: 1035px!important;
width: 300px !important;
top: 70px !important;
}
:focus{
outline: -webkit-focus-ring-color auto 0px !important;
}
#notes_edit_option{
outline: -webkit-focus-ring-color auto 2px !important;
}
.notes_overview {
/*
overflow-x: hidden;
overflow-y: scroll;
height: 270px; */
}
.notes_overview {
background-color: #f7f7f7;
width: 100%;
height: 2em;
padding: 9px 6px 0;
/*
overflow-x: hidden;
overflow-y: scroll;
height: 270px; */
}
#notes-slider {
/* left: 3px;
top: 43px; */
}
.notes_section {
padding: 4px 0px 4px 1px;
}
#course_name {
/* padding: 4px 0px 0px 8px;
font-size: 19px;
color: black; */
}
.notes_course {
background-color: #dddddd;
width: 100%;
height: 2em;
padding: 9px 6px 0;
padding: 4px 0px 0px 8px;
font-size: 19px;
color: black;
}
.notes_data {
/* background-color: #f7f7f7;
width: 100%; */
border: 2px solid #fff;
text-align: left;
padding: 8px;
}
#delete_icon.fa.fa-trash{
margin-right: 20em;
text-decoration: underline;
}
#edit_icon.far.fa-edit{
margin-right: 25em;
text-decoration: underline;
}
/* .page-header{
margin-top: 2em !important;
}
.page-title {
margin-top: inherit !important;
} */
......
<?php
require_once('/../../config.php');
// require_once($CFG->dirroot.'/user/profile/lib.php');
// require_once($CFG->dirroot.'/course/lib.php');
require_once($CFG->dirroot . '/blocks/mynotes/lib.php');
global $USER,$DB;
// if (!isloggedin()) {
// echo json_encode(array('error' => 'require_login'));
// die();
// }
$timertext = optional_param('notestime', '', PARAM_TEXT);
// $myuser=profile_user_record($USER->id);
if ($timertext){
echo $timertext;
}
else{
echo "value fromrhere";
}
......@@ -23,7 +23,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2018011202; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2018011203; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2015050500; // Requires this Moodle version
$plugin->component = 'block_mynotes'; // Full name of the plugin (used for diagnostics)
$plugin->release = 'V3.4 r1';
......
<?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 ();
\ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!