MarkUs Blog

MarkUs Developers Blog About Their Project

Archive for the ‘javascript’ tag

Introducing MarkUs 1.0-alpha!

without comments

The team is pleased to announce MarkUs 1.0-alpha! This release is tagged as « alpha » in order to allow for further testing and feedback, and all input is welcome. This release may be used in production.

MarkUs 1.0-alpha contains many fixes and some features:

  • We are now using Rails 3.0
  • We fully support for Ruby 1.9.x
  • Changed PDF conversion to Ghostscript for faster conversion
  • We introduced a new REST API
  • Users now have the ability to import/export assignments settings
  • Improvements have been made to section management
  • Tests no longer use fixtures

For a list of all fixed issues, refer to: https://github.com/MarkUsProject/Markus/issues?milestone=8&state=closed Furthermore, the change log can be found at: https://github.com/MarkUsProject/Markus/blob/master/Changelog.

Go to http://www.markusproject.org to download it!

We suggest not updating from previous instances, as due to the significant number of changes introduced to the application, data loss is possible.

Thanks to all the contributors who made this release possible. Keep up the good work!

Written by Benjamin Vialle

September 11th, 2013 at 1:09 pm

Posted in Releases

Tagged with , , , ,

Introducing MarkUs 0.10.1!

without comments

The team is pleased to announce MarkUs 0.10.1!

MarkUs 0.10.1 fixes a nasty little bug that prevents students from viewing uploaded files when running the french translation.

If you’re running 0.10.0 and want to patch up – download the patch here (you’ll want to apply sequentially). It’s short, sweet, and shouldn’t require any special configuration. All wins.

Great job team – keep up the good work!

Written by Benjamin Vialle

September 28th, 2011 at 5:45 pm

Posted in Releases

Tagged with , ,

Javascript to Redirect a Drop Down List (select)

without comments

You can redirect using an html select without having to place it in a form, or have the user press a button. The user only needs to change the value.

Check out the following code that you can copy and paste into an html file and take for a test drive:


<html>

<head>
<title>Drop Down List Redirect</title>
</head>

<body>

<select onchange="top.location.href = 'http://www.google.com/search?q='
+ this.options[ this.selectedIndex ].value" >
<option value="">None</option>
<option value="cute+dogs">Cute Dogs</option>
<option value="lasers+beams">Laser Beams</option>
<option value="kitty+cat">Kitty Cat</option>
</select>

</body>
</html>

Breaking down the javascript code into more understandable chunks gives:


// 'this' points to the select object after change the item in the drop down list.
var drop_down = this;

// drop_down.selectedIndex contains the position of the item that was selected from the drop down
var selected_index = drop_down.selectedIndex;

// drop_down.options contains all of html option elements inside the html select
// we need to go to .value to get the 'value="something"' written in the HTML
var selected_value = drop_down.options[ selected_index ].value;

// changing top.location.href redirects ( unless you only append #blah )
top.location.href = 'http://www.google.com/search?q=' + selected_value

I hope you guys find this helpful!

Cheers,
Joseph

Written by jmate

March 4th, 2010 at 8:13 pm

Setting URL using Javascript

with one comment

Severin just pointed out a much easier way to update the URL using javascript:


<script language="javascript" type="text/javascript">
window.location.href = "/main/some_controller/some_action#some_anchor";
</script>

Thanks Severin!
I have extended this code into an example you can copy and paste into an html file and play around with:


<html>
<head><title>URL Updating</title></head>
<body>

<input    type="button"
name="cool"
value="cool"
onclick="window.location.href = window.location.href + '#value=param';" />

</body>
</html>

With Markus, this leaves lots of places for us to place the code. For a link_to_remote, we can place set the window.location.href in the :before or :complete variables. Example:
markus/app/views/ajax_paginate/_initial_paginate_links_alpha.html.erb


<%= link_to_remote "<< " + t('pagination.first'), :url => {
:action => action,
:id => assignment.id,
:filter => filter,
:page => 1,
:per_page => per_page,
:sort_by => sort_by,
:alpha_category => alpha_pagination_options[0],
:update_alpha_pagination_options => "false"
},
:before => "ap_thinking_start('#{table_name}');",
:complete => "ap_thinking_stop(); window.location.href = window.location.href + '#value=param';" %>

Notice that I stuck it right after the :complete =&gt; “ap_thinking_stop(); Additionally, notice that we are no longer limited to a’s. We can not apply this to any html objects.

Cheers,
Joseph

Written by jmate

February 21st, 2010 at 10:55 pm

Posted in Developer Essentials

Tagged with , ,

Rails, AJAX, Back Buttons, and Bookmarks

with one comment

Markus’s submission page uses AJAX to grab the next or previous page of the table of submissions. However, this breaks bookmarks and the back button. So the goal is to do something similar to gmail. They update everything after the anchor (#) in the URL. Here is what we can do with Markus with Ruby on Rails, to do the exact same thing.

My examples are only going to cover the implementation of the Next &gt; button. However, this can apply to any AJAX link.

The part of code that generates the Next link is in:
_initial_paginate_links.html.erb:


<%= link_to_remote "Next >", :url => {
:action => 's_table_paginate',
:id => assignment.id,
:filter => filter,
:page => current_page + 1,
:per_page => per_page,
:sort_by => sort_by
},
:before => "ap_thinking_start();",
:complete => "ap_thinking_stop();" %>

When the page loads it generates:


<a onclick="ap_thinking_start();; new
Ajax.Request('/main/submissions/s_table_paginate/1?filter=none&amp;amp;amp;page=3&amp;amp;amp;per_page=30&amp;amp;amp;sort_by=group_name',
{asynchronous:true, evalScripts:true,
onComplete:function(request){ap_thinking_stop();},
parameters:'authenticity_token=' +
encodeURIComponent('hjLTZo+xwhfYVOjA6E6Cbt3mm0SoaJw3t+nQG9UF/iA=')});
return false;"
href="#">Next ></a>

However, we want the URL to update, so we need to get rid of the ” return false; ” at the end of onclick. I accomplished that by using link_to and the remote_function helpers that Rails provides.

_initial_paginate_links.html.erb:


<%= link_to "Next >", "#value=param",
: onclick =>
remote_function(
:url => {
:action => 's_table_paginate',
:id => assignment.id,
:filter => filter,
:page => current_page + 1,
:per_page => per_page,
:sort_by => sort_by
},
:before => "ap_thinking_start();",
:complete => "ap_thinking_stop();"
)
%>

Which generates:


<a onclick="ap_thinking_start();; new
Ajax.Request('/main/submissions/s_table_paginate/1?filter=none&amp;amp;amp;page=3&amp;amp;amp;per_page=30&amp;amp;amp;sort_by=group_name',
{asynchronous:true, evalScripts:true,
onComplete:function(request){ap_thinking_stop();},
parameters:'authenticity_token=' +
encodeURIComponent('hjLTZo+xwhfYVOjA6E6Cbt3mm0SoaJw3t+nQG9UF/iA=')});"
href="#value=param">Next ></a>

Notice that the return false is no longer there! If you try to click the Next &gt; button, then it will place #value=param at the end of the url without reloading the page.

Now all that remains is figuring out how to do this with an html form. For example drop downlists, with an onchange method that updates the page using AJAX but still appends #value=param to the end of the URL.

Cheers,
Joseph

Written by jmate

February 19th, 2010 at 9:05 pm

Posted in Developer Essentials

Tagged with , , , ,

Updating the URL with a href and #

without comments

You can put parameters into the URL with javascript. Here is an example html document:


<html>
<body>
<a href="#test=test">testing</a>
</body>
</html>

So with Markus’s submission browse page,  instead of having:


<span>
<a href="#" onclick="ajax stuff">Next </a>
</span>

We can have something like:


<span>
<a href="#<PARAMS GO HERE>" onclick="ajax stuff">Next </a>
</span>

However, that means with every AJAX call that flips the page on the table, will will also have to update all the links on the page as well.

Cheers,
Joseph

Written by jmate

February 15th, 2010 at 6:47 pm