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
@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