Skip to content

Instantly share code, notes, and snippets.

@OrenBochman
Last active September 9, 2018 09:31
Show Gist options
  • Save OrenBochman/5442994 to your computer and use it in GitHub Desktop.
Save OrenBochman/5442994 to your computer and use it in GitHub Desktop.
Gist of Leader board script used to genereate XP based on 4 user specific values using the DB module
<table class="generaltable">
<thead>
<tr>
<th class="header c0" style="text-align:left;" scope="col">Field name</th>
<th class="header c1" style="text-align:left;" scope="col">Field type</th>
<th class="header c2" style="text-align:left;" scope="col">Field description</th>
<th class="header c3 lastcol" style="text-align:center;" scope="col">Action</th>
</tr>
</thead>
<tbody><tr class="r0">
<td class="cell c0" style="text-align:left;">Wiki_User_Name</td>
<td class="cell c1" style="text-align:left;">Text</td>
<td class="cell c2" style="text-align:left;"></td>
<td class="cell c3 lastcol" style="text-align:center;"></td>
</tr>
<tr class="r1">
<td class="cell c0" style="text-align:left;">Edit_Count_MainSpace</td>
<td class="cell c1" style="text-align:left;">Number</td>
<td class="cell c2" style="text-align:left;">edit count in main space</td>
<td class="cell c3 lastcol" style="text-align:center;"></td>
</tr>
<tr class="r0">
<td class="cell c0" style="text-align:left;">Edit_Count_Talk</td>
<td class="cell c1" style="text-align:left;">Number</td>
<td class="cell c2" style="text-align:left;">edit count in talk pages</td>
<td class="cell c3 lastcol" style="text-align:center;"></td>
</tr>
<tr class="r1">
<td class="cell c0" style="text-align:left;">Articles_Created</td>
<td class="cell c1" style="text-align:left;">Number</td>
<td class="cell c2" style="text-align:left;">count of articles created</td>
<td class="cell c3 lastcol" style="text-align:center;"></td>
</tr>
<tr class="r0 lastrow">
<td class="cell c0" style="text-align:left;">Is_Student</td>
<td class="cell c1" style="text-align:left;">Radio buttons</td>
<td class="cell c2" style="text-align:left;">if this is a student</td>
<td class="cell c3 lastcol" style="text-align:center;"></td>
</tr>
</tbody>
</table>
<table class="mod-data-default-template" id="yui_3_7_3_2_1366718352092_366">
<tbody id="yui_3_7_3_2_1366718352092_365">
<tr class="r0" id="yui_3_7_3_2_1366718352092_364">
<td class="template-field cell c0" id="yui_3_7_3_2_1366718352092_363">Wiki_User_Name:</td>
<td class="template-token cell c1 lastcol">Oren Bochman</td>
</tr>
<tr class="r1">
<td class="template-field cell c0">Edit_Count_MainSpace:</td>
<td class="template-token cell c1 lastcol" name="ECM">5811</td>
</tr>
<tr class="r0">
<td class="template-field cell c0">Edit_Count_Talk:</td>
<td class="template-token cell c1 lastcol" name="ECT">952</td>
</tr>
<tr class="r1">
<td class="template-field cell c0">Articles_Created:</td>
<td class="template-token cell c1 lastcol" name="AC">29</td>
</tr>
<tr class="r0">
<td class="template-field cell c0">Is_Student:</td>
<td class="template-token cell c1 lastcol">no</td>
</tr>
<tr class="r0">
<td class="template-field cell c0">XP:</td>
<td class="template-token cell c1 lastcol" name="XP">NaN</td>
</tr>
<tr class="r1 lastrow">
<td class="controls template-field cell c0 lastcol" colspan="2"><a href="http://moodle.wmflabs.org/moodle/mod/data/edit.php?d=1&amp;rid=1&amp;sesskey=79iWNYC3Mp"><img src="http://moodle.wmflabs.org/moodle/theme/image.php/standard/core/1366587410/t/edit" class="iconsmall" alt="Edit" title="Edit"></a> <a href="http://moodle.wmflabs.org/moodle/mod/data/view.php?d=1&amp;rid=1"><img src="http://moodle.wmflabs.org/moodle/theme/image.php/standard/core/1366587410/t/preview" class="iconsmall" alt="More" title="More"></a> <a href="http://moodle.wmflabs.org/moodle/mod/data/view.php?d=1&amp;delete=1&amp;sesskey=79iWNYC3Mp"><img src="http://moodle.wmflabs.org/moodle/theme/image.php/standard/core/1366587410/t/delete" class="iconsmall" alt="Delete" title="Delete"></a> </td>
</tr>
</tbody>
</table>
var cnt = 0;
var re = /foo|Foo/;
function init(){
var ECM = 0; // edit count main space
var ECT = 0; // edit count in talk space
var AC = 0; // articles created
var namedElements = document.getElementsByName("ECM");
ECM=parseInt(namedElements);
alert(namedElements.innerHTML);
namedElements = document.getElementsByName("ECT");
ECT=parseInt(namedElements.innerHTML);
namedElements = document.getElementsByName("AC");
AC =parseInt(namedElements.innerHTML);
var namedResult = document.getElementsByName("XP");
// wieghed score called XP - the user's experience points
namedResult[0].innerHTML = (10*ECM)+(5*ECT)+(40*AC);
}
window.onload = init;
<div class="defaulttemplate">
<table class="mod-data-default-template">
<tbody>
<tr class="r0">
<td class="template-field cell c0">Wiki_User_Name:</td>
<td class="template-token cell c1 lastcol">[[Wiki_User_Name]]</td>
</tr>
<tr class="r1">
<td class="template-field cell c0">Edit_Count_MainSpace:</td>
<td class="template-token cell c1 lastcol" name="ECM">[[Edit_Count_MainSpace]]</td>
</tr>
<tr class="r0">
<td class="template-field cell c0">Edit_Count_Talk:</td>
<td class="template-token cell c1 lastcol" name="ECT">[[Edit_Count_Talk]]</td>
</tr>
<tr class="r1">
<td class="template-field cell c0">Articles_Created:</td>
<td class="template-token cell c1 lastcol" name="AC">[[Articles_Created]]</td>
</tr>
<tr class="r0">
<td class="template-field cell c0">Is_Student:</td>
<td class="template-token cell c1 lastcol">[[Is_Student]]</td>
</tr>
<tr class="r0">
<td class="template-field cell c0">XP:</td>
<td class="template-token cell c1 lastcol" name="XP"> </td>
</tr>
<tr class="r1 lastrow">
<td class="controls template-field cell c0 lastcol" colspan="2">##edit## ##more## ##delete## ##approve## ##export##</td>
</tr>
</tbody>
</table>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment