Skip to content

Instantly share code, notes, and snippets.

@znarfm
Last active February 10, 2025 14:05
Show Gist options
  • Save znarfm/d365898b752b3b59046440d46b46009b to your computer and use it in GitHub Desktop.
Save znarfm/d365898b752b3b59046440d46b46009b to your computer and use it in GitHub Desktop.
This script helps PUP students automate faculty evaluations by setting survey ratings to achieve a desired average score. It dynamically adjusts responses, ensures accuracy, and works for any number of questions, saving time and simplifying the feedback process.
const se = async (targetAvg) => {
try {
// If no target average provided, prompt user
if (targetAvg === undefined) {
const input = prompt('Enter desired average (1-5):', '2.5');
if (input === null) return; // User clicked cancel
targetAvg = parseFloat(input);
}
if (isNaN(targetAvg)) {
throw new Error('Please enter a valid number');
}
if (targetAvg < 1 || targetAvg > 5) {
throw new Error('Target average must be between 1 and 5');
}
// Get all radio inputs and calculate total questions
const radios = document.querySelectorAll('input[type="radio"][name^="q"]');
const totalQuestions = radios.length / 5;
if (totalQuestions === 0) {
throw new Error('No questions found on the page');
}
// Calculate required values
const exactTotal = targetAvg * totalQuestions;
const roundedTotal = Math.round(exactTotal);
const lowerValue = Math.floor(targetAvg);
const higherValue = Math.ceil(targetAvg);
const numberOfHigher = roundedTotal - (lowerValue * totalQuestions);
// Validate if average is achievable
if (numberOfHigher < 0 || numberOfHigher > totalQuestions) {
throw new Error(`Target average ${targetAvg} is not achievable with ${totalQuestions} questions`);
}
// Clear any previously selected options
radios.forEach(radio => radio.checked = false);
// Set scores for each question
for (let i = 1; i <= totalQuestions; i++) {
const score = i <= numberOfHigher ? higherValue : lowerValue;
const questionId = `q${i}${score}`;
const element = document.getElementById(questionId);
if (!element) {
throw new Error(`Could not find element with ID: ${questionId}`);
}
element.checked = true;
}
console.log(`Successfully set ${totalQuestions} questions to achieve average of ${targetAvg}`);
console.log(`Using ${numberOfHigher} questions with value ${higherValue} and ${totalQuestions - numberOfHigher} questions with value ${lowerValue}`);
} catch (error) {
console.error('Error:', error.message);
}
};
// Usage examples:
// se() - will prompt for target average
// se(2.5) - will set target average to 2.5
@znarfm
Copy link
Author

znarfm commented Jan 27, 2025

How to Use the Faculty Evaluation Script

English Version

  1. Log in to your SIS account and go to the faculty evaluation page for your chosen instructor.
  2. Open the browser's developer console:
    • Chrome/Edge: Press Ctrl + Shift + J (Windows) or Cmd + Option + J (Mac).
    • Firefox: Press Ctrl + Shift + K (Windows) or Cmd + Option + K (Mac).
  3. Allow pasting (if prompted):
    • If the console blocks pasting, type allow pasting and press Enter.
  4. Copy and paste the script into the developer console:
    // Paste the script here
    const se = async (targetAvg) => { ... }; // (see script above)
  5. Run the script:
    • To enter your desired average dynamically, type se() and press Enter. You'll be prompted to input the target average (e.g., 3.5).
    • Or, provide the target average directly by typing, e.g., se(3.5), and press Enter.
  6. Let the script work its magic!
    • The survey will automatically populate ratings to achieve your target average.
  7. Review the responses, make adjustments if needed, and submit your evaluation.

That's it! The script is simple, flexible, and saves you time.


Tagalog Version

  1. Mag-log in sa iyong SIS account at pumunta sa faculty evaluation page para sa napiling instructor.
  2. Buksan ang developer console ng browser:
    • Chrome/Edge: Pindutin ang Ctrl + Shift + J (Windows) o Cmd + Option + J (Mac).
    • Firefox: Pindutin ang Ctrl + Shift + K (Windows) o Cmd + Option + K (Mac).
  3. Payagan ang pag-paste (kung hihingin):
    • Kung hindi ma-paste sa console, i-type ang allow pasting at pindutin ang Enter.
  4. I-copy at i-paste ang script sa developer console:
    // I-paste ang script dito
    const se = async (targetAvg) => { ... }; // (tingnan ang script sa itaas)
  5. Patakbuhin ang script:
    • Para manual na ilagay ang desired average, i-type ang se() at pindutin ang Enter. Magpa-prompt ito para sa target average (halimbawa: 3.5).
    • O, direktang i-type ang target average, halimbawa: se(3.5), at pindutin ang Enter.
  6. Hayaan ang script na gawin ang trabaho nito!
    • Awtomatikong lalagyan ng ratings ang survey para maabot ang iyong target average.
  7. Suriin ang mga sagot, mag-edit kung kinakailangan, at i-submit ang evaluation mo.

Tapos na! Mabilis, madali, at walang hassle.

@yam2-1111
Copy link

gagi balagbag

@syn-vita
Copy link

syn-vita commented Feb 7, 2025

wala po bang bisakol version ng instructions?

@yam2-1111
Copy link

wala po bang bisakol version ng instructions?

Faculty Evaluation Guide (Bisakol)

Paano Mag-Evaluate sang Faculty sa SIS

1. Mag-log in sa imo SIS account

Log in sa imo SIS account kag kadto sa faculty evaluation page para sa napili nga instructor.

2. Buksan ang Developer Console sang Browser

Para sa Chrome/Edge:

  • Pinduta ang Ctrl + Shift + J (Windows) o Cmd + Option + J (Mac).

Para sa Firefox:

  • Pinduta ang Ctrl + Shift + K (Windows) o Cmd + Option + K (Mac).

3. Paytuguti ang Pag-Paste (kung kinahanglan)

Kung indi ma-paste sa console, i-type ang allow pasting kag pinduta ang Enter.

4. I-copy kag i-paste ang script sa Developer Console

// I-paste ang script diri
const se = async (targetAvg) => { ... }; // (tan-awa ang script sa ibabaw)

5. Ipatakbo ang Script

Para manual nga magbutang sang desired average:

  • I-type ang se() kag pinduta ang Enter. Mag-prompt ini para sa target average (halimbawa: 3.5).

Para direkta nga i-type ang target average:

  • I-type ang se(3.5) kag pinduta ang Enter.

6. Pabayi ang Script nga Magtrabaho!

Awtomatiko nga magbutang sang ratings ang survey para maabot ang imo target average.

7. Suriha kag I-submit

  • Reviewha ang mga tubag, i-edit kung kinahanglan, kag i-submit ang imo evaluation.

Dali, sayon, kag wala hassle! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment