Moodle export lesson contents with images - moodle

I am trying to export Moodle lesson content from Moodle database, but I am having problems exporting images. Moodle stores lesson HTML in a MySQL database but images are referenced and need to be replaced in the HTML string.
For example. This is the source html that is saved in Moodle DB:
<p>
<img style="display: block; margin-left: auto; margin-right: auto;" src="##PLUGINFILE##/sound_card_zpstlml0qfv.png" height="492" width="720" /
</p>
Moodle transforms this into final html:
<p>
<img style="display: block; margin-left: auto; margin-right: auto;" src="http://mymoodleserver.com/pluginfile.php/553/mod_lesson/page_contents/1725/sound_card_zpstlml0qfv.png" height="492" width="720" /
</p>
I have figured out that ##PLUGINFILE## needs to be replaced with the path to the image file but I just don't know what is the first number in the final image URL. I guess it is some ID but I can figure out what. I figured out the second number in the URL is id from lesson_pages table.
http://mymoodleserver.com/pluginfile.php/SOME_ID/mod_lesson/page_contents/PAGE_ID/image_file.jpg

Isn't the first number in the final image URL (553, in your example) an id from mdl_files table?
What I still don't understand is the relationship between the file in the mdl_files table and the actual image file.
Please post the answer, if you found it.

Related

Invalid span tag. Expected closing br tag

I am trying to convert html to pdf using iText and getting below error.
Invalid span tag. Expected closing br tag
How is this an invalid xhtml ?
<span style="font-size: 10pt; line-height: 14.2667px;"><br/></span>
A span is an inline element, and a smallest element of xhtml tree.
styling tags like <u>, <i>, <strong> can be reside there.
A <br> or a <hr> is a full width element. Hence it is suggested to use <br> inside a <div></div>

MODX: MIGX Extremely slow load times

I'm currently implementing MODX into a current site. (click here)
As you can probably tell, loading the site takes an absurd amount of time for something mostly textual. It loaded very quickly before I was using this CMS, so I'm assuming that it's just taking a very long time to request information from my database.
Here's how I have it set up: Each item under the category is included like this:
[[!getImageList?
&tvname=`lunchSoups`
&tpl=`menuItem`
]]
So, seeing as I have both Dinner + Lunch menus as well as all of these items, I end up with 14 requests. Is this what's slowing my page down, or is it just the amount of information? How can I reduce the load time?
Edit: I've taken out the ! in getImageList, so now it caches. The initial load is still extremely slow, though.
Edit: TPL Chunk:
I thought maybe the conditional type statements might be slowing down the website, but they seem to be the same speed without them.
[[+item:notempty=`
<h2>
<span>[[+item]] / <span>[[+price]]</span>
</h2>
`]]
<h3>
<span>[[+description]]</span>
</h3>
[[+addItem:notempty=`
</br>
<h2 style="font-style:italic; font-size: 13px; padding-bottom: 0px; padding-top: 0px; text-align: center; line-height: 1.2;">
[[+addItem]]
</h2>
</br>
`]]

Traverse to get to innerHTML

Using Selenium IDE, I need to verify the text "Schedule Entry Worksheet for ZBW - Boston Center" is present. I'd like to use AssertTextPresent to do this. I'm using Firebug to identify the path to the element.
Here's what I've done so far in IDE:
Command: assertTextPresent
Target: xpath=//html/body/div[7]/div[2]/div/div/span
Value: Schedule Entry Worksheet for ZBW - Boston Center
However, I'm getting "[error] false" in the log section. Does anyone know what I'm doing incorrectly?
Below is a snippet HTML for the page:
<div id="worksheet_div" style="display: inline;">
<div class="fg1" style="width: 2010px;">
<div class="fgt">
<span style="padding-right: 10px; background-color: #E3EFFF;">Schedule Entry Worksheet for ZBW - Boston Center</span>
</div>
does it matter where the text is or just that it is somewhere? if it is the latter you could do something as simple as
css=span
if position on the page matter then need to add more structure to it
css=.fgt span
or similar.
it is also useful to use the firefinder plugin for firefox to debug xpath and css

Span inside text input field?

Is it somehow possible to place a span as the value of a text input field?
I am making a mailing system for a website and want a nice looking receivers input field, where added receivers are contained and added to the value of input text field. At the moment i use a separate "adding field" while showing added receivers in a span-container. I want to merge these to fields together. Just like any input field in regular e-mail software.
Help would be most appreciated! Thanks in advance!
Short answer: no, you cannot include a <span /> within an <input />.
You have a few options. You could use javascript to emulate behaviour like the email To: field. E.g. listen to key presses and handle actions like backspace after a ;.
Another option would be to make a list appear (css styled) like a textbox. Have the last <li /> contain a textbox with cleared styles. Every time the user adds a new email then insert a new <li /> before the textbox.
E.G.
html:
<ul class="email-textbox">
<li>bob#email.com;</li>
<li>jane#email.com;</li>
<li><input type="text" /></li>
</ul>
css:
.email-textbox {
background-color: #fff;
border: 1px solid #ccc;
padding: 2px 4px;
}
.email-textbox li {
display: inline-block;
list-style: none;
margin-left: 5px;
}
.email-textbox input {
background: none;
border: none;
}
javascript (jQuery, can change to vanilla)
$(function () {
$('.email-textbox').find('input').focus();
});
You will need to extend this javascript to include a keypress handler etc, but it gives the general idea.
Demo: http://jsfiddle.net/UeTDw/1/
Any option will require some javascript however.
If you can use jQuery, you could check out jQuery UI autocomplete
One way to do it would be to layer a text input on top of a div that is styled to look like a text input.
<div id="fake-input">
<span class="input-item">John Doe</span>
<span class="input-item">Jane Deere</span>
<input id="receiver-input" type="text" />
</div>
You can strip all styling off of receiver-input, and add borders, background colors, and such to fake-input so that it appears to be a text field. When a receiver is added, you can create a new input-item span and append it to the list.
Input text fields are typically used to accept raw text input. Attempting to wrap input text inside of a text field opens you to user error and potential difficulties with parsing data if the person is able to manipulate the tags.
Personally I would suggest keeping your current method but enabling some form of AJAX support to make things more dynamic and less error-prone to the user.
(My $0.02)
TextExtjs is probably what you want. It's a jquery plugin for allowing removable tags with autocompletion etc in a textarea.
And here is a related SO discussion - where I found this plugin - on mimicking the similar behavior found in some inputs on facebook.

jQuery select image in div if image parent does't have a certain class

Wordpress wraps images with captions in a div with a class of .wp-caption.
I'm looking for a way to select images that don't have this div so I can wrap them in different div. (to keep a consistent border around all the images)
<div class="blog-post-content">
<div id="attachment_220" class="wp-caption alignleft" style="width: 310px">
<img class="size-medium wp-image-220" src="/path/to/image" alt="" width="300" height="280" />
<p class="wp-caption-text">Caption Text</p>
</div>
<p>This is the body of the post</p>
</div>
To test my selector, I'm just trying to add a green border. I can handle the .wrap() once the selector is working.
The most promising of my attempts is:
$('.blog-post-content img').parent('div:not(".wp-caption")').css('border', '2px solid green');
... but no luck.
How about this: (untested)
$('.blog-post-content img').filter(function(){
return !$(this).parents('div').hasClass('wp-caption');
}).css('border', '2px solid green');
try:
$('.blog-post-content img').parent(':not("div.wp-caption")')
Not if what Matti says abotu the a element in the hierarchy then the above wont work.
I know this question was asked a long time ago, but I would like to suggest the following:
$('.blog-post-content img').closest('div:not(".wp-caption")')
Untested, but I think that should work, and is shorter than the answer above that works. Using closest means the a is ignored.