Search for entry then comment

Search for entry then comment

by Dan McGuire -
Number of replies: 16
How do I search for an entry in database module and then make a comment on it? So far the only way I've been able to do it easily is to first search for the entry, a particular student, for instance, note the date of the entry and then go back to 'view single' and click through all of the entries until I get to that one by guessing at the date in the list at the bottom of the page. Is there a quicker way?
Average of ratings: -
In reply to Dan McGuire

Re: Search for entry then comment

by Itamar Tzadok -
Yes. You can add to the repeated section in the list view the ##comments## built-in field which adds to the record a direct link to the comments section of the entry in the single view. (Blue)

You can also add the ##more## field which is a link to the single view of the entry (and then you may need to scroll down to the comments section).

And you can enclose one of the other fields with

<a href="##moreurl##">||that other field||</a>

to make the value of the field a link to the single view of the entry. (Red)

smile
Attachment data-commentslink.png
Average of ratings: Useful (1)
In reply to Itamar Tzadok

Re: Search for entry then comment

by Ivan Dobrovolskij -
Thank you, it's very helpful. But why some data is in red?
In reply to Ivan Dobrovolskij

Re: Search for entry then comment

by Itamar Tzadok -
The image is of a list view of a database activity used for essay submission. The fifth column is the essay word count and the red background indicates that the required word limit is exceeded. The sixth column is submission time and again the red background indicates late submission. smile
Average of ratings: Useful (1)
In reply to Itamar Tzadok

Re: Search for entry then comment

by Ivan Dobrovolskij -
Thank you, Itamar, that's really great! Is it difficult to create? If not, will you please give some instructions. shy

I've added comments-field to my base, how I can sort entries by this field and/or filter results (for example, find all entries with comments). Thanks a lot for your help. smile
In reply to Ivan Dobrovolskij

Re: Search for entry then comment

by Itamar Tzadok -
Highlighting certain cells may be more or less tricky depending on what is indicated. The simple case is when the highlighting is according to the displayed value. See an example and explanation in this thread. Highlighting according to a calculated value (such as the word limit and submission time above) may require scripting.

It appears that sorting or filtering by comments is not currently available in the database activity. Again this can be done by scripting. For instance:

Suppose the following:
The table in your list view is identified as "itemList".
The first row is a header row.
The comments are in the 7th column.

Then, you can add the following function to the javascript template:

function showCommented(){
var list=document.getElementById("itemList");
var rows=list.rows;
var a=[];
for (var i=1;i<rows.length;i++){
if (rows[i].cells[6].firstChild.innerHTML[0]=="0") a.push(rows[i]);
}
for (var i=0;i<a.length;i++){
a[i].parentNode.removeChild(a[i]);
}
}

Then, enclose that heading of the column in the following way (remove the X from the onclick):

<a href="javascript:void(0);" Xonclick="showCommented();">Comments</a>

And that should allow you to filter out all the rows in the current display which have 0 comments by clicking the column title.

smile



Average of ratings: Useful (1)
In reply to Itamar Tzadok

Re: Search for entry then comment

by Ivan Dobrovolskij -
Thanks a lot, Itamar! It's a bit complicated for me, but I'll try.

And would you kindly suggest any ideas about filtering entries with rating, i.e. with rating or with no rating and with this or that rating? Or again it can not be done without javascript? Thanks in a advance!
In reply to Ivan Dobrovolskij

Re: Search for entry then comment

by Ivan Dobrovolskij -
And any way to display ratings (grades) in the list view?
In reply to Ivan Dobrovolskij

Re: Search for entry then comment

by Itamar Tzadok -
Not by the standard UI. I'll look into that soon to see how the code should be hacked to that effect. smile
In reply to Itamar Tzadok

Re: Search for entry then comment

by Amir Elion -

Did someone find a way to show the average rating for an entry on a list?
Also - is there a way to filter or order according to entry average rating?

In reply to Amir Elion

Re: Search for entry then comment

by Itamar Tzadok -
There should be a patch in the tracker for your first item. The second item shouldn't be too difficult to patch but I just haven't had the time. (Of course average is only one possible way to calc the rating of an entry and that patch may need to have a fixed calc method) smile
In reply to Itamar Tzadok

Re: Search for entry then comment

by Dan McGuire -
Wow, thank you, Itamar, for your extremely helpful directions. I actually haven't had time to try it out yet, but will.

I continue to be blown away by the help that shows up on Moodle forums. It truly is inspiring to me that someone from Toronto responds to my request for assistance in a matter of hours and then someone from Moscow expands the issue before I've even had a chance to follow up. There is hope for education!

Thanks to you, too, Ivan, for participating in our work.
Average of ratings: Useful (1)
In reply to Dan McGuire

Re: Search for entry then comment

by Ivan Dobrovolskij -
Dan, thank you for starting the theme. This is dramatically important to me! And I agree with you: such discussions with people from different countries are truly inspiring! cool
In reply to Itamar Tzadok

Re: Search for entry then comment

by Dan McGuire -
I've successfully added the link to 'comments' to the list view. I simply cut and pasted ##comments## from your, Itamar, post above to the list view template.

Itamar, do you know if this feature is discussed as above in Moodle.docs? If not, one of us should add it.

Thanks again for your prompt response. This really makes life beautiful.
In reply to Dan McGuire

Re: Search for entry then comment

by Itamar Tzadok -
Glad to hear it works. smile

The tag usage is documented in the docs in the Database templates page. This page discusses also other available tags.

See image below for where the ##comments## tag is located in the template. When there are many fields the ##comments## tag is not visible and should be scrolled to.

smile


Attachment data-templates-availabletags.png